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

Adding support for the (decommissioned) spectrograph: AAT/UHRF #1834

Merged
merged 50 commits into from
Aug 30, 2024

Conversation

rcooke-ast
Copy link
Collaborator

There is an accompanying dev-suite PR. I will also add some documentation about this spectrograph. Tests currently pass.

@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 48.29932% with 76 lines in your changes missing coverage. Please review.

Project coverage is 38.03%. Comparing base (745f36c) to head (905d775).

Files with missing lines Patch % Lines
pypeit/spectrographs/aat_uhrf.py 30.43% 64 Missing ⚠️
pypeit/spectrographs/spectrograph.py 63.63% 4 Missing ⚠️
pypeit/io.py 85.71% 2 Missing ⚠️
pypeit/scripts/obslog.py 0.00% 2 Missing ⚠️
pypeit/pypeitsetup.py 87.50% 1 Missing ⚠️
pypeit/scripts/chk_for_calibs.py 0.00% 1 Missing ⚠️
pypeit/scripts/setup_gui.py 0.00% 1 Missing ⚠️
pypeit/spectrographs/keck_kcwi.py 0.00% 1 Missing ⚠️

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

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1834      +/-   ##
===========================================
+ Coverage    38.01%   38.03%   +0.01%     
===========================================
  Files          210      211       +1     
  Lines        48850    48975     +125     
===========================================
+ Hits         18569    18626      +57     
- Misses       30281    30349      +68     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

All good on my end. I hear @kbwestfall will have one fix
to suggest/add.

@@ -186,7 +186,20 @@ def from_file_root(cls, root, spectrograph, extension='.fits'):
Returns:
:class:`PypeitSetup`: The instance of the class.
"""
return cls.from_rawfiles(io.files_from_extension(root, extension=extension), spectrograph)
spec = load_spectrograph(spectrograph)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hear that @kbwestfall has some issues/fixes for this

Copy link
Collaborator

@kbwestfall kbwestfall left a comment

Choose a reason for hiding this comment

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

There are a couple of somewhat buried changes that I was hoping you could comment on. I merged in release and develop. Can we re-run tests?

maxi = min(nmask[0], ww.size)
outbpm[pks[i]:ww[maxi]+2] = True
# Return the output bpm
return outbpm
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be great to have a test for this, but I'm fine with you punting on that for this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point - I've added one in.

flux_smash_mean, flux_smash_med, flux_smash_std = astropy.stats.sigma_clipped_stats(
flux_smash, mask=np.logical_not(gpm_smash), sigma_lower=3.0, sigma_upper=3.0
)
flux_smash, mask=smash_mask, sigma_lower=3.0, sigma_upper=3.0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't dug into the context of this change, but it feels important. Can you give us more information about the problem that you've addressed with this code? And, do you have any assessments of how this affects all the other instruments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To be honest, I developed this many months ago, and I can't remember the motivation, or why it wasn't working in the first place. The code is basically finding peaks and masking around them, provided that pixel values continuously decrease away from the peak pixel. There needs to be a continuous decrease of 5+ pixels in order to activate this feature. I suspect this is only important when object profiles are excessively broad (which is what I was dealing with at the time).

Given that I can't recall what the motivation was, I am happy to revert this.

@@ -860,7 +860,7 @@ def get_detector_par(self, det, hdu=None):
# Some properties of the image
binning = self.compound_meta(self.get_headarr(hdu), "binning")
numamps = hdu[0].header['NVIDINP']
specflip = True if hdu[0].header['AMPID1'] == 2 else False
specflip = False if hdu[0].header['AMPMODE'] == 'ALL' else True
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would comment on this in the change log. Is this a general change for all KCWI taken, or does it reflect a change in header that needs an associated date if..else check?

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 was finding a problem with one of the datasets I have. This is effectively the same thing, but it depends which 2 amplifiers are used. This is more conservative. I have added this to the change log.

Copy link
Collaborator Author

@rcooke-ast rcooke-ast left a comment

Choose a reason for hiding this comment

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

Comments addressed @kbwestfall - thanks! I'll run tests

maxi = min(nmask[0], ww.size)
outbpm[pks[i]:ww[maxi]+2] = True
# Return the output bpm
return outbpm
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point - I've added one in.

@@ -860,7 +860,7 @@ def get_detector_par(self, det, hdu=None):
# Some properties of the image
binning = self.compound_meta(self.get_headarr(hdu), "binning")
numamps = hdu[0].header['NVIDINP']
specflip = True if hdu[0].header['AMPID1'] == 2 else False
specflip = False if hdu[0].header['AMPMODE'] == 'ALL' else True
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 was finding a problem with one of the datasets I have. This is effectively the same thing, but it depends which 2 amplifiers are used. This is more conservative. I have added this to the change log.

flux_smash_mean, flux_smash_med, flux_smash_std = astropy.stats.sigma_clipped_stats(
flux_smash, mask=np.logical_not(gpm_smash), sigma_lower=3.0, sigma_upper=3.0
)
flux_smash, mask=smash_mask, sigma_lower=3.0, sigma_upper=3.0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To be honest, I developed this many months ago, and I can't remember the motivation, or why it wasn't working in the first place. The code is basically finding peaks and masking around them, provided that pixel values continuously decrease away from the peak pixel. There needs to be a continuous decrease of 5+ pixels in order to activate this feature. I suspect this is only important when object profiles are excessively broad (which is what I was dealing with at the time).

Given that I can't recall what the motivation was, I am happy to revert this.

@rcooke-ast
Copy link
Collaborator Author

Tests pass
image

# Conflicts:
#	doc/releases/1.16.1dev.rst
# Conflicts:
#	doc/releases/1.16.1dev.rst
@kbwestfall kbwestfall merged commit bd77c38 into develop Aug 30, 2024
23 checks passed
@kbwestfall kbwestfall deleted the aat_uhrf branch August 30, 2024 17:27
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