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

.. py:module:: hats.catalog

.. autoapi-nested-parse::

   
   Catalog data wrappers
















   ..
       !! processed by numpydoc !!


Submodules
----------

.. toctree::
   :maxdepth: 1

   /autoapi/hats/catalog/association_catalog/index
   /autoapi/hats/catalog/catalog/index
   /autoapi/hats/catalog/catalog_collection/index
   /autoapi/hats/catalog/catalog_snapshot/index
   /autoapi/hats/catalog/catalog_type/index
   /autoapi/hats/catalog/dataset/index
   /autoapi/hats/catalog/healpix_dataset/index
   /autoapi/hats/catalog/index/index
   /autoapi/hats/catalog/map/index
   /autoapi/hats/catalog/margin_cache/index
   /autoapi/hats/catalog/partition_info/index


Classes
-------

.. autoapisummary::

   hats.catalog.AssociationCatalog
   hats.catalog.Catalog
   hats.catalog.CatalogCollection
   hats.catalog.CatalogType
   hats.catalog.CollectionProperties
   hats.catalog.Dataset
   hats.catalog.TableProperties
   hats.catalog.IndexCatalog
   hats.catalog.MapCatalog
   hats.catalog.MarginCatalog
   hats.catalog.PartitionInfo


Package Contents
----------------

.. py:class:: AssociationCatalog(catalog_info: hats.catalog.dataset.table_properties.TableProperties, pixels: hats.catalog.partition_info.PartitionInfo | hats.pixel_tree.pixel_tree.PixelTree | list[hats.pixel_math.HealpixPixel], catalog_path: str | pathlib.Path | upath.UPath | None = None, moc: mocpy.MOC | None = None, schema: pyarrow.Schema | None = None, snapshot: hats.catalog.catalog_snapshot.CatalogSnapshot | None = None, generate_snapshot: bool = False)

   Bases: :py:obj:`hats.catalog.healpix_dataset.healpix_dataset.HealpixDataset`


   
   A HATS Catalog for enabling fast joins between two HATS catalogs
















   ..
       !! processed by numpydoc !!

.. py:class:: Catalog(catalog_info: hats.catalog.dataset.table_properties.TableProperties, pixels: hats.catalog.partition_info.PartitionInfo | hats.pixel_tree.pixel_tree.PixelTree | list[hats.pixel_math.HealpixPixel], catalog_path: str | pathlib.Path | upath.UPath | None = None, moc: mocpy.MOC | None = None, schema: pyarrow.Schema | None = None, snapshot: hats.catalog.catalog_snapshot.CatalogSnapshot | None = None, generate_snapshot: bool = False)

   Bases: :py:obj:`hats.catalog.healpix_dataset.healpix_dataset.HealpixDataset`


   
   A HATS Catalog with data stored in a HEALPix Hive partitioned structure

   Catalogs of this type are partitioned spatially, contain `partition_info` metadata specifying
   the pixels in Catalog, and on disk conform to the parquet partitioning structure
   `Norder=/Dir=/Npix=.parquet`















   ..
       !! processed by numpydoc !!

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

      
      Get the leaf nodes at each healpix order that have zero catalog data.

      For example, if an example catalog only had data points in pixel 0 at
      order 0, then this method would return order 0's pixels 1 through 11.
      Used for getting full coverage on margin caches.




      :Returns:

          list[HealpixPixel]
              List of HealpixPixels representing the 'negative tree' for the catalog.











      ..
          !! processed by numpydoc !!


