opsimsummaryv2.summary_opsim#

Main module to read OpSim output database.

Attributes#

Classes#

OpSimSurvey

A class to manipulate OpSim db data and turn them into simulation inputs.

Module Contents#

class opsimsummaryv2.summary_opsim.OpSimSurvey(db_path, mjd_range=None, host_file=None, host_config={})[source]#

A class to manipulate OpSim db data and turn them into simulation inputs.

db_path#

Path to the database file

Type:

pathlib.Path

sql_engine#

The sqlalchemy engine link to the db.

Type:

sqlalchemy.engine.base.Engine

opsimdf#

Dataframe of the simulated observations.

Type:

pandas.DataFrame

tree#

A BallTree used to select observations on the healpy representation of the survey.

Type:

sklearn.neighbors.BallTree

host#

Dataframe of the hosts.

Type:

pandas.DataFrame

hp_rep#

The healpy representation oif the survey

Type:

pandas.DataFrame

survey#

The healpy representation oif the survey

Type:

pandas.DataFrame

survey_hosts#

The hosts that are inside the survey.

Type:

pandas.DataFrame

static _get_df_from_sql(sql_engine, mjd_range=None)[source]#

Load data from the db file.

Parameters:
  • sql_engine (sqlalchemy.engine.base.Engine) – The sqlalchemy engine link to the db.

  • mjd_range (( , ) str or float, optional) – Min and Max date to query if float assumed to be mjd, by default None

Returns:

Dataframe of the simulated observations.

Return type:

pandas.DataFrame

static _get_sql_engine(dbname)[source]#

Read a sql db Opsim output file.

Parameters:

dbname (str) – Path to sql file.

Returns:

The sqlalchemy engine link to the db.

Return type:

sqlalchemy.engine.base.Engine

_read_host_file(host_file, col_ra='ra', col_dec='dec', ra_dec_unit='radians', wgt_map=None, add_SNMAGSHIFT=False)[source]#

Read a parquet file containing hosts.

Parameters:
  • host_file (str) – Path to the parquet file

  • col_ra (str, optional) – Key of column containing RA, by default ‘ra’

  • col_dec (str, optional) – Key of column containing Dec, by default ‘dec’

  • ra_dec_unit (str, optional) – Unit of ra_dec (radians or degrees), by default ‘radians’

Returns:

Dataframe of the hosts.

Return type:

pandas.DataFrame

compute_hp_rep(nside=256, minVisits=500, maxVisits=100000, ddf_nobs_thresh=1100, add_ddf_tag=False, angle_sep_tol=10)[source]#

Compute a healpy version of the survey.

Parameters:
  • nside (int, optional) – Healpy nside, by default 256

  • minVisits (int, optional) – Minimum number of observations required in the survey, by default 500

  • maxVisits (int, optional) – Maximum number of observations required in the survey, by default 100000

formatObs(OpSimObs, keep_keys=[])[source]#

Format function to get quantities of interest for simulation.

Parameters:
  • OpSimObs (pandas.DataFrame) – Dataframe of OpSim output

  • keep_keys (list(str)) – List of keys to keep in addition to formatted quantities

Returns:

Dataframe that contains quantities for simulation.

Return type:

pandas.DataFrame

Notes

Quantities are obtained following arxiv:1905.02887

Details of the calculs:

The \(\sigma_\mathrm{PSF}\) in units of \(\mathrm{arcsec}^{-1}\) is obtained as

\[\sigma_\mathrm{PSF} = \frac{\mathbf{seeingFwhmEff}}{2\sqrt{2\ln2}}.\]

The \(\mathbf{PSF}\) is computed in units of \(\mathrm{pixel}^{-1}\) as

\[\mathbf{PSF} = \frac{\sigma_\mathrm{PSF}}{\mathrm{PixelSize}},\]

where \(\mathrm{PixelSize}\) is the pixel size in \(\mathrm{arcsec}^{-1}\).

The zero-point \(\mathbf{ZPT}\) is computed as

\[\mathbf{ZPT} = 2 m_5 - m_\mathrm{sky} + 2.5 \log\left[25 A \left(1 + A^{-1}10^{-0.4(m_5-m_\mathrm{sky})}\right)\right],\]

where \(m_5 = \mathbf{fiveSigmaDepth}\), \(m_\mathrm{sky} = \mathbf{skyBrightness}\) and \(A\) is the noise equivalent area given by \(A = 4 \pi \sigma_\mathrm{PSF}^2\).

The sky noise \(\mathbf{SKYSIG}\) in unit of \(\mathrm{ADU}.\mathrm{pixel}^{-1}\) is computed such as

\[\mathbf{SKYSIG}^2 = 10^{-0.4\left(m_\mathrm{sky} - \mathbf{ZPT}\right)} \times \mathrm{PixelSize}^2.\]
get_obs_from_coords(ra, dec, is_deg=True, formatobs=False, keep_keys=[])[source]#

Get observations at ra, dec coordinates.

Parameters:
  • ra (numpy.ndarray(float)) – RA coordinate

  • dec (numpy.ndarray(float)) – Dec coordinate

  • is_deg (bool, optional) – is RA, Dec given in degrees, by default True

  • formatobs (bool, optional) – format obs for simulation, by default False

  • keep_keys (list(str)) – List of keys to keep in addition to formatted quantities

Yields:

pandas.DatFrame – Dataframes of observations.

get_survey_hosts(nworkers=10)[source]#

Get survey hosts.

Parameters:

nworkers (int, optional) – Number of cores used to run multiprocessing, by default 10

Returns:

Dataframe of host inside the survey, matched to their field indicated by GROUPID.

Return type:

pandas.DataFrame

get_survey_obs(formatobs=True, keep_keys=[])[source]#

Get survey observations.

Parameters:
  • formatobs (bool, optional) – Format the observation to get only quantities of interest for simulation, by default True

  • keep_keys (list(str)) – List of keys to keep in addition to formatted quantities

Yields:

pandas.DatFrame – Dataframes of observations.

plot_hp_rep(**hp_mollview_kwargs)[source]#

Plot the healpy mollview of the survey representation.

Returns:

The mollview figure

Return type:

matplotlib.Figure

sample_survey(N_fields, random_seed=None, nworkers=10)[source]#

Sample Nfields inside the survey’s healpy representation.

Parameters:
  • N_fields (int) – Number of fields to sample

  • random_seed (int or numpy.random.SeedSquence, optional) – The random seed used to sample the fields, by default None

  • nworkers (int, optional) – Number of cores used to run multiprocessing on host matching, by default 10

Notes

Random seed only apply on field sampling.

__LSST_DDF_TAGS__#
__LSST_FIELD_RADIUS__#
__LSST_pixelSize__ = 0.2#
_hp_rep = None#
_survey = None#
db_path#
host = None#
property hp_rep#
opsimdf#
sql_engine = None#
property survey#
property survey_hosts#
tree#
opsimsummaryv2.summary_opsim.use_geopandas = True#