# ASteCA

## Contents

# ASteCA#

Warning

This documentation is updated as the package evolves and it is possibly
outdated and/or incomplete. Feel free to contact me if you have questions
about using **ASteCA** in your research, or open a new issue in the
code’s repository.

This is the manual of operation for the Automated Stellar
Cluster Analysis (**ASteCA**) package.
**ASteCA** is an open source code developed entirely in Python, designed to
handle the usual tests applied to stellar clusters in order to
determine their characteristics: center, radius, membership probabilities
and associated intrinsic/extrinsic parameters (metallicity, age, extinction,
distance, binarity, total mass, etc).

The code is currently designed as a large script that combines functions sequentially. This allows the user to select which ones to run and which to skip, through a single input data file.

## License & Attribution#

Copyright 2015-2022 Gabriel I Perren.

**ASteCA** is free software made available under the GPL3 License. For details
see the LICENSE.

The accompanying article describing the code in detail can be accessed via A&A, and referenced using the following BibTeX entry:

```
@article{Perren_2015,
author = {{Perren, G. I.} and {V\'azquez, R. A.} and {Piatti, A. E.}},
title = {ASteCA: Automated Stellar Cluster Analysis},
DOI= "10.1051/0004-6361/201424946",
url= "http://dx.doi.org/10.1051/0004-6361/201424946",
journal = {A\&A},
year = 2015,
volume = 576,
pages = "A6",
month = "04",
}
```

## Changelog#

### [v0.4.3] - 2022-06-01#

This is a large update mostly on the synthetic cluster generation process. Two extra free fundamental parameters are added: differential reddening and the ratio of total to selective absorption.

Fit Av instead of E(B-V) (544)

Clean up before releasing 0.4.3 (541)

Change the ‘completeness’ function (540)

Structural analysis consumes too much memory for large fields (539)

Remove mass parameter (538)

Use pandas to read cluster data (537)

Remove complete/incomplete codebase + simplify get_data() (533)

Change several input parameters (532)

Fix King profile fit (529)

Add a flag to turn completeness on/off (528)

Make the lower mass limits input parameters (526)

Remove (RA, DE) transformation, RV mentions, trim frame, error rejection (524)

Optimal radius estimation fails for some clusters (521)

Gap in the synthetic cluster (519)

DA ‘read’ mode: read from column (match with pyUPMASK) (518)

Simplify Bayesian parallax inference (516)

Per cluster fundamental parameters range (514)

Revise default parallax offset following eDR3 release (501)

Generalize mass-ratio distribution for binaries using a power law (496)

Output of cluster memberships is very slow for large clusters (437)

Generate finding chart plot (210)

Probability density for binary assignment (198)

Differential reddening (174)

Make extinction parameter Rv a free parameter (170)

### [v0.4.2] - 2021-05-10#

Fixed two issues: don’t read hidden files from the

`input/`

folder, remove forgotten parameter that was removed in the previous release.

### [v0.4.1] - 2021-05-05#

### [v0.4.0] - 2021-05-03#

Compensate cluster’s mass for binaries masses? (488)

Estimate individual per-star masses (484)

Improve performance of synth cluster generation (3) (506)

Simplify isochrones download/handling (497)

Add CS 37 COLIBRI track + deprecate old versions 10 & 11 of PARSEC (495)

Optimal radius too large for some clusters (510)

Project equatorial coordinates before processing (237)

Add eccentricity parameter to KP fit? (480)

Finish working on enhanced King profile fitting (456)

Remove KDE_stds and mp_flag parameters (500)

Simplify input of structure parameters (512)

Deprecate all likelihoods except Tremmel (507)

Interpolate IMF masses into the isochrones, not the other way around (503)

Add minimum binary mass ratio to fundamental parameters? (504)

Deprecate Anderson-Darling test (499)

Deprecate “Read mode” (498)

Add IMF and PMF curves obtention (96)