.. py:class:: CatalogCollection(collection_path: upath.UPath, collection_properties: hats.catalog.dataset.collection_properties.CollectionProperties, main_catalog: hats.catalog.catalog.Catalog)

   
   A collection of HATS Catalog with data stored in a HEALPix Hive partitioned structure

   Catalogs of this type are described by a `collection.properties` file which specifies
   the underlying main catalog, margin catalog and index catalog paths. These catalogs are
   stored at the root of the collection, each in its separate directory::

       catalog_collection/
       ├── main_catalog/
       ├── margin_catalog/
       ├── index_catalog/
       ├── collection.properties

   Margin and index catalogs are optional but there could also be multiple of them. The
   catalogs used by default are specified in the `collection.properties` file in the
   `default_margin` and `default_index` keywords.















   ..
       !! processed by numpydoc !!

   .. py:attribute:: collection_path


   .. py:attribute:: collection_properties


   .. py:attribute:: main_catalog


   .. py:property:: main_catalog_dir
      :type: upath.UPath


      
      Path to the main catalog directory
















      ..
          !! processed by numpydoc !!


   .. py:property:: all_margins
      :type: list[str] | None


      
      The list of margin catalog names in the collection
















      ..
          !! processed by numpydoc !!


   .. py:property:: default_margin
      :type: str | None


      
      The name of the default margin
















      ..
          !! processed by numpydoc !!


   .. py:property:: default_margin_catalog_dir
      :type: upath.UPath | None


      
      Path to the default margin catalog directory
















      ..
          !! processed by numpydoc !!


   .. py:property:: all_indexes
      :type: dict[str, str] | None


      
      The mapping of indexes in the collection
















      ..
          !! processed by numpydoc !!


   .. py:property:: default_index_field
      :type: str | None


      
      The name of the default index field
















      ..
          !! processed by numpydoc !!


   .. py:property:: default_index_catalog_dir
      :type: upath.UPath | None


      
      Path to the default index catalog directory
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_index_dir_for_field(field_name: str | None = None) -> upath.UPath | None

      
      Path to the field's index catalog directory
















      ..
          !! processed by numpydoc !!


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

      
      The list of HEALPix pixels of the main catalog
















      ..
          !! processed by numpydoc !!


   .. py:method:: get_margin_thresholds() -> dict[str, float]

      
      Get the margin thresholds for all margin catalogs in the collection.





      :Returns:

          dict[str, float]
              A dictionary mapping margin catalog names to their threshold values.




      :Raises:

          ValueError
              if a catalog listed as a margin catalog is not configured as a margin catalog.







      ..
          !! processed by numpydoc !!


.. py:class:: CatalogType

   Bases: :py:obj:`str`, :py:obj:`enum.Enum`


   
   Enum for possible types of catalog
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: OBJECT
      :value: 'object'



   .. py:attribute:: SOURCE
      :value: 'source'



   .. py:attribute:: ASSOCIATION
      :value: 'association'



   .. py:attribute:: INDEX
      :value: 'index'



   .. py:attribute:: MARGIN
      :value: 'margin'



   .. py:attribute:: MAP
      :value: 'map'



   .. py:method:: all_types()
      :classmethod:


      
      Fetch a list of all catalog types
















      ..
          !! processed by numpydoc !!


