-
Notifications
You must be signed in to change notification settings - Fork 107
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
Update LDT/DeVeny + "quality of life" changes #1712
Conversation
modified: pypeit/spectrographs/ldt_deveny.py
modified: pypeit/data/arc_lines/lists/Hg_DeVeny1200_lines.dat modified: pypeit/spectrographs/ldt_deveny.py
* Allow `pypeit_chk_wavecalib` to accept lists of input files If more than one WaveCalib is to be checked at once, this commit allows for the script to accept a list of input files, and simply loops the main execution over the list of input files. * Allow restricted wavelength range for flexure cross-correlation Add FlexurePar parameters ``minwave`` and ``maxwave`` that may be used to restrict the wavelength range used for the flexure cross-correlation. This is useful in the cases where the wavelength calibration _at the edges_ of the spectral range is poorly constrained, yet there is a night-sky line used in the correlation there. Other uses may be possible. The new parameters are passed to the wavelength restrictor in `pypeit.core.flexure.spec_flux_shift` as 0 and numpy.inf as the effective min and max specified values, respectively, (while the actual parameters are ``None`` if not specified). * Tweak Hg wavelength * Adjust wavecal fit parameters for LDT/DeVeny * Update verbosity assignment in show_2dspec modified: pypeit/core/flexure.py modified: pypeit/data/arc_lines/lists/Hg_DeVeny1200_lines.dat modified: pypeit/extraction.py modified: pypeit/find_objects.py modified: pypeit/par/pypeitpar.py modified: pypeit/scripts/chk_wavecalib.py modified: pypeit/scripts/show_2dspec.py modified: pypeit/spectrographs/ldt_deveny.py
The code for fitting a polynomial to the overscan region of a raw image file for subtraction only requires one parameter (order), whereas the documentation and PypeIt parameter fed into the overscan-subtraction routine say "three". This commit aligns the documentation and params with the reality of the code. Also, for the polynomial fitting, move away from the `np.polyfit()` function (deprecated in NumPy v1.4 -- way way long time ago) to the `numpy.polynomial` pagkage. In particular, use a Chebyshev polynomial for the fitting here (orthonormal basis sets can be useful for seeing where the power is). Modify the LDT/DeVeny params to use a polynomial (order=1) for fitting the overscan. This is more appropriate for this chip and EMI pickup environment than the default SavGol filter. modified: pypeit/core/procimg.py modified: pypeit/par/pypeitpar.py modified: pypeit/spectrographs/ldt_deveny.py
modified: doc/releases/1.14.1dev.rst
Neon lines routinely recovered with LDT/DeVeny These lines were originally included with #1595, but were causing various issues with DevSuite tests. Once more robust DevSuite VET tests are developed for wavelength calibration checking, we can try again with these neon lines. new file: pypeit/data/arc_lines/lists/ArI_DeVeny_lines.dat renamed: pypeit/data/arc_lines/lists/Cd_DeVeny1200_lines.dat -> pypeit/data/arc_lines/lists/CdI_DeVeny_lines.dat renamed: pypeit/data/arc_lines/lists/Hg_DeVeny1200_lines.dat -> pypeit/data/arc_lines/lists/HgI_DeVeny_lines.dat new file: pypeit/data/arc_lines/lists/NeI_DeVeny_lines.dat modified: pypeit/spectrographs/ldt_deveny.py
Add function in the template-maker file for DV5. (Update things to pathlib.Path... needed to add a force-str in one of the other functions.) modified: pypeit/core/wavecal/spectrographs/templ_ldt_deveny.py modified: pypeit/core/wavecal/templates.py modified: pypeit/data/arc_lines/reid_arxiv/ldt_deveny_500_HgCdAr.fits
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #1712 +/- ##
===========================================
+ Coverage 40.96% 40.98% +0.01%
===========================================
Files 190 190
Lines 43892 43904 +12
===========================================
+ Hits 17982 17994 +12
Misses 25910 25910 ☔ View full report in Codecov by Sentry. |
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.
Thanks, Tim! I have a few very minor comments and typo fixes.
I think your change from a warning to an error for the pattern-noise subtraction likely points to a deeper change we should make to rawimage
, but I'd like to get input from @rcooke-ast about it. I will ping him over Slack.
c = np.polyfit(np.arange(osfit.size), osfit, params[0]) | ||
ossub = np.polyval(c, np.arange(osfit.size)) | ||
poly = np.polynomial.Chebyshev.fit(np.arange(osfit.size), osfit, params[0]) | ||
ossub = poly(np.arange(osfit.size)) |
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 suggest that we make this more explicit. For now I would do:
if method.lower() == 'polynomial':
warnings.warn('Method "polynomial" is identical to "chebyshev". Former will be deprecated.', DeprecationWarning)
if method.lower() in ['polynomial', 'chebyshev']:
...
And then eventually we get rid of the polynomial option.
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 added the suggested code. When I run this with method=polynomial
, however, I am not seeing the DeprecationWarning
(i.e., it is being filtered somewhere). I couldn't find a warning filter within PypeIt, so it may be coming from one of the imported libraries. In this case, do we change this to a msgs.warn()
, or just let it be for now? I've included the same notice in the pypeitpar
listing, so it will show up in the docs.
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.
D'Oh! Ah, well. Those warnings would likely fly by unnoticed anyway. I think having the notice in the docs is likely more useful anyway!
pypeit/par/pypeitpar.py
Outdated
'number of repeats ; for \'savgol\', set overscan_par = ' \ | ||
'order, window size ; for \'median\', set overscan_par = ' \ | ||
'None or omit the keyword.' | ||
'\'polynomial\', set overcan_par = order; for \'savgol\', ' \ |
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.
change "polynomial" to "chebyshev"
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.
Done. Added deprecation warning here, and also included both "chebyshev" and "polynomial" in this class's valid_overscan_methods()
method to allow both for now.
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.
Some comments/thoughts :-)
|
||
# For processing the arc frame, these settings allow for the combination of | ||
# of frames from different lamps into a comprehensible Master | ||
par['calibrations']['arcframe']['process']['clip'] = False | ||
par['calibrations']['arcframe']['process']['combine'] = 'mean' | ||
par['calibrations']['arcframe']['process']['subtract_continuum'] = True | ||
# par['calibrations']['arcframe']['process']['subtract_continuum'] = True |
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 reason to uncomment this for the arc lines? To be fair, it's only needed in cases where arc frames are being that contain different lamp spectra. Is this the case? Looking at the dev suite, it seems that dv7 contains multiple different lamp spectra?
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 continuum-subtraction is an aesthetic issue for me -- without the subtraction (and hence negative flux values), the WaveCalib QA plots are done with a log scale. For most of our users, the desired lamps are all on at the same time (e.g., HgCdAr) -- but some insist on taking separate frames for each lamp. I have instructions in our instrument manual that if arcs with individual arc lamps are used/combined, then this parameter needs to be set to True
.
I should check the DV7 .pypeit
file in the DevSuite -- thanks for flagging 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.
Note: I fixed the DV7 .pypeit
file in pypeit/PypeIt-development-suite#296.
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.
Fixed typos, added "chebyshev" option for overscan subtraction with a deprecation notice for the "polynomial" option, and updated the argument help for `pypeit_chk_wavecalib`. modified: pypeit/core/flexure.py modified: pypeit/core/procimg.py modified: pypeit/par/pypeitpar.py modified: pypeit/scripts/chk_wavecalib.py
modified: doc/releases/1.14.1dev.rst
modified: pypeit/core/procimg.py modified: pypeit/par/pypeitpar.py
Cleaned up the help string for the `--mode` command-line option. modified: pypeit/scripts/chk_noise_2dspec.py
Update docs realted to both this PR and the datacube PR. NOTE: python files edited are docstring-only changes to make sphinx happy, with the following exceptions: pypeit/core/procimg.py & pypeit/spectrographs/ldt_deveny.py -- finish adding "chebyshev" In setup.cfg, added `psutil` as a [test] and [dev] dependency for use with the DevSuite (dependency added in pypeit/PypeIt-development-suite#235). new file: doc/api/pypeit.coadd3d.rst modified: doc/api/pypeit.rst modified: doc/help/pypeit_chk_noise_2dspec.rst modified: doc/help/pypeit_chk_wavecalib.rst modified: doc/include/class_datamodel_datacube.rst modified: doc/include/dependencies_table.rst modified: doc/pypeit_par.rst modified: doc/scripts/build_datacontainer_datamodels.py modified: pypeit/coadd3d.py modified: pypeit/core/datacube.py modified: pypeit/core/procimg.py modified: pypeit/spectrographs/ldt_deveny.py modified: pypeit/specutils/pypeit_loaders.py modified: setup.cfg
@kbwestfall: NOTE: python files edited in 54afea0 are docstring-only changes to make sphinx happy, with the following exceptions: In |
Apologies. Most (all?) of these doc fixes are repeats of things waiting on merging of other PRs (e.g., #1706) ...
I'm being overly picky, but I noticed you re-ordered the imports in procimg.py. I recommend we try to follow PEP 8.
Thanks! (But also in #1706 ) |
I think the new order is in PEP8 format:
Am I misinterpreting something? Sorry about all the duplicated changes -- was just trying to follow the development workflow and make things work. |
No, sorry, I regretted that complaint almost immediately after sending it! I mistakenly thought of numpy as a standard lib. So, technically you're right. E.g., astropy and numpy are both 3rd party. But I think of these imports as a dependency tree with lowest dependencies first. This means I tend to group numpy, scipy, + matplotlib first, then astropy, then ..., then pypeit. I.e., astropy depends on numpy, but not vice versa.
Not your fault! I was just bemoaning duplicated work. |
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.
Happy to approve, but it might be good to confirm that this passes the dev suite DV7 before merging. To be fair, the dev-suite fail is likely because that merge has been done into develop
already, but the PypeIt one hasn't been merged.
|
||
# For processing the arc frame, these settings allow for the combination of | ||
# of frames from different lamps into a comprehensible Master | ||
par['calibrations']['arcframe']['process']['clip'] = False | ||
par['calibrations']['arcframe']['process']['combine'] = 'mean' | ||
par['calibrations']['arcframe']['process']['subtract_continuum'] = True | ||
# par['calibrations']['arcframe']['process']['subtract_continuum'] = True |
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 DevSuite PR was merged into I've requested a full cloud DevSuite run for this branch. |
Apart from waiting for the DevSuite results, this PR needs to wait until #1706 clears because of duplicated doc changes that need merging. |
No code changes other than variable name changes to make it easier to follow what is being done in computing the RMS of the wavelength calibration solutions. Also, add instrument-specific documentation page. new file: doc/spectrographs/ldt_deveny.rst modified: doc/spectrographs/spectrographs.rst modified: pypeit/core/wavecal/autoid.py modified: pypeit/core/wavecal/wv_fitting.py modified: pypeit/spectrographs/ldt_deveny.py
modified: pypeit/spectrographs/ldt_deveny.py
modified: pypeit/spectrographs/ldt_deveny.py
modified: README.rst
9b4d75e
to
1b6404f
Compare
modified: doc/pypeit_par.rst modified: setup.cfg
1b6404f
to
670a644
Compare
Change the default verbosity for `pypeit_show_2dspec` to 1 (which is where all the other scripts -- save `run_pypeit` -- are). This was an oversight in #1712. Also, add new "scattlight" frametype to list of ignored frametypes for LDT/DeVeny. modified: pypeit/scripts/show_2dspec.py modified: pypeit/spectrographs/ldt_deveny.py
Primarily an update to LDT/DeVeny:
A series of small "quality of life" improvements:
pypeit_chk_wavecalib
to accept lists of input files.pypeit_show_2dspec
.np.polyfit()
->np.polynomial.Chebyshev.fit()
.Main repo unit tests pass, will request cloud run of DevSuite following review.
Companion DevSuite PR (pypeit/PypeIt-development-suite#295) adds wavelength templates.