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

wave rms refactor #1672

Merged
merged 16 commits into from
Oct 1, 2023
Merged

wave rms refactor #1672

merged 16 commits into from
Oct 1, 2023

Conversation

debora-pe
Copy link
Collaborator

As titled. The parameter rms_thresh is now replaced by rms_thresh_frac_fwhm, which is expressed as a fraction of FWHM.

I run the Dev Suite and it passed. I compared the wavelength calibration with these changes to a Dev Suite run in the develop branch, see plots. What do you think?

histo_comparison
plot_comparison

Copy link
Collaborator

@profxj profxj left a comment

Choose a reason for hiding this comment

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

Great stuff. If you can inspect the outputs for a few of the ones I mentioned, that would be great. Maybe you have already. :)

@@ -1712,6 +1724,10 @@ class HolyGrail:
islinelist : bool, optional
Is lamps a linelist (True), or a list of ions (False)
The former is not recommended except by expert users/developers
rms_thresh : float, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

It isn't optional, right?

@@ -1712,6 +1724,10 @@ class HolyGrail:
islinelist : bool, optional
Is lamps a linelist (True), or a list of ions (False)
The former is not recommended except by expert users/developers
rms_thresh : float, optional
RMS threshold for the wavelength solution fit
measured_fwhms : ndarray, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe explain what happens if it isn't provided?

@@ -322,7 +322,8 @@ def config_specific_par(self, scifile, inp_par=None):
par['calibrations']['slitedges']['fit_min_spec_length'] = 0.5

# Wavelengths
par['calibrations']['wavelengths']['rms_threshold'] = 1.0 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.4 # Might be grating dependent..
Copy link
Collaborator

Choose a reason for hiding this comment

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

Am a bit surprised at how high this is, but it was before.
@jhennawi -- does this make sense to you?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know where I got 2.5 for fwhm, it's more like 4 (the default) from the dev suite. I changed that. The RMS values for 32/mm are pretty high in the Dev Suite (even before these changes), the calibration wasn't that great. See below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Arc_2dfit_orders_A_0_DET01

@@ -354,7 +355,7 @@ def config_specific_par(self, scifile, inp_par=None):
par['calibrations']['slitedges']['sync_predict'] = 'nearest'

# Wavelengths
par['calibrations']['wavelengths']['rms_threshold'] = 1.0 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 1.0 # Might be grating dependent..
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here. we should inspect the solutions for GNIRS and see if this makes sense..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I may have forgotten to change this. I checked the values in the Dev Suite and rms is ~0.1 (fwhm ~3pixels), so I changed this to 0.05

@@ -391,9 +392,9 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution with arc lines
par['calibrations']['wavelengths']['rms_threshold'] = 1.0
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be 0.05 given we reduced the FWHM?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed to 0.05, but it does not matter much, since FIRE long uses the template method and the rms threshold is not used.

@@ -310,7 +310,7 @@ def default_pypeit_par(cls):
par['calibrations']['wavelengths']['lamps'] = ['NeI', 'ArI', 'HgI']
# Wavelengths
# 1D wavelength solution
par['calibrations']['wavelengths']['rms_threshold'] = 0.5
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.17
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not 0.1? I'm assuming you found a higher value was better here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found that the measured fwhm is more like 3 pixels (but 2x binned), therefore rms_thresh_frac_fwhm would become 0.17. The datasets that we have in the Dev Suite use the template method anyway.

@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2023

Codecov Report

Merging #1672 (ad36b23) into develop (4715a1b) will decrease coverage by 0.25%.
The diff coverage is 11.32%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@             Coverage Diff             @@
##           develop    #1672      +/-   ##
===========================================
- Coverage    41.33%   41.09%   -0.25%     
===========================================
  Files          189      189              
  Lines        43296    43544     +248     
===========================================
- Hits         17896    17893       -3     
- Misses       25400    25651     +251     
Files Coverage Δ
pypeit/par/pypeitpar.py 96.07% <100.00%> (ø)
pypeit/spectrographs/keck_deimos.py 24.80% <ø> (+0.03%) ⬆️
pypeit/spectrographs/keck_esi.py 24.09% <0.00%> (+0.14%) ⬆️
pypeit/spectrographs/keck_hires.py 27.04% <0.00%> (ø)
pypeit/spectrographs/keck_mosfire.py 16.25% <0.00%> (+0.06%) ⬆️
pypeit/spectrographs/keck_nires.py 25.82% <0.00%> (+0.12%) ⬆️
pypeit/spectrographs/magellan_mage.py 31.40% <0.00%> (+0.25%) ⬆️
pypeit/spectrographs/ntt_efosc2.py 19.85% <0.00%> (ø)
pypeit/spectrographs/p200_tspec.py 30.32% <0.00%> (+0.24%) ⬆️
pypeit/spectrographs/shane_kast.py 63.72% <50.00%> (ø)
... and 20 more

