Skip to content

Commit

Permalink
Merge pull request #40 from JarronL/develop
Browse files Browse the repository at this point in the history
Fix Roll 2 WFE drift not propagating correctly
  • Loading branch information
JarronL committed Nov 18, 2020
2 parents ce15749 + fb12d8e commit 3d367cc
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 98 deletions.
180 changes: 91 additions & 89 deletions notebooks/GTO/NRC_GTO_YSO_PDS70.ipynb

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions pynrc/nb_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def do_opt(obs_dict, tacq_max=1800, **kwargs):


# For each filter setting, generate a series of contrast curves at different WFE values
def do_contrast(obs_dict, wfe_list, filt_keys, nsig=5, roll_angle=10, verbose=True, **kwargs):
def do_contrast(obs_dict, wfe_list, filt_keys, nsig=5, roll_angle=10, verbose=False, **kwargs):
"""
kwargs to pass to calc_contrast() and their defaults:
Expand All @@ -346,16 +346,18 @@ def do_contrast(obs_dict, wfe_list, filt_keys, nsig=5, roll_angle=10, verbose=Tr
ref_scale_all = False
"""
contrast_all = {}
for i, key in enumerate(filt_keys):
if verbose: print(key)
for i in trange(len(filt_keys), desc='Observations'):
key = filt_keys[i]
obs = obs_dict[key]
if verbose:
print(key)

wfe_roll_temp = obs.wfe_roll_drift
wfe_ref_temp = obs.wfe_ref_drift

# Stores tuple of (Radial Distances, Contrast, and Sensitivity) for each WFE drift
curves = []
for wfe_drift in wfe_list:
for wfe_drift in tqdm(wfe_list, leave=False, desc='WFE Drift'):

if ('no_ref' in list(kwargs.keys())) and (kwargs['no_ref']==True):
obs.wfe_roll_drift = wfe_drift
Expand Down Expand Up @@ -563,7 +565,7 @@ def average_slopes(hdulist):
for i in np.arange(1,ng)[::-1]:
ind = (im_slope==-10) & (~sat_mask[i])
if np.any(ind): # Check if any pixels are still True
im_slope[ind] = pynrc.fast_poly.jl_poly_fit(tvals, data[:,ind])[1]
im_slope[ind] = jl_poly_fit(tvals, data[:,ind])[1]
#print(im_slope[ind].shape)

# Special case of only first frame unsaturated
Expand Down
6 changes: 3 additions & 3 deletions pynrc/obs_nircam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,9 +1309,9 @@ def gen_roll_image(self, PA1=0, PA2=10, zfact=None, oversample=None,

# Change self.wfe_drift, gen image, and return wfe_drift
if np.abs(wfe_roll_drift) > eps:
im_roll2 = self.gen_slope_image(PA=PA2, wfe_drift0=wfe_drift1, **kwargs)
im_roll2 = self.gen_slope_image(PA=PA2, wfe_drift0=wfe_drift1, do_roll2=True, **kwargs)
else:
im_roll2 = self.gen_slope_image(PA=PA2, im_star=im_star, **kwargs)
im_roll2 = self.gen_slope_image(PA=PA2, im_star=im_star, do_roll2=True, **kwargs)

# Fix saturated pixels
if fix_sat:
Expand Down Expand Up @@ -1401,7 +1401,7 @@ def gen_roll_image(self, PA1=0, PA2=10, zfact=None, oversample=None,
else:
im_star2 = im_star
im_star2_sub = im_star_sub
im_roll2 = self.gen_slope_image(PA=PA2, im_star=im_star2, **kwargs)
im_roll2 = self.gen_slope_image(PA=PA2, im_star=im_star2, do_roll2=True, **kwargs)

if ref_scale_all:
im_star2_sub = fshift(im_roll2, delx=-delx, dely=-dely, pad=True)
Expand Down
2 changes: 1 addition & 1 deletion pynrc/psfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def _wrap_wfed_coeff_for_mp(arg):
args, kwargs = arg

wfe = kwargs['wfe_drift']
print('WFE Drift: {} nm'.format(wfe))
# print('WFE Drift: {} nm'.format(wfe))

cf, _ = gen_psf_coeff(*args, **kwargs)
return cf
Expand Down

0 comments on commit 3d367cc

Please sign in to comment.