-
Notifications
You must be signed in to change notification settings - Fork 174
JP-1431: add parameter extract_height to wfss extraction #5140
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
Conversation
@hbushouse Is the |
Codecov Report
@@ Coverage Diff @@
## master #5140 +/- ##
=======================================
Coverage 52.53% 52.54%
=======================================
Files 406 406
Lines 36247 36265 +18
Branches 5615 5620 +5
=======================================
+ Hits 19044 19056 +12
- Misses 16026 16031 +5
- Partials 1177 1178 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
JP-1431 requests that the extraction parameter be a half-height, such that param=N results in a total height of 2N+1. |
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.
Does this also allow all the grism extractions to have their height set to a specific value, not just SOSS? That could be useful for the WFSS modes as well I suspect.
jwst/assign_wcs/util.py
Outdated
@@ -506,7 +506,8 @@ def get_object_info(catalog_name=None): | |||
def create_grism_bbox(input_model, | |||
reference_files, | |||
mmag_extract=99.0, | |||
extract_orders=None): | |||
extract_orders=None, | |||
extract_height=None): |
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.
If the keyword is extract_height
it would be clearer if it was the full height of the extraction. And this is already what the current keyword is.
jwst/jwst/extract_2d/extract_2d.py
Lines 37 to 40 in ff9ea40
extract_height: int | |
Cross-dispersion extraction height to use for time series grisms. | |
This will override the default which for NRC_TSGRISM is a set | |
size of 64 pixels. |
If it is to be the half height, then extraction_half_height
would be clearer to users I think.
jwst/assign_wcs/util.py
Outdated
_extract_height_direction = 'y' | ||
else: | ||
_extract_height_direction = 'x' |
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.
The DISPAXIS or meta.wcsinfo.dispersion_direction
keyword should give the dispersion direction without having to rely on filter name parsing. Or move the filter name parsing to the dispersion direction function
Lines 6 to 8 in ff9ea40
def get_dispersion_direction(exposure_type, grating="ANY", filter_wh="ANY", | |
pupil="ANY"): | |
"""Get the dispersion direction. |
This PR IS for WFSS mode, not SOSS. |
Doh! brainfart Then the |
@jdavies-st SOSS does not go through extract_2d. The parameter is for TSGRISM mode. But it's a good point. @hbushouse Would it be possible to change the TSGRISM parameter to "half height" as well or does the INS team want is to be a full height. If so we'll have to have two parameters. |
I know the NIRCam TSO folks were specific about the placement and height of the extraction box that they wanted for TSGRISM. If the current height happens to be an odd number, then it too could be expressed as a half-height, like WFSS. But I'm guessing that the default values will be different for TSGRISM and WFSS, so it's not possible to combine into a single parameter, unless we create separate extract_2d parameter files and install them in CRDS. During processing, the appropriate one would be selected based on EXP_TYPE. |
In this case I'll create a new parameter |
That's fine, but I would use the term "wfss" in the parameter name, instead of the generic "grism", because TSGRISM and WFSS both use a grism. This parameter will be specific to WFSS only. Perhaps "wfss_extract_half_height". |
add change log
I took the opportunity to refactor |
For NIRCam and NIRISS WFSS mode, the ``extract_2d`` step has one optional argument: | ||
|
||
``--wfss_extract_half_height`` | ||
int. The cross-dispersion half size, in pixels. |
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.
Again, note that this only applies to sources tagged in the source catalog as point-like (based on the catalog entry "is_star" - boolean).
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.
will make that check and point this pout in the documentation
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.
The catalog I have lists is_star
as float, not boolean, and all values are NaNs.
<Column name='is_star' dtype='float64' description='Flag indicating whether the source is a star' length=116>
nan
nan
nan
nan
Do you know if this column is computed in photutils or source_catalog?
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.
From source_catalog
:
@lazyproperty
def is_star(self):
"""
Flag indicating whether the source is a star.
2020.03.02: The JWST Photometry Working Group has not determined
the criteria for this flag.
"""
# TODO: need algorithm for this flag
#is_star = np.random.randint(2, size=len(self.id))
#return is_star.astype(bool)
return self.null_column
This is where NaNs are returned.
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.
An algorithm was specified a month or two ago, but it hasn't been implemented yet. It will be Boolean when implemented, with a value of True
for point sources.
jwst/assign_wcs/util.py
Outdated
Cross-dispersion extraction half height in pixels, WFSS mode. | ||
Overwrites the computed extraction height in ``GrismObject.order_bounding.`` | ||
If ``None``, it's computed from the segementation map, | ||
using the min and max wavelegnth for each of the orders that |
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.
typo in "wavelegnth"
jwst/assign_wcs/util.py
Outdated
message = "If reference files are not supplied, ``wavelength_range`` must be provided." | ||
raise TypeError(message) | ||
else: | ||
# Get the list of extract_orders and lmin, lmax from the ``wavelengthrange11 reference file. |
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.
typo "wavelengthrange11"
jwst/extract_2d/extract_2d_step.py
Outdated
@@ -16,7 +16,8 @@ class Extract2dStep(Step): | |||
spec = """ | |||
slit_name = string(default=None) | |||
extract_orders = int_list(default=None) # list of orders to extract | |||
extract_height = integer(default=None) # extraction height in pixels | |||
extract_height = integer(default=None) # extraction height in pixels, TSGRISM mode |
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.
Since we now have 2 extraction height params, maybe we should be explicit in the names for both of them which mode they apply to, such as tsgrism_extract_height
.
jwst/extract_2d/grisms.py
Outdated
@@ -299,6 +300,9 @@ def extract_grism_objects(input_model, | |||
Compute a wavelength array for the datamodel. Computationally | |||
expensive, but saves doing it repeatedly later on in pipeline. | |||
|
|||
wfss_extract_half_heigh : int, (optional) |
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.
typo: missing the trailing "t" on height
jwst/assign_wcs/util.py
Outdated
@@ -658,6 +677,17 @@ def create_grism_bbox(input_model, | |||
xmax = int(np.max(xstack)) | |||
ymin = int(np.min(ystack)) | |||
ymax = int(np.max(ystack)) | |||
if wfss_extract_half_height is not None: |
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.
Is the source catalog info for each source known at this point in the processing? This param value needs to be applied ONLY if the source being processed has is_star = True
in the source catalog (only applied to point sources).
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.
yes, the source catalog is available, will include this check
I added the check for |
jwst/assign_wcs/util.py
Outdated
# The ``72`` criteria is a placeholder fof when there's a decision | ||
# on how to populate the ``is_star`` column in the catalog. | ||
# See ``is_star`` property in source_catalog.py | ||
if wfss_extract_half_height is not None and obj.is_star > 72: |
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.
Is there a way to test for NaN
versus True
, such that if NaN
, don't apply, and if True
, then do apply it.
docs/jwst/extract_2d/main.rst
Outdated
``--extract_orders`` | ||
list. The list of orders to extract. The default is taken from the ``wavelengthrange`` | ||
reference file. | ||
For NIRCam TSGRISM, the ``extract_2d`` step has one optional argument: | ||
|
||
``--extract_height`` |
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.
Should update this now to --tsgrism_extract_height
@@ -23,6 +23,7 @@ | |||
# - {name: orientation_sky, unit: deg, datatype: float64} | |||
# - {name: isophotal_abmag, datatype: float64} | |||
# - {name: isophotal_abmag_err, datatype: float32} | |||
# - {name: is_star, datatype: float64} |
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.
Perhaps you should modify the data file used in the test to have the is_star
column be Boolean and modify the entries in the ecsv file itself to also be boolean for that column (perhaps with a mixture of True and False values).
jwst/assign_wcs/util.py
Outdated
@@ -659,6 +680,21 @@ def create_grism_bbox(input_model, | |||
ymin = int(np.min(ystack)) | |||
ymax = int(np.max(ystack)) | |||
|
|||
# The ``72`` criteria is a placeholder fof when there's a decision |
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.
You can get rid of this comment now, since you've already changed obj.is_star
to be used as a boolean.
jwst/lib/catalog_utils.py
Outdated
@@ -118,6 +119,8 @@ class SkyObject(namedtuple('SkyObject', ("id", | |||
Upper left corner of the minimum bounding DE0F box | |||
sky_bbox_ur : `~astropy.coordinates.SkyCoord` | |||
Upper right corner of the minimum bounding box | |||
is_star : float |
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.
Need to change the data type to bool
Fixes #4896 / JP-1431