In [2]:
import scda
import pprint
import logging
import os
scda.configure_log()

Prepare a single SCDA design

Set the design parameters


In [3]:
pupil_params = {'N': 300, 'prim':'hex4', 'centobs':True, 'secobs':'X', 'thick':'025'}
fpm_params = {'rad': 4.}
ls_params = {'shape':'ann', 'obscure':1, 'ppad':0, 'spad':5, 'id':25, 'od':90}
image_params = {'c': 10., 'ida':3.5, 'oda':10., 'bw':0.10, 'Nlam':3}

In [4]:
ampl_dir = "../hex4_design_test_ntz" # where to write the AMPL source code
if not os.path.exists(ampl_dir):
    os.mkdir(ampl_dir)
#input_dir = "/astro/opticslab1/SCDA/Apertures/STSCI" # location of input TelAp, FPM, and LS arrays
input_dir = "../Apertures/STSCI/" # location of input TelAp, FPM, and LS arrays
sol_dir = "../hex4_design_test_ntz"

In [5]:
design_params = {'Pupil': pupil_params, 'FPM': fpm_params, 'LS': ls_params, 'Image': image_params}
fileorg = {'work dir': ampl_dir, 'TelAp dir': input_dir,
           'FPM dir': input_dir, 'LS dir': input_dir, 'sol dir': sol_dir}
#solver_params = {'method': 'barhom'}
solver_params = {'method': 'bar'}

Initiate a coronagraph object with the above parameters


In [6]:
hexap_coron = scda.QuarterplaneAPLC(design=design_params, fileorg=fileorg, solver=solver_params)


WARNING:root:Warning: The specified location of 'TelAp dir', "../Apertures/STSCI/" does not exist
WARNING:root:Warning: The specified location of 'FPM dir', "../Apertures/STSCI/" does not exist
WARNING:root:Warning: The specified location of 'LS dir', "../Apertures/STSCI/" does not exist

Show the file organization for the coronagraph


In [7]:
hexap_coron.fileorg


Out[7]:
{'FPM dir': '../Apertures/STSCI/',
 'FPM fname': '../Apertures/STSCI/FPM_quart_occspot_M050.dat',
 'LS dir': '../Apertures/STSCI/',
 'LS fname': '../Apertures/STSCI/LS_quart_ann25D90_X025cobs1Pad05_N0300.dat',
 'TelAp dir': '../Apertures/STSCI/',
 'TelAp fname': '../Apertures/STSCI/TelAp_quart_hex4X025cobs1_N0300.dat',
 'ampl src dir': '../hex4_design_test_ntz',
 'ampl src fname': '../hex4_design_test_ntz/APLC_quart_hex4X025cobs1_N0300_FPM400M050_LSann25D90X025cobs1Pad05_Img100C_35DA100_BW10Nlam03fpres2_linbarpre1.mod',
 'eval dir': '../hex4_design_test_ntz',
 'exec script dir': '../hex4_design_test_ntz',
 'exec script fname': '../hex4_design_test_ntz/APLC_quart_hex4X025cobs1_N0300_FPM400M050_LSann25D90X025cobs1Pad05_Img100C_35DA100_BW10Nlam03fpres2_linbarpre1.sh',
 'job name': 'APLC_quart_hex4X025cobs1_N0300_FPM400M050_LSann25D90X025cobs1Pad05_Img100C_35DA100_BW10Nlam03fpres2_linbarpre1',
 'log dir': '../hex4_design_test_ntz',
 'log fname': '../hex4_design_test_ntz/APLC_quart_hex4X025cobs1_N0300_FPM400M050_LSann25D90X025cobs1Pad05_Img100C_35DA100_BW10Nlam03fpres2_linbarpre1.log',
 'sol dir': '../hex4_design_test_ntz',
 'sol fname': '../hex4_design_test_ntz/ApodSol_APLC_quart_hex4X025cobs1_N0300_FPM400M050_LSann25D90X025cobs1Pad05_Img100C_35DA100_BW10Nlam03fpres2_linbarpre1.dat',
 'work dir': '../hex4_design_test_ntz'}

Check the status of input files needed to run the AMPL program


In [8]:
hexap_coron.check_ampl_input_files()


Out[8]:
False

Write the AMPL source file


In [9]:
hexap_coron.write_ampl(override_infile_status=True, overwrite=False)


INFO:root:Wrote ../hex4_design_test_ntz/APLC_quart_hex4X025cobs1_N0300_FPM400M050_LSann25D90X025cobs1Pad05_Img100C_35DA100_BW10Nlam03fpres2_linbarpre1.mod

Evaluate basic coronagraph metrics


In [10]:
hexap_coron.get_metrics()


---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-10-060571aeeee1> in <module>()
----> 1 hexap_coron.get_metrics()

/Users/ntz/SCDA/scda_pytools/scda.pyc in get_metrics(self, fp2res, verbose)
   1566 
   1567     def get_metrics(self, fp2res=16, verbose=True):
-> 1568         TelAp = np.loadtxt(self.fileorg['TelAp fname'])
   1569         FPM = np.loadtxt(self.fileorg['FPM fname'])
   1570         LS = np.loadtxt(self.fileorg['LS fname'])

/usr/stsci/ssbdev/python/lib/python2.7/site-packages/numpy/lib/npyio.pyc in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin)
    735                 fh = iter(bz2.BZ2File(fname))
    736             elif sys.version_info[0] == 2:
--> 737                 fh = iter(open(fname, 'U'))
    738             else:
    739                 fh = iter(open(fname))

IOError: [Errno 2] No such file or directory: '../Apertures/STSCI/TelAp_quart_hex4X025cobs1_N0300.dat'

In [ ]: