Skip to content

Commit

Permalink
Merge pull request #434 from lsst/tickets/SP-1732
Browse files Browse the repository at this point in the history
upadate sky generation
  • Loading branch information
yoachim authored Dec 10, 2024
2 parents f985ce2 + 13c0c63 commit e5f36e6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions rubin_sim/skybrightness/generate_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ def generate_sky(
mjd1 = dict_of_lists["mjds"][-3]
mjd3 = dict_of_lists["mjds"][-1]
if (mjd2 > mjd1) & (mjd2 < mjd3):
indx = np.where(last_5_mjds == mjd2)[0]
indx = np.min(np.where(last_5_mjds == mjd2)[0])
# Linear interpolation weights
wterm = (mjd2 - mjd1) / (mjd3 - mjd1)
w1 = 1.0 - wterm
w2 = wterm
for filter_name in filter_names:
interp_sky = w1 * sky_brightness[filter_name][-3]
interp_sky += w2 * sky_brightness[filter_name][-1]
diff = np.abs(last_5_mags[int(indx)][filter_name] - interp_sky)
diff = np.abs(last_5_mags[indx][filter_name] - interp_sky)
if np.size(diff[~np.isnan(diff)]) > 0:
if np.max(diff[~np.isnan(diff)]) > dm:
can_interp = False
Expand All @@ -192,6 +192,8 @@ def generate_sky(
version = rubin_sim.version.__version__
fingerprint = version
# Generate a header to save all the kwarg info for this run
if outpath is None:
outpath = ""
header = {
"mjd0": mjd0,
"mjd_max": mjd_max,
Expand All @@ -200,15 +202,7 @@ def generate_sky(
"outfile": outfile,
"outpath": outpath,
"nside": nside,
"sunLimit": sunLimit,
"airmas_overhead": airmass_overhead,
"dm": dm,
"airmass_limit": airmass_limit,
"alt_limit": alt_limit,
"ra": ra,
"dec": dec,
"verbose": verbose,
"required_mjds": required_mjds,
"version": version,
"fingerprint": fingerprint,
}
Expand Down

0 comments on commit e5f36e6

Please sign in to comment.