Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/JarronL/pynrc
Browse files Browse the repository at this point in the history
  • Loading branch information
JarronL committed Mar 19, 2019
2 parents c5d50ae + c3a6656 commit d5528ac
Show file tree
Hide file tree
Showing 8 changed files with 1,013 additions and 209 deletions.
9 changes: 6 additions & 3 deletions TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Planned Updates

FoV aware positions
+++++++++++++++++++
- Correct coronagraph field locations (CIRC vs BAR)
- Correct coronagraph field locations depending on Lyot optical wedge
- Background roll off at grism edges
- Filter location relative offsets
- SIAF info
Expand All @@ -15,6 +15,8 @@ Detector updates in ngNRC.py
- Pixel non-linearity
- Intrapixel Capacitance (IPC)
- Post-pixel Coupling (PPC) due to ADC "smearing"
- Pixel glow based on subarray size
- Charge diffusion (esp for saturated pixels)
- Persistence/latent image
- Optical distortions
- QE variations across a pixel's surface
Expand All @@ -23,15 +25,16 @@ Detector updates in ngNRC.py

PSF Related
+++++++++++
- Coronagraph target acquisition uncertainties
- Small grid dither strategy in coronagraphic observations
- Actual coronagraphic throughput from FITS files
- Include dispersion of coronagraph PSF
- More PSF Jitter options
- PSF convolution based on geometric spot size

Observation Classes
+++++++++++++++++++
- Grism time series
- Photometric time series (incl. weak lens)
- Grism time series
- Wide-field grism
- Wide field imaging (esp. SW modules)

Expand Down
81 changes: 79 additions & 2 deletions pynrc/WFE_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,82 @@
# plt.ylim([Y.min(),Y.max()])
# plt.axes().set_aspect('equal', 'datalim')

# names = ['Guider1', 'Guider2', 'MIRI', 'NIRCamLWA', 'NIRCamLWB',
# 'NIRCamSWA', 'NIRCamSWB', 'NIRISS', 'NIRSpec']



names = ['Guider1', 'Guider2', 'MIRI', 'NIRISS', 'NIRSpec',
'NIRCamLWA', 'NIRCamLWB', 'NIRCamSWA', 'NIRCamSWB']

from pysiaf.siaf import plot_main_apertures

fig, axes = plt.subplots(3,1, figsize=(8,10))
axes = axes.flatten()

lookup_name = 'NIRSpec'

for lookup_name in names:
ztable = ztable_full[ztable_full['instrument'] == lookup_name]

v2 = ztable['V2']
v3 = ztable['V3']

i=4
zkey = 'Zernike_{}'.format(i)
zvals = ztable[zkey]


dstep = 1. / 60. # 1" steps
xgrid = np.arange(v2.min(), v2.max()+dstep, dstep)
ygrid = np.arange(v3.min(), v3.max()+dstep, dstep)
X, Y = np.meshgrid(xgrid,ygrid)

# Cubic interpolation of all points
zgrid = griddata((v2, v3), zvals, (X, Y), method='cubic')
zmin, zmax = np.nanmin(zgrid), np.nanmax(zgrid)

ax = axes[0]
extent = np.array([xgrid.min(),xgrid.max(),ygrid.min(),ygrid.max()]) * 60
ax.imshow(zgrid, extent=extent, vmin=zmin, vmax=zmax)
ax.plot(v2*60, v3*60, ls='none', marker='x', color='C1')
ax.set_title("griddata with method='cubic'")


# There will be some NaNs along the border that need to be replaced
ind_nan = np.isnan(zgrid)
# Remove rows/cols 1 by 1 until no NaNs
zgrid2 = zgrid
ygrid2 = ygrid
xgrid2 = xgrid
while np.isnan(zgrid2.sum()):
zgrid2 = zgrid2[1:-1,1:-1]
ygrid2 = ygrid2[1:-1]
xgrid2 = xgrid2[1:-1]

ax = axes[1]
extent = np.array([xgrid2.min(),xgrid2.max(),ygrid2.min(),ygrid2.max()]) * 60
ax.imshow(zgrid2, extent=extent, vmin=zmin, vmax=zmax)
ax.plot(v2*60, v3*60, ls='none', marker='x', color='C1')
ax.set_title("Trimmed for RegularGridInterpolator")


# Create regular grid interpolator function for extrapolation of NaN's
func = RegularGridInterpolator((ygrid2,xgrid2), zgrid2, method='linear',
bounds_error=False, fill_value=None)

