-
Notifications
You must be signed in to change notification settings - Fork 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
RCAL-919: Formalize the patches (sky cells) file (e.g., add a data model to support it as a reference fiel) #441
base: main
Are you sure you want to change the base?
Changes from all commits
cd6352e
c5f88d2
1c1d6a7
dc6fb11
3ffd496
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added support for skycell reference file |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -754,6 +754,24 @@ def mk_ref_readnoise_meta(**kwargs): | |||||||||||||
return meta | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
def mk_ref_skycells_meta(**kwargs): | ||||||||||||||
""" | ||||||||||||||
Create dummy metadata for skycells reference file instances. | ||||||||||||||
|
||||||||||||||
Returns | ||||||||||||||
------- | ||||||||||||||
dict (follows reference_file/ref_common-1.0.0 schema + skycell reference file meta data) | ||||||||||||||
""" | ||||||||||||||
meta = mk_ref_common("SKYCELLS", **kwargs) | ||||||||||||||
del meta["instrument"]["detector"] | ||||||||||||||
del meta["instrument"]["optical_element"] | ||||||||||||||
meta["nxy_skycell"] = 5000 | ||||||||||||||
meta["skycell_border_pixels"] = 100 | ||||||||||||||
meta["plate_scale"] = 0.055 | ||||||||||||||
Comment on lines
+768
to
+770
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.
Suggested change
Any reason to not use 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. Probably not, but I'm loathe to make changes until the naming stuff and file structure is settled. |
||||||||||||||
|
||||||||||||||
return meta | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
def mk_mosaic_basic(**kwargs): | ||||||||||||||
""" | ||||||||||||||
Create a dummy mosaic basic instance with valid values for attributes | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
mk_ref_epsf_meta, | ||
mk_ref_pixelarea_meta, | ||
mk_ref_readnoise_meta, | ||
mk_ref_skycells_meta, | ||
mk_ref_units_dn_meta, | ||
) | ||
|
||
|
@@ -32,6 +33,7 @@ | |
"mk_pixelarea", | ||
"mk_readnoise", | ||
"mk_refpix", | ||
"mk_roman_skycells", | ||
"mk_saturation", | ||
"mk_superbias", | ||
"mk_wfi_img_photom", | ||
|
@@ -565,6 +567,169 @@ def mk_saturation(*, shape=(4096, 4096), filepath=None, **kwargs): | |
return save_node(saturationref, filepath=filepath) | ||
|
||
|
||
def mk_roman_skycells(*, filepath=None, **kwargs): | ||
skycellref = stnode.RomanSkycellsRef() | ||
skycellref["meta"] = mk_ref_skycells_meta(**kwargs) | ||
proj_dtype = np.dtype( | ||
[ | ||
("index", "<i4"), | ||
("ra_tangent", "<f8"), | ||
("dec_tangent", "<f8"), | ||
("ra_min", "<f8"), | ||
("ra_max", "<f8"), | ||
("dec_min", "<f8"), | ||
("dec_max", "<f8"), | ||
("orientat", "<f4"), | ||
("x_tangent", "<f8"), | ||
("y_tangent", "<f8"), | ||
("nx", "<i4"), | ||
("ny", "<i4"), | ||
("skycell_start", "<i4"), | ||
("skycell_end", "<i4"), | ||
("nxy_skycell", "<i4"), | ||
("skycell_border_pixels", "<i4"), | ||
("pixel_scale", "<f4"), | ||
] | ||
) | ||
skycell_dtype = np.dtype( | ||
[ | ||
("name", "<U16"), | ||
("ra_center", "<f8"), | ||
("dec_center", "<f8"), | ||
("orientat", "<f4"), | ||
("x_tangent", "<f8"), | ||
("y_tangent", "<f8"), | ||
("ra_corn1", "<f8"), | ||
("dec_corn1", "<f8"), | ||
("ra_corn2", "<f8"), | ||
("dec_corn2", "<f8"), | ||
("ra_corn3", "<f8"), | ||
("dec_corn3", "<f8"), | ||
("ra_corn4", "<f8"), | ||
("dec_corn4", "<f8"), | ||
] | ||
) | ||
proj_tab = np.array( | ||
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. Is it possible to fill these with empty arrays with the structured dtype rather than hard-coding data here? 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. I think so, though there is a minor benefit for showing realistic values. I'm happy to change it though (after this whole name business is settled. |
||
[ | ||
( | ||
0, | ||
225.0, | ||
90.0, | ||
0.0, | ||
360.0, | ||
88.20062575, | ||
90.0, | ||
0.0, | ||
117776.5, | ||
117776.5, | ||
235554, | ||
235554, | ||
0, | ||
1985, | ||
5000, | ||
100, | ||
1.5277777e-05, | ||
), | ||
( | ||
1, | ||
0.0, | ||
86.40080763, | ||
-22.5, | ||
22.5, | ||
84.60010081, | ||
88.20062575, | ||
0.0, | ||
138592.5, | ||
117834.5, | ||
277186, | ||
235670, | ||
1985, | ||
3986, | ||
5000, | ||
100, | ||
1.5277777e-05, | ||
), | ||
( | ||
2, | ||
45.0, | ||
86.40080763, | ||
22.5, | ||
67.5, | ||
84.60010081, | ||
88.20062575, | ||
0.0, | ||
138592.5, | ||
117834.5, | ||
277186, | ||
235670, | ||
3986, | ||
5987, | ||
5000, | ||
100, | ||
1.5277777e-05, | ||
), | ||
], | ||
dtype=proj_dtype, | ||
) | ||
skycell_tab = np.array( | ||
[ | ||
( | ||
"a225dp90xm25yp01", | ||
317.2901524, | ||
88.16584325, | ||
-92.29015, | ||
122499.5, | ||
7299.5, | ||
318.40988935, | ||
88.12583697, | ||
318.55462778, | ||
88.20200659, | ||
316.1209133, | ||
88.20512017, | ||
316.07517233, | ||
88.12882346, | ||
), | ||
( | ||
"a225dp90xm25yp00", | ||
314.99952253, | ||
88.16730723, | ||
-89.99952, | ||
122499.5, | ||
2499.5, | ||
316.16868134, | ||
88.1287637, | ||
316.2183982, | ||
88.20505786, | ||
313.78062699, | ||
88.20505721, | ||
313.8303836, | ||
88.12876307, | ||
), | ||
( | ||
"a225dp90xm25yp01", | ||
312.70889418, | ||
88.16584203, | ||
-87.70889, | ||
122499.5, | ||
-2300.5, | ||
313.92389255, | ||
88.12882289, | ||
313.87811182, | ||
88.20511958, | ||
311.44440071, | ||
88.2020047, | ||
311.58917851, | ||
88.12583515, | ||
), | ||
], | ||
dtype=skycell_dtype, | ||
) | ||
skycellref["projection_regions"] = proj_tab | ||
skycellref["skycells"] = skycell_tab | ||
|
||
return save_node(skycellref, filepath=filepath) | ||
|
||
|
||
def mk_superbias(*, shape=(4096, 4096), filepath=None, **kwargs): | ||
""" | ||
Create a dummy Superbias instance (or file) with arrays and valid values for | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import asdf | ||
import numpy as np | ||
from astropy.time import Time | ||
|
||
import roman_datamodels.stnode as stnode | ||
|
||
|
||
def mk_skycell(output_filename, projection_regions, skycells, author, useafter, plate_scale, border_pixels): | ||
""" | ||
Create a skycell reference file. | ||
|
||
|
||
Parameters | ||
---------- | ||
output_filename : string. | ||
The name of the created reference file. | ||
projection_regions : numpy structure array. | ||
An array that defines the projection regions containing the fields as defined by | ||
the schema. | ||
skycells : numpy structure array. | ||
An array that defines all skycells containing the fields as defined by the schema. | ||
author : string. | ||
The name of the person creating the reference file. | ||
useafter : astropy.time.Time instance. | ||
The useafter date that CRDS requires. | ||
plate_scale: float. | ||
The plate scale of the pixel at the tangent point. | ||
border_pixels: integer. | ||
The number of pixels the skycells within a projection region overlap with adjacent | ||
skycells in the same projection region. | ||
""" | ||
meta = { | ||
"reftype": "SKYCELLS", | ||
"pedigree": "GROUND", | ||
"description": "Skycells covering the celestial sphere", | ||
"author": author, | ||
"useafter": Time("2024-01-01T01:00:00.000"), | ||
"telescope": "ROMAN", | ||
"origin": "STSCI", | ||
"instrument": {"name": "WFI"}, | ||
"nxy_skycell": 5000, | ||
"skycell_border_pixels": border_pixels, | ||
"plate_scale": plate_scale, | ||
} | ||
projection_regions = np.array(projection_regions) | ||
skycells = np.array(skycells) | ||
skycellref = stnode.RomanSkycellsRef() | ||
skycellref["meta"] = meta | ||
skycellref["projection_regions"] = projection_regions | ||
skycellref["skycells"] = skycells | ||
skycellref["datamodel_name"] = "RomanSkycellsRefModel" | ||
with asdf.AsdfFile() as afout: | ||
afout = asdf.AsdfFile() | ||
afout.tree["roman"] = skycellref | ||
afout.write_to(output_filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the
Roman
prefix?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mulled over that, more for the filename than for the class (which is clearly associated with Roman in its context). I worry that the reference file by itself may need a clear association with Roman in the event skycells end up being used for other telescopes (like JWST). It is a good question.