... and 3 files with indirect coverage changes

@debora-pe
Copy link
Collaborator Author

@jhennawi I set for all the spectrographs to use the measured fwhm. The Dev Suite run is successful. These are the slits/orders that have a difference of RMS >0.1 compared to a develop branch run.

 N._1 SpatID minWave_1 Wave_cen_1 maxWave_1 dWave_1 Nlin_1    IDs_Wave_range_1   IDs_Wave_cov(%)_1 mesured_fwhm_1  RMS_1                                                file                                               N._2 minWave_2 Wave_cen_2 maxWave_2 dWave_2 Nlin_2    IDs_Wave_range_2   IDs_Wave_cov(%)_2 mesured_fwhm_2  RMS_2 
int64 int64   float64   float64    float64  float64 int64          str21              float64         float64     float64                                              str95                                              int64  float64   float64    float64  float64 int64          str21              float64         float64     float64
----- ------ --------- ---------- --------- ------- ------ --------------------- ----------------- -------------- ------- ----------------------------------------------------------------------------------------------- ----- --------- ---------- --------- ------- ------ --------------------- ----------------- -------------- -------
    5    307   18762.6    22040.1   25330.6   6.452     41 19194.450 - 24724.243              84.2            2.3   0.338                              gemini_gnirs_ifu/LR_IFU_32mm/Calibrations/WaveCalib_A_0_DET01.fits     5   18758.0    22039.3   25332.8   6.442     39 19250.174 - 24724.243              83.3            2.3   0.460
    8    420   18750.5    22028.9   25321.0   6.452     42 19194.450 - 24724.243              84.2            2.3   0.345                              gemini_gnirs_ifu/LR_IFU_32mm/Calibrations/WaveCalib_A_0_DET01.fits     8   18747.0    22028.4   25322.9   6.445     39 19250.174 - 24724.243              83.2            2.3   0.457
   15    683   18723.0    22000.4   25291.5   6.453     41 19194.450 - 24724.243              84.2            2.4   0.342                              gemini_gnirs_ifu/LR_IFU_32mm/Calibrations/WaveCalib_A_0_DET01.fits    15   18718.4    21999.6   25293.4   6.442     39 19250.174 - 24724.243              83.3            2.4   0.462
    1    274    4027.2     6226.2    8620.7   2.171     22  5402.063 -  7726.333              50.6            7.2   0.796                                      gtc_osiris/R1000BMOS/Calibrations/WaveCalib_A_0_DET01.fits     1    4197.5     6220.4    8641.1   2.178     36  4336.557 -  8387.030              91.2            7.2   1.167
   11    613    3652.8     5528.9    7879.4   2.126     41  3664.327 -  7725.887              96.1            3.9   0.208                                      gtc_osiris/R1000BMOS/Calibrations/WaveCalib_A_0_DET02.fits    11    3651.5     5528.9    7878.6   2.126     49  3651.198 -  7725.887              96.4            3.9   0.318
    0    109    5683.6     7851.6   12913.1   3.771     14  5792.276 - 10142.530              60.2            7.4   0.499                                      gtc_osiris/R1000RMOS/Calibrations/WaveCalib_A_0_DET01.fits     0    5712.5     8226.2   11133.2   2.651     25  5766.017 - 10142.530              80.7            7.4   1.435
    6    315       0.0        0.0       0.0   0.000      0     0.000 -     0.000               0.0            0.0   0.000                                      gtc_osiris/R1000RMOS/Calibrations/WaveCalib_A_0_DET01.fits     6    5457.9     8066.3   10466.3   2.903     30  5564.311 -  9165.167              71.9            7.5   3.010
   15    671    5182.2     7625.6   10518.6   2.652     31  5462.268 - 10142.530              87.7            7.2   0.785                                      gtc_osiris/R1000RMOS/Calibrations/WaveCalib_A_0_DET01.fits    15    5102.3     7639.2   10516.5   2.617     32  5402.063 - 10142.530              87.6            7.2   1.257
    0    457    5104.3     7481.9   10305.0   2.622     43  5342.579 - 10142.530              92.3            3.4   0.188                                    gtc_osiris_plus/R1000R/Calibrations/WaveCalib_A_0_DET01.fits     0    5102.9     7482.5   10304.8   2.622     44  5462.268 -  9925.919              85.8            3.4   0.405
   24   2623    9427.4     9515.4    9603.7   0.045      7  9434.870 -  9589.657              87.8            5.1   0.086 keck_hires/J0100+2802_H204Hr_RED_C1_ECH_-0.82_XD_1.62_1x2/Calibrations/WaveCalib_A_0_MSC01.fits    24    9452.3     9545.7    9632.8   0.044      8  9458.615 -  9624.705              92.0            5.1   0.249
   25   2799    9765.9     9859.6    9947.2   0.045     29  9776.248 -  9935.498              87.8            5.1   0.555 keck_hires/J0100+2802_H204Hr_RED_C1_ECH_-0.82_XD_1.62_1x2/Calibrations/WaveCalib_A_0_MSC01.fits    25    9848.8     9935.4   10015.0   0.041     11  9858.444 -  9996.603              83.1            5.1   1.166
   26   2596    9246.6     9335.8    9417.8   0.042     55  9247.790 -  9416.671              98.6            5.0   0.241 keck_hires/J0100+2802_H237Hr_RED_C1_ECH_-0.91_XD_1.46_1x2/Calibrations/WaveCalib_A_0_MSC01.fits    26    9194.9     9286.4    9370.5   0.043     12  9196.115 -  9369.367              98.6            5.0   0.875
   28   2940    9760.7     9854.4    9942.3   0.044     48  9761.313 -  9937.923              97.2            5.2   0.294 keck_hires/J0100+2802_H237Hr_RED_C1_ECH_-0.91_XD_1.46_1x2/Calibrations/WaveCalib_A_0_MSC01.fits    28    9763.7     9854.4    9940.4   0.044     39  9774.510 -  9937.770              92.4            5.2   0.555
    8    468    6165.8     6225.3    6280.1   0.028     95  6166.185 -  6278.975              98.7            4.8   0.136   keck_hires/J0306+1853_U074_RED_C2_ECH_-0.86_XD_1.31_1x3/Calibrations/WaveCalib_A_0_MSC01.fits     8    6125.9     6186.8    6243.8   0.029     35  6126.266 -  6242.680              98.7            4.8   1.177
   33   2671    8626.0     8705.9    8779.0   0.076     48  8626.174 -  8777.983              99.2            2.9   0.190    keck_hires/J1723+2243_W241_RED_C5_ECH_0.08_XD_0.90_2x2/Calibrations/WaveCalib_A_0_MSC01.fits    33    8628.3     8706.0    8777.6   0.073     19  8635.826 -  8773.874              92.5            2.9   1.039
   14   1304    8599.5     9016.3    9389.2   0.384      9  8622.828 -  9356.787              92.9            2.0   0.019                                      keck_kcrm/medium_rh3/Calibrations/WaveCalib_A_0_DET01.fits    14    8599.4     9016.2    9389.1   0.384     13  8608.140 -  9356.787              94.8            2.0   0.170
    1    288    8304.0     8738.5    9167.6   0.425      5  8401.478 -  8888.289              56.4            3.4   0.281                                magellan_fire/FIRE_Echelle/Calibrations/WaveCalib_A_0_DET01.fits     1    8463.5     8740.2    9289.2   0.388      6  8507.178 -  9003.817              60.1            3.4   0.526
    2    401    8630.1     9044.5    9481.9   0.468     12  8761.267 -  9479.454              84.3            3.4   1.255                                magellan_fire/FIRE_Echelle/Calibrations/WaveCalib_A_0_DET01.fits     2    8630.2     9041.7    9482.7   0.464     15  8761.267 -  9479.454              84.2            3.4   5.809
   20   1931   22800.3    24067.6   25195.0   1.179     30 23524.574 - 24878.931              56.6            6.4   0.220                                magellan_fire/FIRE_Echelle/Calibrations/WaveCalib_A_0_DET01.fits    20   22802.4    24067.6   25193.8   1.180     37 23524.574 - 24946.601              59.5            6.4   0.329
    0    191    3734.7     5251.7    6790.0   1.093    121  3738.194 -  6768.480              99.2            3.3   0.234                               p200_dbsp_blue/600_4000_d68/Calibrations/WaveCalib_A_0_DET01.fits     0    3734.6     5251.4    6814.5   1.093     99  3738.194 -  6686.138              95.7            3.3   0.614
    0    293    5695.4     6565.6    7414.1   0.648     22  5771.210 -  6534.687              44.4            2.5   0.024                              shane_kast_red/1200_5000_d57/Calibrations/WaveCalib_A_0_DET01.fits     0    5647.1     6571.4    6676.6   0.657     15  5877.249 -  6539.918              64.4            2.5   0.468
    0    188    5318.4     7046.2    8788.2   1.301     53  5462.268 -  8670.325              92.5            2.3   0.037                               shane_kast_red/600_7500_d57/Calibrations/WaveCalib_A_0_DET01.fits     0    5289.0     7046.3    8786.8   1.298     54  5441.501 -  8670.325              92.3            2.3   0.493
    5    353   19468.5    22027.4   24613.9   2.514     21 19771.862 - 24502.344              91.9            1.3   0.119                                         vlt_sinfoni/K_0.8/Calibrations/WaveCalib_A_1_DET01.fits     5   19633.5    22096.3   24604.5   2.430     16 19925.023 - 24513.442              92.3            1.3   0.821
    8    543   19396.6    21954.7   24544.8   2.514     20 19771.862 - 24513.442              92.1            1.3   0.078                                         vlt_sinfoni/K_0.8/Calibrations/WaveCalib_A_1_DET01.fits     8   19394.6    21954.5   24545.8   2.512     24 19642.466 - 24513.442              94.6            1.3   0.240
   19   1304   19394.8    21954.7   24543.4   2.515     20 19701.979 - 24502.344              93.2            1.3   0.132                                         vlt_sinfoni/K_0.8/Calibrations/WaveCalib_A_1_DET01.fits    19   19393.3    21954.7   24543.2   2.511     19 19541.091 - 24461.050              95.5            1.3   0.364
   20   1367   19471.2    22029.5   24614.9   2.513     28 19771.862 - 24594.959              93.8            1.4   0.254                                         vlt_sinfoni/K_0.8/Calibrations/WaveCalib_A_1_DET01.fits    20   18267.1    20817.5   23389.2   2.503     14 18283.469 - 23284.866              97.6            1.4   0.906
    6    486   12482.4    13129.5   13718.9   0.585     28 12667.734 - 13527.439              69.5            2.9   0.083                                          vlt_xshooter/NIR/Calibrations/WaveCalib_A_1_DET01.fits     6   12479.8    13129.5   13716.9   0.585     30 12683.295 - 13527.439              68.2            2.9   0.257
   15   1019   22740.1    23804.6   24812.9   0.994     32 23524.632 - 24678.080              55.6            5.7   0.134                                  vlt_xshooter/NIR_LTT3218/Calibrations/WaveCalib_C_0_DET01.fits    15   22730.2    23804.5   24812.1   0.995     44 23516.527 - 24752.859              59.4            5.7   0.306

