yippy.header
============

.. py:module:: yippy.header

.. autoapi-nested-parse::

   Module for handling FITS header data.



Classes
-------

.. autoapisummary::

   yippy.header.HeaderData


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

.. py:class:: HeaderData

   A dataclass for storing the header data with units attached.

   I think this will be a useful system, however this has not been tested
   considerably. This is just a suggestion for a more robust way to keep the
   FITS header data attached to the coronagraph. Right now, the header data is
   loaded by Coronagraph from the stellar_intens file. This may make more
   sense if Offax, StellarIntens, and SkyTrans each load their own header.


   .. py:attribute:: simple
      :type:  bool


   .. py:attribute:: bitpix
      :type:  int


   .. py:attribute:: naxis
      :type:  int


   .. py:attribute:: naxis1
      :type:  int


   .. py:attribute:: naxis2
      :type:  int


   .. py:attribute:: naxis3
      :type:  int


   .. py:attribute:: design
      :type:  str


   .. py:attribute:: diameter
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:attribute:: diameter_inscribed
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:attribute:: pixscale
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:attribute:: lambda0
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:attribute:: minlam
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:attribute:: maxlam
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:attribute:: xcenter
      :type:  float | None
      :value: None



   .. py:attribute:: ycenter
      :type:  float | None
      :value: None



   .. py:attribute:: obscured
      :type:  float | None
      :value: None



   .. py:attribute:: jitter
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:attribute:: n_lam
      :type:  int | None
      :value: None



   .. py:attribute:: n_star
      :type:  int | None
      :value: None



   .. py:attribute:: zernike
      :type:  str | None
      :value: None



   .. py:attribute:: wfe
      :type:  astropy.units.Quantity | None
      :value: None



   .. py:method:: extract_unit(comment, default_unit, key)
      :staticmethod:


      Extract a unit from the comment string of a FITS header entry.

      This attempts to read the FITS header comment and search for an astropy
      Unit. This seems fairly robust, but it may not catch all cases in which
      case a warning is raised. It is also possible that the unit is not
      explicitly stated in the comment, in which case a default unit is
      returned.

      Args:
          comment (str):
              The comment string associated with a FITS header key.
          default_unit (u.Unit):
              The default unit to return if no unit is found in the comment.
          key (str):
              The key of the header entry to extract the unit from.

      Returns:
          u.Unit:
              The extracted astropy unit or the default unit if no
              recognizable unit is found.

      Raises:
          Warning:
              Logs a warning if no unit could be extracted and the default
              unit is used.



   .. py:method:: get_header_value(header, key, default_unit)
      :staticmethod:


      Retrieves a header value by key and converts it to a specified unit.

      Args:
          header (fits.Header):
              The FITS header from which to retrieve the value.
          key (str):
              The key of the header entry to retrieve.
          default_unit (u.Unit):
              The unit to associate with the returned value.

      Returns:
          Optional[u.Quantity]:
              The header value with the specified unit, or None if the key is
              not present.



   .. py:method:: from_fits_header(header)
      :staticmethod:


      Parses a FITS header.

      This parses the FITS header to initialize the HeaderData class,
      checking for any unhandled fields.

      Args:
          header (fits.Header):
              The FITS header to parse.

      Returns:
          HeaderData:
              An initialized HeaderData object populated with values from the
              FITS header.

      Raises:
          Warning:
              Logs a warning for any unhandled fields in the FITS header.



