lsst.sims.maf.utils package¶
Submodules¶
lsst.sims.maf.utils.astrometryUtils module¶
-
lsst.sims.maf.utils.astrometryUtils.
astrom_precision
(fwhm, snr)[source]¶ Calculate the approximate precision of astrometric measurements, given a particular seeing and SNR value.
-
lsst.sims.maf.utils.astrometryUtils.
m52snr
(m, m5)[source]¶ Calculate the SNR for a star of magnitude m in an observation with 5-sigma limiting magnitude depth m5. Assumes gaussian distribution of photons and might not be strictly due in bluer filters. See table 2 and equation 5 in astroph/0805.2366.
-
lsst.sims.maf.utils.astrometryUtils.
sigma_slope
(x, sigma_y)[source]¶ Calculate the uncertainty in fitting a line, as given by the spread in x values and the uncertainties in the y values.
- Parameters
x (numpy.ndarray) – The x values of the data
sigma_y (numpy.ndarray) – The uncertainty in the y values
- Returns
The uncertainty in the line fit
- Return type
lsst.sims.maf.utils.getDateVersion module¶
lsst.sims.maf.utils.mafUtils module¶
-
lsst.sims.maf.utils.mafUtils.
collapse_night
(dataSlice, nightCol='night', filterCol='filter', m5Col='fiveSigmaDepth', mjdCol='observationStartMJD')[source]¶ Collapse a dataSlice down by night. Convert the MJD to the median MJD per night and coadd 5-sigma depth (per filter)
-
lsst.sims.maf.utils.mafUtils.
gnomonic_project_toxy
(RA1, Dec1, RAcen, Deccen)[source]¶ Calculate the x/y values of RA1/Dec1 in a gnomonic projection with center at RAcen/Deccen.
- Parameters
- Returns
The x/y values of the projected RA1/Dec1 positions.
- Return type
numpy.ndarray, numpy.ndarray
-
lsst.sims.maf.utils.mafUtils.
optimalBins
(datain, binmin=None, binmax=None, nbinMax=200, nbinMin=1)[source]¶ Set an ‘optimal’ number of bins using the Freedman-Diaconis rule.
- Parameters
datain (numpy.ndarray or numpy.ma.MaskedArray) – The data for which we want to set the binsize.
binmin (float) – The minimum bin value to consider (if None, uses minimum data value).
binmax (float) – The maximum bin value to consider (if None, uses maximum data value).
nbinMax (int) – The maximum number of bins to create. Sometimes the ‘optimal binsize’ implies an unreasonably large number of bins, if the data distribution is unusual.
nbinMin (int) – The minimum number of bins to create. Default is 1.
- Returns
The number of bins.
- Return type
-
lsst.sims.maf.utils.mafUtils.
percentileClipping
(data, percentile=95.0)[source]¶ Calculate the minimum and maximum values of a distribution of points, after discarding data more than ‘percentile’ from the median. This is useful for determining useful data ranges for plots. Note that ‘percentile’ percent of the data is retained.
-
lsst.sims.maf.utils.mafUtils.
radec2pix
(nside, ra, dec)[source]¶ Calculate the nearest healpixel ID of an RA/Dec array, assuming nside.
- Parameters
nside (int) – The nside value of the healpix grid.
ra (numpy.ndarray) – The RA values to be converted to healpix ids, in radians.
dec (numpy.ndarray) – The Dec values to be converted to healpix ids, in radians.
- Returns
The healpix ids.
- Return type
numpy.ndarray
lsst.sims.maf.utils.obs2sqlite module¶
lsst.sims.maf.utils.opsimUtils module¶
-
lsst.sims.maf.utils.opsimUtils.
calcCoaddedDepth
(nvisits, singleVisitDepth)[source]¶ Calculate the coadded depth expected for a given number of visits and single visit depth.
- Parameters
nvisits (dict of ints or floats) – Dictionary (per filter) of number of visits
singleVisitDepth (dict of floats) – Dictionary (per filter) of the single visit depth
- Returns
Dictionary of coadded depths per filter.
- Return type
dict of floats
-
lsst.sims.maf.utils.opsimUtils.
getFieldData
(opsimDb, sqlconstraint)[source]¶ Find the fields (ra/dec/fieldID) relevant for a given sql constraint. If the opsimDb contains a Fields table, it uses
OpsimDatabase.fetchFieldsFromFieldTable()
to get the fields. If the opsimDb contains only a Summary, it usesOpsimDatabase.fetchFieldsFromSummaryTable()
.- Parameters
opsimDb (OpsimDatabase) – An opsim database to use to query for field information.
sqlconstraint (str) – A SQL constraint to apply to the query (i.e. find all fields for DD proposal)
- Returns
A numpy structured array containing the field information. This data will ALWAYS be in radians.
- Return type
numpy.ndarray
-
lsst.sims.maf.utils.opsimUtils.
getSimData
(opsimDb, sqlconstraint, dbcols, stackers=None, groupBy='default', tableName=None)[source]¶ Query an opsim database for the needed data columns and run any required stackers.
- Parameters
opsimDb (OpsimDatabase) –
sqlconstraint (str) – SQL constraint to apply to query for observations.
dbcols (list of str) – Columns required from the database.
stackers (list of Stackers) – Stackers to be used to generate additional columns.
tableName (str) – Name of the table to query.
distinctExpMJD (bool) – Only select observations with a distinct expMJD value. This is overriden if groupBy is not expMJD.
groupBy (str) – Column name to group SQL results by.
- Returns
A numpy structured array with columns resulting from dbcols + stackers, for observations matching the SQLconstraint.
- Return type
numpy.ndarray
-
lsst.sims.maf.utils.opsimUtils.
scaleBenchmarks
(runLength, benchmark='design')[source]¶ Set the design and stretch values of the number of visits, area of the footprint, seeing values, FWHMeff values, skybrightness, and single visit depth (based on SRD values). Scales number of visits for the length of the run, relative to 10 years.
- Parameters
- Returns
A dictionary containing the number of visits, area of footprint, seeing and FWHMeff values, skybrightness and single visit depth for either the design or stretch SRD values.
- Return type
dict of floats
-
lsst.sims.maf.utils.opsimUtils.
writeConfigs
(opsimDb, outDir)[source]¶ Convenience function to get the configuration information from the opsim database and write this information to text files ‘configSummary.txt’ and ‘configDetails.txt’.
- Parameters
opsimDb (OpsimDatabase) – The opsim database from which to pull the opsim configuration information. Opsim SQLite databases save this configuration information in their config table.
outputDir (str) – The path to the output directory, where to write the config*.txt files.
lsst.sims.maf.utils.outputUtils module¶
-
lsst.sims.maf.utils.outputUtils.
nameSanitize
(inString)[source]¶ Convert a string to a more file name (and web) friendly format.
-
lsst.sims.maf.utils.outputUtils.
printDict
(content, label, filehandle=None, delimiter=' ', _level=0)[source]¶ Print dictionaries (and/or nested dictionaries) nicely. Can also print other simpler items (such as numpy ndarray) nicely too. This is used to print the config files.
lsst.sims.maf.utils.snNSNUtils module¶
-
class
lsst.sims.maf.utils.snNSNUtils.
CovColor
(lc)[source]¶ Bases:
object
class to estimate CovColor from lc using Fisher matrix element :param lc: :type lc: pandas df :param lc to process. Should contain the Fisher matrix components: :param ie the sum of the derivative of the fluxes wrt SN parameters:
-
class
lsst.sims.maf.utils.snNSNUtils.
GetReference
(lcName, gammaName, tel_par, param_Fisher=['x0', 'x1', 'color', 'daymax'])[source]¶ Bases:
object
Class to load reference data used for the fast SN simulator :param lcName: name of the reference file to load (lc) :type lcName: str :param gammaName: name of the reference file to load (gamma) :type gammaName: str :param tel_par: telescope parameters :type tel_par: dict :param param_Fisher: list of SN parameter for Fisher estimation to consider
(default: [‘x0’, ‘x1’, ‘color’, ‘daymax’])
- Returns
The following dict can be accessed
mag_to_flux_e_sec (Interp1D of mag to flux(e.sec-1) conversion)
flux (dict of RegularGridInterpolator of fluxes (key: filters, (x,y)=(phase, z), result=flux))
fluxerr (dict of RegularGridInterpolator of flux errors (key: filters, (x,y)=(phase, z), result=fluxerr))
param (dict of dict of RegularGridInterpolator of flux derivatives wrt SN parameters) – (key: filters plus param_Fisher parameters; (x,y)=(phase, z), result=flux derivatives)
gamma (dict of RegularGridInterpolator of gamma values (key: filters))
-
Read_Multiproc
(tab)[source]¶ Multiprocessing method to read references :param tab: :type tab: astropy Table of data
- Returns
- Return type
stacked astropy Table of data
-
Read_Ref
(fi, j=- 1, output_q=None)[source]¶ ” Load the reference file and make a single astopy Table from a set of. :param fi: name of the file to be loaded :type fi: str,
- Returns
tab_tot – single table = vstack of all the tables in fi.
- Return type
astropy table
-
limVals
(lc, field)[source]¶ Get unique values of a field in a table :param lc: astropy Table (here probably a LC) :type lc: Table :param field: name of the field of interest :type field: str
- Returns
vmin (float) – min value of the field
vmax (float) – max value of the field
vstep (float) – step value for this field (median)
nvals (int) – number of unique values
-
class
lsst.sims.maf.utils.snNSNUtils.
LCfast
(reference_lc, x1, color, telescope, mjdCol='observationStartMJD', RACol='fieldRA', DecCol='fieldDec', filterCol='filter', exptimeCol='visitExposureTime', m5Col='fiveSigmaDepth', seasonCol='season', nexpCol='numExposures', snr_min=5.0)[source]¶ Bases:
object
class to simulate supernovae light curves in a fast way The method relies on templates and broadcasting to increase speed :param reference_lc: :param x1: SN stretch :type x1: float :param color: SN color :type color: float :param telescope: telescope for the study :type telescope: Telescope() :param mjdCol: name of the MJD col in data to simulate (default: observationStartMJD) :type mjdCol: str, opt :param RACol: name of the RA col in data to simulate (default: fieldRA) :type RACol: str, opt :param DecCol: name of the Dec col in data to simulate (default: fieldDec) :type DecCol: str, opt :param filterCol: name of the filter col in data to simulate (default: filter) :type filterCol: str, opt :param exptimeCol: name of the exposure time col in data to simulate (default: visitExposureTime) :type exptimeCol: str, opt :param m5Col: name of the fiveSigmaDepth col in data to simulate (default: fiveSigmaDepth) :type m5Col: str, opt :param seasonCol: name of the season col in data to simulate (default: season) :type seasonCol: str, opt :param snr_min: minimal Signal-to-Noise Ratio to apply on LC points (default: 5) :type snr_min: float, opt
-
__call__
(obs, gen_par=None, bands='grizy')[source]¶ Simulation of the light curve
- Parameters
obs (array) – array of observations
gen_par (array, opt) – simulation parameters (default: None)
bands (str, opt) – filters to consider for simulation (default: grizy)
- Returns
astropy table with
columns (band, flux, fluxerr, snr_m5,flux_e,zp,zpsys,time)
metadata (SNID,RA,Dec,DayMax,X1,Color,z)
-
processBand
(sel_obs, band, gen_par, j=- 1, output_q=None)[source]¶ LC simulation of a set of obs corresponding to a band The idea is to use python broadcasting so as to estimate all the requested values (flux, flux error, Fisher components, …) in a single path (i.e no loop!) :param sel_obs: array of observations :type sel_obs: array :param band: band of observations :type band: str :param gen_par: simulation parameters :type gen_par: array :param j: index for multiprocessing (default: -1) :type j: int, opt :param output_q: queue for multiprocessing (default: None) :type output_q: multiprocessing.Queue(),opt
- Returns
- Return type
astropy table with fields corresponding to LC components
-
-
class
lsst.sims.maf.utils.snNSNUtils.
Load_Reference
(server='https://me.lsst.eu/gris/DESC_SN_pipeline', templateDir=None)[source]¶ Bases:
object
class to load template files requested for LCFast These files should be stored in a reference_files directory
- Parameters
server (str, opt) – where to get the files (default: https://me.lsst.eu/gris/DESC_SN_pipeline/Reference_Files)
templateDir (str, opt) – where to put the files (default: reference_files)
-
class
lsst.sims.maf.utils.snNSNUtils.
SN_Rate
(rate='Perrett', H0=70, Om0=0.25, min_rf_phase=- 15.0, max_rf_phase=30.0)[source]¶ Bases:
object
Estimate production rates of typeIa SN Available rates: Ripoche, Perrett, Dilday
- Parameters
rate (str,opt) – type of rate chosen (Ripoche, Perrett, Dilday) (default : Perrett)
H0 (float, opt) – Hubble constant value :math:`H_{0}`(default : 70.)
Om0 (float, opt) – matter density value \(\Omega_{0}\) (default : 0.25)
min_rf_phase (float, opt) – min rest-frame phase (default : -15.)
max_rf_phase (float, opt) – max rest-frame phase (default : 30.)
-
DildayRate
(z)[source]¶ - The Dilday rate according to
Parameters
- zfloat
redshift
- Returns
rate (float)
error_rate (float)
-
PerrettRate
(z)[source]¶ The SNLS SNIa rate according to (Perrett et al, 201?) :param z: redshift :type z: float
- Returns
rate (float)
error_rate (float)
-
PlotNSN
(zmin=0.1, zmax=0.2, dz=0.01, survey_area=9.6, bins=None, account_for_edges=False, duration=140.0, duration_z=None, norm=False)[source]¶ Plot integrated number of supernovae as a function of redshift uses the __call__ function :param zmin: minimal redshift (default : 0.1) :type zmin: float, opt :param zmax: max redshift (default : 0.2) :type zmax: float,opt :param dz: redshift bin (default : 0.001) :type dz: float, opt :param survey_area: area of the survey (\(deg^{2}\)) (default : 9.6 \(deg^{2}\)) :type survey_area: float, opt :param bins: redshift bins (default : None) :type bins: list(float), opt :param account_for_edges: to account for season edges. If true, duration of the survey will be reduced by (1+z)*(maf_rf_phase-min_rf_phase)/365.25 (default : False) :type account_for_edges: bool :param duration: survey duration (in days) (default : 140 days) :type duration: float, opt :param duration_z: survey duration (as a function of z) (default : None) :type duration_z: list(float),opt :param norm: to normalise the results (default: False) :type norm: bool, opt
-
RipocheRate
(z)[source]¶ The SNLS SNIa rate according to the (unpublished) Ripoche et al study. :param z: redshift :type z: float
- Returns
rate (float)
error_rate (float)
-
SNRate
(z)[source]¶ SN rate estimation :param z: redshift :type z: float
- Returns
rate (float)
error_rate (float)
-
__call__
(zmin=0.1, zmax=0.2, dz=0.01, survey_area=9.6, bins=None, account_for_edges=False, duration=140.0, duration_z=None)[source]¶ call method :param zmin: minimal redshift (default : 0.1) :type zmin: float, opt :param zmax: max redshift (default : 0.2) :type zmax: float,opt :param dz: redshift bin (default : 0.001) :type dz: float, opt :param survey_area: area of the survey (\(deg^{2}\)) (default : 9.6 \(deg^{2}\)) :type survey_area: float, opt :param bins: redshift bins (default : None) :type bins: list(float), opt :param account_for_edges: to account for season edges. If true, duration of the survey will be reduced by (1+z)*(maf_rf_phase-min_rf_phase)/365.25 (default : False) :type account_for_edges: bool :param duration: survey duration (in days) (default : 140 days) :type duration: float, opt :param duration_z: survey duration (as a function of z) (default : None) :type duration_z: list(float),opt
- Returns
Lists
zz (float) – redshift values
rate (float) – production rate
err_rate (float) – production rate error
nsn (float) – number of SN
err_nsn (float) – error on the number of SN
-
class
lsst.sims.maf.utils.snNSNUtils.
Telescope
(name='unknown', airmass=1.0, **kwargs)[source]¶ Bases:
lsst.sims.maf.utils.snNSNUtils.Throughputs
Telescope class inherits from Throughputs estimate quantities defined in LSE-40 The following quantities are accessible: mag_sky: sky magnitude m5: 5-sigma depth Sigmab: see eq. (36) of LSE-40 zp: see eq. (43) of LSE-40 counts_zp: Skyb: see eq. (40) of LSE-40 flux_sky: :param through_dir: throughput directory
Default : LSST_THROUGHPUTS_BASELINE
- Parameters
atmos_dir (str, opt) – directory of atmos files Default : THROUGHPUTS_DIR
telescope_files (list(str),opt) –
list of of throughput files Default : [‘detector.dat’, ‘lens1.dat’,’lens2.dat’,
’lens3.dat’,’m1.dat’, ‘m2.dat’, ‘m3.dat’]
filterlist (list(str), opt) – list of filters to consider Default : ‘ugrizy’
wave_min (float, opt) – min wavelength for throughput Default : 300
wave_max (float, opt) – max wavelength for throughput Default : 1150
atmos (bool, opt) – to include atmosphere affects Default : True
aerosol (bool, opt) – to include aerosol effects Default : True
airmass (float, opt) – airmass value Default : 1.
- Returns
Accessible throughputs (per band, from Throughput class)
lsst_system (system throughput (lens+mirrors+filters))
lsst_atmos (lsst_system+atmosphere)
lsst_atmos_aerosol (lsst_system+atmosphere+aerosol)
Note (I would like to see this replaced by a class in sims_photUtils instead. This does not belong in MAF.)
-
Calc_Integ
(bandpass)[source]¶ integration over bandpass :param bandpass: :type bandpass: float
- Returns
- Return type
integration
-
Calc_Integ_Sed
(sed, bandpass, wavelen=None, fnu=None)[source]¶ SED integration :param sed: sed to integrate :type sed: float :param bandpass: bandpass :type bandpass: float :param wavelength:
- wavelength values
Default : None
- Parameters
fnu (float, opt) – fnu values Default : None
- Returns
- Return type
integrated sed over the bandpass
-
flux_to_mag
(flux, band, zp=None)[source]¶ Flux to magnitude conversion :param flux: input fluxes :type flux: float :param band: input band :type band: str :param zp: zeropoints
Default : None
- Returns
- Return type
magnitudes
-
get
(what, band)[source]¶ Decorator to access quantities :param what: parameter to estimate :type what: str :param band: filter :type band: str
-
get_inputs
(what, band)[source]¶ decorator to access Tb, Sigmab, mag_sky :param what: parameter to estimate :type what: str :param band: filter :type band: str
-
get_zp
(what, band)[source]¶ decorator get zero points formula used here are extracted from LSE-40 :param what: parameter to estimate :type what: str :param band: filter :type band: str
-
mag_to_flux
(mag, band, zp=None)[source]¶ Magnitude to flux conversion :param mag: input mags :type mag: float :param band: input band :type band: str :param zp: zeropoints
Default : None
- Returns
- Return type
fluxes
-
mag_to_flux_e_sec
(mag, band, exptime)[source]¶ Mag to flux (in photoelec/sec) conversion :param mag: input magnitudes :type mag: float :param band: input bands :type band: str :param exptime: input exposure times :type exptime: float
- Returns
counts (float) – number of ADU counts
e_per_sec (float) – flux in photoelectron per sec.
-
return_value
(what, band)[source]¶ accessor :param what: parameter to estimate :type what: str :param band: filter :type band: str
-
class
lsst.sims.maf.utils.snNSNUtils.
Throughputs
(**kwargs)[source]¶ Bases:
object
class to handle instrument throughput :param through_dir: throughput directory. If None, uses $THROUGHPUTS_DIR/baseline :type through_dir: str, opt :param atmos_dir: directory of atmos files. If None, uses $THROUGHPUTS_DIR :type atmos_dir: str, opt :param telescope_files: list of of throughput files
- Default[‘detector.dat’, ‘lens1.dat’,’lens2.dat’,
‘lens3.dat’,’m1.dat’, ‘m2.dat’, ‘m3.dat’]
- Parameters
filterlist (list(str), opt) – list of filters to consider Default : ‘ugrizy’
wave_min (float, opt) – min wavelength for throughput Default : 300
wave_max (float, opt) – max wavelength for throughput Default : 1150
atmos (bool, opt) – to include atmosphere affects Default : True
aerosol (bool, opt) – to include aerosol effects Default : True
- Returns
Accessible throughputs (per band)
lsst_system (system throughput (lens+mirrors+filters))
lsst_atmos (lsst_system+atmosphere)
lsst_atmos_aerosol (lsst_system+atmosphere+aerosol)
Note (I would like to see this replaced by a class in sims_photUtils instead. This does not belong in MAF.)
-
Load_Atmosphere
(airmass=1.2)[source]¶ Load atmosphere files and convolve with transmissions :param airmass: airmass value
Default : 1.2
-
property
aerosol
¶
-
property
atmosphere
¶
-
property
system
¶
-
property
telescope
¶
lsst.sims.maf.utils.snUtils module¶
-
class
lsst.sims.maf.utils.snUtils.
GenerateFakeObservations
(config, mjdCol='observationStartMJD', RaCol='fieldRA', DecCol='fieldDec', filterCol='filter', m5Col='fiveSigmaDepth', exptimeCol='visitExposureTime', nexpCol='numExposures', seasonCol='season')[source]¶ Bases:
object
Class to generate Fake observations
- Parameters
config (yaml-like) – configuration file (parameter choice: filter, cadence, m5,Nseasons, …)
list (str,opt) – Name of the columns used. Default : ‘observationStartMJD’, ‘fieldRA’, ‘fieldDec’,’filter’,’fiveSigmaDepth’,’visitExposureTime’,’numExposures’,’visitTime’,’season’
- Returns
recordarray of observations with the fields
MJD, Ra, Dec, band,m5,Nexp, ExpTime, Season
-
class
lsst.sims.maf.utils.snUtils.
Lims
(Li_files, mag_to_flux_files, band, SNR, mag_range=(23.0, 27.5), dt_range=(0.5, 25.0))[source]¶ Bases:
object
class to handle light curve of SN
- Parameters
Li_files (str) – light curve reference file
mag_to_flux_files (str) – files of magnitude to flux
band (str) – band considered
SNR (float) – Signal-To-Noise Ratio cut
mag_range (pair(float),opt) – mag range considered Default : (23., 27.5)
dt_range (pair(float)) – difference time range considered (cadence) Default : (0.5, 25.)
-
interp
()[source]¶ Estimate a grid of interpolated values in the plane (m5, cadence, metric)
- Parameters
None –