.. py:class:: CollectionProperties(/, **data: Any)

   Bases: :py:obj:`pydantic.BaseModel`


   
   Container class for catalog metadata
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: name
      :type:  str
      :value: None



   .. py:attribute:: hats_primary_table_url
      :type:  str
      :value: None


      
      Reference to object catalog. Relevant for nested, margin, association, and index.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: all_margins
      :type:  Annotated[Optional[list[str]], Field(default=None)]


   .. py:attribute:: default_margin
      :type:  Optional[str]
      :value: None



   .. py:attribute:: all_indexes
      :type:  Annotated[Optional[dict[str, str]], Field(default=None)]


   .. py:attribute:: default_index
      :type:  Optional[str]
      :value: None



   .. py:attribute:: model_config

      
      Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
















      ..
          !! processed by numpydoc !!


   .. py:method:: space_delimited_list(str_value: str) -> list[str]
      :classmethod:


      
      Convert a space-delimited list string into a python list of strings.


      :Parameters:

          **str_value: str**
              a space-delimited list string



      :Returns:

          list[str]
              a python list of strings











      ..
          !! processed by numpydoc !!


   .. py:method:: index_tuples(str_value: str) -> dict[str, str]
      :classmethod:


      
      Convert a space-delimited list string into a python list of strings.


      :Parameters:

          **str_value: str**
              a space-delimited list string



      :Returns:

          dict[str, str]
              a python dict of strings




      :Raises:

          ValueError
              if the string list has an odd number of elements (and so is not pairs of
              field and index name)







      ..
          !! processed by numpydoc !!


   .. py:method:: serialize_list_as_space_delimited_list(str_list: Iterable[str]) -> str

      
      Convert a python list of strings into a space-delimited string.


      :Parameters:

          **str_list: Iterable[str]**
              a python list of strings



      :Returns:

          str
              a space-delimited string











      ..
          !! processed by numpydoc !!


   .. py:method:: serialize_dict_as_space_delimited_list(str_dict: dict[str, str]) -> str

      
      Convert a python list of strings into a space-delimited string.


      :Parameters:

          **str_dict: dict[str, str]**
              a python dict of strings



      :Returns:

          str
              a space-delimited string











      ..
          !! processed by numpydoc !!


   .. py:method:: check_allowed_and_required() -> Self

      
      Check that type-specific fields are appropriate, and required fields are set.
















      ..
          !! processed by numpydoc !!


   .. py:method:: check_default_margin_exists() -> Self

      
      Check that the default margin is in the list of all margins.
















      ..
          !! processed by numpydoc !!


   .. py:method:: check_default_index_exists() -> Self

      
      Check that the default index is in the list of all indexes.
















      ..
          !! processed by numpydoc !!


   .. py:method:: explicit_dict()

      
      Create a dict, based on fields that have been explicitly set, and are not "extra" keys.
















      ..
          !! processed by numpydoc !!


   .. py:method:: __str__()

      
      Friendly string representation based on named fields.
















      ..
          !! processed by numpydoc !!


   .. py:method:: read_from_dir(catalog_dir: str | pathlib.Path | upath.UPath) -> Self
      :classmethod:


      
      Read field values from a java-style properties file.


      :Parameters:

          **catalog_dir: str | Path | UPath**
              base directory of catalog.



      :Returns:

          CollectionProperties
              new object from the contents of a ``collection.properties`` file in the directory.











      ..
          !! processed by numpydoc !!


   .. py:method:: to_properties_file(catalog_dir: str | pathlib.Path | upath.UPath)

      
      Write fields to a java-style properties file.


      :Parameters:

          **catalog_dir: str | Path | UPath**
              base directory of catalog.














      ..
          !! processed by numpydoc !!


.. py:class:: Dataset(catalog_info: hats.catalog.dataset.table_properties.TableProperties, catalog_path: str | pathlib.Path | upath.UPath | None = None, schema: pyarrow.Schema | None = None, snapshot: hats.catalog.catalog_snapshot.CatalogSnapshot | None = None, generate_snapshot: bool = False)

   
   A base HATS dataset that contains a properties file and the data contained in parquet files
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: catalog_info


   .. py:attribute:: catalog_name


   .. py:attribute:: catalog_path
      :value: None



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



   .. py:attribute:: schema
      :value: None



   .. py:attribute:: snapshot
      :value: None



   .. py:property:: original_schema
      :type: pyarrow.Schema | None


      
      The original on-disk schema, before any column selection.
















      ..
          !! processed by numpydoc !!


   .. py:property:: on_disk
      :type: bool


      
      Is the catalog stored on disk?
















      ..
          !! processed by numpydoc !!


   .. py:property:: unmodified
      :type: bool


      
      Has the catalog been modified from its original on disk state?
















      ..
          !! processed by numpydoc !!


   .. py:method:: aggregate_column_statistics(exclude_hats_columns: bool = True, exclude_columns: list[str] = None, include_columns: list[str] = None)

      
      Read footer statistics in parquet metadata, and report on global min/max values.


      :Parameters:

          **exclude_hats_columns** : bool
              exclude HATS spatial and partitioning fields
              from the statistics. Defaults to True.

          **exclude_columns** : list[str]
              additional columns to exclude from the statistics.

          **include_columns** : list[str]
              if specified, only return statistics for the column
              names provided. Defaults to None, and returns all non-hats columns.



      :Returns:

          Dataframe
              aggregated statistics.











      ..
          !! processed by numpydoc !!


   .. py:method:: per_pixel_statistics(*, exclude_hats_columns: bool = True, exclude_columns: list[str] | None = None, include_columns: list[str] | None = None, only_numeric_columns: bool = False, include_stats: list[str] | None = None, multi_index=False, per_row_group: bool = False)

      
      Read footer statistics in parquet metadata, and report on statistics about
      each pixel partition.
















      ..
          !! processed by numpydoc !!


   .. py:method:: per_partition_statistics(*, exclude_hats_columns: bool = True, exclude_columns: list[str] = None, include_columns: list[str] = None, only_numeric_columns: bool = False, include_stats: list[str] = None, multi_index=False, per_row_group: bool = False)

      
      Read footer statistics in parquet metadata, and report on statistics about
      each pixel partition.


      :Parameters:

          **exclude_hats_columns** : bool
              exclude HATS spatial and partitioning fields from the statistics. Defaults to True.

          **exclude_columns** : list[str]
              additional columns to exclude from the statistics.

          **include_columns** : list[str]
              if specified, only return statistics for the column
              names provided. Defaults to None, and returns all non-hats columns.

          **include_stats** : list[str]
              if specified, only return the kinds of values from list
              (min_value, max_value, null_count, row_count). Defaults to None, and returns all values.

          **multi_index** : bool
              should the returned frame be created with a multi-index, first on
              pixel, then on column name? Default is False, and instead indexes on pixel, with
              separate columns per-data-column and stat value combination.
              (Default value = False)



      :Returns:

          Dataframe
              all statistics.











      ..
          !! processed by numpydoc !!


