MulensModel.mulensdata module

class MulensModel.mulensdata.MulensData(data_list=None, file_name=None, phot_fmt='mag', chi2_fmt='flux', coords=None, ra=None, dec=None, ephemerides_file=None, add_2450000=False, add_2460000=False, bandpass=None, bad=None, good=None, plot_properties=None, **kwargs)

Bases: object

A set of photometric measurements for a microlensing event.

Examples of how to define a MulensData object:

data = MulensData(file_name=SAMPLE_FILE_01)

data = MulensData(data_list=[[Dates], [Magnitudes], [Errors]])

Parallax calculations assume that the dates supplied are BJD_TDB. See Trajectory. If you aren’t using parallax, the time system shouldn’t matter as long as it is consistent across all MulensData and Model objects. If you have multiple datasets, then you also need multiple instances of MulensData class.

Keywords :
data_list: [list of lists, numpy.ndarray], optional
The list that contains three lists or numpy.ndarrays that specify: time, magnitude or flux, and its uncertainty (in that order0. The lengths of these three objects must be the same.
file_name: str, optional
The path to a file with columns: Date, Magnitude/Flux, Err. Loaded using numpy.loadtxt(). See **kwargs.

Either data_list or file_name is required.

phot_fmt: str
Specifies whether the photometry is provided in magnitude or flux space. Accepts either ‘mag’ or ‘flux’. Default = ‘mag’.
chi2_fmt: str
Specifies whether the format used for chi^2 calculation should be done in Magnitude or Flux spaces. Accepts either ‘mag’ or ‘flux’. Default is ‘flux’ because almost always the errors are gaussian in flux space.
coords: astropy.SkyCoord, optional
sky coordinates of the event
ra, dec: str, optional
sky coordinates of the event
ephemerides_file: str, optional
Specify the ephemerides of a satellite over the period when the data were taken. You may want to extend the time range to get nicer plots. Will be interpolated as necessary to model the satellite parallax effect. See instructions on getting satellite positions. Note that there is no check on time format (e.g., BJD TBD vs. HJD) and it should be the same as in data_list or file_name.
add_2450000: boolean, optional
Adds 2450000 to the input dates. Useful if the dates are supplied as HJD-2450000.
add_2460000: boolean, optional
Adds 2460000 to the input dates. Useful if the dates are supplied as HJD-2460000.

bandpass: see bandpass

bad: boolean np.ndarray, optional
Flags for bad data (data to exclude from fitting and plotting). Should be the same length as the number of data points.
good: boolean np.ndarray, optional
Flags for good data, should be the same length as the number of data points.

plot_properties: dict, optional

Specify properties for plotting, e.g. color, marker, label, alpha, zorder, markersize, visible, and also the show_bad and show_errorbars properties.

Note: pyplot functions errorbar() and scatter() are used to plot data with errorbars and without them, respectively. The type and size of marker are specified using different keywords: (‘fmt’, ‘markersize’) for errorbar() and (‘marker’, ‘size’) for scatter(). You can use either convention in plot_properties and they will be translated to appropriate keywords. If there are similar problems with other keywords, then they won’t be translated unless you contact code authors.

Other special keys :
show_errorbars: boolean, optional
Whether or not to show the errorbars for this dataset.
show_bad: boolean, optional
Whether or not to plot data points flagged as bad.

Attributes :

flux: numpy.ndarray
The measured brightness in flux units.
err_flux: numpy.ndarray
Uncertainties of flux values.
input_fmt: str (‘mag’, ‘flux’)
Input format - same as phot_fmt keyword in __init__.
chi2_fmt: str (‘mag’, ‘flux’)
Photometry format used for chi^2 calculations. Default is ‘flux’.
ephemerides_file: str
File with satellite ephemeris.
bad

np.ndarray boolean

flags marking bad data

good

np.ndarray boolean

flags marking good data i.e., opposite to bad()

time

np.ndarray

vector of dates

mag

np.ndarray

magnitude vector

err_mag

np.ndarray

vector of magnitude errors

coords

see Coordinates

n_epochs

int

give total number of epochs (including bad data)

data_and_err_in_input_fmt()

Gives photometry in input format (mag or flux).

Returns :
data: np.ndarray
Magnitudes or fluxes
data_err: np.ndarray
Uncertainties of magnitudes or of fluxes
data_and_err_in_chi2_fmt()

Gives photometry in format used for chi2 calculation (flux in most cases, but magnitude possible).

Returns :
data: np.ndarray
Magnitudes or fluxes
data_err: np.ndarray
Uncertainties of magnitudes or of fluxes
satellite_skycoord

Astropy.SkyCoord object for satellite positions at epochs covered by the dataset

Returns :
skycoord: astropy.coordinates.SkyCoord
satellite positions at epochs covered by the dataset
bandpass

String

Bandpass of given dataset (primary usage is limb darkening), e.g. ‘I’ or ‘V’. Returns None if not set.

set_limb_darkening_weights(weights)

Save a dictionary of weights that will be used to evaluate the limb darkening coefficient. See also LimbDarkeningCoeffs

Parameters :
weights: dict
A dictionary that specifies weight for each bandpass. Keys are str and values are float, e.g., {'I': 1.5, 'V': 1.} if the I-band gamma limb-darkening coefficient is 1.5-times larger than the V-band.
plot(phot_fmt=None, show_errorbars=None, show_bad=None, subtract_2450000=False, subtract_2460000=False, model=None, plot_residuals=False, **kwargs)

Plot the data.

Uses plot_properties to for label, color, etc. This settings can be changed by setting **kwargs.

You can plot in either flux or magnitude space. You can plot data in a scale defined by other dataset – pass model argument and model.data_ref will be used as reference. Instead of plotting data themselves, you can also plot the residuals of a model.

Keywords:
phot_fmt: string (‘mag’, ‘flux’)
Whether to plot the data in magnitudes or in flux. Default is the same as input_fmt.
show_errorbars: boolean
If show_errorbars is True (default), plots with matplotlib.errorbar(). If False, plots with matplotlib.scatter().
show_bad: boolean
If False, bad data are suppressed (default). If True, shows points marked as bad (mulensdata.MulensData.bad) as ‘x’
subtract_2450000, subtract_2460000: boolean
If True, subtracts 2450000 or 2460000 from the time axis to get more human-scale numbers. If using it, make sure to also set the same settings for all other plotting calls (e.g. plot_lc()).
model: Model
Model used to scale the data or calculate residuals (if plot_residuals is True). If provided, then data are scaled to model.data_ref dataset.
plot_residuals: boolean
If True then residuals are plotted (model is required). Default is False, i.e., plot the data.

**kwargs: passed to matplotlib plotting functions.