Skip to content

Make Region a TOMToolkit model#7

Open
phycodurus wants to merge 21 commits intomainfrom
dev
Open

Make Region a TOMToolkit model#7
phycodurus wants to merge 21 commits intomainfrom
dev

Conversation

@phycodurus
Copy link
Copy Markdown
Member

This is designed to be the basis of a future tom_nonlocalizedevents refactor and future radio astronomy use cases.

  • Ports Leo's HEALPix Alchemy to Django ORM in healpix_django subpackage
  • Creates RegionList and RegionDetail pages, and Regions nav-bar item.
  • To create a region by hand from Aladin go to "Stack menu" > Overlays > MOC > From selection
    • select Circle, Rect, or Polygon
    • draw region in Aladin window
    • see new region in Aladin
    • expand "Save a MOC drawn in Aladin" form
    • select Aladin overlay from unsaved Aladin regions
    • give it a name
    • Select "Save Region"
    • see you region (now in the db) in the htmx-driven table
  • You can also upload a IVOC MOC Fits file
    • try curl -o gaiaDR2.fits "http://alasky.u-strasbg.fr/MocServer/query?ID=CDS/I/345/gaia2&get=moc&fmt=fits" and upload the saved file (gaiaDR2.fits)
image

Self-contained port of skyportal/healpix-alchemy onto
django.contrib.postgres primitives. MOCs are stored as one row per
int8range tile with SP-GiST. PostgreSQL 14+ only; hard-fails
elsewhere from AppConfig.ready().
mocpy 0.19 dropped its public cdshealpix dep, and cdshealpix 0.8
requires Longitude/Latitude (with units) rather than radian floats.
ListView, DetailView, app integration points
urls, etc.
The List page reders an HTMX-driven, filterable table with an Aladin Lite
skymap whose MOC overlay set updates in lockstep via the OOB-data-update
pattern. Detail page reuses the same Aladin partial for a single-region
view and exposes the IVOA MOC JSON via a labeled link.
Aladin Lite's A.MOCFromURL parses FITS only; switch the overlay to
A.MOCFromJSON with the IVOA dict inlined in the page payload. Extract a
region_to_moc_json helper so the HTTP endpoint and the inline overlay
share one encoder. Label the detail-page link as IVOA.
Tiles are stored at their native HEALPix level (length-encoded
in the int8range), so a single region's rows span multiple orders,
and that's where the compression vs. a flat depth-29 list comes from.
Adds two MultiOrderStorageTests cases that demonstrate the property
at the database layer.
boot_django.py + run_tests.py runs the test suite via
`python tom_regions/tests/run_tests.py` without standing up a host
TOM; the GitHub Actions matrix exercises Python 3.12/3.13 against a
postgres:16-alpine service container.
Steradians is the SI unit and stays as the database column. but every
user-facing display converts to square degrees.
 - SQ_DEG_PER_STERADIAN goes in `healpix_django.constants`.
 - `BaseRegion.area_sq_deg` is a thin @Property wrapping the conversion.
Read the upload's bytes into a BytesIO before passing it to
MOC.from_fits. mocpy's MOC.from_fits checks for BytesIO first
and reads its bytes directly.
@jchate6 jchate6 moved this to Needs Review in TOM Toolkit May 1, 2026
@phycodurus phycodurus mentioned this pull request May 7, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

2 participants