<jupyter_start><jupyter_text>Single APLC design evaluation, without LS alignment tolerance  Set the design parameters<jupyter_code>pupil_params = {'N': 500, 'prim':'hex4', 'centobs':True, 'secobs':'X', 'thick':'025'}
fpm_params = {'rad': 4., 'M':60}
ls_params_noaligntol = {'obscure':0, 'id':28, 'od':83, 'aligntol':None}
image_params = {'c': 10., 'ida':-0.5, 'oda':10., 'bw':0., 'Nlam':1, 'fpres':2}
#work_dir = "."
work_dir = os.path.normpath("/astro/opticslab1/SCDA/Scripts/AMPL/qpaplc_tests/")
if not os.path.exists(os.path.normpath(work_dir)):
    os.mkdir(work_dir)
#input_dir = "./InputMasks" # location of input TelAp, FPM, and LS arrays
#input_dir = "/astro/opticslab1/SCDA/Scripts/AMPL/scda_qpaplc_tests/InputMasks/"
input_dir = os.path.normpath("/astro/opticslab1/SCDA/Apertures/InputMasks/")
TelAp_dir = os.path.join(input_dir, "TelAp")
FPM_dir = os.path.join(input_dir, "FPM")
LS_dir = os.path.join(input_dir, "LS")
design_params_noaligntol = {'Pupil': pupil_params, 'FPM': fpm_params,
                            'LS': ls_params_noaligntol, 'Image': image_params}
fileorg = {'work dir': work_dir, 'TelAp dir': TelAp_dir,
           'FPM dir': FPM_dir, 'LS dir': LS_dir}
bar_solver = {'method': 'bar'}
barhom_solver = {'method': 'barhom', 'convtol': 9.}
#dualsimp_solver = {'method': 'dualsimp'}
#barhom_solver = {'method': 'barhom'}<jupyter_output><empty_output><jupyter_text>Initiate the coronagraph object<jupyter_code>hexap_coron = scda.QuarterplaneAPLC(design=design_params_noaligntol, fileorg=fileorg, solver=barhom_solver)<jupyter_output><empty_output><jupyter_text>Show the file organization<jupyter_code>hexap_coron.fileorg<jupyter_output><empty_output><jupyter_text>Check the status of input files needed to run the AMPL program<jupyter_code>hexap_coron.check_ampl_input_files()
print("All the input files for AMPL are in place? {0:}".format(hexap_coron.ampl_infile_status))<jupyter_output>All the input files for AMPL are in place? True<jupyter_text>Write the AMPL source file<jupyter_code>hexap_coron.write_ampl(override_infile_status=False, overwrite=True)<jupyter_output>WARNING:root:Warning: Overwriting the existing copy of /astro/opticslab1/SCDA/Scripts/AMPL/qpaplc_tests/APLC_quart_hex4X025cobs1_N0500_FPM400M060_LSann28D83clear_Img100C_35DA100_BW00Nlam01fpres2_linbarhompre1convtol90.mod<jupyter_text>Create a bundled source + input file subdirectory for both designs<jupyter_code>bundled_dir = os.path.join(hexap_coron.fileorg['work dir'], "qpaplc_ampl_bundle")
#bundled_coron_list = scda.make_ampl_bundle([hexap_coron_noaligntol, hexap_coron_aligntol], bundled_dir)
#os.listdir(bundled_dir)<jupyter_output><empty_output><jupyter_text>Evaluate basic coronagraph metrics<jupyter_code>hexap_coron.get_metrics()<jupyter_output><empty_output><jupyter_text>Full-plane on-axis PSF evaluation  Reset input file locations, in case out of STScI network<jupyter_code>#hexap_coron.fileorg['TelAp fname'] = os.path.join(os.path.expanduser("~/Box Sync/scda/InputMasks/TelAp"),
#                                                  os.path.basename(hexap_coron.fileorg['TelAp fname']))

#hexap_coron.fileorg['FPM fname'] = os.path.join(os.path.expanduser("~/Box Sync/scda/InputMasks/FPM"),
#                                                os.path.basename(hexap_coron.fileorg['FPM fname']))

