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

Prepare a design survey test to run on NCCS Discover


In [2]:
survey_params = {'Pupil': { 'prim': ['hex1', 'hex2', 'hex3', 'hex4'],
                 'secobs': 'X',
                 'thick': '025',
                 'centobs': [True],
                 'N': 250 },
                 'FPM': { 'rad': 4. },
                 'LS': { 'shape':'ann', 'obscure':1, 'spad':[5,10], 'id':[20, 25, 30], 'od':85 },
                 'Image': { 'ida':3.5, 'bw':0.10, 'Nlam':3 }}

In [3]:
survey_dir = "./nccs_survey_test/"
ampl_src_dir = os.path.join(survey_dir, "amplsrc")
sol_dir = os.path.join(survey_dir, "solutions")
log_dir = os.path.join(survey_dir, "logs")
TelAp_dir = "./InputMasks/TelAp"
LS_dir = "./InputMasks/LS"
FPM_dir = "./InputMasks/FPM"

fileorg = {'work dir':survey_dir, 'ampl src dir':ampl_src_dir, 'log dir':log_dir, 'sol dir':sol_dir,
           'TelAp dir':TelAp_dir, 'LS dir':LS_dir, 'FPM dir':FPM_dir}

Initiate a survey object with the above parameter combinations


In [4]:
hexap_survey = scda.DesignParamSurvey(scda.QuarterplaneAPLC, survey_params, fileorg=fileorg)
print("This survey has {0:d} design parameter combinations.".format(hexap_survey.N_combos))
print("{0:d} parameters are varied: {1}".format(len(hexap_survey.varied_param_index), hexap_survey.varied_param_index))


This survey has 24 design parameter combinations.
4 parameters are varied: (('Pupil', 'prim'), ('Pupil', 'centobs'), ('LS', 'id'), ('LS', 'spad'))

Show the file organization scheme


In [5]:
pprint.pprint(hexap_survey.fileorg)


{'FPM dir': './InputMasks/FPM',
 'LS dir': './InputMasks/LS',
 'TelAp dir': './InputMasks/TelAp',
 'ampl src dir': './nccs_survey_test/amplsrc',
 'eval dir': './nccs_survey_test/',
 'exec script dir': './nccs_survey_test/',
 'log dir': './nccs_survey_test/logs',
 'sol dir': './nccs_survey_test/solutions',
 'work dir': './nccs_survey_test/'}

Show some attributes of an individual coronagraph object


In [6]:
#i = 100
i = 0
print("Telescope aperture file for design #{:d}: {:s}".format(i+1, hexap_survey.coron_list[i].fileorg['TelAp fname']))
print("Focal plane mask file for design #{:d}: {:s}".format(i+1, hexap_survey.coron_list[i].fileorg['FPM fname']))
print("Lyot stop file for design #{:d}: {:s}".format(i+1, hexap_survey.coron_list[i].fileorg['LS fname']))


Telescope aperture file for design #1: ./InputMasks/TelAp/TelAp_quart_hex1X025cobs1_N0250.dat
Focal plane mask file for design #1: ./InputMasks/FPM/FPM_quart_occspot_M050.dat
Lyot stop file for design #1: ./InputMasks/LS/LS_quart_ann20D85_X025cobs1Pad05_N0250.dat

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


In [7]:
hexap_survey.check_ampl_input_files()


Out[7]:
False

List the varying parameter combinations


In [8]:
# pprint.pprint(hexap_survey.varied_param_combos)

Write the batch of AMPL files


In [9]:
hexap_survey.write_ampl_batch(override_infile_status=True, overwrite=True)


INFO:root:Wrote the batch of design survey AMPL programs into ./nccs_survey_test/amplsrc

Write the batch of queue execution scripts


In [10]:
hexap_survey.write_exec_script_batch(overwrite=True)


INFO:root:Wrote the batch of execution scripts into ./nccs_survey_test/

Write tables summarizing the design survey configuration and status to a spreadsheet


In [11]:
hexap_survey.write_spreadsheet()


INFO:root:Wrote design survey spreadsheet to ./nccs_survey_test/scda_QuarterplaneAPLC_survey_ntz_2016-03-30.csv

Store the design survey as a serialized python object


In [12]:
hexap_survey.write()


INFO:root:Wrote the design parameter survey object to ./nccs_survey_test/scda_QuarterplaneAPLC_survey_ntz_2016-03-30.pkl

Load an existing design survey


In [13]:
mysurvey = scda.load_design_param_survey(hexap_survey.fileorg['survey fname'])

In [ ]: