Skip to content
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

HIRES wavelengths and a bit more #1628

Merged
merged 43 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cb52d46
wip
Apr 24, 2023
f074e6d
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
Apr 24, 2023
3001b80
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
profxj May 23, 2023
25a3d36
redo a single order well
profxj May 29, 2023
9761588
fuss
profxj Jun 5, 2023
e039188
Merge remote-tracking branch 'origin/develop' into hires_waves_and_re…
profxj Jul 3, 2023
58871ca
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
profxj Jul 3, 2023
01c8702
wip
profxj Jul 3, 2023
e738f91
wip!
profxj Jul 3, 2023
85bc73b
semi-successful
profxj Jul 3, 2023
73a91fa
good as it gets for now
profxj Jul 5, 2023
9ef5fa0
wip
profxj Jul 6, 2023
bd38ce1
closer!
profxj Jul 6, 2023
db75b59
id fix (I hope)
profxj Jul 6, 2023
8a82176
mo
profxj Jul 7, 2023
69e32e7
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
profxj Jul 10, 2023
e9ebbf9
good progress
profxj Jul 10, 2023
7463cdd
polishing
profxj Jul 10, 2023
d8e314f
docs
profxj Jul 10, 2023
e1327b1
2d
profxj Jul 13, 2023
71f2cb3
nires fixes
profxj Jul 13, 2023
ba74766
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
profxj Jul 13, 2023
5c2ae30
debuggin
profxj Jul 13, 2023
97627dd
debuggin continues
profxj Jul 13, 2023
d50b53d
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
profxj Jul 20, 2023
35c3d3a
PR edits
profxj Jul 20, 2023
0939c93
fix
profxj Jul 21, 2023
c11a0b5
the fix is in
profxj Jul 21, 2023
a3fd75f
mo
profxj Jul 21, 2023
569a736
unknowns bug
profxj Jul 21, 2023
336f3a3
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
profxj Jul 21, 2023
c8479ad
xshooter doc
profxj Jul 24, 2023
969a930
Merge remote-tracking branch 'origin/sensfunc_blaze_jwst_lists' into …
profxj Jul 24, 2023
3d40489
bump up rms
profxj Jul 24, 2023
2db1699
identify fix
profxj Jul 24, 2023
1e513ef
Merge remote-tracking branch 'origin/develop' into hires_waves_and_re…
profxj Aug 3, 2023
74cd1a0
edits for PR
profxj Aug 4, 2023
f8a0ff8
RC comments
profxj Aug 6, 2023
bdc4296
Merge remote-tracking branch 'origin/develop' into hires_waves_and_re…
profxj Aug 6, 2023
ea55d54
docs
profxj Aug 11, 2023
3198a88
load_object
profxj Aug 11, 2023
c1eb574
Merge remote-tracking branch 'origin/develop' into hires_waves_and_re…
profxj Aug 11, 2023
f3fcde3
Merge remote-tracking branch 'origin/develop' into hires_waves_and_re…
profxj Aug 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
- Now ``only_slits`` parameter in `pypeit_coadd_2dspec` includes the detector number (similar to ``slitspatnum``)
- Added ``exclude_slits`` parameter in `pypeit_coadd_2dspec` to exclude specific slits
- Fix wrong RA & Dec for 2D coadded serendips
- HIRES wavelength solution improvements galor
- Added `redo_slits` option
- Refactored ``load_line_lists()`` yet again!


1.13.0 (2 June 2023)
Expand Down
51 changes: 51 additions & 0 deletions doc/calibrations/wave_calib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,57 @@ observations, long-slit observations where wavelengths
vary (*e.g.*, grating tilts). We are likely to implement
this for echelle observations (*e.g.*, HIRES).

.. _wvcalib-echelle:

Echelle Spectrographs
=====================

Echelle spectrographs are a special case for wavelength
solutions, primarily because the orders follow the
grating equation.

In general, the approach is:

1. Identify the arc lines in each order
2. Fit the arc lines in each order to a polynomial, individually
3. Fit a 2D solution to the lines using the order number as a basis
4. Reject orders where the RMS of the fit (measured in binned pixels) exceeds ``rms_threshold``
5. Attempt to recover the missing orders using the 2D fit and
a higher RMS threshold
6. Refit the 2D solution

One should always inspect the outputs, especially the 2D solution
(global and orders). One may then need to modify the ``rms_threshold``
parameter and/or hand-fit a few of the orders to improve the solution.

.. _wvcalib-rms-threshold:

rms_threshold
-------------

All of the echelle spectrographs have a default ``rms_threshold``
matched to a default ``FWHM`` parameter (also measured in binned pixels).
The ``rms_threshold`` adopted in the analysis is one
scaled by the measured FWHM from the arc lines
(again, binned pixels) of the adopted calibration files

That is, each order must satisfy the following:

.. code-block:: ini

Copy link
Collaborator

Choose a reason for hiding this comment

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

My suggestion is that we instead define:

rms_pixels = rms_threshold*FWHM

Where FWHM is either the default FWHM or the measured FWHM, i.e. it will be the latter when the automatic FWHM determination is turned on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is what we are trying to handle:

  1. For a given spectrograph, we have a default rms_threshold (pixels) corresponding to a default fwhm (pixels) which we tune from the DevSuite. Both of these depend on slit width and binning
  2. Now, consider a new exposure with different slit width and/or binning. The sensible thing is to scale rms_threshold by the measured fwhm. This works relatively well but is not perfect. Nothing ever is for wavelengths.. This is what is currently implemented in the code and described in the docs.

