Skip to content

Commit

Permalink
Remove margin fine filtering, and healpy dependency. (#434)
Browse files Browse the repository at this point in the history
* Remove margin fine filtering.

* Remove unused unseen.

* Remove margin fine filtering. (#421)

* Remove margin fine filtering.

* Remove unused unseen.

* Use cdshealpix for margin pixel finding.

* Unused import.

* add color_by_order option and plot on existing axes

* reset matplotlib after tests

* pylint

* Migrate ang2vec (#426)

* Use astropy for ang2vec conversion

* Allow for kwargs in ang2vec

* use mindist instead of resol for margin filter

* Replace healpy in healpix_shim pixel math operations

* isort

* support np arrays

* use order instead of nside

* remove unused variable

* Return int64 from radec2pix (#432)

* Migrate box filtering to use MOCpy (#428)

* Use mocpy in box filtering

* Update tests

* Ensure moc is correct in box filter test

* Remove unused healpy methods

* Pin mocpy

* Remove healpy references. (#433)

* Address merge conflicts

---------

Co-authored-by: Sean McGuire <123987820+smcguire-cmu@users.noreply.github.com>
Co-authored-by: Sean McGuire <seanmcgu@andrew.cmu.edu>
Co-authored-by: Sandro Campos <scampos@andrew.cmu.edu>
  • Loading branch information
4 people authored Nov 26, 2024
1 parent c39621d commit ad6efa0
Show file tree
Hide file tree
Showing 23 changed files with 504 additions and 980 deletions.
14 changes: 1 addition & 13 deletions docs/guide/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,7 @@ Notes:

.. tip::
Installing on Mac

Native prebuilt binaries for healpy on Apple Silicon Macs
`do not yet exist <https://healpy.readthedocs.io/en/latest/install.html#binary-installation-with-pip-recommended-for-most-other-python-users>`_,
so it's recommended to install via conda before proceeding to hats.

.. code-block:: bash
$ conda config --add channels conda-forge
$ conda install healpy
$ git clone https://github.com/astronomy-commons/hats
$ cd hats
$ pip install -e .

When installing dev dependencies, make sure to include the single quotes.

.. code-block:: bash
Expand Down
194 changes: 0 additions & 194 deletions docs/guide/pixel_math.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ operations on top of these utilities. Some known extensions:
:caption: Developers

guide/contributing
Pixel math <guide/pixel_math>
API Reference <autoapi/index>

Getting Started
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ dependencies = [
"aiohttp", # http filesystem support
"astropy",
"fsspec>=2023.10.0", # Used for abstract filesystems
"healpy",
"jproperties",
"matplotlib>=3.3,<3.9",
"mocpy",
"mocpy>=0.17.1",
"numba>=0.58",
"numpy<3",
"pandas",
Expand Down
8 changes: 3 additions & 5 deletions src/hats/catalog/healpix_dataset/healpix_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,10 @@ def filter_by_cone(self, ra: float, dec: float, radius_arcsec: float) -> Self:
)
return self.filter_by_moc(cone_moc)

def filter_by_box(
self, ra: Tuple[float, float] | None = None, dec: Tuple[float, float] | None = None
) -> Self:
def filter_by_box(self, ra: Tuple[float, float], dec: Tuple[float, float]) -> Self:
"""Filter the pixels in the catalog to only include the pixels that overlap with a
right ascension or declination range. In case both ranges are provided, filtering
is performed using a polygon.
zone, defined by right ascension and declination ranges. The right ascension edges follow
great arc circles and the declination edges follow small arc circles.
Args:
ra (Tuple[float, float]): Right ascension range, in degrees
Expand Down
4 changes: 2 additions & 2 deletions src/hats/catalog/margin_cache/margin_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def filter_by_moc(self, moc: MOC) -> Self:
pixel sizes.
"""
max_order = moc.max_order
max_order_size = hp.nside2resol(2**max_order, arcmin=True)
if self.catalog_info.margin_threshold > max_order_size * 60:
max_order_size_arcsec = hp.order2mindist(max_order) * 60
if self.catalog_info.margin_threshold > max_order_size_arcsec:
raise ValueError(
f"Cannot Filter Margin: Margin size {self.catalog_info.margin_threshold} is "
f"greater than the size of a pixel at the highest order {max_order}."
Expand Down
2 changes: 1 addition & 1 deletion src/hats/catalog/partition_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def calculate_fractional_coverage(self):
"""Calculate what fraction of the sky is covered by partition tiles."""
pixel_orders = [p.order for p in self.pixel_list]
cov_order, cov_count = np.unique(pixel_orders, return_counts=True)
area_by_order = [hp.nside2pixarea(hp.order2nside(order), degrees=True) for order in cov_order]
area_by_order = [hp.order2pixarea(order, degrees=True) for order in cov_order]
# 41253 is the number of square degrees in a sphere
# https://en.wikipedia.org/wiki/Square_degree
return (area_by_order * cov_count).sum() / (360**2 / np.pi)
Loading

0 comments on commit ad6efa0

Please sign in to comment.