From 4d629c30e0ce0bfe1bb88612d6420cacb4d1a4f8 Mon Sep 17 00:00:00 2001 From: rcooke Date: Fri, 15 Nov 2024 13:18:09 +0000 Subject: [PATCH 1/5] update users --- presentations/py/users.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/presentations/py/users.py b/presentations/py/users.py index 73902997e4..8a1fe49092 100644 --- a/presentations/py/users.py +++ b/presentations/py/users.py @@ -21,9 +21,9 @@ def set_fontsize(ax, fsz): ax.get_xticklabels() + ax.get_yticklabels()): item.set_fontsize(fsz) -user_dates = ["2021-03-11", "2022-04-29", "2022-11-07", "2022-12-06", "2023-06-08", "2023-06-29", "2023-07-11", "2023-09-03", "2023-10-13", "2023-12-01", "2023-12-15", "2024-02-22", "2024-03-21", "2024-04-09", "2024-05-02", "2024-05-19", "2024-06-06", "2024-06-10", "2024-08-20"] +user_dates = ["2021-03-11", "2022-04-29", "2022-11-07", "2022-12-06", "2023-06-08", "2023-06-29", "2023-07-11", "2023-09-03", "2023-10-13", "2023-12-01", "2023-12-15", "2024-02-22", "2024-03-21", "2024-04-09", "2024-05-02", "2024-05-19", "2024-06-06", "2024-06-10", "2024-08-20", "2024-11-15"] user_dates = numpy.array([numpy.datetime64(date) for date in user_dates]) -user_number = numpy.array([125, 293, 390, 394, 477, 487, 506, 518, 531, 544, 551, 568, 579, 588, 596, 603, 616, 620, 643]) +user_number = numpy.array([125, 293, 390, 394, 477, 487, 506, 518, 531, 544, 551, 568, 579, 588, 596, 603, 616, 620, 643, 688]) user_pred_dates = numpy.array([numpy.datetime64(date) for date in ["2024-06-10", "2024-12-31", "2025-12-31", "2026-12-31", From b9097ffdcacfd2f5ff61e4e69d7eaec83f860fa6 Mon Sep 17 00:00:00 2001 From: rcooke Date: Fri, 15 Nov 2024 20:35:19 +0000 Subject: [PATCH 2/5] fix WCS offset --- pypeit/alignframe.py | 2 +- pypeit/core/datacube.py | 11 ++++++----- pypeit/slittrace.py | 2 +- pypeit/spectrographs/keck_kcwi.py | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pypeit/alignframe.py b/pypeit/alignframe.py index fb899525a9..d7b8916226 100644 --- a/pypeit/alignframe.py +++ b/pypeit/alignframe.py @@ -397,7 +397,7 @@ def build_splines(self): xcoord = np.arange(np.floor(np.min(xlr)), np.ceil(np.max(xlr))+1, 1.0) out_transform = np.zeros((self.nspec, xcoord.size)) for sp in range(self.nspec): - out_transform[sp,:] = (self.spl_loc[sl][sp](xcoord) - 0.5) * self.spl_slen[sl](sp) + out_transform[sp,:] = self.spl_loc[sl][sp](xcoord) * self.spl_slen[sl](sp) self.spl_transform[sl] = RegularGridInterpolator((ycoord, xcoord), out_transform, method='linear', bounds_error=False, fill_value=None) # This will extrapolate # TODO :: Remove these notes... diff --git a/pypeit/core/datacube.py b/pypeit/core/datacube.py index 3b5ff61923..5c3ba124fd 100644 --- a/pypeit/core/datacube.py +++ b/pypeit/core/datacube.py @@ -1309,11 +1309,6 @@ def compute_weights(raImg, decImg, waveImg, sciImg, ivarImg, slitidImg, #idx_max = np.unravel_index(np.argmax(whitelight_img), whitelight_img.shape) msgs.info("Highest S/N object located at spaxel (x, y) = {0:d}, {1:d}".format(idx_max[0], idx_max[1])) - # Generate a 2D WCS to register all frames - coord_min = [_ra_min, _dec_min, _wave_min] - coord_dlt = [dspat, dspat, dwv] - whitelightWCS = generate_WCS(coord_min, coord_dlt) - wcs_scale = (1.0 * whitelightWCS.spectral.wcs.cunit[0]).to(units.Angstrom).value # Ensures the WCS is in Angstroms # Make the bin edges to be at +/- 1 pixels around the maximum (i.e. summing 9 pixels total) numwav = int((_wave_max - _wave_min) / dwv) xbins = np.array([idx_max[0]-1, idx_max[0]+2]) - 0.5 @@ -1321,6 +1316,12 @@ def compute_weights(raImg, decImg, waveImg, sciImg, ivarImg, slitidImg, spec_bins = np.arange(1 + numwav) - 0.5 bins = (xbins, ybins, spec_bins) + # Generate a 2D WCS to register all frames + coord_min = [_ra_min, _dec_min, _wave_min] + coord_dlt = [dspat, dspat, dwv] + whitelightWCS = generate_WCS(coord_min, coord_dlt) + wcs_scale = (1.0 * whitelightWCS.spectral.wcs.cunit[0]).to(units.Angstrom).value # Ensures the WCS is in Angstroms + # Extract the spectrum of the highest S/N object flux_stack = np.zeros((numwav, numframes)) ivar_stack = np.zeros((numwav, numframes)) diff --git a/pypeit/slittrace.py b/pypeit/slittrace.py index e1367629f3..ebab1ae220 100644 --- a/pypeit/slittrace.py +++ b/pypeit/slittrace.py @@ -556,7 +556,7 @@ def get_radec_image(self, wcs, alignSplines, tilts, slit_compute=None, slice_off minmax[slit_idx, 0] = np.min(evalpos) minmax[slit_idx, 1] = np.max(evalpos) # Calculate the WCS from the pixel positions - slitID = np.ones(evalpos.size) * slit_idx + slice_offset - wcs.wcs.crpix[0] + slitID = np.ones(evalpos.size) * slit_idx + slice_offset world_ra, world_dec, _ = wcs.wcs_pix2world(slitID, evalpos, tilts[onslit_init]*(self.nspec-1), 0) # Set the RA first and DEC next raimg[onslit] = world_ra.copy() diff --git a/pypeit/spectrographs/keck_kcwi.py b/pypeit/spectrographs/keck_kcwi.py index 218937bd66..cf9dbb28b9 100644 --- a/pypeit/spectrographs/keck_kcwi.py +++ b/pypeit/spectrographs/keck_kcwi.py @@ -720,7 +720,7 @@ def get_datacube_bins(self, slitlength, minmax, num_wave): when constructing a histogram of the spec2d files. The elements are :math:`(x,y,\lambda)`. """ - xbins = np.arange(1 + 24) - 24/2 - 0.5 + xbins = np.arange(1 + 24) - 0.5 ybins = np.linspace(np.min(minmax[:, 0]), np.max(minmax[:, 1]), 1+slitlength) - 0.5 spec_bins = np.arange(1+num_wave) - 0.5 return xbins, ybins, spec_bins From df83a6a9369765ecf733932111c2eb4667d36154 Mon Sep 17 00:00:00 2001 From: rcooke Date: Fri, 15 Nov 2024 21:41:07 +0000 Subject: [PATCH 3/5] Adopt East/West convention --- pypeit/core/datacube.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pypeit/core/datacube.py b/pypeit/core/datacube.py index 5c3ba124fd..9651586dfd 100644 --- a/pypeit/core/datacube.py +++ b/pypeit/core/datacube.py @@ -979,7 +979,7 @@ def create_wcs(raImg, decImg, waveImg, slitid_img_gpm, dspat, dwave, # Generate a master WCS to register all frames coord_min = [_ra_min, _dec_min, _wave_min] - coord_dlt = [dspat, dspat, dwave] + coord_dlt = [-dspat, dspat, dwave] # If a reference image is being used and a white light image is requested (collapse=True) update the celestial parts reference_image = None @@ -991,7 +991,7 @@ def create_wcs(raImg, decImg, waveImg, slitid_img_gpm, dspat, dwave, coord_dlt[:2] = imgwcs.wcs.cdelt numra, numdec = reference_image.shape - cubewcs = generate_WCS(coord_min, coord_dlt, equinox=equinox, name=specname) + cubewcs = generate_WCS(coord_min, coord_dlt, numra, equinox=equinox, name=specname) msgs.info(msgs.newline() + "-" * 40 + msgs.newline() + "Parameters of the WCS:" + msgs.newline() + "RA min = {0:f}".format(coord_min[0]) + @@ -1009,7 +1009,7 @@ def create_wcs(raImg, decImg, waveImg, slitid_img_gpm, dspat, dwave, return cubewcs, voxedges, reference_image -def generate_WCS(crval, cdelt, equinox=2000.0, name="PYP_SPEC"): +def generate_WCS(crval, cdelt, numra, equinox=2000.0, name="PYP_SPEC"): """ Generate a WCS that will cover all input spec2D files @@ -1020,6 +1020,10 @@ def generate_WCS(crval, cdelt, equinox=2000.0, name="PYP_SPEC"): cdelt (list): 3 element list containing the delta values of the [RA, DEC, WAVELENGTH] + numra (int): + Number of RA values in the WCS. This is used to ensure + that the convention of the WCS is so that North is up + and East is to the left. equinox (float, optional): Equinox of the WCS @@ -1037,7 +1041,7 @@ def generate_WCS(crval, cdelt, equinox=2000.0, name="PYP_SPEC"): w.wcs.cunit = [units.degree, units.degree, units.Angstrom] w.wcs.ctype = ["RA---TAN", "DEC--TAN", "WAVE"] w.wcs.crval = crval # RA, DEC, and wavelength zeropoints - w.wcs.crpix = [0, 0, 0] # RA, DEC, and wavelength reference pixels + w.wcs.crpix = [numra, 0, 0] # RA, DEC, and wavelength reference pixels #w.wcs.cd = np.array([[cdval[0], 0.0, 0.0], [0.0, cdval[1], 0.0], [0.0, 0.0, cdval[2]]]) w.wcs.cdelt = cdelt w.wcs.lonpole = 180.0 # Native longitude of the Celestial pole @@ -1317,9 +1321,10 @@ def compute_weights(raImg, decImg, waveImg, sciImg, ivarImg, slitidImg, bins = (xbins, ybins, spec_bins) # Generate a 2D WCS to register all frames + numra = xbins.size - 1 coord_min = [_ra_min, _dec_min, _wave_min] - coord_dlt = [dspat, dspat, dwv] - whitelightWCS = generate_WCS(coord_min, coord_dlt) + coord_dlt = [-dspat, dspat, dwv] + whitelightWCS = generate_WCS(coord_min, coord_dlt, numra) wcs_scale = (1.0 * whitelightWCS.spectral.wcs.cunit[0]).to(units.Angstrom).value # Ensures the WCS is in Angstroms # Extract the spectrum of the highest S/N object From 3e63d4111b5f5bca6b76907c3bfe83c9a6727ddb Mon Sep 17 00:00:00 2001 From: rcooke Date: Fri, 15 Nov 2024 21:58:56 +0000 Subject: [PATCH 4/5] Adopt East/West convention --- doc/releases/1.17.1dev.rst | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 doc/releases/1.17.1dev.rst diff --git a/doc/releases/1.17.1dev.rst b/doc/releases/1.17.1dev.rst new file mode 100644 index 0000000000..b171ec5821 --- /dev/null +++ b/doc/releases/1.17.1dev.rst @@ -0,0 +1,42 @@ + +Version 1.17.1dev +================= + +Installation Changes +-------------------- + + +Dependency Changes +------------------ + + +Functionality/Performance Improvements and Additions +---------------------------------------------------- + +- The WCS for datacubes now adopts the convention of North + is up and East is left. In previous version of PypeIt, + East was right. + +Instrument-specific Updates +--------------------------- + + +Script Changes +-------------- + + + +Datamodel Changes +----------------- + + +Under-the-hood Improvements +--------------------------- + + +Bug Fixes +--------- + +- Fix the WCS for the datacube generation. There was an offset + in both spatial dimensions equal to half the field of view. + From 34d49ba622dac9a47a2c11e8a6adcb5f09e77d99 Mon Sep 17 00:00:00 2001 From: rcooke Date: Mon, 18 Nov 2024 17:00:02 +0000 Subject: [PATCH 5/5] add new release file --- doc/whatsnew.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/whatsnew.rst b/doc/whatsnew.rst index 85de8cae70..9313a9bfe5 100644 --- a/doc/whatsnew.rst +++ b/doc/whatsnew.rst @@ -11,6 +11,10 @@ What's New in PypeIt ---- +.. include:: releases/1.17.1dev.rst + +---- + .. include:: releases/1.17.0.rst ----