8000 Kcwi dec 2024 by jhennawi · Pull Request #1929 · pypeit/PypeIt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Kcwi dec 2024 #1929

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

Open
wants to merge 39 commits into
base: develop
Choose a base branch
from
Open

Kcwi dec 2024 #1929

wants to merge 39 commits into from

Conversation

jhennawi
Copy link
Collaborator

This PR involves major upgrades to KCWI and specifically KCRM functionality.

jhennawi and others added 30 commits December 16, 2024 12:24
…dec_2024

# Conflicts:
#	pypeit/core/datacube.py
…= True. The mask that is returned should always be the extraction mask used.
…into kcwi_dec_2024

# Conflicts:
#	pypeit/core/skysub.py
@profxj profxj requested a review from rcooke-ast May 24, 2025 12:55
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!

Do we need new docs (i.e. .rst files) or tests?
If so, demand them of your chat-bot. :)

# Store the shift in the RA and DEC offsets in degrees
ra_offsets[ff] += ra_shift
dec_offsets[ff] += dec_shift
image_phase=False
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, this should be removed. The Gauss fit will only work for point sources.

return ra_offsets, dec_offsets

def compute_weights(self):
def compute_weights(self, show_qa=False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

add show_qa to doc string

self.all_tilts, self.all_slits, self.all_align, self.all_dar,
self.ra_offsets, self.dec_offsets,
outfile=outfile, overwrite=self.overwrite, whitelight_range=wl_wvrng,
# if self.combine:
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove?

combine (bool):
Should the input frames be combined into a single datacube?
idx (int, optional):
Index of filename to be saved. Required if combine=False.

Returns:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Parameters

and

Returns:

do not go together.

outfile (str):
The output filename for the datacube.
output_dir (str):
The output directory to save the datacube.
Copy link
Collaborator

Choose a reason for hiding this comment

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

add overwrite




def make_whitelight_fromcube_old(cube, bpmcube, wave=None, wavemin=None, wavemax=None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe send to deprecate? Really, I think we should include this old functionality by not enforcing the sigma clipping.




#extract_good_frac=0.005
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

@@ -671,7 +672,7 @@ def reidentify(spec, spec_arxiv_in, wave_soln_arxiv_in, line_list,
if pdiff[bstpx] < match_toler:
# Using the arxiv arc wavelength solution, search for the nearest line in the line list
bstwv = np.abs(wvdata - wvval_arxiv[bstpx])
# This is a good wavelength match if it is within match_toler disperion elements
# This is a good wavelength match if it is within match_toler daisperion elements
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo

Copy link
Collaborator
@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.

Thanks, @jhennawi, for this massive revision of the datacube code. A lot of excellent updates here. I've been through the code carefully and commented extensively. Most of the changes are pretty straight forward, but I've marked some places where we should really discuss things on Slack (or here) before further. Once you've addressed these, please post a report of the tests. Thanks again!

@@ -258,7 +263,7 @@ def broadcast_weights(weights, shape):
weights_stack = weights
elif len(shape) == 3:
weights_stack = np.einsum('ij,k->ijk', weights, np.ones(shape[2]))
elif weights.ndim == 3:
elif (weights.ndim == 3) | (weights.ndim == 4):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the | (a bitwise operator) should be or (a logical operator).


Args:
spatx (`numpy.ndarray`_): Array of spatial positions to hand extract
spaty (`numpy.ndarray`_): Array of spectral positions to hand extract
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think spectral should be spatial here. Perhaps make it clear which directions spatx and spaty corresponding to (presumably one aligns with either the spatial slice, or with declination)?

Args:
spatx (`numpy.ndarray`_): Array of spatial positions to hand extract
spaty (`numpy.ndarray`_): Array of spectral positions to hand extract
fwhm (`numpy.ndarray`_): Array of FWHM for hand extraction in arcserconds.
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 "optional" as well, because in the datamodel below you list it as optional?

idict['spatx'] += [float(parse[0])]
idict['spaty'] += [float(parse[1])]

# FWHM?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be concerned that FWHM must be specified if you want to specify boxcar_rad? What if someone just wants the boxcar, for example?

"""
if len(self.spatx) != len(self.spaty):
raise ValueError("spatx and spaty not of the same length")
#if len(self.fwhm) != len(self.spatx):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also be checking FWHM and boxcar_rad? Seems to make sense.


Returns:
:obj:`tuple`: Three or four `numpy.ndarray`_ objects containing (1) the
datacube generated from the subpixellated inputs, (2) the corresponding
variance cube, and (3) the corresponding bad pixel mask cube.
standard deviation cube, and (3) the corresponding bad pixel mask cube. (4) A cube
indicating the occupation number of a given pixel TODO: elaborate on this
Copy link
Collaborator

Choose a reason for hiding this comment

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

elaborate here too, thanks.

@@ -1784,7 +2310,7 @@ def subpixellate(output_wcs, bins, sciImg, ivarImg, waveImg, slitid_img_gpm, wgh
vox_coord = np.full((numpix, num_all_subpixels, 3), -1, dtype=float)
# Loop over the subslices
for ss in range(slice_subpixel):
if slice_subpixel > 1:
if verbose and slice_subpixel > 1:
Copy link
Collaborator

Choose a reason for hiding this comment

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

for clarity, can we change this to: verbose and (slice_subpixel > 1)

#this_dec_int += dec_corr + _dec_offset[fr]
# TODO: Below was a hack to fix bug for KCRM. I suspected the WCS was being set incorrectly,
# which was true, and this hack fixed it. Old code is the line above.
this_dec_int += dec_corr - _dec_offset[fr]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not so sure about this change. Let's investigate this further. You have used a different/new approach to determine dec_offset, and we need to make sure that this is consistent with the old approach. The new method (in run_align()) may have a bug, and this line of code should be reverted to the old code. Please read the following section of the documentation to make sure that your new approach is consistent with the docs:
Setting offsets in PypeIt

@@ -1829,7 +2359,94 @@ def subpixellate(output_wcs, bins, sciImg, ivarImg, waveImg, slitid_img_gpm, wgh
nc_inverse = utils.inverse(normcube)
flxcube *= nc_inverse
varcube *= nc_inverse**2
bpmcube = (normcube == 0).astype(np.uint8)
bpmcube = (normcube == 0) #.astype(np.uint8)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can remove the commented code, or include the type set to uint8.




def make_whitelight_fromcube_old(cube, bpmcube, wave=None, wavemin=None, wavemax=None):
Copy link
Collaborator

CEB7 Choose a reason for hiding this comment

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

Maybe send to deprecate? Really, I think we should include this old functionality by not enforcing the sigma clipping.

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
0