Convert pixel coordinates to RA & DEC (203)

Add ZAMS to CMD final plot (160)

Add semi_input.dat checking to checker (214)

Add weighted spatial density map (167)

Generate output CMD-CCD plots for the mean+median+mode (479)

Exact circle area using geometry instead of Monte Carlo (446)

Use the maximum number of members in the optimal radius? (494)

Add 1-sigma region to King profile (478)

Turn off MP coloring in D2 plots for binned likelihoods (473)

### [v0.3.1] - 2020-06-19#

Only the `ptemcee`

method is kept, all others are now deprecated.

Corrected an error in the

`CMD_systs.dat`

file (468)Fixed path for

`CMD_systs.dat`

, now works in Windows (and Mac?)Control (some) plotting parameters through custom style and allow the selection of one of the supported styles (464)

Dump the results of the fundamental parameters analysis to file (467)

Closed several issues related to the deprecated bootstrap(+GA), brute force, and emcee methods (265, 280, 284, 324, 341, 347, 418, 442, 447)

Split D1 plots (MCMC convergence diagnostics plots & values) (389)

Explore Zeus as a possible addition to the best fit process (457)

Add mode, median to King’s profile plot (470)

Make “trim frame” option per cluster (474)

### [v0.3.0] - 2020-04-22#

Massive changes introduced in this new version. Python 2.7.x is no longer supported.

Port to Python 3 (243)

Upgrade to

`emcee`

v3.0.2 (423)Add

`emcee`

to the best fit process (193)Upgraded to

`astropy`

v0.0.4Remove (z,a) steps (413)

Bug fix: binary probabilities should not be averaged by

`zaWAverage`

(462)Add Tremmel’s implementation of the PLR (447)

Improve performance of synthetic cluster generation (445)

Fix Tolstoy likelihood accounting for uncertainties twice (406)

Add option to apply ’pmRA*cos(DE)’ correction (452)

Added

`optm`

method to local removal of stars (432)Added

`manual`

binning method to likelihood block (325)New radius estimating method and many improvements to structural functions (RDP, field dens, radius) (454, 449, 346, 378)

Added maximum likelihood method for fitting King profiles (268, 298)

Allow seeding the synthetic cluster generation process (196)

Add stopping condition to the plotting line (443)

Add Nsigma region to the best fit synthetic cluster (460)

Fix small bug in radii arrows (182)

### [v0.2.7] - 2019-10-03#

### [v0.2.6] - 2019-09-19#

Fix normalization in Bayesian DA (426)

Fix function to detect X11 that fails in Mac OS (Windows too?) (428)

Merge

`semi_input.dat`

file into`params_input.dat`

and copy input file as output (427)Remove modes (429)

Use one photometric systems file instead of two identical ones (421)

Fix Ext/Imm operator causing spurious points in the GA (424)

### [v0.2.5] - 2019-08-07#

Added the

`ptemcee`

method, and deprecated (for now) the BF (367)Add support for the new set of isochrones PARSEC+COLIBRI (322)

Output all information obtained from the bootstrap (279)

Mask stars with photometry outside of reasonable range (414)

Add proper motions, parallax, and radial velocity support to Bayesian DA (220)

Use stars with no complete data in the Bayesian equation (377).

Add dimensional weights to Bayesian DA.

Use all positions for structural functions (107).

Make the bootstrap the actual method (instead of GA) (64)

Make the GA work with floats instead of a grid (412)

Plot the incomplete dataset with MPs information (411)

Use a total number of masses, not a step value (410)

Use stars after error rejection for LF & completeness (390)

Switch to astropy’s read module (327) and allow reading columns by name.

Update check for installed packages (newer

`pip`

threw an error).Added a 2D cluster vs field KDE comparison, and the A-D test (255, 356)

Added MAP, median and mode to output parameters.

Added R2 normality estimator to distributions (401)

Deprecated KDE p-value function.

Deprecated

