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

allow matched pixels/wavelengths to be in either direction #177

Merged
merged 9 commits into from
Jun 9, 2023

Conversation

cshanahan1
Copy link
Contributor

@cshanahan1 cshanahan1 commented Jun 1, 2023

This PR removes sorting in wavelength calibration to allow for either right-to-left or left-to-right inputs. A check that input matched pixels/wavelengths are monotonic in either direction is added.

Addresses #174

@codecov
Copy link

codecov bot commented Jun 1, 2023

Codecov Report

Merging #177 (b6c792f) into main (014f37b) will increase coverage by 0.06%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##             main     #177      +/-   ##
==========================================
+ Coverage   81.28%   81.35%   +0.06%     
==========================================
  Files          10       10              
  Lines         983      992       +9     
==========================================
+ Hits          799      807       +8     
- Misses        184      185       +1     
Impacted Files Coverage Δ
specreduce/wavelength_calibration.py 87.39% <85.71%> (+0.12%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

cshanahan1 and others added 2 commits June 1, 2023 22:00
Co-authored-by: Ricky O'Steen <39831871+rosteen@users.noreply.github.com>
@kecnry
Copy link
Member

kecnry commented Jun 2, 2023

Can we remove the internal sorting with this check in place? Is there anything fundamental in the logic that would prevent us from handling the inverted case (besides the internal sorting - if the check was instead to make sure that they either increase or decrease, would that work)?

@cshanahan1 cshanahan1 changed the title enforce spectral axis being left to right for wavelength calibration allow matched pixels/wavelengths to be in either direction Jun 9, 2023
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

Just a few small comments/suggestions, but otherwise I think this looks good and is an elegant solution. Thanks!

Comment on lines +136 to +139
if not _check_arr_monotonic(line_wavelengths):
if str(line_wavelengths.unit.physical_type) == "frequency":
raise ValueError('Frequencies must be strictly increasing or decreasing.')
raise ValueError('Wavelengths must be strictly increasing or decreasing.')
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but I wonder if we should rename line_wavlengths to line_spectral_values or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, also we should not be checking strictly for a 'wavelength' column if frequencies are allowed.

Comment on lines +144 to +145
if not _check_arr_monotonic(line_wavelengths['wavelength']):
raise ValueError('Wavelengths must be strictly increasing or decreasing.')
Copy link
Member

Choose a reason for hiding this comment

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

do we support a frequency option for the QTable case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thats what was implied, but are checks for the presence of a 'wavelength' column so it seems like you could input something with frequency units but the column must be named wavelength which is confusing.

i also am not a fan of all the different input options available - i feel like it would be a lot less confusing if we just forced users to input a table with pixel and wavelength or frequency (or eventually, the catalog option) instead of allowing two matched arrays, or a table, or a table with a pixel column and an array, or two tables each with one col. i think this is too many options and a lot of this code is just figuring out the logic of the inputs where we could just insist on users constructing a table beforehand (or, and i might like this option better because then youre not checking for table column names, an input pixel array and an input wavelength/freq array, and then internally convert to a table).

specreduce/wavelength_calibration.py Outdated Show resolved Hide resolved
Copy link
Contributor

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

LGTM, and I agree that a separate effort to simplify the inputs would be worth doing. I erred too far on the side of flexibility when I first implemented the class.

@cshanahan1
Copy link
Contributor Author

thanks everyone, im going to merge this now :)

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.

3 participants