MulensModel.fit module

class MulensModel.fit.Fit(data=None, magnification=None, n_sources=None)

Bases: object

Fits source and blending fluxes for given data and model magnification.

Keywords :
data: MulensData or list of MulensData
Photometric data to be fitted.
magnification: np.ndarray or list of np.ndarrays
Model magnification.
n_sources: int
The number of microlensing sources. It’s suggested not to use this option now.
fit_fluxes(fit_blending=True)

Fit source(s) and blending fluxes. Performs a least squares linear fit (np.linalg.lstsq()) to the data for the flux parameters. I.e., given the data \(y\) and magnification \(A\), solves for \(f_{source}\) and \(f_{blend}\):

\[y = f_{source} * A + f_{blend}\]
Parameters :
fit_blending: boolean, optional
Do you want the blending to be fitted (True) or to be fixed at 0 (False)? Default is True
flux_of_sources(dataset)

Fluxes of source(s).

Parameters :
dataset: MulensData
A dataset for which source fluxes will be given.
Returns :
source_fluxes: np.ndarray
Fluxes of sources in units where 1 corresponds to 22 mag. The number of array elements is the same as number of sources.
blending_flux(dataset)

Blending flux for given dataset.

Parameters :
dataset: MulensData
A dataset for which blending flux will be given.
Returns :
blending_flux: np.float64
Blending flux in units where 1 corresponds to 22 mag.
get_flux(data)

Microlensing model in flux units.

Parameters :
data: MulensData
A dataset for which model will be returned.
Returns :
flux: np.ndarray
Microlensing model in flux units.
get_input_format(data=None)

Microlensing model in the same format as given dataset. The output is either in flux units or magnitudes, depending on format of the input data.

Parameters :
data: MulensData
A dataset for which model will be returned.
Returns :
model: np.ndarray
Microlensing model in flux units or magnitudes (depending on the format of input data).
get_chi2_format(data)

Microlensing model in the format used for chi^2 calculation. The output is in flux space in most cases, but can be in magnitudes depending on dataset format.

Parameters :
data: MulensData
A dataset for which model will be returned.
Returns :
model: np.ndarray
Microlensing model in flux units or magnitudes (depending on the settings of input data).
get_n_sources()

Count sources.

Returns :
n_sources: int
Number of sources in input data.
update(fit)

Update internal variables using information from a different instance of the same class.

Parameters :
fit: Fit
A different instance of this class.