@debora-pe
Copy link
Collaborator Author

@jhennawi I added an issue about using the measured fwhm for tilts. I'll try to address it some other time.
I am now re-running the full Dev Suite tests, and if all it's good I'm ready to merge. Please review this when you can.

#embed()

return new_bad_slits
# This routine is commented out because it is not used.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we move to deprecated.

# plt.show()
# #embed()
#
# return new_bad_slits

def get_use_tcent_old(self, corr, cut=True, arr_err=None, weak=False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It this ever used?

Copy link
Collaborator

@jhennawi jhennawi left a comment

Choose a reason for hiding this comment

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

Thanks! Great work here.

@jhennawi jhennawi merged commit b4f86a5 into develop Oct 1, 2023
23 checks passed
@jhennawi jhennawi deleted the rms_refactor branch October 1, 2023 17:41
@debora-pe
Copy link
Collaborator Author

For the records, full Dev suite tests pass.

Test Summary
--------------------------------------------------------
--- PYTEST PYPEIT UNIT TESTS PASSED  239 passed, 68 warnings in 312.89s (0:05:12) ---
--- PYTEST UNIT TESTS PASSED  133 passed, 172 warnings in 1554.52s (0:25:54) ---
--- PYTEST VET TESTS PASSED  58 passed, 69 warnings in 838.98s (0:13:58) ---
--- PYPEIT DEVELOPMENT SUITE PASSED 231/231 TESTS  ---
Testing Started at 2023-09-29T23:00:41.096799
Testing Completed at 2023-09-30T08:49:20.509063
Total Time: 9:48:39.412264

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

Successfully merging this pull request may close these issues.

4 participants