Data Utilities
- class bagle.data.EventDataDict(val=None)
A dictionary object to hold the photometric and astrometric data for a specified target.
- The object must be initialized with
target: event name raL: R.A. of the target decL: Dec. of the target
and other entries are expected by the Multinest fitter and can be set at or after initialization. If they are not set at initialization, they will be initiliazed.
The other expected entries include:
For each photometric data set, the dictionary should contain:
t_phot1: Numpy array of times in MJD. mag1: Numpy array of magnitudes. mag_err1: Numpy array of magnitude errors. t_phot2: … additional data sets… mag2: … additional data sets… mag_err2: … additional data sets…
where the ‘1’ at the end is incremented for additional photometric data sets.
For each astrometric data set, the dictionary contains:
t_ast1: Numpy array of times in MJD. xpos1: Numpy array of positions on the sky in the East direction in arcsec. ypos1: Numpy array of positions on the sky in the North direction in arcsec. xpos_err1: Numpy array of positional errors on the sky in the East direction in arcsec. ypos_err1: Numpy array of positional errors on the sky in the North direction in arcsec. t_ast2: … additional data sets… xpos2: … additional data sets… ypos2: … additional data sets… xpos_err2: … additional data sets… ypos_err2: … additional data sets…
where the index is incremented for additional astrometric data sets.
There should also be entries containing a list of the names and file locations of all the photometric and astrometric data sets loaded. This is used during fitting and for reporting (and convenient reloading). These entries MUST match the order and length of the corresponding data sets. The entries are:
phot_data: list of names for photometric data sets (e.g. I_OGLE, Kp_Keck, Ch1_Spitzer, MOA) phot_files: list of filename strings for photometric data sets ast_data: list of names for astrometric data sets (e.g. Kp_Keck) ast_files: list of filename strings for astrometric data sets
One last note, if a data set is used to provide both photometry and astrometry, it should have the same “phot_data” and “ast_data” key. This will be used to tie parameters together between the two sets during fitting.
Methods
clear()copy()fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
items()keys()pop(key[, default])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem(/)Remove and return a (key, value) pair as a 2-tuple.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()EventDataDict must be instantiated with a dictionary containing
target raL decL
See class notes for a full description of what should be defined on the dictionary for normal use.
Methods
clear()copy()fromkeys(iterable[, value])Create a new dictionary with keys from iterable and values set to value.
get(key[, default])Return the value for key if key is in the dictionary, else default.
items()keys()pop(key[, default])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem(/)Remove and return a (key, value) pair as a 2-tuple.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()
- bagle.data.getdata(target, phot_data='I_OGLE', ast_data='Kp_Keck', time_format='mjd', verbose=False)
Helper function to illustrate how to load photometric and astrometric data. You will likely want to write your own version of this.
Get the photometric and astrometric data for the specified target. Specify the types of data through the phot_data and ast_data lists.
- Returns:
- data_dictEventDataDict
A dictionary containing the data. See documentation on data.EventDataDict for details.
For each photometric data set, the dictionary contains:
t_phot1 mag1 mag_err1
where the ‘1’ at the end is incremented for additional data sets.
For each astrometric data set, the dictionary contains:
t_ast1 xpos1 ypos1 xpos_err1 ypos_err1
where the index is incremented for additional astrometric data sets (useful for the future).
There are two additional entries in the dictionary which contain the R.A. and Dec. of the lensing target… this is the photocenter of the joint lens/source system and is hard-coded in module tables. Note that if only a single astrometry data set is requested, the returned keys are t_ast, xpos, ypos, xpos_err, ypos_err with no index on the end.
data[‘raL’] data[‘decL’]
- bagle.data.read_hst_astrometry(filename, target)
Read HST astrometry for one target from a multi-star FITS table.
- Parameters:
- filenamestr
Path to a FITS table containing astrometry for multiple stars.
- targetstr
Target name to select from the table name column (matched in uppercase).
- Returns:
- tuple
(t, x, y, xe, ye) where t is an astropy.time.Time array and x/y are East/North offsets with corresponding uncertainties for non-NaN epochs.
- bagle.data.read_hst_lightcurve(filename, target)
Read HST photometry for one target from a multi-star FITS table.
- Parameters:
- filenamestr
Path to a FITS file in flystar.StarTable-like format.
- targetstr
Target name to select from the table name column (matched in uppercase).
- Returns:
- tuple
(t, m, me) where t is an astropy.time.Time array and m/me are magnitude and magnitude-error arrays for non-NaN epochs.
- bagle.data.read_keck_astrometry(filename, target)
Read Keck astrometry for one target from a multi-star FITS table.
- Parameters:
- filenamestr
Path to a FITS table containing astrometry for multiple stars.
- targetstr
Target name to select from the table name column.
- Returns:
- tuple
(t, x, y, xe, ye) where t is an astropy.time.Time array and x/y are East/North offsets with corresponding uncertainties.
- bagle.data.read_keck_lightcurve(filename, target, verbose=False)
Read Keck photometry for one target from a multi-star FITS table.
- Parameters:
- filenamestr
Path to a FITS table containing all stars and epochs.
- targetstr
Target name to select from the table name column.
- verbosebool, optional
If True, print details about neighboring stars used to estimate empirical photometric uncertainties.
- Returns:
- tuple
(t, m, me) where t is an astropy.time.Time array and m/me are magnitude and magnitude-error arrays for the target.
- bagle.data.read_kmt_dia_lightcurve(filename)
Read a KMT DIA lightcurve file and convert fluxes to magnitudes.
- Parameters:
- filenamestr
Path to an ASCII KMT DIA file with time, flux, and flux-error columns in col1, col2, and col3.
- Returns:
- tuple
(t, m, me) where t is an astropy.time.Time array and m/me are converted magnitude and magnitude-error arrays.
- bagle.data.read_kmt_lightcurve(filename)
Read a KMTNet photometry file.
- Parameters:
- filenamestr
Path to an ASCII KMT lightcurve file with HJD, mag, and mag_err columns.
- Returns:
- tuple
(t, m, me) where t is an astropy.time.Time array and m/me are magnitude and magnitude-error arrays.
- bagle.data.read_moa_lightcurve(filename, target_coords)
Read a MOA photometry file and convert HJD-like times to JD.
- Parameters:
- filenamestr
Path to an ASCII MOA lightcurve file.
- target_coordsSkyCoord
Coordinates of the target are needed to correct for light travel time.
- Returns:
- tuple
(t, m, me) where t is an astropy.time.Time array and m/me are magnitude and magnitude-error arrays.
- bagle.data.read_ogle_lightcurve(filename)
Read an OGLE photometry file with columns for time, magnitude, magnitude-error.
- Parameters:
- filenamestr
Path to an ASCII OGLE lightcurve file with JD, magnitude, and magnitude-error columns in col1, col2, and col3.
- Returns:
- tuple
(t, m, me) where t is an astropy.time.Time array and m/me are magnitude and magnitude-error arrays.
- bagle.data.read_spitzer_lightcurve(filename)
Read a Spitzer lightcurve file and convert fluxes to magnitudes.
- Parameters:
- filenamestr
Path to an ASCII file with time, flux, and flux-error columns in col1, col2, and col3.
- Returns:
- tuple
(t, m, me) where t is an astropy.time.Time array and m/me are converted magnitude and magnitude-error arrays.