`trim_frame`

, and`manual`

mode in photometric error rejection.Deprecated integrated magnitude function.

Store input parameters as .json for each cluster (126)

Don’t read hidden files from the ‘isochrones’ folder (403)

Use KDE instead of Gaussian filters (379)

Split C2 plot into C2 and C3

### [v0.2.4] - 2018-03-16#

Extend support for up to two colors.

Improved performance (#357):

Make mass sampling optional (#373)

Move binarity assignment outside of the synthetic cluster generation.

Move isochrone sorting outside of the synthetic cluster generation.

Move random floats for photometric errors outside of the synthetic cluster generation.

Move random floats for completeness outside of the synthetic cluster generation. Code is now ~3.3X faster

### [v0.2.3] - 2017-09-23#

Improved performance of synthetic cluster generation (#227). Code is now ~4X faster.

Fix excessive use of memory by Rbf interpolation (#350)

Use equal bin widths in LF and completeness function (#300)

Faster star separation by errors (#351)

Generalize Bayesian DA to N-dimensions, fix statistical issues, improve performance (#352)

### [v0.2.2] - 2017-08-29#

Add weights to binned likelihood (#216)

Fix bug in progress bar.

Identify binaries in plotted HR diagram.

Modify the information presented by the 2-parameters density plots. Takes care of #71.

Smarter empty field region around cluster region (#345).

Detect stars with duplicate IDs in data file (#212).

### [v0.2.1] - 2017-08-11#

### [v0.2.0] - 2017-08-07#

Generalized code to accept an arbitrary CMD in any

*single*photometric system supported by the CMD service (#24).Identify binary systems in synthetic clusters (#199).

Plots are now produced per blocks, instead of all together at the end (#271)

Switch dependency requirement from astroML to astropy (#303).

Remove unused error rejection modes (#331)

Simplify params_input.dat file (#217)

Check that all metallicity files contain the same number of age values (#218)

Add density maps analysis for center function (#164)

Remove weight added to the observed cluster CMD’s histogram (#308)

Fix bad parameter rounding (#248)

Plot results of brute force minimization (#100)

Make extinction parameter Rv a manual input parameter (#314)

Use numpy’s binning methods (#317)

Modify RDP limit (#294)

Store extra data from theoretical isochrones (#201)

### [v0.1.9.5] - 2016-08-07#

### [v0.1.9.4] - 2016-07-25#

### [v0.1.9.3] - 2016-05-25#

Add support for CMD in the HST/ACS WFC photometric system (requested by Daniel Arbelaez).

### [v0.1.9.2] - 2016-04-17#

Add support for three CMDs in the Strömgren photometric system (requested by J. Hughes Clark).

Change likelihood density plots to scatter plots which show more information.

Add extra condition for DA break: minimum 10% of the runs must have passed.

Fix bug with ‘mag’ mode in ‘Reduced membership’, wouldn’t run if the Bayesian DA was skipped.

Fix minor bug (#241) when printing KP results to screen.

### [v0.1.9.1] - 2015-08-25#

Fixed rounding of errors that returned 0. values if error was larger than value (#213).

Check if

`pip`

module is installed + search for installed packages globally, not locally.Catch badly formatted input data file.

Restructure King radii obtention.

Correctly plot stars in cluster region, not used in best fit function.

### [v0.1.9] - 2015-06-18#

(**Warning**: this release breaks compatibility with the previous
version of the `params_input.dat`

& `semi_input.dat`

files)

Models (ie: isochrone + extinction +distance modulus + mass distribution + binarity) are now evaluated

*each time the GA selects them as a solution*, thus a new mass distribution is generated (#186). This has a performance cost, but provides higher accuracy in the best model assignment process since a single model can now be evaluated with a slightly different mass distribution several times (only with GA,*Brute Force*method will only process a model once).Added an

*exit switch*to the decontamination algorithm. It will stop iterations if the MPs converged to 0.1% tolerance values for all the stars in the cluster region (compared to the previous iteration). This speeds up the function considerably (#185).The upper mass value in the IMF can now be modified via the input parameters file.

Code can now read

`params_input_XX.dat`

files when using lazy parallelization.Number of field regions can now be set individually via the

`semi_input.dat`

file.Added ‘bb’ binning method based on Bonnato & Bica (2007). Sets bin widths of 0.25 and 0.5 for colors and magnitudes respectively.

Fixed bug in

`manual`

mode when displaying errors.Fixed bug when narrow frames were plotted (#168).

Moved text box outside of synthetic cluster’s plot to improve its visibility (#205).

Closed #13. Saha’s W likelihood needs the number of model points to be fixed, which prevents it from being used when the mass varies. There’s nothing to be gained by adding this function.

### [v0.1.8] - 2015-04-09#

(**Warning**: this release breaks compatibility with the previous
version of the `params_input.dat`

file)

Added

`local`

and`mp_05`

methods to the selection of which stars to use in the best fit cluster parameter assignation process (#180, #183).Added an

*automatic update checker*function that notifies the user if an updated version of`ASteCA`

is available for download (#179).Added grid lines over the photometric diagrams of the observed and synthetic cluster, showing the binning made by the method selected in each case (#131).

Best fit synthetic cluster found is now saved to file (#154).

Correctly obtain approximate number of members (

`n_memb`

) and contamination index (`CI`

) when the cluster radius extends beyond the RDP, thus making the field star density value (`field_dens`

) unreliable (#111).Added

`f10`

flag to alert when the`memb_par`

value is greater than +-0.33, which means that there are twice as many estimated true members in either method (#175).Improved

`top_tiers`

plotting and saved file (#184).

#### Caveats#

Same as version 0.1.2.

### [v0.1.7] - 2015-03-26#

(**Warning**: this release breaks compatibility with the previous
version of the `params_input.dat`

file)

Re-write

`lowexp`

error rejection method, now uses*prediction bands*instead of*confidence intervals*.Force

`matplotlib`

’s backend to make the code work in servers.Fixed

`eyefit`

method for error rejection. It changed after fixing #169.Added SDSS CMDs

`g vs (u-g)`

&`g vs (g-r)`

, at the request of Tjibaria Pijloo (Department of Astrophysics, Radboud University Nijmegen).Fixed bug in binarity generation for the CMDs of the form

`X vs (X-Y)`

(#181).Smarter selection of stars to be used by the best fit function, improvements in several plots (#171, #172).

Best fit function can now accept a

*minimum magnitude*value instead of just a*minimum probability*value (#115).Added a

`memb_par`

parameter to compare the number of approximate cluster members obtained via the structural analysis and via the decontamination algorithm (#162).Code is now able to correctly read the names of files with more than one dot in it’s name.

Fixed bad alphabetical ordering of input cluster files.

Better limits for photometric diagram (#173).

Fixed

`DeprecationWarning`

issue.Invert x axis when RA cords are used (improved here).

Several fixes and improvements made to plotted diagrams (5c7dc7f; 1642349; b57028c; 240178a; 9ec0ab8; fef14c4; db0df2a; 575ebe7; #177; #178).

#### Caveats#

Same as version 0.1.2.

### [v0.1.61] - 2015-03-04#

Added “lazy parallelization” ability. Now the user can run as many instances of the code as needed simply by creating extra

`asteca_xx.py`

and`input_xx`

folders where`xx`

are integers of the form: 01, 02,…, 99.Reposition several text boxes in output images, newer versions of

`matplotlib`

moved them from the previous position.Fix bad import of

`rpy2`

package, positioned incorrectly in two functions.Fix

`DeprecationWarning`

showing when`exp_function`

was used (#169).

#### Caveats#

Same as version 0.1.2.

### [v0.1.5] - 2015-03-03#

(**Warning**: this release breaks compatibility with the previous
version of the `params_input.dat`

file)

Improved radius assignment algorithm (#146).

Detect cropped cluster region and use correct area when generating field regions (#139, #157).

Fixed bug that crashed the code when top tiers synthetic clusters with no stars were plotted (#147). Added minimum total mass of 10Mo.

Fixed bug where KDE p-values for field vs field comparison were artificially increased by comparing a field region with itself (#138).

Obtain KDE p-value even if one field region is defined (#114).

Fixed small bug that prevented integrated magnitude curves from being plotted (#145).

Fixed several smaller bugs and issues (#110, #150, #140, #142, #141, #149, #95, #148, #136, #163, #143).

#### Caveats#

Same as version 0.1.2.

### [v0.1.4] - 2014-12-18#

Improved plotting of crowded fields (#62).

Function to generate image is now more stable (#112). Re-arranged plots in output image.

Add

*Top tiers*models output (#130).Fixed small bug in KDE p-values function (#134).

Minor re-arrangement with semi-input data.

#### Caveats#

Same as version 0.1.2.

### [v0.1.3] - 2014-12-10#

Accept arrays of non-equispaced parameter values instead of only equispaced ranges (#121).

Added support for log-normal Chabrier (2001) IMF.

More precise encoding/decoding in genetic algorithm.

Functions separated into sections (#125).

Input parameters set as global variables (#132).

#### Caveats#

Same as version 0.1.2.

### [v0.1.2] - 2014-12-01#

Likelihood method now supports Dolphin (2002)

*Poisson likelihood ratio*function.Minor position fix for synthetic cluster text box in output plot.

Brute force algorithm now returns correct errors.

Some fixes for when unique values in the input parameter ranges are used ([1], [2]).

Replaced deprecated compiler package used to flatten list.

#### Caveats#

Still not sure why

*tolstoy*likelihood is biased towards high masses :confused:

### [v0.1.1] - 2014-11-07#

*More stable release.*

#### Caveats#

Same as previous version.

### [v0.1.0] - 2014-10-08#

*First semi-stable buggy release*

Changed the way the IMF was sampled, now it should be faster and more precise.

Some speed improvements (moved things around mainly).

Binary fraction is now a free parameter.

#### Known issues#

**Serious bug**: if the DA is set to run but the*Best fit method*isn’t, the final plot can’t be produced since the`syn_cl_err`

function isn’t used (fixed in next release).Forgotten

`print`

prints out mass values every time the E/I operator is applied (fixed in next release).If the number of points (

`n_left`

) in the radius finding function is smaller than 4, a very small radius is likely to be selected. Fixed in next release.

#### Caveats#

The total initial mass can be set as a free parameter but the likelihood function will select always synthetic clusters of high mass. Thus it is advised to leave this parameter fixed to 1000 solar masses.

The binary fraction found is not stored in the output data file.

Some density map plots for mass and binary fraction are missing.

### [v4.0.0-beta] - 2014-09-23#

### [v3.0.0-beta] - 2014-09-16#

### [v2.0.1-beta] - 2014-09-15#

Correct version number.

### [v2.0.0-beta] - 2014-09-11#

Closed issues: #15, #73, #53, #24, #75, #79, #81, #59, #83, #78, #69, #74.

Changed name of package (OCAAT –> ASteCA).

Added separate function to handle the spatial 2D histogram.

Changes to

`get_center`

function (now hopefully simpler)Added UBVI support for

*V vs (U-V)*.Added 2MASS CMD support for

*J vs (J-H)*,*H vs (J-H)*and*K vs (H-K)*.Improve field star regions integrated magnitudes curve averaging.

Simplify process of adding a new CMD.

Added details on how the integrated magnitude calculation is done in the manual.

Lots of minor edits/corrections.

### [v1.0.0-beta] - 2014-08-24#

*First beta release*

Version used (with some small changes) in the original article.