8000 JP-1431: add parameter extract_height to wfss extraction by nden · Pull Request #5140 · spacetelescope/jwst · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 6 commits into from
Jul 21, 2020

Conversation

nden
Copy link
Collaborator
@nden nden commented Jul 10, 2020

Fixes #4896 / JP-1431

@nden
Copy link
Collaborator Author
nden commented Jul 10, 2020

@hbushouse Is the extraction_height parameter supposed to be a full or half height?

@codecov
Copy link
codecov bot commented Jul 10, 2020

Codecov Report

Merging #5140 into master will increase coverage by 0.00%.
The diff coverage is 60.41%.

Impacted file tree graph

@@           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     
Flag Coverage Δ
#unit 52.54% <60.41%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jwst/extract_2d/extract_2d.py 50.00% <0.00%> (ø)
jwst/extract_2d/extract_2d_step.py 100.00% <ø> (ø)
jwst/lib/catalog_utils.py 94.73% <ø> (ø)
jwst/source_catalog/source_catalog.py 27.22% <0.00%> (ø)
jwst/assign_wcs/util.py 51.03% <51.51%> (+0.11%) ⬆️
jwst/datamodels/wcs_ref_models.py 50.88% <100.00%> (+0.58%) ⬆️
jwst/extract_2d/grisms.py 75.57% <100.00%> (ø)
jwst/datamodels/source_container.py 57.14% <0.00%> (-3.73%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65c6882...712cd05. Read the comment docs.

@hbushouse
Copy link
Collaborator

JP-1431 requests that the extraction parameter be a half-height, such that param=N results in a total height of 2N+1.

@hbushouse hbushouse added this to the Build 7.6 milestone Jul 10, 2020
Copy link
Collaborator
@jdavies-st jdavies-st left a 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.

@@ -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):
Copy link
Collaborator

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.

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.

Comment on lines 568 to 570
_extract_height_direction = 'y'
else:
_extract_height_direction = 'x'
Copy link
Collaborator

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

def get_dispersion_direction(exposure_type, grating="ANY", filter_wh="ANY",
pupil="ANY"):
"""Get the dispersion direction.

@hbushouse
Copy link
Collaborator

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.

This PR IS for WFSS mode, not SOSS.

@jdavies-st
Copy link
Collaborator

Doh! brainfart

Then the extract_height keyword should be consistent with what it is for SOSS, i.e. the full height of the extraction box. Having the same keyword mean 2 different things with two different datasets using the same code is not good.

@nden
Copy link
Collaborator Author
nden commented Jul 17, 2020

@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.

@hbushouse
Copy link
Collaborator

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.

@nden
Copy link
Collaborator Author
nden commented Jul 17, 2020

In this case I'll create a new parameter extract_half_hight_grism and say the rest is out of scope for this PR. If there are better ideas, please speak.

@hbushouse
Copy link
Collaborator

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".

@nden
Copy link
Collaborator Author
nden commented Jul 18, 2020

I took the opportunity to refactor create_grism_bbox by splitting it into two functions (unfortunately still long), one that performs the computations and one that sets the input parameters. I also added another optional parameter, wavelength_range, to create_grim_bbox which gives more control over setting the extraction parameters.

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.
Copy link
Collaborator

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).

Copy link
8000 Collaborator Author

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

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in "wavelegnth"

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "wavelengthrange11"

@@ -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
Copy link
Collaborator

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.

@@ -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)
Copy link
Collaborator

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

@@ -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:
Copy link
Collaborator

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).

Copy link
Collaborator Author

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

@nden
Copy link
Collaborator Author
nden commented Jul 19, 2020

I added the check for is_star with a made up value. This will need to be revised after the decision of how to populate the column. I also addressed the rest of the comments.

# 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:
Copy link
Collaborator

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.

``--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``
Copy link
Collaborator

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}
Copy link
Collaborator

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).

@@ -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
Copy link
Collaborator

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.

@@ -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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WFSS extraction size for point sources needs to be a fixed value that the user can set
3 participants
0