.. py:class:: TableProperties(/, **data: Any)

   Bases: :py:obj:`pydantic.BaseModel`


   
   Container class for catalog metadata
















   ..
       !! processed by numpydoc !!

   .. py:attribute:: catalog_name
      :type:  str
      :value: None



   .. py:attribute:: catalog_type
      :type:  hats.catalog.catalog_type.CatalogType
      :value: None



   .. py:attribute:: total_rows
      :type:  Optional[int]
      :value: None



   .. py:attribute:: ra_column
      :type:  Optional[str]
      :value: None



   .. py:attribute:: dec_column
      :type:  Optional[str]
      :value: None



   .. py:attribute:: default_columns
      :type:  Optional[list[str]]
      :value: None


      
      Which columns should be read from parquet files, when user doesn't otherwise specify.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: healpix_column
      :type:  Optional[str]
      :value: None


      
      Column name that provides a spatial index of healpix values at some fixed, high order.
      A typical value would be ``_healpix_29``, but can vary.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: healpix_order
      :type:  Optional[int]
      :value: None


      
      For the spatial index of healpix values in ``hats_col_healpix``
      what is the fixed, high order. A typicaly value would be 29, but can vary.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: primary_catalog
      :type:  Optional[str]
      :value: None


      
      Reference to object catalog. Relevant for nested, margin, association, and index.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: margin_threshold
      :type:  Optional[float]
      :value: None


      
      Threshold of the pixel boundary, expressed in arcseconds.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: primary_column
      :type:  Optional[str]
      :value: None


      
      Column name in the primary (left) side of join.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: primary_column_association
      :type:  Optional[str]
      :value: None


      
      Column name in the association table that matches the primary (left) side of join.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: join_catalog
      :type:  Optional[str]
      :value: None


      
      Catalog name for the joining (right) side of association.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: join_column
      :type:  Optional[str]
      :value: None


      
      Column name in the joining (right) side of join.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: join_column_association
      :type:  Optional[str]
      :value: None


      
      Column name in the association table that matches the joining (right) side of join.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: assn_max_separation
      :type:  Optional[float]
      :value: None


      
      The maximum separation between two points in an association catalog, expressed in arcseconds.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: contains_leaf_files
      :type:  Optional[bool]
      :value: None


      
      Whether or not the association catalog contains leaf parquet files.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: indexing_column
      :type:  Optional[str]
      :value: None


      
      Column that we provide an index over.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: extra_columns
      :type:  Optional[list[str]]
      :value: None


      
      Any additional payload columns included in index.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: npix_suffix
      :type:  str
      :value: None


      
      Suffix of the Npix partitions.
      In the standard HATS directory structure, this is ``'.parquet'`` because there is a single file
      in each Npix partition and it is named like ``'Npix=313.parquet'``.
      Other valid directory structures include those with the same single file per partition but
      which use a different suffix (e.g., ``'npix_suffix' = '.parq'`` or ``'.snappy.parquet'``),
      and also those in which the Npix partitions are actually directories containing 1+ files
      underneath (and then ``'npix_suffix' = '/'``).
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: skymap_order
      :type:  Optional[int]
      :value: None


      
      Nested Order of the healpix skymap stored in the default skymap.fits.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: skymap_alt_orders
      :type:  Optional[list[int]]
      :value: None


      
      Nested Order (K) of the healpix skymaps stored in altnernative skymap.K.fits.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: hats_max_rows
      :type:  Optional[int]
      :value: None


      
      Maximum number of rows in any partition of the catalog.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: hats_max_bytes
      :type:  Optional[int]
      :value: None


      
      Maximum number of bytes in any partition of the catalog.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: hats_estsize
      :type:  Optional[int]
      :value: None


      
      Estimated size of the catalog on disk, in kilobytes.
















      ..
          !! processed by numpydoc !!


   .. py:attribute:: moc_sky_fraction
      :type:  Optional[float]
      :value: None



   .. py:attribute:: model_config

      
      Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
















      ..
          !! processed by numpydoc !!


   .. py:method:: space_delimited_list(str_value: str) -> list[str]
      :classmethod:


      
      Convert a space-delimited list string into a python list of strings.


      :Parameters:

          **str_value: str**
              a space-delimited list string



      :Returns:

          list[str]
              python list of strings











      ..
          !! processed by numpydoc !!


   .. py:method:: space_delimited_int_list(str_value: str | list[int]) -> list[int]
      :classmethod:


      
      Convert a space-delimited list string into a python list of integers.


      :Parameters:

          **str_value** : str | list[int]
              string representation of a list of integers, delimited by
              space, comma, or semicolon, or a list of integers.



      :Returns:

          list[int]
              a python list of integers




      :Raises:

          ValueError
              if any non-digit characters are encountered







      ..
          !! processed by numpydoc !!


   .. py:method:: serialize_as_space_delimited_list(str_list: Iterable) -> str

      
      Convert a python list of strings into a space-delimited string.


      :Parameters:

          **str_list: Iterable**
              a python list of strings



      :Returns:

          str
              a space-delimited string.











      ..
          !! processed by numpydoc !!


   .. py:method:: check_required() -> Self

      
      Check that type-specific fields are appropriate, and required fields are set.
















      ..
          !! processed by numpydoc !!


   .. py:method:: copy_and_update(**kwargs)

      
      Create a validated copy of these table properties, updating the fields provided in kwargs.


      :Parameters:

          **\*\*kwargs**
              values to update



      :Returns:

          TableProperties
              new instance of properties object











      ..
          !! processed by numpydoc !!


   .. py:method:: explicit_dict(by_alias=False, exclude_none=True)

      
      Create a dict, based on fields that have been explicitly set, and are not "extra" keys.


      :Parameters:

          **by_alias** : bool
              (Default value = False)

          **exclude_none** : bool
              (Default value = True)



      :Returns:

          dict
              all keys that are attributes of this class and not "extra".











      ..
          !! processed by numpydoc !!


   .. py:method:: extra_dict(by_alias=False, exclude_none=True)

      
      Create a dict, based on fields that are "extra" keys.


      :Parameters:

          **by_alias** : bool
              (Default value = False)

          **exclude_none** : bool
              (Default value = True)



      :Returns:

          dict
              all keys that are *not* attributes of this class, e.g. "extra".











      ..
          !! processed by numpydoc !!


   .. py:method:: __repr__()


   .. py:method:: __str__()

      
      Friendly string representation based on named fields.
















      ..
          !! processed by numpydoc !!


   .. py:method:: read_from_dir(catalog_dir: str | pathlib.Path | upath.UPath) -> Self
      :classmethod:


      
      Read field values from a java-style properties file.


      :Parameters:

          **catalog_dir: str | Path | UPath**
              path to a catalog directory.



      :Returns:

          TableProperties
              object created from the contents of a ``hats.properties`` file in
              the given directory




      :Raises:

          FileNotFoundError
              if there is no properties or hats.properties file in the directory







      ..
          !! processed by numpydoc !!


   .. py:method:: to_properties_file(catalog_dir: str | pathlib.Path | upath.UPath)

      
      Write fields to a java-style properties file.


      :Parameters:

          **catalog_dir: str | Path | UPath**
              directory to write the file














      ..
          !! processed by numpydoc !!


   .. py:method:: new_provenance_dict(path: str | pathlib.Path | upath.UPath | None = None, builder: str | None = None, **kwargs) -> dict
      :staticmethod:


      
      Constructs the provenance properties for a HATS catalog.


      :Parameters:

          **path: str | Path | UPath | None**
              The path to the catalog directory.

          **builder** : str | None
              The name and version of the tool that created the catalog.

          **\*\*kwargs**
              Additional properties to include/override in the dictionary.



      :Returns:

          dict
              A dictionary with properties for the HATS catalog.











      ..
          !! processed by numpydoc !!


