Skip to content

Commit

Permalink
Merge pull request #125 from desihub/binning
Browse files Browse the repository at this point in the history
Simulate DESI spectra with the same output wavelength binning as the pipeline
  • Loading branch information
dkirkby authored Dec 4, 2024
2 parents 1765a63 + 07ed700 commit 0a15080
Show file tree
Hide file tree
Showing 5 changed files with 1,070 additions and 12 deletions.
668 changes: 668 additions & 0 deletions docs/nb/SpecsimBinning.ipynb

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions specsim/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@ def __init__(self, name, wavelength, throughput, row_size,

# The arrays defining the CCD properties must all have identical
# wavelength coverage.
# Since these arrays are generally interpolated, we might have some
# very small values due to roundoff errors. Set those to zero first.
for data in (self._row_size, self._fwhm_resolution, self._neff_spatial):
data[np.abs(data) < 1e-10] = 0.
# Use the row size array to define the CCD coverage.
ccd_nonzero = np.where(self._row_size > 0)[0]
ccd_start, ccd_stop = ccd_nonzero[0], ccd_nonzero[-1] + 1
# Verify that the other arrays have matching coverage.
if (np.any(self._fwhm_resolution[:ccd_start] != 0) or
np.any(self._fwhm_resolution[ccd_stop:] != 0)):
raise RuntimeError('Resolution extends beyond CCD coverage.')
Expand Down
2 changes: 1 addition & 1 deletion specsim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def update(self):
"""
# Initialize our wavelength grid.
grid = self.wavelength_grid
nwave = 1 + int(math.floor(
nwave = 1 + int(np.round(
(grid.max - grid.min) / grid.step))
if nwave <= 0:
raise ValueError('Invalid wavelength grid.')
Expand Down
22 changes: 11 additions & 11 deletions specsim/data/config/desi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ verbose: no
# CCD 3569.000 5949.000 5625.000 7741.000 7435.000 9834.000
wavelength_grid:
unit: Angstrom
min: 3550.0
max: 9850.0
min: 3550.05
max: 9850.05
step: 0.1

# The atmosphere configuration is interpreted and validated by the
Expand Down Expand Up @@ -203,10 +203,10 @@ instrument:
# Output pixels are used to report simulation results but are
# not the physical pixels. The output pixel size must be a
# multiple of wavelength_grid.step.
output_pixel_size: 0.5 Angstrom
output_pixel_size: 0.8 Angstrom
ccd:
table:
path: specpsf/psf-quicksim.fits
path: specpsf/psf-quicksim-rebin.fits
hdu: QUICKSIM-B
extrapolated_value: 0.0
columns:
Expand All @@ -222,7 +222,7 @@ instrument:
neff_spatial: { name: neff_spatial }
throughput:
table:
path: throughput/thru-b.fits
path: throughput/thru-b_y1measured.fits
hdu: THROUGHPUT
extrapolated_value: 0.0
columns:
Expand All @@ -240,10 +240,10 @@ instrument:
# Output pixels are used to report simulation results but are
# not the physical pixels. The output pixel size must be a
# multiple of wavelength_grid.step.
output_pixel_size: 0.5 Angstrom
output_pixel_size: 0.8 Angstrom
ccd:
table:
path: specpsf/psf-quicksim.fits
path: specpsf/psf-quicksim-rebin.fits
hdu: QUICKSIM-R
extrapolated_value: 0.0
columns:
Expand All @@ -259,7 +259,7 @@ instrument:
neff_spatial: { name: neff_spatial }
throughput:
table:
path: throughput/thru-r.fits
path: throughput/thru-r_y1measured.fits
hdu: THROUGHPUT
extrapolated_value: 0.0
columns:
Expand All @@ -277,10 +277,10 @@ instrument:
# Output pixels are used to report simulation results but are
# not the physical pixels. The output pixel size must be a
# multiple of wavelength_grid.step.
output_pixel_size: 0.5 Angstrom
output_pixel_size: 0.8 Angstrom
ccd:
table:
path: specpsf/psf-quicksim.fits
path: specpsf/psf-quicksim-rebin.fits
hdu: QUICKSIM-Z
extrapolated_value: 0.0
columns:
Expand All @@ -296,7 +296,7 @@ instrument:
neff_spatial: { name: neff_spatial }
throughput:
table:
path: throughput/thru-z.fits
path: throughput/thru-z_y1measured.fits
hdu: THROUGHPUT
extrapolated_value: 0.0
columns:
Expand Down
Loading

0 comments on commit 0a15080

Please sign in to comment.