# Replace NaNs
pts = np.array([Y[ind_nan], X[ind_nan]]).transpose()
zgrid[ind_nan] = func(pts)

ax = axes[2]
extent = np.array([xgrid.min(),xgrid.max(),ygrid.min(),ygrid.max()]) * 60
ax.imshow(zgrid, extent=extent, vmin=zmin, vmax=zmax)
ax.plot(v2*60, v3*60, ls='none', marker='x', color='C1')
ax.set_title("NaN replacement")

for ax in axes:
plot_main_apertures(ax=ax, fill=False, mark_ref=False)
ax.set_xlim([600,-600])
ax.set_ylim([-800,-250])

fig.tight_layout()

227 changes: 227 additions & 0 deletions pynrc/apertures.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
# Full instrument aperture
'NRCALL_FULL'

# SW module Apertures
'NRCAS_FULL'
'NRCBS_FULL'

# Mod A SCAs
'NRCA1_FULL'
'NRCA2_FULL'
'NRCA3_FULL'
'NRCA4_FULL'
'NRCA5_FULL'

# Mod B SCAs
'NRCB1_FULL'
'NRCB2_FULL'
'NRCB3_FULL'
'NRCB4_FULL'
'NRCB5_FULL'

# Mod B SW/LW full frame point source obs
'NRCB1_FULLP'
'NRCB5_FULLP'

# 160x160 direct imaging subarray
'NRCA1_SUB160'
'NRCA2_SUB160'
'NRCA3_SUB160'
'NRCA4_SUB160'
'NRCA5_SUB160'
'NRCB1_SUB160'
'NRCB2_SUB160'
'NRCB3_SUB160'
'NRCB4_SUB160'
'NRCB5_SUB160'

# 320x320 subarray
'NRCA1_SUB320'
'NRCA2_SUB320'
'NRCA3_SUB320'
'NRCA4_SUB320'
'NRCA5_SUB320'
'NRCB1_SUB320'
'NRCB2_SUB320'
'NRCB3_SUB320'
'NRCB4_SUB320'
'NRCB5_SUB320'

# 6400x640 subarray
'NRCA1_SUB640'
'NRCA2_SUB640'
'NRCA3_SUB640'
'NRCA4_SUB640'
'NRCA5_SUB640'
'NRCB1_SUB640'
'NRCB2_SUB640'
'NRCB3_SUB640'
'NRCB4_SUB640'
'NRCB5_SUB640'

# Grism STRIPE observations (filter dependent)
'NRCA5_GRISM256_F322W2'
'NRCA5_GRISM128_F322W2'
'NRCA5_GRISM64_F322W2'
'NRCA5_GRISM256_F277W'
'NRCA5_GRISM128_F277W'
'NRCA5_GRISM64_F277W'
'NRCA5_GRISM256_F356W'
'NRCA5_GRISM128_F356W'
'NRCA5_GRISM64_F356W'
'NRCA5_GRISM256_F444W'
'NRCA5_GRISM128_F444W'
'NRCA5_GRISM64_F444W'

# Grism Full frame observations (filter dependent)
'NRCA5_GRISM_F322W2'
'NRCA5_GRISM_F277W'
'NRCA5_GRISM_F356W'
'NRCA5_GRISM_F444W'

# Time series grism observations
'NRCA1_GRISMTS'
'NRCA1_GRISMTS256'
'NRCA1_GRISMTS128'
'NRCA1_GRISMTS64'
'NRCA3_GRISMTS'
'NRCA3_GRISMTS256'
'NRCA3_GRISMTS128'
'NRCA3_GRISMTS64'

# Time series grism target acquisition
'NRCA5_TAGRISMTS32'
'NRCA5_TAGRISMTS_SCI_F322W2'
'NRCA5_TAGRISMTS_SCI_F444W'

# Wide field slitless
'NRCA5_GRISMC_WFSS'
'NRCA5_GRISMR_WFSS'
'NRCALL_GRISMC_WFSS'
'NRCALL_GRISMR_WFSS'
'NRCB5_GRISMC_WFSS'
'NRCB5_GRISMR_WFSS'


# DHS PIL
'NRCA3_DHSPIL'
'NRCA3_DHSPIL_SUB96'
'NRCA3_DHSPIL_WEDGES'
'NRCB4_DHSPIL'
'NRCB4_DHSPIL_SUB96'
'NRCB4_DHSPIL_WEDGES'

