Skip to content

Commit

Permalink
🎨 Add minor changes after feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed May 17, 2024
1 parent 66a54f9 commit 99b756a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
12 changes: 7 additions & 5 deletions src/ipyaladin/aladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,14 @@ def add_overlay(
Parameters
----------
region: str, `~CircleSkyRegion`, `~EllipseSkyRegion`, `~LineSkyRegion`,
`~PolygonSkyRegion`, `~RectangleSkyRegion`
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 string or one of the supported regions
as a string or one of the supported regions.
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):
Expand All @@ -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'."
Expand All @@ -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."
)

Expand Down
12 changes: 8 additions & 4 deletions src/ipyaladin/region_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import numpy as np

from astropy.coordinates import SkyCoord

try:
from regions import (
RectangleSkyRegion,
Expand All @@ -18,7 +20,6 @@
CircleSkyRegion = None
EllipseSkyRegion = None
LineSkyRegion = None
from astropy.coordinates import SkyCoord
from typing import Union

TWICE_PI = 2 * math.pi
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 99b756a

Please sign in to comment.