-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
(#675)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,9 +30,8 @@ | |
# Define a default set of bandpasses for which this routine works. | ||
default_bandpass_list = ['J129', 'F184', 'W149', 'Y106', 'Z087', 'H158'] | ||
# Prefix for files containing information about Zernikes for each SCA. | ||
zemax_filepref = os.path.join(galsim.meta_data.share_dir, | ||
"AFTA_WFI_v4-2-5_140326_192nmRMS_NoAps_PLT_Zemax_ZernStanTerm_C") | ||
zemax_filesuff = '_F01_W04.txt' | ||
zemax_filepref = "AFTA_C5_WFC_Zernike_Data_150717_SCA" | ||
zemax_filesuff = '.txt' | ||
zemax_wavelength = 1293. #nm | ||
|
||
def getPSF(SCAs=None, approximate_struts=False, n_waves=None, extra_aberrations=None, | ||
|
@@ -42,8 +41,8 @@ def getPSF(SCAs=None, approximate_struts=False, n_waves=None, extra_aberrations= | |
By default, this routine returns a dict of ChromaticOpticalPSF objects, with the dict indexed by | ||
the SCA (Sensor Chip Array, the equivalent of a chip in an optical CCD). The PSF for a given | ||
SCA corresponds to that for the center of the SCA. Currently we do not have information about | ||
PSF variation within each SCA, though it is expected to be relatively small. | ||
SCA corresponds to that for the center of the SCA. Currently we do not use information about | ||
PSF variation within each SCA, which is relatively small. | ||
This routine also takes an optional keyword `SCAs`, which can be a single number or an iterable; | ||
if this is specified then results are not included for the other SCAs. | ||
|
@@ -77,9 +76,10 @@ def getPSF(SCAs=None, approximate_struts=False, n_waves=None, extra_aberrations= | |
part of the design. This should be in the same format as for the ChromaticOpticalPSF class, | ||
with units of waves at the fiducial wavelength, 1293 nm. Currently, only aberrations up to order | ||
11 (Noll convention) can be simulated. For WFIRST, the current tolerance for additional | ||
aberrations is a total of 195 nanometers RMS, distributed largely among coma, astigmatism, | ||
trefoil, and spherical aberrations (NOT defocus). This information might serve as a guide for | ||
reasonable `extra_aberrations` inputs. | ||
aberrations is a total of 90 nanometers RMS: | ||
http://wfirst.gsfc.nasa.gov/science/sdt_public/wps/references/instrument/README_AFTA_C5_WFC_Zernike_and_Field_Data.pdf | ||
distributed largely among coma, astigmatism, trefoil, and spherical aberrations (NOT defocus). | ||
This information might serve as a guide for reasonable `extra_aberrations` inputs. | ||
Jitter and charge diffusion are, by default, not included. Users who wish to include these can | ||
find some guidelines for typical length scales of the Gaussians that can represent these | ||
|
@@ -184,32 +184,12 @@ def getPSF(SCAs=None, approximate_struts=False, n_waves=None, extra_aberrations= | |
raise TypeError("Keyword 'wavelength' should either be a Bandpass, float," | ||
" or None.") | ||
|
||
# Start reading in the aberrations for the relevant SCAs. Take advantage of symmetries, so we | ||
# don't have to call the reading routine too many times. | ||
# Start reading in the aberrations for the relevant SCAs. | ||
aberration_dict = {} | ||
PSF_dict = {} | ||
if logger: logger.debug('Beginning to loop over SCAs and get the PSF:') | ||
for SCA in SCAs: | ||
# Check if it's above 10. If it is, the design aberrations are the same as for the SCA with | ||
# index that is 9 lower, except for certain sign flips (astig1, coma2, trefoil2) that result | ||
# in symmetry about the FPA y axis (except for the struts). | ||
read_SCA = SCA | ||
if SCA >= 10: | ||
read_SCA -= 9 | ||
# Check if we already read it in. If so, just take the previously-read one, but do the | ||
# necessary flips to account for symmetry. | ||
if read_SCA in aberration_dict.keys(): | ||
tmp_aberrations = aberration_dict[read_SCA] | ||
tmp_aberrations *= np.array([1.,1.,1.,1.,1.,-1.,1.,1.,-1.,1.,-1.,1.]) | ||
aberration_dict[SCA]=tmp_aberrations | ||
read_SCA = -1 # This tells the routine not to bother reading it in. | ||
|
||
# If we got here, then it means we have to read in the aberrations. | ||
if read_SCA > 0: | ||
aberrations = _read_aberrations(read_SCA) | ||
if read_SCA != SCA: | ||
aberrations *= np.array([1.,1.,1.,1.,1.,-1.,1.,1.,-1.,1.,-1.,1.]) | ||
aberration_dict[SCA]=aberrations | ||
aberration_dict[SCA] = _read_aberrations(SCA) | ||
|
||
use_aberrations = aberration_dict[SCA] | ||
if extra_aberrations is not None: | ||
|
@@ -410,19 +390,20 @@ def _read_aberrations(SCA): | |
This is a helper routine that reads in aberrations for a particular SCA and wavelength from | ||
stored files. It returns the aberrations in a format required by ChromaticOpticalPSF. | ||
@param SCA The identifier for the SCA, from 1-9. | ||
@param SCA The identifier for the SCA, from 1-18. | ||
@returns a NumPy array containing the aberrations, in the required format for | ||
ChromaticOpticalPSF. | ||
""" | ||
if SCA < 1 or SCA > 9: | ||
if SCA < 1 or SCA > galsim.wfirst.n_sca: | ||
raise ValueError("SCA requested is out of range: %d"%SCA) | ||
|
||
# Construct filename. | ||
sca_str = '%02d'%SCA | ||
infile = zemax_filepref + sca_str + zemax_filesuff | ||
infile = os.path.join(galsim.meta_data.share_dir, | ||
zemax_filepref + sca_str + zemax_filesuff) | ||
|
||
# Read in data. | ||
dat = np.loadtxt(infile, skiprows=41, usecols=(2,)).transpose() | ||
dat = np.loadtxt(infile).transpose() | ||
# Put it in the required format: an array of length 12, with the first entry empty (Zernike | ||
# polynomials are 1-indexed so we use entries 1-11). The units are waves. | ||
aberrations = np.zeros(12) | ||
|
@@ -448,3 +429,37 @@ def _find_limits(bandpasses, bandpass_dict): | |
if bp.blue_limit < min_wave: min_wave = bp.blue_limit | ||
if bp.red_limit > max_wave: max_wave = bp.red_limit | ||
return min_wave, max_wave | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rmandelb
Author
Member
|
||
def _parse_new_zernikes(infile, out_dir): | ||
""" | ||
This is a helper routine to parse the new WFIRST Zernike information from | ||
http://wfirst.gsfc.nasa.gov/science/sdt_public/wps/references/instrument/ | ||
More specifically, it takes as input a tab-separated version of the Zernike information in | ||
AFTA_C5_WFC_Zernike_and_Field_Data_150717.xlsx | ||
isolates the entries for the center of each SCA and our wavelength that we use as default (1293 | ||
nm), and makes output in the per-SCA format that the `_read_aberrations` routine wants. | ||
""" | ||
dat = np.loadtxt(infile).transpose() | ||
sca_num = dat[0,:] | ||
wave = dat[1,:] #in microns | ||
field_pos = dat[2,:] | ||
aberrs = dat[12:23,:] | ||
|
||
# select out SCA centers (field_pos = 1) and default wavelength | ||
to_use = np.logical_and.reduce( | ||
[field_pos == 1, | ||
1000*wave == zemax_wavelength]) | ||
sca_num = sca_num[to_use] | ||
aberrs = aberrs[:,to_use] | ||
|
||
for SCA in galsim.wfirst._parse_SCAs(None): | ||
|
||
# Construct filename. | ||
sca_str = '%02d'%SCA | ||
outfile = os.path.join(out_dir, zemax_filepref+sca_str+zemax_filesuff) | ||
outarr = aberrs[:,sca_num==SCA] | ||
np.savetxt(outfile, outarr) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-4.724799999999999833e-02 | ||
-2.273400000000000074e-02 | ||
7.273499999999999410e-02 | ||
-2.048900000000000027e-02 | ||
-4.168199999999999683e-02 | ||
-3.583100000000000174e-02 | ||
2.767899999999999874e-02 | ||
-8.961999999999999481e-03 | ||
-1.714000000000000029e-03 | ||
1.069699999999999991e-02 | ||
5.819999999999999653e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-5.649999999999999641e-03 | ||
-3.415599999999999886e-02 | ||
9.917299999999999727e-02 | ||
4.223000000000000191e-03 | ||
-3.266100000000000253e-02 | ||
-2.707499999999999837e-02 | ||
3.652199999999999891e-02 | ||
-1.267500000000000050e-02 | ||
-1.180999999999999975e-03 | ||
4.553999999999999888e-03 | ||
6.359000000000000069e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-6.081400000000000000e-02 | ||
2.328000000000000208e-03 | ||
2.418899999999999870e-02 | ||
-2.901099999999999859e-02 | ||
-4.475500000000000311e-02 | ||
-4.003099999999999714e-02 | ||
1.094099999999999934e-02 | ||
-3.770000000000000022e-04 | ||
-2.037000000000000182e-03 | ||
1.909399999999999986e-02 | ||
5.283999999999999635e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-5.381600000000000272e-02 | ||
-1.834900000000000073e-02 | ||
7.571100000000000052e-02 | ||
-2.423200000000000007e-02 | ||
-2.516699999999999840e-02 | ||
-4.506099999999999689e-02 | ||
2.890900000000000067e-02 | ||
-6.877000000000000300e-03 | ||
-7.842000000000000012e-03 | ||
7.087999999999999683e-03 | ||
5.857000000000000227e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-1.700799999999999881e-02 | ||
-1.973000000000000101e-02 | ||
1.029319999999999957e-01 | ||
-2.327000000000000075e-03 | ||
-1.638799999999999979e-02 | ||
-3.395299999999999707e-02 | ||
3.803000000000000130e-02 | ||
-7.034000000000000322e-03 | ||
-4.394999999999999601e-03 | ||
1.965000000000000167e-03 | ||
6.364999999999999998e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-6.721380000000000410e-02 | ||
-4.647599999999999995e-03 | ||
2.665384000000000156e-02 | ||
-3.262922000000000045e-02 | ||
-3.013102999999999962e-02 | ||
-4.966459000000000151e-02 | ||
1.199023999999999923e-02 | ||
-2.316239999999999792e-03 | ||
-1.133218000000000072e-02 | ||
1.455521000000000072e-02 | ||
5.343819999999999994e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-6.779699999999999616e-02 | ||
-1.274400000000000012e-02 | ||
7.818300000000000249e-02 | ||
-3.223899999999999683e-02 | ||
-3.348999999999999980e-03 | ||
-4.537599999999999967e-02 | ||
2.982999999999999888e-02 | ||
-4.277000000000000419e-03 | ||
-1.026999999999999962e-02 | ||
-2.000000000000000096e-04 | ||
5.908000000000000057e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-4.154900000000000260e-02 | ||
-4.445000000000000166e-03 | ||
1.011770000000000030e-01 | ||
-1.651899999999999896e-02 | ||
4.076999999999999895e-03 | ||
-3.003300000000000067e-02 | ||
3.745300000000000018e-02 | ||
-1.005000000000000034e-03 | ||
-4.542000000000000030e-03 | ||
-2.801999999999999803e-03 | ||
6.347000000000000211e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-7.956399999999999584e-02 | ||
-1.116699999999999984e-02 | ||
3.444900000000000045e-02 | ||
-3.962999999999999856e-02 | ||
-1.019399999999999994e-02 | ||
-5.295199999999999907e-02 | ||
1.479699999999999939e-02 | ||
-4.010999999999999809e-03 | ||
-1.643999999999999975e-02 | ||
4.877000000000000259e-03 | ||
5.444000000000000054e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-4.662299999999999778e-02 | ||
-2.683100000000000068e-02 | ||
7.003600000000000103e-02 | ||
-2.015000000000000124e-02 | ||
-5.151700000000000029e-02 | ||
-2.117399999999999838e-02 | ||
2.643099999999999963e-02 | ||
-1.087199999999999972e-02 | ||
5.167999999999999851e-03 | ||
9.613000000000000017e-03 | ||
5.802999999999999999e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-5.133999999999999675e-03 | ||
-4.652799999999999991e-02 | ||
9.120999999999999941e-02 | ||
4.499000000000000395e-03 | ||
-4.186100000000000237e-02 | ||
-1.375299999999999960e-02 | ||
3.341000000000000220e-02 | ||
-1.751499999999999932e-02 | ||
2.732000000000000053e-03 | ||
3.908000000000000015e-03 | ||
6.342000000000000415e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-6.008999999999999758e-02 | ||
7.184000000000000281e-03 | ||
2.719200000000000089e-02 | ||
-2.861599999999999908e-02 | ||
-5.408999999999999919e-02 | ||
-2.647400000000000100e-02 | ||
1.171299999999999945e-02 | ||
8.850000000000000444e-04 | ||
8.028000000000000413e-03 | ||
1.754999999999999963e-02 | ||
5.266999999999999980e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-5.199299999999999755e-02 | ||
-3.130100000000000243e-02 | ||
6.720299999999999885e-02 | ||
-2.324599999999999930e-02 | ||
-5.351999999999999813e-02 | ||
-3.762999999999999852e-03 | ||
2.502000000000000057e-02 | ||
-1.283899999999999972e-02 | ||
9.941999999999999449e-03 | ||
4.244999999999999642e-03 | ||
5.806000000000000397e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-1.550699999999999995e-02 | ||
-5.592300000000000049e-02 | ||
7.964200000000000446e-02 | ||
-1.528000000000000061e-03 | ||
-4.221300000000000052e-02 | ||
1.994999999999999812e-03 | ||
2.890399999999999914e-02 | ||
-2.122699999999999934e-02 | ||
4.989999999999999644e-03 | ||
3.690000000000000246e-04 | ||
6.311999999999999902e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-6.510085000000000177e-02 | ||
7.950850000000000625e-03 | ||
3.441302999999999723e-02 | ||
-3.147533999999999749e-02 | ||
-5.763507999999999826e-02 | ||
-1.026224000000000060e-02 | ||
1.386299000000000038e-02 | ||
7.726799999999999814e-04 | ||
1.558935000000000008e-02 | ||
1.038583000000000041e-02 | ||
5.292690000000000068e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-6.494600000000000373e-02 | ||
-3.583100000000000174e-02 | ||
6.307899999999999618e-02 | ||
-3.070399999999999865e-02 | ||
-4.617500000000000077e-02 | ||
1.327799999999999987e-02 | ||
2.302099999999999980e-02 | ||
-1.474400000000000016e-02 | ||
1.004200000000000058e-02 | ||
-3.595000000000000105e-03 | ||
5.821999999999999918e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-3.921499999999999986e-02 | ||
-6.064800000000000052e-02 | ||
6.501899999999999347e-02 | ||
-1.528400000000000071e-02 | ||
-3.252000000000000030e-02 | ||
1.535399999999999959e-02 | ||
2.318599999999999828e-02 | ||
-2.320200000000000040e-02 | ||
3.602000000000000167e-03 | ||
-4.356999999999999762e-03 | ||
6.259999999999999939e-03 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-7.624100000000000321e-02 | ||
3.661999999999999891e-03 | ||
4.347600000000000076e-02 | ||
-3.782200000000000145e-02 | ||
-5.377699999999999841e-02 | ||
7.230000000000000315e-03 | ||
1.653500000000000109e-02 | ||
-1.046999999999999971e-03 | ||
1.760499999999999912e-02 | ||
-5.330000000000000536e-04 | ||
5.359000000000000048e-03 |
The helper routine
_parse_new_zernikes
is run only once (by @rmandelb ) and only the output files are distributed. Assuming that the Zernike coefficients are changed in future and are made available in the exact same format, should we just let the users run this routine to update their files or should we update the GalSim? If it's the former, then I would suggest letting the user know about this routine that the user can run to update the coefficients. Otherwise, should this even be a part of the code?