-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Boxcar extraction using Trace class #82
Conversation
Update main in fork
Co-authored-by: @duytnguyendtn Co-authored-by: @ibusko Co-authored-by: @ojustino
* return as Spectrum1D object * remove get_checkplot (at least for now) * update API docs to match new parameter names
Boxcar extract
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'll plan to go through the notebook and some test-cases next week, but just wanted to add a few comments on the BoxcarExtract
class itself.
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.
a few minor comments and requests. the most substantive one is the hard-coding of units in the output Spectrum1D
. it will be encouraged to use CCDData
as the input data format for specreduce
which will allow for input data to contain flux units and uncertainty arrays. that information should be checked for and utilized if available.
i am not sure why the |
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.
extract.py
- I think we should either take each of
image
,trace_object
, andwidth
as arguments ofBoxcarExtract
's__call__()
/__init__()
or have them all be assigned as class attributes. Having some be set one way and some the other isn't intuitive to me.
I lean toward having them all as arguments of __call__()
for increased flexibility with the BoxcarExtract
object and since some other astropy utilities (e.g. modeling
) also work this way. I'm also writing HorneExtract
like this. Whichever route we go, consistency and intuitiveness should be our biggest concerns.
- This is more germane to the upcoming tracing discussion (Spectral tracing discussion #83), but I think allowing for interchangeability of dispersion and cross-dispersion axes like we do here is better than assuming each is always on a specific axis. We don't have a mandate to write a full pipeline, so in my mind, that limits the number of assumptions we can make about the spectra we receive.
My ideal would be to store dispersion axis info in trace objects, which would make those arguments unneeded in BoxcarExtract
. Barring that, I think the current approach here is OK.
-
What do we think of having
_get_boxcar_weights()
and_ap_weight_images()
as class methods ofBoxcarExtract
instead of free-floating functions? -
The previous iteration of
BoxcarExtract
had some plotting functionality. Does it make sense to include a rudimentary version of that here? -
Some lines run long on characters and could be separated.
test_extract.py
Would it be useful to include real data as part of our tests? I can share several 2D VLT spectra alongside their pipeline's 1D extractions if so.
boxcar_extraction.ipynb
The notebook runs for me and I find the expository text at the beginning helpful.
- I think it would be useful to see the pipeline 1D spectrum on the same plot as the extracted 1D spectrum at the end.
- I suggest rearranging imports into a more standard order (
from
s, then regularimport
s, etc.)
@ojustino thanks for the detailed review! As for the simultaneous plot of extracted spectrum and pipeline result in the notebook: it doesn't work well because of the units in which each one is expressed. Until we add to the extraction code the ability to construct a wavelength scale (from WCS perhaps, or from user-supplied information of some sort), they are not directly comparable. I think the notebook can be reused when we implement that ability, and at that point one may create the plot as you suggest (and I agree with you that is what we really need, a simultaneous plot of both). |
looks like the |
thanks for all this work, @ibusko, and for the detailed review, @ojustino! per @ojustino's points:
|
* in response to review comments
I think this is now ready for re-(final?)-review (assuming CI passes) |
Tried out boxcar_extraction.ipynb:
|
That's a good point - we did pull the following out from the code when migrating from the notebook. I'm not sure where this factor best belongs (somewhere in the code without the factor being hardcoded for JWST or maybe in the
|
CI has passed and i think we're in agreement on the changes that have been made. as far as i'm concerned, this is good to merge. there's more work to do, but it depends on tracing functionality being fleshed out further which is work-in-progress. |
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 agree and also approve -- looks like we've addressed everything that was immediately crucial.
Also happy to merge, thanks everyone! |
This PR modifies the boxcar extraction code to directly interface with the Trace class in
specreduce
.It also removes references to background extraction from the unit test module (
test_extract.py
), and adds a few unit tests to check corner cases involving fractional pixels.Support for 2D "transposed" spectral images (where the dispersion axis is the first axis), and 3D spectral cubes, was partially added but not fully implemented and tested. Transposed spectral images are not yet supported by the Trace class, and 3D cubes were deemed low priority at this point.
Note that the
tracing.py
module currently does not provide any tool to actually find a trace in a spectral image (although it contains a function to build an image to be used in unit tests). In the original notebook the trace finding function was provided by thekosmos
package.A new notebook was added (
notebook_sandbox/jwst_boxcar/boxcar_extraction.ipynb
) to demonstrate the use ofTrace
andBoxcarExtract
in practice.Currently there is no support for a WCS, if present in the data.