opsimsummaryv2.sim_io#

Class to write simulations input files.

Attributes#

Classes#

SNANA_Simlib

A class to write SNANA simulation output from OpSimSurvey object.

SNSIM_obsfile

SimWriter

Module Contents#

class opsimsummaryv2.sim_io.SNANA_Simlib(OpSimSurvey, out_path=None, author_name=None, file_suffix='', ZPTNoise=0.005, CCDgain=1.0, CCDnoise=0.25, NOTES={})[source]#

Bases: SimWriter

A class to write SNANA simulation output from OpSimSurvey object.

OpSimSurvey#

The OpSimSurvey object

Type:

opsimsummaryv2.summary_opsim.OpSimSurvey

author_name#

The author of the SIMLIB

Type:

str, optional

out_path#

The path of the output file, default ‘./’

Type:

str, optional

date_time#

The current time, to be written in SIMLIB

Type:

str

dataline#

A vectorized function to write SIMLIB dataline

Type:

numpy.vectorize

ZPTNoise#

The constant ZPTNoise value, by default 0.005

Type:

float

CCDNoise#

The constant CCDNoise value, by default 0.25

Type:

float

CCDGain#

The CCD gain in e-/ADU, by default 1.

Type:

float

LIBdata(opsimdf)[source]#

Give the string of a LIB entry.

Parameters:

opsimdf (pandas.DataFrame) – LIB entry observations

Returns:

The str of the LIB entry.

Return type:

str

LIBfooter(LIBID)[source]#

Give the string of a LIB entry footer.

Parameters:

LIBID (int) – The LIBID of the entry

Returns:

The string of a LIB entry footer

Return type:

str

LIBheader(LIBID, ra, dec, opsimdf, mwebv=0.0, groupID=None, field_label=None)[source]#

Give the string of the header of a LIB entry.

Parameters:
  • LIBID (int) – The LIBID of the entry.

  • ra (float) – RA [deg] coordinate of the entry

  • dec (float) – Dec [deg] coordinate of the entry

  • opsimdf (pandas.DataFrame) – LIB entry observations

  • mwebv (float, optional) – MWEBV of the entry, default = 0.0

  • groupID (int, optional) – GROUPID of the entry used to match with HOSTLIB hosts.

Returns:

The LIB entry header string.

Return type:

str

_init_dataline()[source]#
get_HOSTLIB_doc()[source]#

Give docstring for HOSTLIB file.

Returns:

Docstring of the HOSTLIB file

Return type:

str

get_HOSTLIB_header(hostdf)[source]#

Give HOSTLIB header.

Parameters:

hostdf (pandas.DataFrame) – Hosts dataframe

Returns:

Header of HSOTLIB file

Return type:

str

get_SIMLIB_doc()[source]#

Give the DOCUMENTATION string for SIMLIB.

Returns:

DOCUMENTATION string

Return type:

str

Give SIMLIB footer.

get_SIMLIB_header(saturation_flag=1024, comments='\n')[source]#

Give the SIMLIB header string.

Parameters:
  • saturation_flag (int, optional) – The flag corresponding to saturated obs, by default 1024

  • comments (str, optional) – Comments to add to the header, by default ‘n’

Returns:

The SIMLIB header string.

Return type:

str

write_HOSTLIB(hostdf, buffer_size=8192)[source]#

Write the HOSTLIB file. Called in write_SIMLIB.

Parameters:
  • hostdf (pandas.DataFrame) – Hosts dataframe

  • buffer_size (int) – buffering option for open() function

write_SIMLIB(write_batch_size=10, buffer_size=8192)[source]#

write the SIMLIB (and the HOSTLIB) file(s).

Parameters:
  • write_batch_size (int) – Number of LIBID to write at the same time

  • buffer_size (int) – buffering option for open() function

NOTES#
dataline#
class opsimsummaryv2.sim_io.SNSIM_obsfile(OpSimSurvey, out_path=None, author_name=None, ZPTNoise=0.005, CCDgain=1.0, CCDnoise=0.25)[source]#

Bases: SimWriter

static get_LSST_field()[source]#
get_survey_config(write_field_map=False)[source]#
write_survey_file(write_survey_conf=True, write_field_map=True)[source]#
class opsimsummaryv2.sim_io.SimWriter(OpSimSurvey, out_path=None, author_name=None, ZPTNoise=0.005, CCDgain=1.0, CCDnoise=0.25, outfile_ext='.SIMLIB', file_suffix='')[source]#
_init_out_path(out_path, outfile_ext, file_suffix='')[source]#

Format output path for SIMLIB and HOSTLIB.

Parameters:

out_path (str) – Output directory or file.

Returns:

Path to the output SIMLIB.

Return type:

pathlib.Path

CCDgain = 1.0#
CCDnoise = 0.25#
OpSimSurvey#
ZPTNoise = 0.005#
author_name = None#
date_time#
out_path#
opsimsummaryv2.sim_io.use_pyarrow = True#