fidanka.fiducial package

Subpackages

Submodules

fidanka.fiducial.fiducial module

fidanka.fiducial.fiducial.MC_convex_hull_density_approximation(filter1: ndarray[Any, dtype[float64]] | Series, filter2: ndarray[Any, dtype[float64]] | Series, error1: ndarray[Any, dtype[float64]] | Series, error2: ndarray[Any, dtype[float64]] | Series, width_coeff: float | str | None = None, reverseFilterOrder: bool = False, mcruns: int = 10, convexHullPoints: int = 100, pbar: bool = True) ndarray[Any, dtype[float64]]

Compute the density at each point in a CMD accounting for uncertainty in data. Uncertainty is accounted for through monte carlo sampleling wherin all data is shifted around based on individual uncertainties, the density is calculate using the methods described in the hull_density function, and then process is repeated mcruns times. After each repetion the density is averaged with a running density. The final reported density at each point is the average density at each point with mcruns shifts of the data around based on its photometric uncertainty.

Parameters:
  • filter1 (Union[ndarray[float64], pd.Series]) – First filter, will be A in A-B color

  • filter2 (Union[ndarray[float64], pd.Series]) – Second filter, will be B in A-B color

  • error1 (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from filter1.

  • error2 (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from filter2.

  • width_coeff (float, default=None) – The ratio of the range of manitude and range of color. If none then this will be set to 1. If set to ‘auto’ then this will calculate the range automatically.

  • reverseFilterOrder (bool, default=False) – Flag to determine which filter is used as the magnitude. If reverseFilterOrder is false then filter1 is is the magnitude. If reverseFilterOrder is True then filter2 is the magnitude

  • mcruns (int, default=10) – Number of monte carlo runs to use when calculating the density. Note that increasing this will linearlly slow down your code. If mcruns is set to 1 then the density will be calculated without accounting for uncertainty.

  • convexHullPoints (int, default=100) – Number of closest points to considered when finding the convex hull used to define the area in the instantaious_hull_density function.

  • pbar (bool, default=True) – Flag controlling whether a progress bar is written to standard output. This will marginally slow down your code; however, its a very small effect and I generally find it helpful to have this turned on.

Returns:

density – 1D array of density at each point in the color magnitude diagram.

Return type:

ndarray[float64]

Examples

Given some pandas dataframe which contains photometric data called “Photometry” the density of the F275W-F814W CMD could be computed

>>> from fidanka.fiducial import MC_convex_hull_density_approximation
>>> f1 = Photometry["F275W"]
>>> f2 = Photometry["F814W"]
>>> density = MC_convex_hull_density_approximation(f1, f2, reverseFilterOrder=True)
fidanka.fiducial.fiducial.approximate_fiducial_line_function(color: ndarray[Any, dtype[float64]], mag: ndarray[Any, dtype[float64]], density: ndarray[Any, dtype[float64]], binSize: str | float, percLow: float = 31.03, percHigh: float = 68.97, allowMax: bool = False, targetStat: int = 250, binSize_min: float = 0.1) Callable

Get an approximate fiducua line from a CMD using the basic ridge bounding algorithm

Parameters:
  • color (ndarray[float64]) – Color of each target in a CMD of shape m.

  • mag (ndarray[float64]) – Magnitude of each target in a CMD of shape m.

  • density (ndarray[float64]) – Density at each point in a CMD of shape m.

  • binSize (Union[str, float], default='adaptive') – Spacing between each left bin edge to each right bin edge. Default is ‘adaptive’ which will generate bins adaptivly in order to maintain uniform counting statistics.

  • percLow (float, default=1) – Lower bound percentile to base range on

  • percHigh (float, default=99) – Upper bound percentile to base range on

  • allowMax (bool, default=False) – If true then the ridge bounding algorithm will allow the maximum value in the color distribution to be used as a fiducial point if the gaussian fitting fails. If false and if the gaussian curve fit failes then a nan will be used. (depricated, will be removed in a latter version)

  • targetStat (int, default=250) – Number of points per bin to aim to when using uniformCS binning algorithm

  • binSize_min (float, default = 0.1) – The minimum size of mag bin. Set to 0.1 to avoid overfitting Main sequence

Returns:

ff – 1d linear interpolation between the calculate fiducial points using the ridge bounding method. ff is parmeterized as a function of magnitude (so as to make it a one-to-one function)

Return type:

Callable

fidanka.fiducial.fiducial.color_mag_from_filters(filter1: ndarray[Any, dtype[float64]] | Series, filter2: ndarray[Any, dtype[float64]] | Series, reverseFilterOrder: bool) Tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Given two filters and the a flag saying which one to use as the magnitude return the color and magnitude arrays.

Parameters:
  • filter1 (Union[ndarray[float64], pd.Series]) – First filter, will be A in A-B color

  • filter2 (Union[ndarray[float64], pd.Series]) – Second filter, will be B in A-B color

  • reverseFilterOrder (bool) – Flag to determine which filter is used as the magnitude. If reverseFilterOrder is false then filter1 is is the magnitude. If reverseFilterOrder is True then filter2 is the magnitude

Returns:

Where color and magnitude are of type Union[ndarray[float64], pd.Series] and have the same shape.

Return type:

Tuple[color, magnitude]

fidanka.fiducial.fiducial.get_mag_and_color_ranges(color: ndarray[Any, dtype[float64]] | Series, mag: ndarray[Any, dtype[float64]] | Series, percLow: float, percHigh: float) Tuple[Tuple[float, float], Tuple[float, float]]

Find the ranges of both color and magnitude between their percLow and percHigh percentiles

Parameters:
  • color (Union[ndarray[float64], pd.Series]) – 1D array of color of shape m

  • mag (Union[ndarray[float64], pd.Series]) – 1D array of magnitude of shape m

  • percLow (float) – Lower bound percentile to base range on

  • percHigh (float) – Upper bound percentile to base range on

Returns:

  • colorRange (Tuple[float, float]) – Range of color between its percLow and percHigh percentiles

  • magRange (Tuple[float, float]) – Range of mag between its percLow and percHigh percentiles

fidanka.fiducial.fiducial.hull_density(X: ndarray[Any, dtype[float64]], Y: ndarray[Any, dtype[float64]], n: int = 100) ndarray[Any, dtype[float64]]

Calculate the number density at each point (i, j) for i, j in X, Y using the instantaious_hull_density function. X and Y must have the same shape

Parameters:
  • X (ndarray[float64]) – x values of dataset

  • Y (ndarray[float64]) – y values of dataset

  • n (int, default=100) – Number of closest points to considered when finding the convex hull used to define the area in the instantaious_hull_density function.

Returns:

density – 1D array of density. If len(X) == len(Y)

Return type:

ndarray[float64]

Examples

Given some array color and magnitude, defining some CMD for a globular clusters then you could find the approximate density at each target

>>> from fidanka.fiducial import hull_density
>>> density = hull_density(color, magnitude)

Note that this is not a very fast algorithm as its complexity scales like O(n^2). For each data point the distance to every other data point must be calculated.

fidanka.fiducial.fiducial.instantaious_hull_density(r0: ~numpy.ndarray[~typing.Any, ~numpy.dtype[[<class 'numpy.float64'>, <class 'numpy.float64'>]]], ri: ~numpy.ndarray[~typing.Any, ~numpy.dtype[[numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]], numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]]]], n: int = 100) Tuple[float64, ConvexHull, ndarray[Any, dtype[int32]]]

