-
-
Notifications
You must be signed in to change notification settings - Fork 58
Add spherical sky region classes #618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sedonaprice
wants to merge
56
commits into
astropy:main
Choose a base branch
from
sedonaprice:add-spherical-regions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
0564a4f
Initial commit of spherical sky regions
sedonaprice b462147
Add spherical polygon, boundary discretization
sedonaprice bcc4394
Add bounding lonlat
sedonaprice 07ae77f
Add spherical circle annulus
sedonaprice e692aa4
Add spherical lune
sedonaprice d440e35
Add spherical range region
sedonaprice d73e471
Add `to_spherical_sky()` to PixelRegion, SkyRegion classes
sedonaprice b318613
Codestyle fixes
sedonaprice 4f077bb
Implement test suite for spherical regions
sedonaprice f849f25
Correct docstring syntax for sphinx docs
sedonaprice c5ca371
Initial docs edits
sedonaprice 9b82237
Landing page example
sedonaprice 79c2ee9
Changes to shapes doc page
sedonaprice fc2e55d
Edited contains docs to include spherical regions
sedonaprice 81b5662
Updated compound docs to add spherical regions
sedonaprice 8819aab
Added spherical example to plotting doc page
sedonaprice ee51156
Spherical region frame transformation doc
sedonaprice 1eab89e
Spherical region bounding info docs
sedonaprice ac2ee60
Bugfixes, update tests
sedonaprice fb9164b
Add FLOAT_CMP to docs for testing
sedonaprice eec6f4b
Apply changes from #628 to CompoundSphericalSkyRegion
sedonaprice 5af9c7c
Correct in-line comments
sedonaprice 515dd16
Rename test to spherical sky
sedonaprice ffa959c
Remove unused function in test_polygon.py
sedonaprice 0880acb
Fix typo
sedonaprice 5e38b61
Split compound examples for smaller code chunks
sedonaprice 89c3bf0
Change test expected failure handling
sedonaprice 618e80b
Change lon/lat derivation handling in range
sedonaprice 400327a
Validate range lon/lat range & bound inputs
sedonaprice a6483fd
Update spherical <-> planar transform errors
sedonaprice 924f92d
Added changelog entry
sedonaprice dd8d364
Fix assert vs error messages in range validation
sedonaprice a1beb97
Remove unnecessary comment from whole_sky.py
sedonaprice 7d04909
Fix typo in plotting.rst
sedonaprice 0d7ec10
Resolve conflict with main in test_api.py
larrybradley 03af2c1
Fix deprecation in coord concatenation
sedonaprice 521b875
Bugfix polygon vertices ordering
sedonaprice 4f8150f
Simplify/speed up with patthern `.to_value(UNIT)`
sedonaprice b604d25
Swap to use `np.minimum` directly on quantities
sedonaprice 9e2bf5b
Correct discretization to use `circ_center`
sedonaprice 55e6567
Correct spelling of "latitude"
sedonaprice 57d2310
Correct `latitude_range` description
sedonaprice b2e8259
Correct docstring: second `lons_arr` -> `lats_arr`
sedonaprice e96cf35
Remove commented lines
sedonaprice 0ee3cb8
Add `merge_attributes` kwarg to inheriting `transform_to`
sedonaprice 671a7a1
Add tildes for links to package classes
sedonaprice 830c3c6
Simplify discretization boundary SkyCoord creation
sedonaprice 933d8b9
Remove unnecessary if statement in lune.py
sedonaprice 99e82c6
Remove other unnecessary if statements from lune,range
sedonaprice 681a059
Change include_bound_dist + no WCS error msg format
sedonaprice 4e83ab7
Simplify range bound transformation method
sedonaprice 00afea0
Common _validate_planar_spherical_transform() method
sedonaprice 0df756e
Document convex-only spherical polygon limitation
sedonaprice cddd5f5
Update test: improved pixel <-> sky conversion
sedonaprice 0d1ce5c
Update shapes.rst for repr, wcs sky<->pix changes
sedonaprice af173f4
Run pre-commit for linting
sedonaprice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,14 +10,22 @@ Introduction | |
|
|
||
| The Regions package provides classes to represent: | ||
|
|
||
| * Regions defined using pixel coordinates (e.g., | ||
| * Regions defined using pixel coordinates (a "region-on-image"; e.g., | ||
| `~regions.CirclePixelRegion`) | ||
| * Regions defined using celestial coordinates, but still in an Euclidean | ||
| geometry (e.g., `~regions.CircleSkyRegion`) | ||
| geometry (i.e., a planar projection, as a "region-on-image"; | ||
| e.g., `~regions.CircleSkyRegion`) | ||
| * Regions defined using celestial coordinates, and with a spherical | ||
| geometry (a "region-on-celestial-sphere"; e.g., `~regions.CircleSphericalSkyRegion`) | ||
|
|
||
| To transform between sky and pixel regions, a `world coordinate system | ||
| To transform between (planar) sky and pixel regions, a `world coordinate system | ||
| <https://docs.astropy.org/en/stable/wcs/wcsapi.html>`_ object (e.g., | ||
| `astropy.wcs.WCS`) is needed. | ||
| `~astropy.wcs.WCS`) is needed. To transform between spherical and planar (sky or pixel) | ||
| regions, in addition to a `wcs | ||
| <https://docs.astropy.org/en/stable/wcs/wcsapi.html>`_, it is also | ||
| necessary to specify whether or not boundary distortions should be included | ||
| (capturing the projection effects inherent in projection-to-spherical | ||
| transformations, or the inverse). | ||
|
|
||
| Regions also provides a unified interface for reading, writing, | ||
| parsing, and serializing regions data in different formats, including | ||
|
|
@@ -122,7 +130,7 @@ Pixel/Sky Coordinate Transformations | |
|
|
||
| To transform between pixel and sky coordinates, a `world coordinate system | ||
| <https://docs.astropy.org/en/stable/wcs/wcsapi.html>`_ object (e.g., | ||
| `astropy.wcs.WCS`) is needed. | ||
| `~astropy.wcs.WCS`) is needed. | ||
|
|
||
| Let's start by creating a WCS object: | ||
|
|
||
|
|
@@ -187,10 +195,10 @@ Sky Regions | |
|
|
||
| Sky regions are regions that are defined using celestial coordinates. | ||
| Please note they are **not** defined as regions on the celestial sphere, | ||
| but rather are meant to represent shapes on an image. They simply use | ||
| sky coordinates instead of pixel coordinates to define their position. | ||
| The remaining shape parameters are converted to pixels using the pixel | ||
| scale of the image. | ||
| but rather are meant to represent shapes on an image ("region-on-image"). | ||
| They simply use sky coordinates instead of pixel coordinates to define | ||
| their position. The remaining shape parameters are converted to pixels | ||
| using the pixel scale of the image. | ||
|
|
||
| Let's create a sky region: | ||
|
|
||
|
|
@@ -236,3 +244,67 @@ You can access its properties via attributes: | |
| See the :ref:`shapes` documentation for the complete list of pixel-based | ||
| regions and to learn more about :class:`~regions.Region` objects and | ||
| their capabilities. | ||
|
|
||
|
|
||
| Spherical Sky Regions | ||
| --------------------- | ||
|
|
||
| Spherical sky regions are defined using celestial coordinates, | ||
| and **are** defined as regions on the celestial sphere | ||
| ("regions-on-celestial-sphere", in contrast to the planar Sky Regions). | ||
| In order to transform between spherical and planar ("region-on-image") regions, | ||
| the planar projection (encoded in a `world coordinate system | ||
| <https://docs.astropy.org/en/stable/wcs/wcsapi.html>`_ object; e.g., | ||
| `~astropy.wcs.WCS`) must be specified, along with a specification of | ||
| whether or not boundary distortions should be included. | ||
| These distortions (implemented through discrete boundary sampling) | ||
| capture the impact of the spherical-to-planar (or vice versa) projection. | ||
| However, it is possible to ignore these distortions (e.g., | ||
| transforming a spherical circle to a planar circle). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add an example here showing the difference - i.e., showing how a point could go from inside the spherical circle to outside the planar circle, and vice-versa? The more clear we can make the limitations of each approach, the better. |
||
|
|
||
| Spherical sky regions are created using celestial coordinates (as | ||
| `~astropy.coordinates.SkyCoord`) and angular distances, | ||
| for instance specified as | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| >>> from astropy.coordinates import Angle, SkyCoord | ||
| >>> from regions import CircleSphericalSkyRegion | ||
| >>> center = SkyCoord(42, 43, unit='deg') | ||
| >>> radius = Angle(3, 'deg') | ||
| >>> region = CircleSphericalSkyRegion(center, radius) | ||
|
|
||
| Alternatively, one can define the radius using a | ||
| `~astropy.units.Quantity` object with angular units: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| >>> import astropy.units as u | ||
| >>> from regions import CircleSphericalSkyRegion | ||
| >>> center = SkyCoord(42, 43, unit='deg') | ||
| >>> radius = 3.0 * u.deg | ||
| >>> region = CircleSphericalSkyRegion(center, radius) | ||
|
|
||
| You can print the region to get some information about its properties: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| >>> print(region) | ||
| Region: CircleSphericalSkyRegion | ||
| center: <SkyCoord (ICRS): (ra, dec) in deg | ||
| (42., 43.)> | ||
| radius: 3.0 deg | ||
|
|
||
| You can access its properties via attributes: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| >>> region.center | ||
| <SkyCoord (ICRS): (ra, dec) in deg | ||
| (42., 43.)> | ||
| >>> region.radius | ||
| <Quantity 3. deg> | ||
|
|
||
| See the :ref:`shapes` documentation for the complete list of pixel-based | ||
| regions and to learn more about :class:`~regions.Region` objects and | ||
| their capabilities. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.