sfit_minimizer.mm_funcs module¶
- sfit_minimizer.mm_funcs.fit_mulens_event(event, parameters_to_fit=None, initial_guess=None, plot=False, tol=1e-05, verbose=False)¶
Basic function for fitting a point-lens microlensing model to data.
- Arguments:
- event: MulensModel.Event() object
event contains datasets and an initial model.
- parameters_to_fit: list of str, optional
List of names of point-lens parameters to fit, e.g. [‘t_0’, ‘u_0’, ‘t_E’, ‘rho’]. If not given, will fit for all parameters of event.model.
- initial_guess: list, np.ndarray, optional
Starting values for the parameters to be fitted. Must include values for the flux parameters. If not included, will be set to the values of the parameters in event.model and the initial values of the fluxes will be set with event.fit_fluxes().
- plot: bool, optional
After the fitting is complete, plot the best-fitting model with the data.
- tol: float
- verbose: bool
- Returns:
- class sfit_minimizer.mm_funcs.PointLensSFitFunction(event, parameters_to_fit, estimate_fluxes=False, add_2450000=False)¶
Bases:
SFitFunctionA class for fitting a point-source point-lens microlensing light curve to observed data using
sfit_minimizer.sfit_minimize.minimize(). Simultaneously fits microlensing parameters and source and blend fluxes for each dataset.- Arguments:
- event: MulensModel.Event() object
event contains datasets and an initial model.
- parameters_to_fit: list of str
list of the named model parameters to be fit. (Not including the fluxes.)
- estimate_fluxes: bool
If set, will use event.fit_fluxes() to generate initial values for the flux parameters for each data set. Otherwise, will initialize the fitting with fixed values from event.fix_source_flux and event.fix_blend_flux or if they are not set for a particular dataset, will use source_flux = 1. and blend_flux = 0.
- add_2450000: bool
see
add_2450000
- Attributes:
- n_params = int
Number of parameters to fit. Includes flux parameters.
- Notes:
if you want to fix the source or blend flux for a particular dataset,
use the fix_source_flux or fix_blend_flux keywords in event as usual.
If u_0 is a parameter of the fit and it is too close to zero,
the matrix inversion will fail (produce numpy.linalg.LinAlgError: Singular matrix). So if you see this error, check the value of u_0. (Probably true of other parameters as well)
- property add_2450000¶
bool
if True: add 2450000 to theta[t_0] before putting it in the model.
- flatten_data()¶
Concatenates good points for all datasets into a single array with columns: Date, flux, err.
- set_flux_indices()¶
Count the total number of parameters of the model, n_params, and sets makes list of indices to match the flux parameters to the correct columns in the b, c, and d matrices after accounting for fixed flux parameters.
- update_all(theta=None, verbose=False)¶
- calc_residuals()¶
Calculate expected values of the residuals
- calc_df()¶
Calculate the derivatives of the fitting function and store as self.df.