hats.catalog.partition_info
===========================

.. py:module:: hats.catalog.partition_info

.. autoapi-nested-parse::

   Container class to hold per-partition metadata

   ..
       !! processed by numpydoc !!


Classes
-------

.. autoapisummary::

   hats.catalog.partition_info.PartitionInfo


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

.. py:class:: PartitionInfo(pixel_list: list[hats.pixel_math.healpix_pixel.HealpixPixel], catalog_base_dir: str = None)

   
   Container class for per-partition info.
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: METADATA_ORDER_COLUMN_NAME
      :value: 'Norder'



   .. py:attribute:: METADATA_PIXEL_COLUMN_NAME
      :value: 'Npix'



   .. py:attribute:: pixel_list
      :value: []



   .. py:attribute:: catalog_base_dir
      :value: None



   .. py:method:: get_healpix_pixels() -> list[hats.pixel_math.healpix_pixel.HealpixPixel]

      
      Get healpix pixel objects for all pixels represented as partitions.





      :Returns:

          list[HealpixPixel]
              List of HealpixPixel











      ..
          !! processed by numpydoc !!


   .. py:method:: get_highest_order() -> int

      
      Get the highest healpix order for the dataset.





      :Returns:

          int
              int representing highest order.











      ..
          !! processed by numpydoc !!


   .. py:method:: __len__()

      
      The number of partitions.





      :Returns:

          int
              The number of partition pixels.











      ..
          !! processed by numpydoc !!


   .. py:method:: write_to_file(partition_info_file: str | pathlib.Path | upath.UPath | None = None, catalog_path: str | pathlib.Path | upath.UPath | None = None)

      
      Write all partition data to CSV file.

      If no paths are provided, the catalog base directory from the `read_from_dir` call is used.

      :Parameters:

          **partition_info_file** : str | Path | UPath | None
              path to where the `partition_info.csv` file will be written.

          **catalog_path** : str | Path | UPath | None
              base directory for a catalog where the `partition_info.csv` file will be written.







      :Raises:

          ValueError
              if no path is provided, and could not be inferred.







      ..
          !! processed by numpydoc !!


   .. py:method:: read_from_dir(catalog_base_dir: str | pathlib.Path | upath.UPath | None) -> PartitionInfo
      :classmethod:


      
      Read partition info from a file within a hats directory.

      This will look for a `partition_info.csv` file, and if not found, the partition info
      will be computed from the individual catalog files. Computing from catalog files will be slower:
      in internal testing, it took about half a second to compute from a catalog with ~40k partitions,
      versus a few milliseconds to read from the CSV file.

      :Parameters:

          **catalog_base_dir** : str | Path | UPath | None
              Path to the root directory of the catalog



      :Returns:

          PartitionInfo
              A `PartitionInfo` object with the data from the file











      ..
          !! processed by numpydoc !!


   .. py:method:: read_from_file(metadata_file: str | pathlib.Path | upath.UPath) -> PartitionInfo
      :classmethod:


      
      Read partition info from a `_metadata` file to create an object


      :Parameters:

          **metadata_file** : str | Path | UPath
              path to the `_metadata` file



      :Returns:

          PartitionInfo
              A `PartitionInfo` object with the data from the file











      ..
          !! processed by numpydoc !!


   .. py:method:: read_from_csv(partition_info_file: str | pathlib.Path | upath.UPath) -> PartitionInfo
      :classmethod:


      
      Read partition info from a `partition_info.csv` file to create an object


      :Parameters:

          **partition_info_file** : str | Path | UPath
              path to the `partition_info.csv` file



      :Returns:

          PartitionInfo
              A `PartitionInfo` object with the data from the file











      ..
          !! processed by numpydoc !!


   .. py:method:: as_dataframe()

      
      Construct a pandas dataframe for the partition info pixels.





      :Returns:

          pd.DataFrame
              Pandas Dataframe with order, directory, and pixel info.











      ..
          !! processed by numpydoc !!


   .. py:method:: from_healpix(healpix_pixels: list[hats.pixel_math.healpix_pixel.HealpixPixel]) -> PartitionInfo
      :classmethod:


      
      Create a partition info object from a list of constituent healpix pixels.


      :Parameters:

          **healpix_pixels: list[HealpixPixel]**
              a list of constituent healpix pixels



      :Returns:

          PartitionInfo
              A `PartitionInfo` object with the same healpix pixels











      ..
          !! processed by numpydoc !!


   .. py:method:: calculate_fractional_coverage()

      
      Calculate what fraction of the sky is covered by partition tiles.
















      ..
          !! processed by numpydoc !!