#hexap_coron.fileorg['LS fname'] = os.path.join(os.path.expanduser("~/Box Sync/scda/InputMasks/LS"),
#                                               os.path.basename(hexap_coron.fileorg['LS fname']))<jupyter_output><empty_output><jupyter_text>Load and reorganize mask arrays<jupyter_code>TelAp_qp = np.loadtxt(hexap_coron.fileorg['TelAp fname'])
TelAp = np.concatenate((np.concatenate((TelAp_qp[::-1,::-1], TelAp_qp[:,::-1]),axis=0),
                        np.concatenate((TelAp_qp[::-1,:], TelAp_qp),axis=0)), axis=1)

FPM_qp = np.loadtxt(hexap_coron.fileorg['FPM fname'])
FPM = np.concatenate((np.concatenate((FPM_qp[::-1,::-1], FPM_qp[:,::-1]),axis=0),
                      np.concatenate((FPM_qp[::-1,:], FPM_qp),axis=0)), axis=1)

LS_qp = np.loadtxt(hexap_coron.fileorg['LS fname'])
LS = np.concatenate((np.concatenate((LS_qp[::-1,::-1], LS_qp[:,::-1]),axis=0),
                     np.concatenate((LS_qp[::-1,:], LS_qp),axis=0)), axis=1)

#new_sol_fname = os.path.join(hexap_coron.fileorg['sol dir'],
#                             "ApodSol_APLC_quart_hex3X025cobs1_N0250_FPM400M050_LSann25D85clear_Img100C_35DA080_BW10Nlam03fpres2_linbarhompre1convtol2e9.dat")
#                             "ApodSol_APLC_quart_hex3X025cobs1_N0125_FPM400M050_LSann25D85clear_Img100C_35DA080_BW10Nlam03fpres2_linbarhompre1_convtol1e9.dat")
#                             "ApodSol_APLC_quart_hex3X025cobs1_N0125_FPM400M050_LSann25D85clear_Img100C_35DA080_BW10Nlam03fpres2_linbarpre1_ftol.dat")
#hexap_coron.fileorg['sol fname'] = new_sol_fname
#hexap_coron.design['Image']['bw'] = 0.10

A_col = np.loadtxt(hexap_coron.fileorg['sol fname'])[:,-1]
A_qp = A_col.reshape(TelAp_qp.shape)
A = np.concatenate((np.concatenate((A_qp[::-1,::-1], A_qp[:,::-1]),axis=0),
                    np.concatenate((A_qp[::-1,:], A_qp),axis=0)), axis=1)

plt.figure(figsize=(8,8))
plt.imshow(A*TelAp)
psf_img_polychrom, radial_seps, radial_psf_profile_polychrom = hexap_coron.eval_onax_psf(Nlam=1)
plt.figure(figsize=(10,8))
plt.imshow(np.log10(psf_img_polychrom[-2]), vmin=-11, vmax=-7, cmap='CMRmap')
plt.colorbar()<jupyter_output><empty_output><jupyter_text>Radial PSF profile<jupyter_code>plt.figure(figsize=(10,8))
plt.plot(radial_seps, np.log10(radial_psf_profile_polychrom[0,:]))
plt.plot(radial_seps, np.log10(radial_psf_profile_polychrom[radial_psf_profile_polychrom.shape[0]/2,:]))
plt.plot(radial_seps, np.log10(radial_psf_profile_polychrom[-1,:]))
plt.legend(['blue','center','red'], loc='upper left')
plt.xlabel('angular sep. (lambda_0/D)')
plt.ylabel('log10(I/I0)')
radial_psf_profile_polychrom[-1,0]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1552627132961649, 'fraction_numerical': 0.039026862645717184, 'mean_word_length': 5.796785304247991, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '211859', 'license': 'MIT', 'n_tokens_mistral': 2556, 'n_tokens_neox': 2385, 'n_words': 281, 'path': 'examples/qpaplc_tests.ipynb', 'repo_name': 'neilzim/SCDA', 'size': '5919'}