Calculate the density at a given point in a dataset in a way which keeps the counting statistics for each density calculation uniform. In order to do this four steps.

1. Calculate the euclidian distance between the point in question (ri) and every other point (r0[j]) in the data set. 2. Partition the 50 smallest elements from the calculated distance array 3. Use those indicies to select the 50 points from r0 which are the closest to ri 4. Find the convex hull of those 50 (it will be 50 not 51 as r0 is assumed to be a member of ri so there will always be at least one distance of 0 in the distance array which is the self distance) 5. Define and return the area as the number of points (n) / the area of the convex hull

This method dynamically varies the area considered when calculating the density in order to maintain a fixed number of samples per area bin.

Parameters:
  • r0 (ndarray[[float64, float64]]) – x, y coordinates of the point where you wish to calculate the density of. Assumed to be a member of ri. If this is not a member of ri the algorithm should still work under the constraint that the data is well distributed in all directions around r0, otherwise the area calculation could be off.

  • ri (ndarray[[ndarray[float64], ndarray[float64]]]) – x,y coordinates of all data points. This should have the shape (n, 2) where n is the numbe of data points

  • n (int, default=100) – Number of closest points to considered when finding the convex hull used to define the area.

Returns:

  • density (float64) – The approximate density at ri embeded within the r0 data field

  • hull (ConvexHull) – The fully computed convex hull of the n closest points to ri within the ri data field. Computed by scipy.spatial.ConvexHull (qhull)

  • partition (ndarray[int]) – The indicies of the n closest points to ri within the ri data field.

