lsst.sims.maf.utils package¶
Submodules¶
lsst.sims.maf.utils.astrometryUtils module¶
-
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.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.
Parameters: Returns: The SNR
Return type: float or numpy.ndarray
lsst.sims.maf.utils.getDateVersion module¶
lsst.sims.maf.utils.mafUtils module¶
-
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.
Parameters: - data (numpy.ndarray) – The data to clip.
- percentile (float) – Retain values within percentile of the median.
Returns: The minimum and maximum values of the clipped data.
Return type:
-
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.
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.obs2sqlite.
obs2sqlite
(observations_in, location='LSST', outfile='observations.sqlite', slewtime_limit=5.0, full_sky=False, radians=True)[source]¶ Utility to take an array of observations and dump it to a sqlite file, filling in useful columns along the way.
- observations_in: numpy array with at least columns of
- ra : RA in degrees dec : dec in degrees mjd : MJD in day filter : string with the filter name exptime : the exposure time in seconds
- slewtime_limit : float
- Consider all slewtimes larger than this to be closed-dome time not part of a slew.
lsst.sims.maf.utils.opsimUtils module¶
-
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.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.
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.outputUtils module¶
-
lsst.sims.maf.utils.outputUtils.
nameSanitize
(inString)[source]¶ Convert a string to a more file name friendly format.
Parameters: inString (str) – The input string to be sanitized. Typically these are combinations of metric names and metadata. Returns: The string after removal/replacement of non-filename friendly characters. Return type: str
-
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.
Parameters: