Commit a36b324e authored by jonas's avatar jonas
Browse files

config, stokes V only unsharp

parent 6782de6f
......@@ -76,7 +76,7 @@ def demod_hrt(data,pmp_temp):
def phihrt_pipe(data_f, dark_f = '', flat_f = '', scale_data = True, bit_flat = True, norm_f = True, clean_f = False,
sigma = 59, flat_states = 24, prefilter_f = None,flat_c = True, dark_c = True, fs_c = True,
demod = True, norm_stokes = True, out_dir = './', out_demod_file = False, out_demod_filename = None,
ItoQUV = False, ctalk_params = None, rte = False, out_rte_filename = None, p_milos = True):
ItoQUV = False, ctalk_params = None, rte = False, out_rte_filename = None, p_milos = True, config_file = True):
'''
PHI-HRT data reduction pipeline
......@@ -150,6 +150,8 @@ def phihrt_pipe(data_f, dark_f = '', flat_f = '', scale_data = True, bit_flat =
if '', takes last 10 characters of input scan filename (assumes its a DID), change if want other name
p_milos: bool, DEFAULT = True
if True, will execute the RTE inversion using the parallel version of the CMILOS code on 16 processors
config_file: bool, DEFAULT = True
if True, will generate config.txt file that writes the reduction process steps done
Returns
-------
......@@ -167,7 +169,7 @@ def phihrt_pipe(data_f, dark_f = '', flat_f = '', scale_data = True, bit_flat =
printc('--------------------------------------------------------------',bcolors.OKGREEN)
overall_time = time.time()
saved_args = locals()
#-----------------
# READ DATA
#-----------------
......@@ -466,7 +468,7 @@ def phihrt_pipe(data_f, dark_f = '', flat_f = '', scale_data = True, bit_flat =
elif cpos_arr[0] == 5:
wv_range = range(5)
for pol in range(1,4):
for pol in range(3,4):
for wv in wv_range: #not the continuum
......@@ -892,6 +894,27 @@ def phihrt_pipe(data_f, dark_f = '', flat_f = '', scale_data = True, bit_flat =
print(" ")
printc('-->>>>>>> No RTE Inversion mode',color=bcolors.WARNING)
#-----------------
# CONFIG FILE
#-----------------
if config_file:
print(" ")
printc('-->>>>>>> Writing out config file ',color=bcolors.OKGREEN)
for count, scan in enumerate(data_f):
with open(f"{out_dir + scan_name_list[count]}" + '_hrt_pipeline_config.txt', "w") as f:
name = scan.split("/")[-1]
flat_n = flat_f.split("/")[-1]
dark_n = dark_f.split("/")[-1]
f.write(f"data_filename: {name} \n" )
f.write(f"flat_filename: {flat_n} \n")
f.write(f"dark_filename: {dark_n} \n")
f.write(f"{saved_args}")
f.close()
print(" ")
printc('--------------------------------------------------------------',color=bcolors.OKGREEN)
printc(f'------------ Reduction Complete: {np.round(time.time() - overall_time,3)} seconds',color=bcolors.OKGREEN)
......
......@@ -50,7 +50,8 @@ out_names = ['0024160031000_test_rte']#, '0024160032000_noflat', '0024160033000_
phihrt_pipe(sciencedata_fits_filenames, flat_f = flatfield_fits_filename, dark_f = darkfield_fits_filename, scale_data = False,
bit_flat = True, norm_f = True, clean_f = False, sigma = 59, flat_states = 24, norm_stokes = True, prefilter_f = None,
dark_c = True, flat_c = True, fs_c = True, demod = True, ctalk_params = c_talk_params, ItoQUV = False, out_demod_file = True,
out_demod_filename = out_names, out_dir = '/data/slam/home/sinjan/hrt_pipe_results/april_2020_pmilos/', rte = 'RTE', out_rte_filename=None, p_milos = True)
out_demod_filename = out_names, out_dir = '/data/slam/home/sinjan/hrt_pipe_results/april_2020/', rte = '-',
out_rte_filename=None, p_milos = False, config_file = True)
"""
Input Parameters:
----------
......
......@@ -324,9 +324,9 @@ def pmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, st
hdul = fits.HDUList([primary_hdu])
hdul.writeto(f'./P-MILOS/run/wavelength_tmp.fits', overwrite=True)
#create input fits file for pmilos
sdata = data[:,:,:,:,scan]
#create input fits file for pmilos
hdr = fits.Header()
hdr['CTYPE1'] = 'HPLT-TAN'
......@@ -338,17 +338,9 @@ def pmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, st
hdul = fits.HDUList([primary_hdu])
hdul.writeto(f'./P-MILOS/run/data/input_tmp.fits', overwrite=True)
#need to change settings for CE or CE+RTE in the pmilos.minit file here
printc(f' ---- >>>>> Inverting data scan number: {scan} .... ',color=bcolors.OKGREEN)
cwd = os.getcwd()
os.chdir("./P-MILOS/run/")
cmd = "mpiexec -np 10 ../pmilos.x pmilos.minit" #PMILOS_LOC+"./milos"
if rte == 'RTE':
cmd = "mpiexec -np 10 ../pmilos.x pmilos.minit"
if rte == 'CE':
cmd = "mpiexec -np 10 ../pmilos.x pmilos_ce.minit"
......@@ -356,8 +348,15 @@ def pmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, st
print("CE+RTE not possible on PMILOS, performing RTE instead")
cmd = "mpiexec -np 10 ../pmilos.x pmilos.minit"
rte_on = subprocess.call(cmd,shell=True)
del sdata
#need to change settings for CE or CE+RTE in the pmilos.minit file here
printc(f' ---- >>>>> Inverting data scan number: {scan} .... ',color=bcolors.OKGREEN)
cwd = os.getcwd()
os.chdir("./P-MILOS/run/")
rte_on = subprocess.call(cmd,shell=True)
os.chdir(cwd)
if rte == 'CE':
......@@ -369,10 +368,11 @@ def pmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, st
with fits.open(f'./P-MILOS/run/results/{out_file}') as hdu_list:
result = hdu_list[0].data
#del_dummy = subprocess.call(f"rm ./P-MILOS/run/results/{out_file}.fits",shell=True)
del_dummy = subprocess.call(f"rm ./P-MILOS/run/results/{out_file}.fits",shell=True) #must delete the output file
#result has dimensions [rows,cols,13]
print(result.shape)
"""
PMILOS Output 13 columns
0. eta0 = line-to-continuum absorption coefficient ratio
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment