Skip to content

Commit

Permalink
skipping sky subtraction refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmejia committed Dec 18, 2023
1 parent 211bbb6 commit dda9437
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion python/lvmdrp/functions/run_quickdrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ def quick_science_reduction(expnum: int, use_fiducial_master: bool = False,

# refine sky subtraction
# TODO: make sure the the master sky being subtracted in this step is stored in the correct extension
sky_tasks.quick_sky_refinement(in_cframe=path.full("lvm_frame", mjd=sci_mjd, drpver=drpver, tileid=sci_tileid, expnum=sci_expnum, kind='CFrame'))

sky_tasks.quick_sky_refinement(in_cframe=path.full("lvm_frame", mjd=sci_mjd, drpver=drpver, tileid=sci_tileid, expnum=sci_expnum, kind='CFrame'),
skip_subtraction=skip_sky_subtraction)

# TODO: add quick report routine

Expand Down
8 changes: 5 additions & 3 deletions python/lvmdrp/functions/skyMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ def quick_sky_subtraction(in_rss: str, out_rss, in_skye: str, in_skyw: str, sky_
return rss


def quick_sky_refinement(in_cframe, band=np.array((7238,7242,7074,7084,7194,7265))):
def quick_sky_refinement(in_cframe, band=np.array((7238,7242,7074,7084,7194,7265)), skip_subtraction=False):
"""Quick sky refinement using the model in the final CFrame
Parameters
Expand Down Expand Up @@ -1717,10 +1717,12 @@ def quick_sky_refinement(in_cframe, band=np.array((7238,7242,7074,7084,7194,7265
smap_1 = bn.nanmean(sky[:, i_band[4]:i_band[5]], axis=1)
smap_c = smap_b - 0.5 * (smap_0 + smap_1)


scale = map_c / smap_c
sky_c = np.nan_to_num(sky * scale[:, None])
data_c = np.nan_to_num(flux - sky_c)
error_c = np.nan_to_num(error - sky_c)
if skip_subtraction:
data_c = np.nan_to_num(flux - sky_c)
error_c = np.nan_to_num(error - sky_c)

cframe["FLUX"].data = data_c
cframe["ERROR"].data = error_c
Expand Down

0 comments on commit dda9437

Please sign in to comment.