-
Notifications
You must be signed in to change notification settings - Fork 0
Sky Coverage Initial Script #21
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
JBorrow
wants to merge
37
commits into
main
Choose a base branch
from
sky_coverage
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
37 commits
Select commit
Hold shift + click to select a range
c405635
feat: initial function for finding tiles from bounding box and tmap
Sulla2012 c141f11
feat: update docs and make composite ID
Sulla2012 252c0fc
feat: init function to get a list of sky coverage table entries from …
Sulla2012 c0162ed
fix: ruff formating
Sulla2012 b451ed3
fix: more ruff formating
Sulla2012 e31e3f1
feat: switching from passing box to getting box using pixell
Sulla2012 90db8e4
feat: moving sky coverage tools
Sulla2012 3d7ef76
fix: fixing composite key generation
Sulla2012 9e30a6f
feat: starting skycoverage update function
Sulla2012 9c64131
Merge remote-tracking branch 'origin/main' into sky_coverage
Sulla2012 0064a15
feat: add sqlite to gitignore
Sulla2012 dbe9283
fix: updating outerjoin query
Sulla2012 98d5d85
feat: move core functionaliy of ingestact to a separate function for …
Sulla2012 5649579
feat: move core functionality of update_sky_coverage to its own funct…
Sulla2012 281f19c
feat: adding test for ingestact and update_sky_coverage
Sulla2012 0d445ca
fix: map=d1table is redundant
Sulla2012 a18fb0b
fix: move update_sky_coverage
Sulla2012 bbe3fe6
fix: ruff
Sulla2012 c9c046f
Fix tests
JBorrow 718265b
Add h5py as dependency
JBorrow c33501e
Satisfy tyg
JBorrow 0fccbb6
fix: remove unneccesary update statement
Sulla2012 3311448
fix: remove unused imports
Sulla2012 a877896
feat: switch to env variables for file paths
Sulla2012 4d5366a
fix: updating to latest ruff
Sulla2012 c4410f5
temp: checking DEPTH_ONE_MAP path
Sulla2012 34ec728
temp: echo DEPTH_ONE_PATH
Sulla2012 38cbe26
fix: wrong variable name for DEPTH_ONE_PARENT
Sulla2012 2cf5e0f
feat: change dec to 0-17, ra to 0-35 and add plotting util
Sulla2012 1c129a8
fix: update test to new ra/dec conventions and plot with ACT (e.g., r…
Sulla2012 13a2740
fix: improper tuple construction
Sulla2012 e2c71d1
Add CLI script
JBorrow 8fa38fc
Merge branch 'main' into sky_coverage
JBorrow d4f2343
fix: updating coverage tests to new ra/dec conventions
Sulla2012 9699857
fix: clean up some tests and increase coverage
Sulla2012 115cefc
fix: making index_to_skybox consistent with ra_to_index and changing …
Sulla2012 ac9b30d
feat: update plot tiles to use argparse
Sulla2012 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ dist/* | |
| *.egg-info | ||
| *.fits | ||
| *.hdf | ||
| .coverage | ||
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from .core import get_maps_by_coverage | ||
|
|
||
| __all__ = [ | ||
| "get_maps_by_coverage", | ||
| ] |
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| from astropy.coordinates import ICRS | ||
| from sqlalchemy import select | ||
| from sqlalchemy.orm import Session | ||
|
|
||
| from mapcat.database import DepthOneMapTable | ||
| from mapcat.toolkit.update_sky_coverage import dec_to_index, ra_to_index | ||
|
|
||
|
|
||
| def get_maps_by_coverage( | ||
| position: ICRS, | ||
| session: Session, | ||
| ) -> list[DepthOneMapTable]: | ||
| """ | ||
| Get the depth one maps that cover a given position. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| position : ICRS | ||
| The position to query for coverage. Should be in ICRS coordinates. | ||
| session : Session | ||
| The database session to use for the query. | ||
|
|
||
| Returns | ||
| ------- | ||
| session.execute(stmt).scalars().all() : list[DepthOneMapTable] | ||
| A list of depth one maps that cover the given position. | ||
|
|
||
| Raises | ||
| ------ | ||
| ValueError | ||
| If the RA or Dec of the position is out of bounds. | ||
| """ | ||
| ra = position.ra.deg | ||
| dec = position.dec.deg | ||
|
|
||
| # These aren't covered since ICRS automatically wraps | ||
| # values back aground to 0-360 for RA and -90 to 90 for Dec. | ||
| if ra < 0 or ra > 360: # pragma: no cover | ||
| raise ValueError("RA must be between 0 and 360 degrees") | ||
| if dec < -90 or dec > 90: # pragma: no cover | ||
| raise ValueError("Dec must be between -90 and 90 degrees") | ||
|
|
||
| ra_idx = ra_to_index(ra) | ||
| dec_idx = dec_to_index(dec) | ||
|
|
||
| stmt = ( | ||
| select(DepthOneMapTable) | ||
| .join(DepthOneMapTable.depth_one_sky_coverage) | ||
| .filter_by(x=ra_idx, y=dec_idx) | ||
| ) | ||
|
|
||
| return session.execute(stmt).scalars().all() |
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
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 |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import argparse as ap | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
| from pixell import enmap | ||
|
|
||
| from mapcat.toolkit.update_sky_coverage import * | ||
|
|
||
| parser = ap.ArgumentParser() | ||
| parser.add_argument("--imap_path", type=str) | ||
| parser.add_argument("--d1map_path", type=str) | ||
| parser.add_argument("--opath", type=str) | ||
|
|
||
| args = parser.parse_args() | ||
| imap_path = args.imap_path | ||
| d1map_path = args.d1map_path | ||
| opath = args.opath | ||
|
|
||
| imap = enmap.read_map(str(imap_path)) | ||
|
|
||
| box = imap.box() | ||
|
|
||
| dec_min, ra_max = np.rad2deg(box[0]) | ||
| dec_max, ra_min = np.rad2deg(box[1]) | ||
|
|
||
| pad_low = int((90 + dec_min) * 6 * 2) | ||
| pad_high = int((90 - dec_max) * 6 * 2) | ||
|
|
||
| imap = imap[0][::10, ::10] | ||
|
|
||
| pad_map = np.pad( | ||
| imap, ((pad_low, pad_high), (0, 0)), mode="constant", constant_values=0 | ||
| ) | ||
| del imap | ||
|
|
||
| left_limit = pad_map.shape[1] | ||
| right_limit = 0 | ||
| top_limit = pad_map.shape[0] | ||
| bottom_limit = 0 | ||
| extent = [left_limit, right_limit, bottom_limit, top_limit] | ||
|
|
||
|
|
||
| plt.imshow(pad_map, vmin=-300, vmax=300, origin="lower", extent=extent) | ||
| plt.vlines( | ||
| np.arange(0, 360 * 6 * 2, 10 * 6 * 2), ymin=0, ymax=180 * 6 * 2, color="black", lw=1 | ||
| ) | ||
| plt.hlines( | ||
| np.arange(0, 180 * 6 * 2, 10 * 6 * 2), xmin=0, xmax=360 * 6 * 2, color="black", lw=1 | ||
| ) | ||
| plt.xticks(np.arange(0, 360 * 6 * 2, 20 * 6 * 2), labels=np.arange(0, 360, 20)) | ||
| plt.yticks(np.arange(0, 180 * 6 * 2, 10 * 6 * 2), labels=np.arange(-90, 90, 10)) | ||
| plt.xlabel("RA (degrees)") | ||
| plt.ylabel("Dec (degrees)") | ||
|
|
||
| d1map = enmap.read_map(str(d1map_path)) | ||
| coverage_tiles = get_sky_coverage(d1map) | ||
|
|
||
| d1box = d1map.box() | ||
|
|
||
| d1dec_min, d1ra_max = np.rad2deg(d1box[0]) | ||
| d1dec_max, d1ra_min = np.rad2deg(d1box[1]) | ||
|
|
||
| d1pad_low_dec = int((90 + d1dec_min) * 6 * 2) | ||
| d1pad_high_dec = int((90 - d1dec_max) * 6 * 2) | ||
|
|
||
| d1pad_low_ra = int((180 + d1ra_min) * 6 * 2) | ||
| d1pad_high_ra = int((180 - d1ra_max) * 6 * 2) | ||
|
|
||
| d1map = d1map[0][::10, ::10] | ||
| d1pad_map = np.pad( | ||
| d1map, | ||
| ((d1pad_low_dec, d1pad_high_dec), (d1pad_high_ra, d1pad_low_ra)), | ||
| mode="constant", | ||
| constant_values=0, | ||
| ) | ||
|
|
||
| plt.imshow( | ||
| d1pad_map, | ||
| vmin=-300, | ||
| vmax=300, | ||
| origin="lower", | ||
| alpha=0.5, | ||
| cmap="seismic", | ||
| extent=extent, | ||
| ) | ||
|
|
||
| for tile in coverage_tiles: | ||
| plt.gca().add_patch( | ||
| plt.Rectangle( | ||
| (tile[0] * 10 * 6 * 2, tile[1] * 10 * 6 * 2), | ||
| 10 * 6 * 2, | ||
| 10 * 6 * 2, | ||
| fill=False, | ||
| edgecolor="red", | ||
| lw=2, | ||
| ) | ||
| ) | ||
|
|
||
| plt.savefig(opath + "act_coverage.png", dpi=300) |
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
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.