Skip to content

Commit

Permalink
Merge pull request #30 from LSSTDESC/issue/29/dereddener_copy_cols
Browse files Browse the repository at this point in the history
Issue/29/dereddener copy cols
  • Loading branch information
hangqianjun authored Nov 23, 2023
2 parents 72896bf + 308a31f commit 84b2eeb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/rail/tools/util_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ def __call__(self, data):

class Dereddener(RailStage):
"""Utility stage that does dereddening
Note: set copy_cols="ALL" to copy all
columns in data
"""
name = 'Dereddener'

Expand Down Expand Up @@ -462,12 +464,23 @@ def run(self):
except KeyError as msg: # pragma: no cover
raise KeyError(f"Unknown dustmap {self.config.dustmap_name}, options are {list(dust_map_dict.keys())}") from msg
ebvvec = dust_map(coords)
band_mag_name_list=[]
for i, band_ in enumerate(self.config.bands):
band_mag_name = self.config.mag_name.format(band=band_)
mag_vals = data[band_mag_name]
out_data[band_mag_name] = mag_vals - ebvvec*self.config.band_a_env[i]
for col_ in self.config.copy_cols: # pragma: no cover
out_data[col_] = data[col_]
band_mag_name_list.append(band_mag_name)

# check if copy_cols is a list, or is set to ALL:
if isinstance(self.config.copy_cols, list): # pragma: no cover
for col_ in self.config.copy_cols: # pragma: no cover
out_data[col_] = data[col_]
elif self.config.copy_cols=="ALL": # pragma: no cover
for col_ in data:
# make sure we do not overwrite the photometry columns
if col_ not in band_mag_name_list:
out_data[col_] = data[col_]

self.add_data('output', out_data)

def __call__(self, data):
Expand Down

0 comments on commit 84b2eeb

Please sign in to comment.