opsimsummaryv2.sim_io
=====================

.. py:module:: opsimsummaryv2.sim_io

.. autoapi-nested-parse::

   Class to write simulations input files.



Attributes
----------

.. autoapisummary::

   opsimsummaryv2.sim_io.use_pyarrow


Classes
-------

.. autoapisummary::

   opsimsummaryv2.sim_io.SNANA_Simlib
   opsimsummaryv2.sim_io.SNSIM_obsfile
   opsimsummaryv2.sim_io.SimWriter


Module Contents
---------------

.. py:class:: SNANA_Simlib(OpSimSurvey, out_path=None, author_name=None, file_suffix='', ZPTNoise=0.005, CCDgain=1.0, CCDnoise=0.25, NOTES={})

   Bases: :py:obj:`SimWriter`


   A class to write SNANA simulation output from OpSimSurvey object.

   .. attribute:: OpSimSurvey

      The OpSimSurvey object

      :type: opsimsummaryv2.summary_opsim.OpSimSurvey

   .. attribute:: author_name

      The author of the SIMLIB

      :type: str, optional

   .. attribute:: out_path

      The path of the output file, default './'

      :type: str, optional

   .. attribute:: date_time

      The current time, to be written in SIMLIB

      :type: str

   .. attribute:: dataline

      A vectorized function to write SIMLIB dataline

      :type: numpy.vectorize

   .. attribute:: ZPTNoise

      The constant ZPTNoise value, by default 0.005

      :type: float

   .. attribute:: CCDNoise

      The constant CCDNoise value, by default 0.25

      :type: float

   .. attribute:: CCDGain

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

      :type: float


   .. py:method:: LIBdata(opsimdf)

      Give the string of a LIB entry.

      :param opsimdf: LIB entry observations
      :type opsimdf: pandas.DataFrame

      :returns: The str of the LIB entry.
      :rtype: str



   .. py:method:: LIBfooter(LIBID)

      Give the string of a LIB entry footer.

      :param LIBID: The LIBID of the entry
      :type LIBID: int

      :returns: The string of a LIB entry footer
      :rtype: str



   .. py:method:: LIBheader(LIBID, ra, dec, opsimdf, mwebv=0.0, groupID=None, field_label=None)

      Give the string of the header of a LIB entry.

      :param LIBID: The LIBID of the entry.
      :type LIBID: int
      :param ra: RA [deg] coordinate of the entry
      :type ra: float
      :param dec: Dec [deg] coordinate of the entry
      :type dec: float
      :param opsimdf: LIB entry observations
      :type opsimdf: pandas.DataFrame
      :param mwebv: MWEBV of the entry, default = 0.0
      :type mwebv: float, optional
      :param groupID: GROUPID of the entry used to match with HOSTLIB hosts.
      :type groupID: int, optional

      :returns: The LIB entry header string.
      :rtype: str



   .. py:method:: _init_dataline()


   .. py:method:: get_HOSTLIB_doc()

      Give docstring for HOSTLIB file.

      :returns: Docstring of the HOSTLIB file
      :rtype: str



   .. py:method:: get_HOSTLIB_header(hostdf)

      Give HOSTLIB header.

      :param hostdf: Hosts dataframe
      :type hostdf: pandas.DataFrame

      :returns: Header of HSOTLIB file
      :rtype: str



   .. py:method:: get_SIMLIB_doc()

      Give the DOCUMENTATION string for SIMLIB.

      :returns: DOCUMENTATION string
      :rtype: str



   .. py:method:: get_SIMLIB_footer()

      Give SIMLIB footer.



   .. py:method:: get_SIMLIB_header(saturation_flag=1024, comments='\n')

      Give the SIMLIB header string.

      :param saturation_flag: The flag corresponding to saturated obs, by default 1024
      :type saturation_flag: int, optional
      :param comments: Comments to add to the header, by default '\n'
      :type comments: str, optional

      :returns: The SIMLIB header string.
      :rtype: str



   .. py:method:: write_HOSTLIB(hostdf, buffer_size=8192)

      Write the HOSTLIB file. Called in write_SIMLIB.

      :param hostdf: Hosts dataframe
      :type hostdf: pandas.DataFrame
      :param buffer_size: buffering option for open() function
      :type buffer_size: int



   .. py:method:: write_SIMLIB(write_batch_size=10, buffer_size=8192)

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

      :param write_batch_size: Number of LIBID to write at the same time
      :type write_batch_size: int
      :param buffer_size: buffering option for open() function
      :type buffer_size: int



   .. py:attribute:: NOTES


   .. py:attribute:: dataline


.. py:class:: SNSIM_obsfile(OpSimSurvey, out_path=None, author_name=None, ZPTNoise=0.005, CCDgain=1.0, CCDnoise=0.25)

   Bases: :py:obj:`SimWriter`


   .. py:method:: get_LSST_field()
      :staticmethod:



   .. py:method:: get_survey_config(write_field_map=False)


   .. py:method:: write_survey_file(write_survey_conf=True, write_field_map=True)


.. py:class:: SimWriter(OpSimSurvey, out_path=None, author_name=None, ZPTNoise=0.005, CCDgain=1.0, CCDnoise=0.25, outfile_ext='.SIMLIB', file_suffix='')

   .. py:method:: _init_out_path(out_path, outfile_ext, file_suffix='')

      Format output path for SIMLIB and HOSTLIB.

      :param out_path: Output directory or file.
      :type out_path: str

      :returns: Path to the output SIMLIB.
      :rtype: pathlib.Path



   .. py:attribute:: CCDgain
      :value: 1.0



   .. py:attribute:: CCDnoise
      :value: 0.25



   .. py:attribute:: OpSimSurvey


   .. py:attribute:: ZPTNoise
      :value: 0.005



   .. py:attribute:: author_name
      :value: None



   .. py:attribute:: date_time


   .. py:attribute:: out_path


.. py:data:: use_pyarrow
   :value: True