.. py:class:: IndexCatalog(catalog_info: hats.catalog.dataset.table_properties.TableProperties, catalog_path: str | pathlib.Path | upath.UPath | None = None, schema: pyarrow.Schema | None = None, snapshot: hats.catalog.catalog_snapshot.CatalogSnapshot | None = None, generate_snapshot: bool = False)

   Bases: :py:obj:`hats.catalog.dataset.Dataset`


   
   An index into HATS Catalog for enabling fast lookups on non-spatial values.

   Note that this is not a true "HATS Catalog", as it is not partitioned spatially.















   ..
       !! processed by numpydoc !!

   .. py:method:: loc_partitions(ids) -> list[hats.pixel_math.HealpixPixel]

      
      Find the set of partitions in the primary catalog for the ids provided.


      :Parameters:

          **ids**
              primary catalog for the ids



      :Returns:

          list[HealpixPixel]
              partitions of leaf parquet files in the primary catalog
              that may contain rows for the id values











      ..
          !! processed by numpydoc !!


.. py:class:: MapCatalog(catalog_info: hats.catalog.dataset.table_properties.TableProperties, pixels: hats.catalog.partition_info.PartitionInfo | hats.pixel_tree.pixel_tree.PixelTree | list[hats.pixel_math.HealpixPixel], catalog_path: str | pathlib.Path | upath.UPath | None = None, moc: mocpy.MOC | None = None, schema: pyarrow.Schema | None = None, snapshot: hats.catalog.catalog_snapshot.CatalogSnapshot | None = None, generate_snapshot: bool = False)

   Bases: :py:obj:`hats.catalog.healpix_dataset.healpix_dataset.HealpixDataset`


   
   A HATS table to represent non-point-source data in a continuous map.
















   ..
       !! processed by numpydoc !!

