From 81b37c14f584b4d1ce17960a7adb7d982525a511 Mon Sep 17 00:00:00 2001 From: Xen0Xys Date: Fri, 17 May 2024 09:22:20 +0200 Subject: [PATCH] :art: Add minor changes after feedbacks --- CHANGELOG.md | 3 +++ README.md | 2 +- src/ipyaladin/aladin.py | 14 ++++++++------ src/ipyaladin/region_converter.py | 12 ++++++++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e6c8409..bced6bfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for `astropy.coordinates.SkyCoord` for assigning and reading the `target` property (#80) - Support for `astropy.coordinates.Angle` for reading the `fov` property (#83) +- Support for `regions.LineSkyRegion`, `regions.CircleSkyRegion`, `regions.EllipseSkyRegion`, `regions.PolygonSkyRegion`, `regions.RectangleSkyRegion`, `regions.Regions` in add_overlay (#88) ### Fixed @@ -30,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Change the jslink target trait from `target` to `shared_target` (#80) - Change the jslink fov trait from `fov` to `shared_fov` (#83) - Deprecate the `add_listener` method for a preferred use of `set_listener` method (#82) +- `add_overlay` second argument is now for Aladin Lite graphic options only (#88) +- Upgrade Aladin Lite version to 3.4.1-beta (#88) ## [0.3.0] diff --git a/README.md b/README.md index 0dd1bfd4..1c4070db 100644 --- a/README.md +++ b/README.md @@ -58,4 +58,4 @@ Correspondence table between ipyaladin versions and Aladin-lite versions: | ipyaladin | Aladin-Lite | | ---------- | ----------- | | 0.3.0 | 3.3.3-dev | -| unreleased | 3.4.0-beta | +| unreleased | 3.4.1-beta | diff --git a/src/ipyaladin/aladin.py b/src/ipyaladin/aladin.py index 8bb2b086..c26c98a6 100644 --- a/src/ipyaladin/aladin.py +++ b/src/ipyaladin/aladin.py @@ -384,12 +384,14 @@ def add_overlay( Parameters ---------- - region: str, `~CircleSkyRegion`, `~EllipseSkyRegion`, `~LineSkyRegion`, - `~PolygonSkyRegion`, `~RectangleSkyRegion` - The region to add in Aladin Lite. It can be given - as a string or one of the supported regions + region: str, `~regions.CircleSkyRegion`, `~regions.EllipseSkyRegion`, + `~regions.LineSkyRegion`,`~regions.PolygonSkyRegion`, + `~regions.RectangleSkyRegion` + The region to add in Aladin Lite. It can be given as a standard + STC-string or as a supported region from the regions package graphic_options: keyword arguments The options for the graphic overlay. Use Region visual for region options. + See graphicOverlay options here https://cds-astro.github.io/aladin-lite/A.html """ if isinstance(region, Regions): @@ -405,7 +407,7 @@ def add_overlay( if ( not isinstance(region_element, str) and Region is None ): # Only need to check one of the imports - raise ValueError( + raise ModuleNotFoundError( "A region can be given as an STC-S string or a regions " "object. To read regions objects, you need to install the regions " "library with 'pip install regions'." @@ -415,7 +417,7 @@ def add_overlay( region_element, Region ): raise ValueError( - "region must be a string or a regions object. See the " + "region must be a string or a `~regions` object. See the " "documentation for the supported region types." ) diff --git a/src/ipyaladin/region_converter.py b/src/ipyaladin/region_converter.py index d2833c83..ee344553 100644 --- a/src/ipyaladin/region_converter.py +++ b/src/ipyaladin/region_converter.py @@ -2,6 +2,8 @@ import numpy as np +from astropy.coordinates import SkyCoord + try: from regions import ( RectangleSkyRegion, @@ -18,7 +20,6 @@ CircleSkyRegion = None EllipseSkyRegion = None LineSkyRegion = None -from astropy.coordinates import SkyCoord from typing import Union TWICE_PI = 2 * math.pi @@ -32,14 +33,14 @@ class RefToLocalRotMatrix: Attributes ---------- - r11-r33 : float - The elements of the rotation matrix. + rotation_matrix : np.ndarray[float] + The rotation matrix. """ def __init__( self, - rotation_matrix: np.ndarray, + rotation_matrix: np.ndarray[float], ) -> None: self.rotation_matrix = rotation_matrix @@ -120,6 +121,9 @@ def to_global_coo(self, x: float, y: float, z: float) -> tuple[float, float]: def rectangle_to_polygon_region(region: RectangleSkyRegion) -> PolygonSkyRegion: """Convert a RectangleSkyRegion to a PolygonSkyRegion. + Converted code from cdshealpix: + https://github.com/cds-astro/cds-healpix-rust/blob/master/src/nested/mod.rs#L3687-3742 + Parameters ---------- region : RectangleSkyRegion