diff --git a/pyproject.toml b/pyproject.toml index c1a6fa01..9b168892 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ full = [ "fsspec[full]", # complete file system specs. "ipykernel", # Support for Jupyter notebooks "ipywidgets", # useful for tqdm in notebooks. + "healpy", # used only in hipscat conversion ] [build-system] diff --git a/src/hats_import/catalog/arguments.py b/src/hats_import/catalog/arguments.py index 51af2724..6bc13535 100644 --- a/src/hats_import/catalog/arguments.py +++ b/src/hats_import/catalog/arguments.py @@ -105,8 +105,8 @@ def _check_arguments(self): raise ValueError("pixel_threshold should be between 100 and 1,000,000,000") self.mapping_healpix_order = self.highest_healpix_order - if self.catalog_type not in ("source", "object"): - raise ValueError("catalog_type should be one of `source` or `object`") + if self.catalog_type not in ("source", "object", "map"): + raise ValueError("catalog_type should be one of `source`, `object`, or `map`") if self.file_reader is None: raise ValueError("file_reader is required") diff --git a/src/hats_import/hipscat_conversion/run_conversion.py b/src/hats_import/hipscat_conversion/run_conversion.py index 0342f604..199562ea 100644 --- a/src/hats_import/hipscat_conversion/run_conversion.py +++ b/src/hats_import/hipscat_conversion/run_conversion.py @@ -4,7 +4,7 @@ import tempfile from typing import no_type_check -import hats.pixel_math.healpix_shim as hp +import healpy as hp import numpy as np import pyarrow.parquet as pq from dask.distributed import as_completed, get_worker @@ -169,11 +169,6 @@ def _write_nested_fits_map(input_dir, output_dir): map_fits_image = hp.read_map(_tmp_file.name) else: map_fits_image = map_fits_image[0] + map_fits_image = map_fits_image.astype(np.int32) - output_file = output_dir / "point_map.fits" - with tempfile.NamedTemporaryFile() as _tmp_file: - with output_file.open("wb") as _map_file: - hp.write_map( - _tmp_file.name, map_fits_image, overwrite=True, dtype=np.int32, nest=True, coord="CEL" - ) - _map_file.write(_tmp_file.read()) + file_io.write_fits_image(map_fits_image, output_dir / "point_map.fits") diff --git a/src/hats_import/margin_cache/margin_cache_arguments.py b/src/hats_import/margin_cache/margin_cache_arguments.py index 69542f07..b56a2a4e 100644 --- a/src/hats_import/margin_cache/margin_cache_arguments.py +++ b/src/hats_import/margin_cache/margin_cache_arguments.py @@ -67,9 +67,7 @@ def _check_arguments(self): "margin_order must be of a higher order than the highest order catalog partition pixel." ) - margin_pixel_nside = hp.order2nside(self.margin_order) - margin_pixel_avgsize = hp.nside2resol(margin_pixel_nside, arcmin=True) - margin_pixel_mindist = hp.avgsize2mindist(margin_pixel_avgsize) + margin_pixel_mindist = hp.order2mindist(self.margin_order) if margin_pixel_mindist * 60.0 < self.margin_threshold: raise ValueError("margin pixels must be larger than margin_threshold") diff --git a/src/hats_import/soap/resume_plan.py b/src/hats_import/soap/resume_plan.py index e4447fc2..bef61335 100644 --- a/src/hats_import/soap/resume_plan.py +++ b/src/hats_import/soap/resume_plan.py @@ -7,7 +7,7 @@ import hats.pixel_math.healpix_shim as hp import numpy as np -from hats import read_hats +from hats import pixel_math, read_hats from hats.catalog import Catalog from hats.io import file_io from hats.pixel_math.healpix_pixel import HealpixPixel @@ -193,8 +193,7 @@ def source_to_object_map(object_catalog, source_catalog): for source, objects in source_to_object.items(): # get all neighboring pixels - nside = hp.order2nside(source.order) - neighbors = hp.get_all_neighbours(nside, source.pixel, nest=True) + neighbors = pixel_math.get_margin(source.order, source.pixel, 0) ## get rid of -1s and normalize to max order explosion_factor = 4 ** (max_order - source.order)