.. py:class:: MarginCatalog(catalog_info: hats.catalog.dataset.table_properties.TableProperties, pixels: hats.catalog.partition_info.PartitionInfo | hats.pixel_tree.pixel_tree.PixelTree | list[hats.pixel_math.HealpixPixel], catalog_path: str | pathlib.Path | upath.UPath | None = None, moc: mocpy.MOC | None = None, schema: pyarrow.Schema | None = None, snapshot: hats.catalog.catalog_snapshot.CatalogSnapshot | None = None, generate_snapshot: bool = False)

   Bases: :py:obj:`hats.catalog.healpix_dataset.healpix_dataset.HealpixDataset`


   
   A HATS Catalog used to contain the 'margin' of another HATS catalog.

   Catalogs of this type are used alongside a primary catalog, and contains the margin points for each
   HEALPix pixel - any points that are within a certain distance from the HEALPix pixel boundary. This is
   used to ensure spatial operations such as crossmatching can be performed efficiently while maintaining
   accuracy.















   ..
       !! processed by numpydoc !!

   .. py:method:: filter_by_moc(moc: mocpy.MOC) -> Self

      
      Filter the pixels in the margin catalog to only include the margin pixels that overlap with the moc

      For the case of margin pixels, this includes any pixels whose margin areas may overlap with the moc.
      This is not always done with a high accuracy, but always includes any pixels that will overlap,
      and may include extra partitions that do not.

      :Parameters:

          **moc** : mocpy.MOC
              the moc to filter by



      :Returns:

          MarginCatalog
              A new margin catalog with only the pixels that overlap or that have margin area that overlap with
              the moc. Note that we reset the total_rows to None, as updating would require a scan over the new
              pixel sizes.











      ..
          !! processed by numpydoc !!


.. 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 !!