fidanka.fiducial.fiducial.instantaious_hull_density_cpp(r0: ~numpy.ndarray[~typing.Any, ~numpy.dtype[[<class 'numpy.float64'>, <class 'numpy.float64'>]]], ri: ~numpy.ndarray[~typing.Any, ~numpy.dtype[[numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]], numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]]]], n: int = 100) Tuple[float64, ConvexHull, ndarray[Any, dtype[int32]]]

Calculate the density at a given point in a dataset in a way which keeps the counting statistics for each density calculation uniform. In order to do this four steps.

1. Calculate the euclidian distance between the point in question (ri) and every other point (r0[j]) in the data set. 2. Partition the 50 smallest elements from the calculated distance array 3. Use those indicies to select the 50 points from r0 which are the closest to ri 4. Find the convex hull of those 50 (it will be 50 not 51 as r0 is assumed to be a member of ri so there will always be at least one distance of 0 in the distance array which is the self distance) 5. Define and return the area as the number of points (n) / the area of the convex hull

This method dynamically varies the area considered when calculating the density in order to maintain a fixed number of samples per area bin.

Parameters:
  • r0 (ndarray[[float64, float64]]) – x, y coordinates of the point where you wish to calculate the density of. Assumed to be a member of ri. If this is not a member of ri the algorithm should still work under the constraint that the data is well distributed in all directions around r0, otherwise the area calculation could be off.

  • ri (ndarray[[ndarray[float64], ndarray[float64]]]) – x,y coordinates of all data points. This should have the shape (n, 2) where n is the numbe of data points

  • n (int, default=100) – Number of closest points to considered when finding the convex hull used to define the area.

Returns:

  • density (float64) – The approximate density at ri embeded within the r0 data field

  • hull (ConvexHull) – The fully computed convex hull of the n closest points to ri within the ri data field. Computed by scipy.spatial.ConvexHull (qhull)

  • partition (ndarray[int]) – The indicies of the n closest points to ri within the ri data field.

fidanka.fiducial.fiducial.load_density(cacheDensity: bool, cacheDensityName: str, filter1: ndarray[Any, dtype[float64]], filter2: ndarray[Any, dtype[float64]], error1: ndarray[Any, dtype[float64]], error2: ndarray[Any, dtype[float64]], reverseFilterOrder: bool, convexHullPoints: int, width_coeff: float) ndarray[Any, dtype[float64]]
fidanka.fiducial.fiducial.measure_fiducial_lines(filter1: ndarray[Any, dtype[float64]] | Series, filter2: ndarray[Any, dtype[float64]] | Series, error1: ndarray[Any, dtype[float64]] | Series, error2: ndarray[Any, dtype[float64]] | Series, reverseFilterOrder: bool = False, mcruns: int = 10, convexHullPoints: int = 100, binSize: str | float = 'uniformCS', percLow: float = 1, percHigh: float = 99, verbose: bool = False, cacheDensity: bool = False, cacheDensityName: str = 'CMDDensity.npz', binSize_min: float = 0.1, piecewise_linear: bool | ndarray[Any, dtype[float64]] = False, nPops: int = 2, targetStat: int = 250) ndarray[Any, dtype[[numpy.ndarray[Any, numpy.dtype[numpy.float64]], numpy.ndarray[Any, numpy.dtype[numpy.float64]]]]]

