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 order). 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.

**kwargs:

Kwargs passed to np.loadtxt(). Works only if file_name is set.

You can print an instance of this class, which always provides label and information on the total number of epochs and the number of bad epochs. If applicable, additional information is provided: bandpass, ephemerides file, color used for plotting, and errorbar scaling.

property plot_properties

dict

Settings that specify how the photometry should be plotted.

The keys in this dict could be either special keys introduced here (i.e., show_bad and show_errorbars) or keys accepted by matplotlib.pyplot plotting functions. The latter could be for example color, marker, label, alpha, zorder, markersize, or visible.

See MulensData for more information.

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 for label, color, etc. This settings can be changed by setting **kwargs.

You can plot in either flux or magnitude space.

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

DEPRECATED. Use plot_data() to plot a dataset scaled to a model.

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.

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.

property coords

Coordinates

Sky coordinates of data. See Coordinates.

property time

np.ndarray

vector of dates

property mag

np.ndarray

magnitude vector

property err_mag

np.ndarray

vector of magnitude errors

property flux

numpy.ndarray

Vector of the measured brightness in flux units.

property err_flux

np.ndarray

Vector of uncertainties of flux values.

property bad

np.ndarray boolean

flags marking bad data

property good

np.ndarray boolean

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

property 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

property bandpass

String

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

property 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

property input_fmt

str (‘mag’ or ‘flux’)

Input format - same as phot_fmt keyword in __init__().

property chi2_fmt

str (‘mag’ or ‘flux’)

Photometry format used for chi^2 calculations. Default is ‘flux’.

property ephemerides_file

str

File with satellite ephemeris.

copy()

Returns a copy of given instance with settings copied

Returns :
mulens_data: MulensData

Copy of self.

scale_errorbars(factor=None, minimum=None)

Scale magnitude errorbars by multiplying by factor and then adding minimum in squares.

Parameters :
factor: float

Multiplication factor. Typically used for faint events.

minimum: float

Floor of magnitude errorbars. Typically used for bright events.

property errorbars_scale_factors

list of two floats

Parameters used by scale_errorbars(). The first one is multiplication factor, while the second is the minimum scatter added in squares.

property errorbars_scaling_equation

str

Equation and parameters used by scale_errorbars().