hyrax.data_sets.lsst_dataset
============================

.. py:module:: hyrax.data_sets.lsst_dataset


Attributes
----------

.. autoapisummary::

   hyrax.data_sets.lsst_dataset.logger


Classes
-------

.. autoapisummary::

   hyrax.data_sets.lsst_dataset.LSSTDataset


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

.. py:data:: logger

.. py:class:: LSSTDataset(config, data_location=None)

   Bases: :py:obj:`hyrax.data_sets.data_set_registry.HyraxDataset`, :py:obj:`hyrax.data_sets.data_set_registry.HyraxImageDataset`, :py:obj:`torch.utils.data.Dataset`


   LSSTDataset: A dataset to access deep_coadd images from lsst pipelines
   via the butler. Must be run in an RSP.

   .. py:method:: __init__

   Initialize the dataset with either a HATS catalog or astropy table.

   Config can specify either:
   - config["data_set"]["hats_catalog"]: path to HATS catalog
   - config["data_set"]["astropy_table"]: path to any file readable by Astropy Table



   .. py:attribute:: BANDS
      :value: ['u', 'g', 'r', 'i', 'z', 'y']



   .. py:attribute:: object_id_autodetect_names
      :value: ['object_id', 'objectId']



   .. py:attribute:: catalog


   .. py:attribute:: sh_deg


   .. py:attribute:: sw_deg


   .. py:attribute:: oid_column_name


   .. py:method:: _butler_available()


   .. py:method:: _get_butler_thread_safe()

      Thread safe butler creation

      This function ensures that there is one and only one butler created per thread
      and that threads always use their assigned butler.

      This is necessary because child classes of this one use butlers, and butler
      objects are not safe for multithreaded access.

      :returns: The butler assigned to the current thread.
      :rtype: butler



   .. py:method:: _detect_object_id_column_name()

      Setup file naming strategy based on catalog columns.



   .. py:method:: _load_catalog(data_set_config)

      Load the catalog from either a HATS catalog or an astropy table.



   .. py:method:: _load_hats_catalog(hats_path)

      Load catalog from HATS format using LSDB.



   .. py:method:: _load_astropy_catalog(table_path)

      Load catalog from astropy table format or pickled astropy table.



   .. py:method:: __len__()


   .. py:method:: get_image(idxs)

      Get image cutouts for the given indices.

      :param idxs: The index or indices of the cutouts to retrieve.
      :type idxs: int or list of int

      :returns: Single cutout tensor or list of cutout tensors.
      :rtype: list or torch.Tensor



   .. py:method:: __getitem__(idxs)

      Get default data fields for the this dataset.

      :param idxs: The index or indices of the cutouts to retrieve.
      :type idxs: int or list of int

      :returns: A dictionary containing the default data fields.
      :rtype: dict



   .. py:method:: _parse_box(patch, row)

      Return a Box2I representing the desired cutout in pixel space, given a "row" of catalog data
      which includes the semi-height (sh) and semi-width (sw) in degrees desired for the cutout.



   .. py:method:: _parse_sphere_point(row)

      Return a SpherePoint with the ra and deck given in the "row" of catalog data.
      Row must include the RA and dec as "ra" and "dec" columns respectively



   .. py:method:: _get_tract_patch(row)

      Return (tractInfo, patchInfo) for a given row.

      This function only returns the single principle tract and patch in the case of overlap.



   .. py:method:: _request_patch(tract_index, patch_index)

      Request a patch from the butler. This will be a list of
      lsst.afw.image objects each corresponding to the configured
      bands

      Uses functools.lru_cache for basic in-memory caching.



   .. py:method:: _fetch_single_cutout(row)

      Make a single cutout, returning a torch tensor.

      Does not handle edge-of-tract/patch type edge cases, will only work near
      center of a patch.



