opsimsummaryv2.utils#

This module contains usefull functions.

Attributes#

Functions#

compute_angle_sep(ra_arr, dec_arr, ra, dec)

Compute angle separation

dataline(expMJD, ObsID, BAND, CCDgain, CCDnoise, ...)

Write a SIMLIB data line

df_subdiviser(df, Nsub)

Divide a dataframe into a list of sub-dataframne

download_rubinlsst_baseline_dbfile(version[, output_dir])

Download a specific versio of Opsim output.

format_poly(poly)

Fromat polygon that cross the 2 PI edge.

host_joiner(survey_fields, host)

Use geopandas to match host in survey fields.

host_resampler(wgt_map_VAR, wgt_map_WGT, index, values)

Resample host according to a WGTMAP

read_SNANA_WGTMAP(file)

Read a SNANA HOSTLIB WGTMAP

Module Contents#

opsimsummaryv2.utils.compute_angle_sep(ra_arr: numpy.array, dec_arr: numpy.array, ra: float, dec: float)[source]#

Compute angle separation

Parameters:
  • ra_arr (np.array) – array of RA coords

  • dec_arr (np.array) – array of Dec coords

  • ra (float) – the RA coord of the reference angle with which compute the separation

  • dec (float) – the Dec coord of the reference angle with which compute the separation

Returns:

angle separation

Return type:

np.array

opsimsummaryv2.utils.dataline(expMJD, ObsID, BAND, CCDgain, CCDnoise, SKYSIG, PSF, ZPT, ZPTNoise)[source]#

Write a SIMLIB data line

Parameters:
  • expMJD (float) – Date of observation in MJD

  • ObsID (int) – ID of the observation

  • BAND (str) – Band used for the observation

  • CCDgain (float) – CCd gain

  • CCDnoise (float) – CCD noise

  • SKYSIG (float) – Sky noise error

  • PSF (float) – Point spread function sigma

  • ZPT (float) – Zero point

  • ZPTNoise (float) – Zero point calibration error

Returns:

A SIMLIB LIB entry line

Return type:

str

opsimsummaryv2.utils.df_subdiviser(df, Nsub)[source]#

Divide a dataframe into a list of sub-dataframne

Parameters:
Returns:

A list of dataframme subdivisions.

Return type:

list(pandas.DataFrame)

opsimsummaryv2.utils.download_rubinlsst_baseline_dbfile(version, output_dir=None)[source]#

Download a specific versio of Opsim output.

Parameters:
  • version (str) – The version of OpSim output to download.

  • output_dir (str, optional) – path of download, by default $SNANA_LSST_ROOT/simlibs/

Raises:

ValueError – _description_

opsimsummaryv2.utils.format_poly(poly)[source]#

Fromat polygon that cross the 2 PI edge.

Parameters:

poly (shapely.polygons) – Polygon that represent fields

Returns:

Polygon that represent fields cutted on 2 PI edge.

Return type:

shapely.MultiPolygons

opsimsummaryv2.utils.host_joiner(survey_fields, host)[source]#

Use geopandas to match host in survey fields.

Parameters:
  • survey_fields (geopandas.GeoDataFrame) – Geodataframe describing survey fields

  • host (pandas.DataFrame) – Dataframe that contains host informations

Returns:

Datafrane containing host that are in field with their correspind GROUPID

Return type:

pandas.DataFrame

opsimsummaryv2.utils.host_resampler(wgt_map_VAR, wgt_map_WGT, index, values, cdf_cut=0.95)[source]#

Resample host according to a WGTMAP

Parameters:
  • wgt_map_VAR (numpy.array(float)) – Variable of the WGTMAP

  • wgt_map_WGT (numpy.array(float)) – Weight values of the WGTMAP

  • index (numpy.array(int)) – Index of hosts

  • values (numpy.array(float)) – Values of the Variable for host

  • cdf_cut (float, optional) – A cut on the cdf to adjust , by default 0.95

Returns:

_description_

Return type:

_type_

opsimsummaryv2.utils.read_SNANA_WGTMAP(file)[source]#

Read a SNANA HOSTLIB WGTMAP

Parameters:

file (str) – path to WGTMAP

Returns:

list of varnames, WGTMAP as a dict

Return type:

list(str), dict

Raises:

ValueError – No WGT key

opsimsummaryv2.utils.use_geopandas = True#