Photometric Fitting API

class WDPhotTools.fitter.WDfitter[source]

This class provide a set of methods to fit white dwarf properties photometrically.

fit(atmosphere=['H', 'He'], filters=['G3', 'G3_BP', 'G3_RP'], mags=[None, None, None], mag_errors=[1.0, 1.0, 1.0], allow_none=False, distance=None, distance_err=None, extinction_convolved=True, kernel='cubic', Rv=3.1, ebv=0.0, ra=None, dec=None, independent=['Mbol', 'logg'], initial_guess=[10.0, 8.0], logg=8.0, atmosphere_interpolator='CT', reuse_interpolator=False, method='minimize', nwalkers=100, nsteps=1000, nburns=100, progress=True, refine=False, refine_bounds=[5.0, 95.0], kwargs_for_RBF={}, kwargs_for_CT={}, kwargs_for_minimize={}, kwargs_for_least_squares={}, kwargs_for_emcee={})[source]

The method to execute a photometric fit. Pure hydrogen and helium atmospheres fitting are supported. See atmosphere_model_reader for more information. Set allow_none to True so that mags can be provided in None to Default non-detection, it is not used in the fit but it allows the fitter to be reused over a large dataset where non-detections occur occasionally. In practice, one can add the full list of filters and set None for all the non-detections, however this is highly inefficent in memory usage: most of the interpolated grid is not used, and masking takes time.