Measure the fiducial lines in a CMD. This function will take in two filters and their associated uncertainties and calculate the fiducial lines in the CMD.

Parameters:
  • filter1 (Union[ndarray[float64], pd.Series]) – First filter, will be A in A-B color

  • filter2 (Union[ndarray[float64], pd.Series]) – Second filter, will be B in A-B color

  • error1 (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from filter1.

  • error2 (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from filter2.

  • reverseFilterOrder (bool, default=False) – Flag to determine which filter is used as the magnitude. If reverseFilterOrder is false then filter1 is is the magnitude. If reverseFilterOrder is True then filter2 is the magnitude

  • mcruns (int, default=10) – Number of monte carlo runs to use when calculating the density. Note that increasing this will linearlly slow down your code. If mcruns is set to 1 then the density will be calculated using the nominal values (no monte carlo).

  • convexHullPoints (int, default=100) – Number of closest points to considered when finding the convex hull used to define the area in the instantaious_hull_density function.

  • binSize (Union[str, float], default=adaptive) – Bin size to use when applying the spline smoothing algorithm. The default is adaptive. It can also be set as fixed values.

  • percLow (float, default=1) – Overall lower percentile bound to cut magnitude on.

  • percHigh (float, default=99) – Overall upper percentile bound to cut magnitude on.

  • splineSmoothMin (float, default=0.1) – Miniumum smoothing factor to use. Generally this should be small but non zero (0.1 has worked well for me)

  • splineSmoothMax (float, default=1) – Maximum smoothing factor to use. I find that its not good to push this much past 1

  • splineSmoothN (int, default=200) – Overall number of splines to fit. The spline fitting routines in scipy, which this function makes use of, are well optimized so you can push this pretty high without too many preformance issues. I find that a value of 100-200 works well. However, this will depend on your specific density profile.

  • colorSigCut (float, default=5) – Sigma distance to cut color based on

  • pbar (bool, default=True) – Flag controlling whether a progress bar is written to standard output. This will marginally slow down your code; however, its a very small effect and I generally find it helpful to have this turned on.

  • allowMax (bool, default=False) – If true then the ridge bounding algorithm will allow the maximum value in the color distribution to be used as a fiducial point if the gaussian fitting fails. If false and if the gaussian curve fit failes then a nan will be used.

  • verbose (bool, default=False) – Flag to control whether or not to print out information about the fiducial line fitting process. This is useful for debugging.

  • cacheDensity (bool, default=False) – Flag to control whether or not to cache the density calculation. This can be useful if you are going to be calling this function multiple times with the same data. However, if you are going to be calling this function multiple times with different data then you should not use this flag.

  • cacheDensityName (str, default='CMDDensity.npz') – Name of the file to use to cache the density calculation. This is only used if cacheDensity is True. If the file does not exist then it will be created. If the file does exist then it will be loaded.

  • minMagCut (float, default=-np.inf) – Minimum magnitude to cut on. This is useful if you want to cut out the RGB. Note that this is applied before the overall magnitude cut (percLow and percHigh) is applied.

  • method (str, default="waveform") – Method to use to calculate the density. Currently the spline and waveform methods are supported. The waveform method is the default while the spline method is the old method used. The spline method is included for backwards compatibility but may be more robust in some cases. Waveform should generally result in beter fiducial lines as it considers more than one magnitude bin at a time. It should also be faster than the spline method generally.

  • uni_density (bool, default=False) – Flag controls whether to change the sampling method to achieve a roughly uniform distribution of numbers of data points in filter1 magnitude

  • max_Num_bin (Union[str, int], default=False) – Control the maximum number of magnitude bins

  • binSize_min (float, default = 0.1) – The minimum size of mag bin. Set to 0.1 to avoid overfitting Main sequence

  • piecewise_linear (Union[bool,FARRAY_1D], default = False) – Introduce a new method of calulating the fiduial line using mcmc to find the best-fit piecewise linear function for the data. Can be turned on when Hull density method struggles in the low density region. Takes [nwalkers, iter] if not set as False

  • nPops (int, default=2) – Number of populations to fit using the gaussian mixture modeling method.

  • targetStat (int, default=250) – Number of points per bin to aim to when using uniformCS binning algorithm

Returns:

fiducial – Ridge line fit to a1 and a2. ridgeLine[0, :] gives the coordinates of the ridge line along the a1 axis, while ridgeLine[1, :] gives the coordinates of the ridgeLine along the a2 axis (these are the infered centers points of the bins)

Return type:

ndarray[[ndarray[float64], ndarray[float64]]]

fidanka.fiducial.fiducial.percentage_within_n_standard_deviations(n)
fidanka.fiducial.fiducial.renormalize(filter1: ndarray[Any, dtype[float64]] | Series, filter2: ndarray[Any, dtype[float64]] | Series, error1: ndarray[Any, dtype[float64]] | Series, error2: ndarray[Any, dtype[float64]] | Series) Tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Resample the data in the first place to ensure new data has roughly uniform distribution in filter1 magnitude. To achieve that, data will be segmented by filter1 magnitude. The uniformity is achieved by over sample low density region and undersample high density region. This function is only used when uni_density = True

Parameters:
  • filter1 (Union[ndarray[float64], pd.Series]) – First filter, will be A in A-B color

  • filter2 (Union[ndarray[float64], pd.Series]) – Second filter, will be B in A-B color

  • error1 (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from filter1.

  • error2 (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from filter2.

Returns:

  • filter1_renomalized (Union[ndarray[float64], pd.Series]) – Renomalized first filter, will be A in A-B color

  • filter2_renomalized (Union[ndarray[float64], pd.Series]) – Renomalized second filter, will be B in A-B color

  • error1_renomalized (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from renomalized filter1.

  • error2_renomalized (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry from renomalized filter2.

fidanka.fiducial.fiducial.shift_photometry_by_error(phot: ndarray[Any, dtype[float64]] | Series, err: ndarray[Any, dtype[float64]] | Series, baseSampling: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]

Shift each point, p_i, in phot by some amount sampled from a normal distribution with standard deviation equal to its associated uncertainty, e_i, in err. Phot and Err must both be 1D and must both be the same shape

Parameters:
  • phot (Union[ndarray[float64], pd.Series]) – Nominal values of Photometry (single filter)

  • err (Union[ndarray[float64], pd.Series]) – One sigma uncertainties in Photometry.

  • baseSampling (ndarray[float64]) – Random samples from a normal distribution with mu = 0 and sig = 1 which will be rescaled to the correct standard deviation and used to shift the photometry by the error. Must have the same shape as filter1 and filter2.

Returns:

shiftedPhot – Array of the same shape as phot but with each point shifted by some amount sampled from a normal distribution with standard deviation equal to that of the uncertainty of each point.

Return type:

ndarray[float64]

fidanka.fiducial.fiducial.verticalize_CMD(color: ndarray[Any, dtype[float64]], mag: ndarray[Any, dtype[float64]], density: ndarray[Any, dtype[float64]], binSize: str | float, percLow: float = 1, percHigh: float = 99, allowMax: bool = False, targetStat: int = 250, binSize_min: float = 0.1) Tuple[ndarray[Any, dtype[float64]], Callable]

Given some CMD fit an approximate fiducual line and use that to verticalize the CMD along the main sequence and the RGB.

Parameters:
  • color (ndarray[float64]) – Color of each target in a CMD of shape m.

  • mag (ndarray[float64]) – Magnitude of each target in a CMD of shape m.

  • density (ndarray[float64]) – Density at each point in a CMD of shape m.

  • binSize (Union[str, float], default='adaptive') – Spacing between each left bin edge to each right bin edge. Default is ‘adaptive’ which will generate bins adaptivly in order to maintain uniform counting statistics.

  • percLow (float, default=1) – Lower bound percentile to base range on

  • percHigh (float, default=99) – Upper bound percentile to base range on

  • allowMax (bool, default=False) – If true then the ridge bounding algorithm will allow the maximum value in the color distribution to be used as a fiducial point if the gaussian fitting fails. If false and if the gaussian curve fit failes then a nan will be used. (depricated, will be removed in a future version)

  • targetStat (int, default=250) – Number of points per bin to aim to when using uniformCS binning algorithm

  • binSize_min (float, default = 0.1) – The minimum size of mag bin. Set to 0.1 to avoid overfitting Main sequence

Returns:

  • vColor (ndarray[float64]) – Verticalized color, indexed the same as color and mag

  • ff (Callable) – 1d linear interpolation between the calculate fiducial points using the ridge bounding method. ff is parmeterized as a function of magnitude (so as to make it a one-to-one function)

fidanka.fiducial.fiducialLine module

class fidanka.fiducial.fiducialLine.fiducial_line(name)

Bases: object

add_measurement(color, mag, Eval_mags)
confidence(p)

Calculate the upper and lower bound confidence intervals for the mean fiducial line.

Parameters:

p (float) – The percentile of the confidence interval. (0 < p < 1)

Returns:

  • lower (ndarray) – The lower bound confidence interval for the mean fiducial line.

  • upper (ndarray) – The upper bound confidence interval for the mean fiducial line.

Examples

>>> import numpy as np
>>> from fiducialLine import fiducial_line
>>> fl = fiducial_line('test')
>>> fl.add_measurement(np.array([1, 2, 3]), np.array([4, 5, 6]))
>>> fl.add_measurement(np.array([2, 3, 4]), np.array([5, 6, 7]))
>>> fl.add_measurement(np.array([3, 4, 5]), np.array([6, 7, 8]))
>>> fl.confidence(0.05, 0.95)
property mean
property std

fidanka.fiducial.utils module

fidanka.fiducial.utils.GMM_component_measurment(xB, yB, n=50)

Fit a Gaussian Mixture Model to each bin of a CMD and return the mean of each component.

Parameters:
  • xB (List[FARRAY_1D]) – List of color bins.

  • yB (List[FARRAY_1D]) – List of magnitude bins.

  • n (int, default=50) – Number of components to fit to each bin.

Returns:

gmm_means – List of the means of the Gaussian Mixture Models fit to each bin.

Return type:

FARRAY_2D_2C

fidanka.fiducial.utils.bin_color_mag_density(color: ndarray[Any, dtype[float64]], mag: ndarray[Any, dtype[float64]], density: ndarray[Any, dtype[float64]], binSize: str | float = 'uniformCS', percLow: float | None = None, percHigh: float | None = None, max_Num_bin: bool | int = False, binSize_min: float = 0.1, targetStat: int = 1000) Tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Use the bin edges from mag_bins to split the color, mag, and density arrays into lists of arrays.

Parameters:
  • color (np.ndarray[float64]) – 1D array of color of shape m for the stars in the CMD

  • mag (np.ndarray[float64]) – 1D array of magnitude of shape m for the stars in the CMD

  • density (np.ndarray[float64]) – 1D array of density of shape m for the stars in the CMD

  • percLow (float) – Lower bound percentile to base range on

  • percHigh (float) – Upper bound percentile to base range on

  • binSize (Union[str, float]) – Size of the bins to use. If ‘adaptive’ will attempt to keep counting statistics the same throughout.

  • max_Num_bin (Union[bool, int]) – False or 0 will not limit the number of bins. Any other integer will limit the number of bins to that number.

  • binSize_min (float) – Minimum bin size to use when using adaptive binning

  • targetStat (int, default=1000) – Target number of stars per bin when using uniformCS binning

Returns:

  • colorBins (List[np.ndarray[float64]]) – List of arrays of color of shape m for the stars in the CMD

  • magBins (List[np.ndarray[float64]]) – List of arrays of magnitude of shape m for the stars in the CMD

  • densityBins (List[np.ndarray[float64]]) – List of arrays of density of shape m for the stars in the CMD

fidanka.fiducial.utils.clean_bins(colorBins: List[ndarray[Any, dtype[float64]]], magBins: List[ndarray[Any, dtype[float64]]], densityBins: List[ndarray[Any, dtype[float64]]], sigma: float = 5, iterations: int = 1) Tuple[List[ndarray[Any, dtype[float64]]], List[ndarray[Any, dtype[float64]]], List[ndarray[Any, dtype[float64]]]]

Remove high sigma outliers from the bins. Repeat the process iterativly.

Parameters:
  • colorBins (List[FARRAY_1D]) – List of color bins.

  • magBins (List[FARRAY_1D]) – List of magnitude bins.

  • densityBins (List[FARRAY_1D]) – List of density bins.

  • sigma (float, default=5) – Sigma value to use for the outlier removal.

  • iterations (int, default=1) – Number of iterations to perform.

Returns:

Cleaned color, magnitude and density bins.

Return type:

Tuple[List[FARRAY_1D], List[FARRAY_1D], List[FARRAY_1D]]

Examples

>>> colorBins = [np.array([1, 2, 3, 4, 5]), np.array([1, 2, 3, 4, 5])]
>>> magBins = [np.array([1, 2, 3, 4, 5]), np.array([1, 2, 3, 4, 5])]
>>> densityBins = [np.array([1, 2, 3, 4, 5]), np.array([1, 2, 3, 4, 5])]
>>> clean_bins(colorBins, magBins, densityBins, sigma=1, iterations=1)
fidanka.fiducial.utils.mag_bins(mag: ndarray[Any, dtype[float64]] | Series, percHigh: float | None, percLow: float | None, binSize: str | float, maxNumBins: bool | int = False, binSizeMin: float = 0.1, targetStat: float = 1000) Tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Find the left and right edges of bins in magnitude space between magnitudes percLow and percHigh percentiles with a bin size of binSize. Find suitable binsize if choose to use adapative bin size

Parameters:
  • mag (Union[ndarray[float64], pd.Series]) – 1D array of magnitude of shape m

  • percLow (float) – Lower bound percentile to base range on

  • percHigh (float) – Upper bound percentile to base range on

  • binSize (Union[str, float]) – Spacing between each left bin edge to each right bin edge. If ‘adaptive’ will attempt to keep match the target number of bins over the range. If binSize is set to uniformCS then the bin size will be adjusted so that the counting statistics are roughly the same in each bin.

  • maxNumBins (Union[str, int], default=False) – maximum number of bins

  • binSizeMin (float, default=0.1) – Minimum bin size to use when using adaptive binning

  • targetStat (int, default=100) – Target number of stars in each bin when using uniformCS binning

Returns:

  • binsLeft (ndarray[float64]) – left edges of bins in magnitude space

  • binsRight (ndarray[float64]) – right edges of bins in magnitude space

fidanka.fiducial.utils.median_ridge_line_estimate(color, mag, density, binSize='uniformCS', max_Num_bin=False, binSize_min=0.1, sigmaCut=3, cleaningIterations=10, components=100, normBinSize=0.3, targetStat=250)
fidanka.fiducial.utils.normalize_density_magBin(color: ndarray[Any, dtype[float64]], mag: ndarray[Any, dtype[float64]], density: ndarray[Any, dtype[float64]], binSize: float = 0.1, pbar: bool = False) ndarray[Any, dtype[float64]]

Normalize the density of each point on a CMD by the mean of the densities within binSize of the point. This allows densities to be compared between the RGB and MS more easily.

Parameters:
  • color (FARRAY_1D) – Colors of stars in the CMD.

  • mag (FARRAY_1D) – Magnitudes of stars in the CMD.

  • density (FARRAY_1D) – Density of stars in the CMDs.

  • binSize (float, default=0.1) – Size of the bins to use for the normalization.

  • pbar (bool, default=False) – Show a progress bar.

Returns:

normDensity – Normalized density of stars in the CMDs.

Return type:

FARRAY_1D

fidanka.fiducial.utils.percentile_range(X: ndarray[Any, dtype[float64]] | Series, percLow: float, percHigh: float) Tuple[float, float]

Extract ranges from an array based on requested percentiles

Parameters:
  • X (Union[ndarray[float64], pd.Series]) – Array to extract range from

  • percLow (float) – Lower bound percentile to base range on

  • percHigh (float) – Upper bound percentile to base range on

Returns:

xRange – range of X between its percLow and percHigh percentiles.

Return type:

Tuple[float, float]

Module contents