Skip to content

Commit 3c83a78

Browse files
committed
Look up Roman sky backgrounds by column names
The index based lookup for sky backgrounds is finicky when requesting only a subset of bandpasses. This could be done by looking up the index of the bandname, but looking up by column name is more robust and has the advantage of documenting the shared data file better.
1 parent 14a6e0d commit 3c83a78

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

galsim/roman/roman_bandpass.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def getBandpasses(AB_zeropoint=True, default_thin_trunc=True, include_all_bands=
123123

124124
# Read in and manipulate the sky background info.
125125
sky_file = os.path.join(meta_data.share_dir, "roman", "roman_sky_backgrounds.txt")
126-
sky_data = np.loadtxt(sky_file).transpose()
127-
ecliptic_lat = sky_data[0, :]
128-
ecliptic_lon = sky_data[1, :]
126+
sky_data = np.genfromtxt(sky_file, names=True)
127+
ecliptic_lat = sky_data['Latitude']
128+
ecliptic_lon = sky_data['Longitude']
129129

130130
# Parse kwargs for truncation, thinning, etc., and check for nonsense.
131131
truncate_kwargs = ['blue_limit', 'red_limit', 'relative_throughput']
@@ -172,7 +172,7 @@ def getBandpasses(AB_zeropoint=True, default_thin_trunc=True, include_all_bands=
172172
# Store the sky level information as an attribute.
173173
bp._ecliptic_lat = ecliptic_lat
174174
bp._ecliptic_lon = ecliptic_lon
175-
bp._sky_level = sky_data[2+index, :]
175+
bp._sky_level = sky_data[bp_name]
176176

177177
# Add it to the dictionary.
178178
bp.name = bp_name if bp_name != 'W149' else 'W146'

share/roman/roman_sky_backgrounds.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Latitude Longitude R062 Z087 Y106 J129 H158 F184 W146 K213 SNPrism Grism_1stOrder Grism_0thOrder
12
0.0000 0.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000
23
1.3976 0.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000
34
2.7960 0.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000 -10.0000

0 commit comments

Comments
 (0)