Parameters:
  • atmosphere (list of str (Default: ['H', 'He'])) – Choose to fit with pure hydrogen atmosphere model and/or pure helium atmosphere model.

  • filters (list/array of str (Default: ['G3', 'G3_BP', 'G3_RP'])) – Choose the filters to be fitted with.

  • mags (list/array of float (Default: [None, None, None])) – The magnitudes in the chosen filters, in their respective magnitude system. None can be provided as non-detection, it does not contribute to the fitting.

  • mag_errors (list/array of float (Default: [1., 1., 1.])) – The uncertainties in the magnitudes provided.

  • allow_none (bool (Default: False)) – Set to True to detect None in the mags list to create a mask, this check requires extra run-time.

  • distance (float (Default: None)) – The distance to the source, in parsec. Set to None if the distance is to be fitted simultanenous. Provide an initial guess in the initial_guess, or it will be initialised at 10.0 pc.

  • distance_err (float (Default: None)) – The uncertainty of the distance.

  • extinction_convolved (bool (Default: True)) – When False, the A_b/E(B-V) values for filter b from Table 6 of Schlafly et al. 2011 are interpolated over the broadband filters. When False, the the A_b/E(B-V) values are from integrating the convolution of the response function of the filters with the DA spectra from Koester et al. 2010 using the equation provided in Schlafly et al. 2011.

  • kernel (str (Default: 'cubic')) – The kernel of interpolation of the extinction curve.

  • Rv (float (Default: 3.1)) – The choice of Rv, only used if a numerical value is provided.

  • ebv (float (Default: 0.0)) – The magnitude of the E(B-V).

  • ra (float (Default: None)) – Right Ascension in unit of degree.

  • dec (float (Default: None)) – Declination in unit of degree.

  • independent (list of str (Default: ['Mbol', 'logg']) – Independent variables to be interpolated in the atmosphere model, these are parameters to be fitted for.

  • initial_guess (list of float (Default: [10.0, 8.0])) – Starting coordinates of the minimisation. Provide an additional value if distance is to be fitted, it would be initialise as 50.0 pc if not provided.

  • logg (float (Default: 8.0)) – Only used if ‘logg’ is not included in the independent argument.

  • atmosphere_interpolator (str (Default: 'RBF')) – Choose between ‘RBF’ and ‘CT’.

  • reuse_interpolator (bool (Default: False)) – Set to use the existing interpolated grid, it should be set to True if the same collection of data is fitted in the same set of filters with occasional non-detection (with allow_none=False).

  • method (str (Default: 'minimize')) – Choose from ‘minimize’, ‘least_squares’ and ‘emcee’ for using the scipy.optimize.minimize, scipy.optimize.least_squares or the emcee respectively.

  • nwalkers (int (Default: 100)) – Number of walkers (emcee method only).

  • nsteps (int (Default: 500)) – Number of steps each walker walk (emcee method only).

  • nburns (int (Default: 50)) – Number of steps is discarded as burn-in (emcee method only).

  • progress (bool (Default: True)) – Show the progress of the emcee sampling (emcee method only).

  • refine (cool (Default: True)) – Set to True to refine the minimum with scipy.optimize.minimize.

  • refine_bounds (str (Default: [5, 95])) – The bounds of the minimizer are definited by the percentiles of the samples.

  • kwargs_for_RBF (dict (Default: {})) – Keyword argument for the interpolator. See scipy.interpolate.RBFInterpolator.

  • kwargs_for_CT (dict (Default: {})) – Keyword argument for the interpolator. See scipy.interpolate.CloughTocher2DInterpolator.

  • kwargs_for_minimize (dict (Default:) – {‘method’: ‘Powell’, ‘options’: {‘xtol’: 0.001}}) Keyword argument for the minimizer, see scipy.optimize.minimize.

  • kwargs_for_least_squares (dict (Default: {})) – keywprd argument for the minimizer, see scipy.optimize.least_squares.

  • kwargs_for_emcee (dict (Default: {})) – Keyword argument for the emcee walker.

set_extinction_mode(mode='total', z_min=100.0, z_max=250.0)[source]

Select the mode of extinction: “total” uses the extinction value as given, “linear” interpolates between z_min and z_max to get the extinction as a function of line of sight distance: zero exxtinction at z_min, and the total extinction at z_max.

Parameters:
  • mode (str (Default: "total")) – Choose from “total” or “linear”

  • z_min (float (Default: 100.0)) – The minimum distance from the galactic mid-plane to have any extinction.

  • z_max (float (Default: 250.0)) – The maximum distance from the galactic mid-plane to use the total extinction.

show_best_fit(figsize=(8, 6), atmosphere=['H', 'He'], color=['red', 'blue'], title=None, display=True, savefig=False, folder=None, filename=None, ext=['png'], return_fig=True)[source]

Generate a figure with the given and fitted photometry.

Parameters:
  • figsize (array of size 2 (Default: (8, 6))) – Set the dimension of the figure.

  • atmosphere (list of str (Default: ['H', 'He'])) – Choose the atmosphere type to be plotted.

  • color (list of str (Default: ['red', 'blue'])) – Set the colour for the respective atmosphere type.

  • title (str (Default: None)) – Set the title of the figure.

  • display (bool (Default: True)) – Set to display the figure.

  • savefig (bool (Default: False)) – Set to save the figure.

  • folder (str (Default: None)) – The relative or absolute path to destination, the current working directory will be used if None.

  • filename (str (Default: None)) – The filename of the figure. The Default filename will be used if None.

  • ext (str (Default: ['png'])) – Image type to be saved, multiple extensions can be provided. The supported types are those available in matplotlib.pyplot.savefig.

  • return_fig (bool (Default: True)) – Set to return the Figure object.

Returns:

fig – Return if return_fig is set the True.

Return type:

matplotlib.figure.Figure object

show_corner_plot(figsize=(8, 8), display=True, savefig=False, folder=None, filename=None, ext=['png'], return_fig=True, kwarg={})[source]

Generate the corner plot(s) of this fit. Only if fitting with emcee.

Parameters:
  • figsize (array of size 2 (Default: (8, 6))) – Set the dimension of the figure.

  • display (bool (Default: True)) – Set to display the figure.

  • savefig (bool (Default: False)) – Set to save the figure.

  • folder (str (Default: None)) – The relative or absolute path to destination, the current working directory will be used if None.

  • filename (str (Default: None)) – The filename of the figure. The Default filename will be used if None.

  • ext (str (Default: ['png'])) – Image type to be saved, multiple extensions can be provided. The supported types are those available in matplotlib.pyplot.savefig.

  • return_fig (bool (Default: True)) – Set to return the Figure object.

  • **kwarg (dict (Default: {) – ‘quantiles’: [0.158655, 0.5, 0.841345], ‘show_titles’: True, ‘range’: [0.95] * len(self.fitting_params[“independent”],}) Keyword argument for the corner.corner().

Returns:

fig – Return if return_fig is set the True.

Return type:

list of matplotlib.figure.Figure object