hats.catalog.partition_info#
Container class to hold per-partition metadata
Classes#
Container class for per-partition info. |
Module Contents#
- class PartitionInfo(pixel_list: list[hats.pixel_math.healpix_pixel.HealpixPixel], catalog_base_dir: str = None)[source]#
Container class for per-partition info.
- get_healpix_pixels() list[hats.pixel_math.healpix_pixel.HealpixPixel][source]#
Get healpix pixel objects for all pixels represented as partitions.
- Returns:
- list[HealpixPixel]
List of HealpixPixel
- get_highest_order() int[source]#
Get the highest healpix order for the dataset.
- Returns:
- int
int representing highest order.
- write_to_file(partition_info_file: str | pathlib.Path | upath.UPath | None = None, catalog_path: str | pathlib.Path | upath.UPath | None = None)[source]#
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_filestr | Path | UPath | None
path to where the partition_info.csv file will be written.
- catalog_pathstr | 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.
- classmethod read_from_dir(catalog_base_dir: str | pathlib.Path | upath.UPath | None, compute_from_catalog: bool = False) PartitionInfo[source]#
Read partition info from a file within a hats directory.
This will look for a partition_info.csv file, and if not found, will look for a _metadata file. The second approach is typically slower for large catalogs therefore a warning is issued to the user. In internal testing with large catalogs, the first approach takes less than a second, while the second can take 10-20 seconds.
If neither file is found, and compute_from_catalog is set to True, the partition info will be computed from the individual catalog files. This is the slowest approach, and a warning is issued to the user. In internal testing with large catalogs, this approach can take (??) time.
- Parameters:
- catalog_base_dirstr | Path | UPath | None
Path to the root directory of the catalog
- compute_from_catalogbool
Whether to compute partition info from catalog files if no metadata or partition info file is found.
- Returns:
- PartitionInfo
A PartitionInfo object with the data from the file
- Raises:
- FileNotFoundError
if neither desired file is found in the catalog_base_dir
- classmethod read_from_file(metadata_file: str | pathlib.Path | upath.UPath) PartitionInfo[source]#
Read partition info from a _metadata file to create an object
- Parameters:
- metadata_filestr | Path | UPath
path to the _metadata file
- Returns:
- PartitionInfo
A PartitionInfo object with the data from the file
- classmethod read_from_csv(partition_info_file: str | pathlib.Path | upath.UPath) PartitionInfo[source]#
Read partition info from a partition_info.csv file to create an object
- Parameters:
- partition_info_filestr | Path | UPath
path to the partition_info.csv file
- Returns:
- PartitionInfo
A PartitionInfo object with the data from the file
- as_dataframe()[source]#
Construct a pandas dataframe for the partition info pixels.
- Returns:
- pd.DataFrame
Pandas Dataframe with order, directory, and pixel info.
- classmethod from_healpix(healpix_pixels: list[hats.pixel_math.healpix_pixel.HealpixPixel]) PartitionInfo[source]#
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