# Field points for wavefront sensing
'NRCA3_FP1'
'NRCA3_FP1_SUB8'
'NRCA3_FP1_SUB64'
'NRCA3_FP2MIMF'
'NRCA1_FP3MIMF'
'NRCA2_FP4MIMF'
'NRCA4_FP5MIMF'
'NRCB4_FP1'
'NRCB4_FP1_SUB8'
'NRCB4_FP1_SUB64'
'NRCB4_FP2MIMF'
'NRCB2_FP3MIMF'
'NRCB1_FP4MIMF'
'NRCB3_FP5MIMF'

# Point source subarrays
'NRCA3_SUB64P'
'NRCA3_SUB160P'
'NRCA3_SUB400P'
'NRCA5_SUB64P'
'NRCA5_SUB160P'
'NRCA5_SUB400P'
'NRCB1_SUB64P'
'NRCB1_SUB160P'
'NRCB1_SUB400P'
'NRCB5_SUB64P'
'NRCB5_SUB160P'
'NRCB5_SUB400P'

# Target acq for point source imaging?
'NRCB5_TAPSIMG32'


# Module A masks and ND Squares
'NRCA2_MASK210R'
'NRCA5_MASK335R'
'NRCA5_MASK430R'
'NRCA4_MASKSWB'
'NRCA5_MASKLWB'
'NRCA2_TAMASK210R'
'NRCA5_TAMASK335R'
'NRCA5_TAMASK430R'
'NRCA4_TAMASKSWB'
'NRCA5_TAMASKLWB'
'NRCA5_TAMASKLWBL'
'NRCA4_TAMASKSWBS'

# Module B masks and ND Squares
'NRCB1_MASK210R'
'NRCB5_MASK335R'
'NRCB5_MASK430R'
'NRCB3_MASKSWB'
'NRCB5_MASKLWB'
'NRCB1_TAMASK210R'
'NRCB5_TAMASK335R'
'NRCB5_TAMASK430R'
'NRCB3_TAMASKSWB'
'NRCB5_TAMASKLWB'
'NRCB5_TAMASKLWBL'
'NRCB3_TAMASKSWBS'

# Module A faint target acq
'NRCA2_FSTAMASK210R'
'NRCA4_FSTAMASKSWB'
'NRCA5_FSTAMASKLWB'
'NRCA5_FSTAMASK335R'
'NRCA5_FSTAMASK430R'

# Module A SWBar wavelength reference points
'NRCA4_MASKSWB_F182M'
'NRCA4_MASKSWB_F187N'
'NRCA4_MASKSWB_F210M'
'NRCA4_MASKSWB_F212N'
'NRCA4_MASKSWB_F200W'
'NRCA4_MASKSWB_NARROW'


# Module A LWBar wavelength reference points
'NRCA5_MASKLWB_F250M'
'NRCA5_MASKLWB_F300M'
'NRCA5_MASKLWB_F277W'
'NRCA5_MASKLWB_F335M'
'NRCA5_MASKLWB_F360M'
'NRCA5_MASKLWB_F356W'
'NRCA5_MASKLWB_F410M'
'NRCA5_MASKLWB_F430M'
'NRCA5_MASKLWB_F460M'
'NRCA5_MASKLWB_F480M'
'NRCA5_MASKLWB_F444W'
'NRCA5_MASKLWB_NARROW'

# Module A Full Frame
'NRCA2_FULL_MASK210R'
'NRCA5_FULL_MASK335R'
'NRCA5_FULL_MASK430R'
'NRCA4_FULL_MASKSWB'
'NRCA4_FULL_MASKSWB_F182M'
'NRCA4_FULL_MASKSWB_F187N'
'NRCA4_FULL_MASKSWB_F210M'
'NRCA4_FULL_MASKSWB_F212N'
'NRCA4_FULL_MASKSWB_F200W'
'NRCA5_FULL_MASKLWB'
'NRCA5_FULL_MASKLWB_F250M'
'NRCA5_FULL_MASKLWB_F300M'
'NRCA5_FULL_MASKLWB_F277W'
'NRCA5_FULL_MASKLWB_F335M'
'NRCA5_FULL_MASKLWB_F360M'
'NRCA5_FULL_MASKLWB_F356W'
'NRCA5_FULL_MASKLWB_F410M'
'NRCA5_FULL_MASKLWB_F430M'
'NRCA5_FULL_MASKLWB_F460M'
'NRCA5_FULL_MASKLWB_F480M'
'NRCA5_FULL_MASKLWB_F444W'

0 comments on commit d5528ac

Please sign in to comment.