The fwhm_fromlines parameter only refers to whether to use the measured_fwhm when finding arclines.
It doesn't play a role rms_threshold.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add an issue to updated the docs and spectrograph files to the convention that we discussed, i.e using rms_threshold_frac_fwhm. That need not be done for this PR, but clearly should be done asap.

RMS < rms_threshold * (measured_FWHM/default_FWHM)

Note: in a future release, we will re-define ``rms_threshold`` to be
in units of the measured FWHM.

Mosaics
-------

For echelle spectrographs with multiple detectors *per* camera
that are mosaiced (e.g. Keck/HIRES), we fit the 2D solutions on a *per* detector
basis. Ths is because we have found the mosaic solutions to be
too difficult to make sufficiently accurate.

profxj marked this conversation as resolved.
Show resolved Hide resolved
.. _wvcalib-byhand:

By-Hand Approach
Expand Down
18 changes: 18 additions & 0 deletions doc/spectrographs/keck_hires.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
==========
Keck HIRES
==========

Overview
========

This file summarizes several instrument specific settings that are related to the Keck/HIRES spectrograph.


Wavelengths
===========

See :ref:`wvcalib-echelle` for details on the wavelength calibration.

We also note that several Orders from 40-45 are
frequently flagged as bad in the wavelength solution.
This is due, in part, to very bright ThAr line contamination.
48 changes: 48 additions & 0 deletions doc/spectrographs/xshooter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,51 @@ This file summarizes several instrument specific
settings that are related to the VLT/XShooter spectrograph.


Wavelengths
===========

As it is common for ESO to obtain calibrations with different
slit widths and binning, this can lead to various challenges
for PypeIt.

As regards wavelengths, the varying binning and slit widths lead
to differing FWHM of the arc lines. And because the RMS threshold
for a good solution is scaled to FWHM, the default is to measure
the FWHM from the lines themselves.

If too many orders are being rejected, you may wish to adjust things
in one or more ways.

FWHM
----

For the UVB or the VIS, you may turn off measuring the FWHM (in units
of binned pixdels) from the arc lines
by adding this to your :doc:`pypeit_file`:


.. code-block:: ini

[calibrations]
[[wavelengths]]
fwhm_fromlines = False

This will set the FWHM to the default value for UVB/VIS which
may yield a better set of discovered arc lines.

RMS
---

Another option is to increase the RMS threshold for a good solution.
This may be done in the :doc:`pypeit_file` as well:

.. code-block:: ini

[calibrations]
[[wavelengths]]
rms_threshold = 1.5


Note that this is scaled by the ratio of the measured FWHM value
Copy link
Collaborator

@jhennawi jhennawi Aug 4, 2023

Choose a reason for hiding this comment

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

"Note that the rms_threshold is unit of the measured FWHM value, in other words, if the FWHM = 3 pixels, then the rms_threshold would be 4.5 pixels in this case."

What I've written above is my understanding of what you have implemented, but it also cannot be correct. But your new definition of rms_threshold is unclear to me. Can you please be as explicit as possible in the docs. What are the units of rms_threshold, what are the units of fwhm, write out the equation that determines the actual final rms threshold in pixels or whatever that we use for determining whether fits are good.

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, this is a bit confusing. I've expanded the discussion on this in wave_calib.rst and now point
the X-Shooter docs there.

to the default value. See :ref:`_wvcalib-echelle` for
further details.
6 changes: 4 additions & 2 deletions pypeit/calibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ def get_wv_calib(self):
self.wv_calib.chk_synced(self.slits)
self.slits.mask_wvcalib(self.wv_calib)
# Return
if self.par['wavelengths']['redo_slit'] is None:
if self.par['wavelengths']['redo_slits'] is None:
return self.wv_calib

# Determine lamp list to use for wavecalib
Expand All @@ -863,7 +863,9 @@ def get_wv_calib(self):
self.wv_calib = waveCalib.run(skip_QA=(not self.write_qa),
prev_wvcalib=self.wv_calib)
# If orders were found, save slits to disk
if self.spectrograph.pypeline == 'Echelle' and not self.spectrograph.ech_fixed_format:
# or if redo_slits
if (self.par['wavelengths']['redo_slits'] is not None) or (
self.spectrograph.pypeline == 'Echelle' and not self.spectrograph.ech_fixed_format):
self.slits.to_file()
# Save calibration frame
self.wv_calib.to_file()
Expand Down
2 changes: 0 additions & 2 deletions pypeit/core/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

from pypeit import msgs
from pypeit import utils
from pypeit.core.wavecal import wvutils
from pypeit.core.wavecal import wv_fitting
profxj marked this conversation as resolved.
Show resolved Hide resolved
from pypeit.core import fitting
from IPython import embed

Expand Down
6 changes: 1 addition & 5 deletions pypeit/core/gui/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,7 @@ def initialise(cls, arccen, lamps, slits, slit=0, par=None, wv_calib_all=None,
detns = tdetns[icut]

# Load line lists
if 'ThAr' in lamps:
line_lists_all = waveio.load_line_lists(lamps)
line_lists = line_lists_all[np.where(line_lists_all['ion'] != 'UNKNWN')]
else:
line_lists = waveio.load_line_lists(lamps)
line_lists, _, _ = waveio.load_line_lists(lamps, include_unknown=False)

# Trim the wavelength scale if requested
if wavelim is not None:
Expand Down
Loading