Skip to content

Commit

Permalink
limit size of field coefficients
Browse files Browse the repository at this point in the history
  • Loading branch information
JarronL committed May 19, 2020
1 parent 8e874a1 commit 240f751
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 14 additions & 2 deletions pynrc/nrc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,20 @@ def field_coeff_resid(filter_or_bp, coeff0, force=False, save=True, save_name=No
filter = bp.name
channel = 'SW' if bp.avgwave() < 24000 else 'LW'

# fov_pix should not be more than 128/129, otherwise memory issues
fov_pix = kwargs['fov_pix'] if 'fov_pix' in list(kwargs.keys()) else 33
oversample = kwargs['oversample'] if 'oversample' in list(kwargs.keys()) else 4

fov_max = 128 if oversample<=4 else 64
if fov_pix>fov_max:
fov_pix = fov_max if (fov_pix % 2 == 0) else fov_max + 1
# Trim input coeff0
new_shape = fov_pix*oversample
cf0_new = np.array([pad_or_cut_to_size(im, new_shape) for im in coeff0])
coeff0 = cf0_new
kwargs['fov_pix'] = fov_pix
kwargs['oversample'] = oversample

# Final filename to save coeff
if save_name is None:
# Name to save array of oversampled coefficients
Expand Down Expand Up @@ -1654,8 +1668,6 @@ def field_coeff_resid(filter_or_bp, coeff0, force=False, save=True, save_name=No

# Split over multiple processors?
if nsplit is None:
fov_pix = kwargs['fov_pix'] if 'fov_pix' in list(kwargs.keys()) else 33
oversample = kwargs['oversample'] if 'oversample' in list(kwargs.keys()) else 4
pupil = kwargs['pupil'] if 'pupil' in list(kwargs.keys()) else None
coron_obs = (pupil is not None) and ('LYOT' in pupil)
nsplit = nproc_use(fov_pix, oversample, npos, coron=coron_obs)
Expand Down
6 changes: 5 additions & 1 deletion pynrc/pynrc_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,11 @@ def gen_psf(self, sp=None, return_oversample=False, use_bg_psf=False,
# print(v2,v3)
nfield = np.size(v2)
cf_mod = field_coeff_func(v2grid, v3grid, cf_fit, v2, v3)
psf_coeff_mod += cf_mod
if not np.allclose(psf_coeff.shape, cf_mod.shape):
new_shape = psf_coeff.shape[1:]
cf_mod_resize = np.array([pad_or_cut_to_size(im, new_shape) for im in cf_mod])
cf_mod = cf_mod_resize
psf_coeff_mod += cf_mod

# Add PSF coefficient modifications due to wedge/bar offset
if (use_bg_psf==False) and (self.mask is not None) and ('WB' in self.mask):
Expand Down

0 comments on commit 240f751

Please sign in to comment.