Skip to content

Commit

Permalink
Merge pull request #27 from GalSim-developers/u/rmandelb/nisp
Browse files Browse the repository at this point in the history
U/rmandelb/nisp
  • Loading branch information
aguinot authored Jul 18, 2024
2 parents dd4571c + 96ecf31 commit 42a0a17
Show file tree
Hide file tree
Showing 7 changed files with 1,828 additions and 14 deletions.
1 change: 1 addition & 0 deletions euclidlike/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .instrument_params import gain, pixel_scale, diameter, obscuration, collecting_area
from .instrument_params import focal_length, fratio
from .instrument_params import vis_bands, nisp_bands
from .instrument_params import long_exptime, short_exptime, read_noise, n_dithers
from .instrument_params import n_ccd, n_pix_row, n_pix_col, pixel_scale_mm
from . import instrument_params
Expand Down
52 changes: 38 additions & 14 deletions euclidlike/bandpass.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""
@file bandpass.py
This file includes any routines needed to define the Euclid bandpass.
This file includes any routines needed to define the Euclid bandpasses.
This module is heavily based on the roman bandpass.py file from the GalSim package.
https://github.com/GalSim-developers/GalSim/blob/releases/2.5/galsim/roman/roman_bandpass.py
The Euclid VIS bandpass is read in from the Euclid_VIS.vis.dat file which can be downloaded from
http://svo2.cab.inta-csic.es/svo/theory/fps3/index.php?mode=browse&gname=Euclid&gname2=VIS&asttype=.
The Euclid NISP bandpasses are read in from files downloaded from
https://euclid.esac.esa.int/msp/refdata/nisp/NISP-PHOTO-PASSBANDS-V1
"""

import numpy as np
Expand All @@ -16,29 +20,49 @@

def getBandpasses(AB_zeropoint=True, default_thin_trunc=True, **kwargs):
"""
Function to get the bandpass information for the Euclid VIS band.
Function to get the bandpass information for the Euclid VIS band and the three Euclid NISP passbands.
This routine reads in a file containing a list of wavelengths and
transmission values for the Euclid VIS band. The file is located in the
This routine reads in files containing a list of wavelengths and
transmission values for the Euclid bands. The files are located in the
euclidlike.data directory. The routine then creates a Bandpass object
using the LookupTable class from the GalSim package.
using the LookupTable class from the GalSim package, and returns a dict with bandpasses for the
keys.
Args:
AB_zeropoint (bool) : If True, set the zeropoint of the bandpass to the AB magnitude system. [default: True]
default_thin_trunc (bool) : If True, use the default thinning and truncation parameters. [default: True]
kwargs : Additional keyword arguments to pass to either `Bandpass.thin` or `Bandpass.truncate`.
"""
# Read in the bandpass file
# Read in the bandpass files, using a dict to distinguish the different filters
wave = {}
data = {}
# Start with VIS
bandpass_file = files('euclidlike.data').joinpath('Euclid_VIS.vis.dat')
bandpass = np.loadtxt(bandpass_file, dtype=float)
wave = bandpass[:, 0]
data = bandpass[:, 1]
# Wavelengths in Angstroms
wave['VIS'] = bandpass[:, 0]
data['VIS'] = bandpass[:, 1]

# Then do NISP - make sure band names that are stored include 'NISP_'
nisp_bands = ['Y', 'H', 'J']
use_nisp_bands = []
for band in nisp_bands:
use_nisp_bands.append('NISP_%s'%band)
for index, nisp_band in enumerate(nisp_bands):
bandpass_file = files('euclidlike.data').joinpath('NISP-PHOTO-PASSBANDS-V1-%s_throughput.dat.txt'%nisp_band)
bandpass = np.loadtxt(bandpass_file, dtype=float)
# These wavelengths are in nm but we want to be consistent for all bands, so multiply by 10
# to get Angstroms
wave[use_nisp_bands[index]] = bandpass[:,0]*10
data[use_nisp_bands[index]] = bandpass[:,1]

# In case we want to add NISP bandpasses
data = np.atleast_2d(data)
# make a list with all bands for later use.
all_bands = use_nisp_bands.copy()
all_bands.append('VIS')

# Below is the original code from the GalSim package.
# I have modified it to read in the Euclid_VIS.vis.dat file.

# Below is the original code from the GalSim package modified for the format of these Euclid
# bandpass files.

# Parse kwargs for truncation, thinning, etc., and check for nonsense.
truncate_kwargs = ['blue_limit', 'red_limit', 'relative_throughput']
Expand All @@ -61,9 +85,9 @@ def getBandpasses(AB_zeropoint=True, default_thin_trunc=True, **kwargs):
raise TypeError("Unknown kwargs: %s"%(' '.join(kwargs.keys())))

bandpass_dict = {}
for index, bp_name in enumerate(['VIS']):
for index, bp_name in enumerate(all_bands):
# Create the bandpass object
bp = Bandpass(LookupTable(wave, data[index]), wave_type='Angstrom')
bp = Bandpass(LookupTable(wave[bp_name], data[bp_name]), wave_type='Angstrom')

# Use any arguments related to truncation, thinning, etc.
if len(tmp_truncate_dict) > 0 or default_thin_trunc:
Expand Down
Loading

0 comments on commit 42a0a17

Please sign in to comment.