Commit cd7a5f7c authored by jonas's avatar jonas
Browse files

cmilos, out_rte checks

parent ab4c30e3
......@@ -17,3 +17,4 @@ _RTE.npz
.env
run.py
P-MILOS/*
utils.py
l1/2020-11-17/solo_L1_phi-hrt-ilam_20201117T170209_V202107090920C_0051170001.fits.gz
l1/2021-02-23/solo_L1_phi-hrt-ilam_20210223T170002_V202107221048C_0142230201.fits.gz
\ No newline at end of file
......@@ -890,10 +890,10 @@ def phihrt_pipe(data_f, dark_f = '', flat_f = '', scale_data = True, bit_flat =
except ValueError:
print("Running CMILOS instead!")
cmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, start_row, start_col, out_rte_filename, out_dir)
cmilos(data_f, hdr_arr, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, start_row, start_col, out_rte_filename, out_dir)
else:
cmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, start_row, start_col, out_rte_filename, out_dir)
cmilos(data_f, hdr_arr, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, start_row, start_col, out_rte_filename, out_dir)
else:
print(" ")
......
from hrt_pipe import phihrt_pipe
import numpy as np
sciencedata_fits_filenames = ['solo_L0_phi-hrt-ilam_20200420T142022_V202004221451C_0024160031000.fits']#,'solo_L0_phi-hrt-ilam_20200420T142252_V202004221452C_0024160032000.fits','solo_L0_phi-hrt-ilam_20200420T142522_V202004221457C_0024160033000.fits','solo_L0_phi-hrt-ilam_20200420T142752_V202004221511C_0024160034000.fits','solo_L0_phi-hrt-ilam_20200420T143023_V202004221517C_0024160035000.fits', 'solo_L0_phi-hrt-ilam_20200420T143253_V202004221518C_0024160036000.fits','solo_L0_phi-hrt-ilam_20200420T143523_V202004221522C_0024160037000.fits', 'solo_L0_phi-hrt-ilam_20200420T143753_V202004231605C_0024160038000.fits','solo_L0_phi-hrt-ilam_20200420T144023_V202004231605C_0024160039000.fits']#'/data/slam/home/sinjan/fits_files/solo_L0_phi-hrt-ilam_20200420T141752_V202004221450C_0024160030000.fits'#solo_L1_phi-hrt-ilam_20201117T170209_V202107090920C_0051170001.fits'#solo_L1_phi-hrt-ilam_20201117T170209_V202107060746C_0051170001.fits'#['solo_L1_phi-hrt-ilam_20200528T171109_V202106111600C_0045140102.fits']
sciencedata_fits_filenames = ['solo_L0_phi-hrt-ilam_20201117T170209_V202106300922C_0051170001.fits']#['solo_L0_phi-hrt-ilam_20200420T142022_V202004221451C_0024160031000.fits']#,'solo_L0_phi-hrt-ilam_20200420T142252_V202004221452C_0024160032000.fits','solo_L0_phi-hrt-ilam_20200420T142522_V202004221457C_0024160033000.fits','solo_L0_phi-hrt-ilam_20200420T142752_V202004221511C_0024160034000.fits','solo_L0_phi-hrt-ilam_20200420T143023_V202004221517C_0024160035000.fits', 'solo_L0_phi-hrt-ilam_20200420T143253_V202004221518C_0024160036000.fits','solo_L0_phi-hrt-ilam_20200420T143523_V202004221522C_0024160037000.fits', 'solo_L0_phi-hrt-ilam_20200420T143753_V202004231605C_0024160038000.fits','solo_L0_phi-hrt-ilam_20200420T144023_V202004231605C_0024160039000.fits']#'/data/slam/home/sinjan/fits_files/solo_L0_phi-hrt-ilam_20200420T141752_V202004221450C_0024160030000.fits'#solo_L1_phi-hrt-ilam_20201117T170209_V202107090920C_0051170001.fits'#solo_L1_phi-hrt-ilam_20201117T170209_V202107060746C_0051170001.fits'#['solo_L1_phi-hrt-ilam_20200528T171109_V202106111600C_0045140102.fits']
# ['solo_L0_phi-hrt-ilam_20210421T120003_V202106080929C_0144210101.fits', 'solo_L0_phi-hrt-ilam_20210424T120003_V202106141014C_0144240101.fits',
# 'solo_L0_phi-hrt-ilam_20210425T120002_V202106141020C_0144250101.fits', 'solo_L0_phi-hrt-ilam_20210426T120002_V202106162118C_0144260101.fits',
......@@ -12,7 +12,7 @@ sciencedata_fits_filenames = ['solo_L0_phi-hrt-ilam_20200420T142022_V20200422145
#sciencedata_fits_filenames = ['solo_L0_phi-hrt-ilam_0667414748_V202103221851C_0142230201.fits']
#sciencedata_fits_filenames = ['solo_L0_phi-hrt-ilam_0667414905_V202103221851C_0142230602.fits', 'solo_L0_phi-hrt-ilam_0667415054_V202103221851C_0142230603.fits', 'solo_L0_phi-hrt-ilam_0667415205_V202103221851C_0142230604.fits', 'solo_L0_phi-hrt-ilam_0667415354_V202103221851C_0142230605.fits', 'solo_L0_phi-hrt-ilam_0667415505_V202103221851C_0142230606.fits', 'solo_L0_phi-hrt-ilam_0667415654_V202103221851C_0142230607.fits', 'solo_L0_phi-hrt-ilam_0667415805_V202103221851C_0142230608.fits']
flatfield_fits_filename = '/data/slam/home/sinjan/fits_files/solo_L0_phi-hrt-ilam_20200417T174529_V202004241516C_0024150020000.fits'#solo_L0_phi-hrt-flat_0667134081_V202103221851C_0162201100.fits' #solo_L0_phi-hrt-ilam_20200417T174529_V202004241516C_0024150020000.fits'#solo_L1_phi-hrt-ilam_20200417T174538_V202106111549C_0024150020.fits'#solo_L0_phi-hrt-flat_0667134081_V202103221851C_0162201100.fits'
flatfield_fits_filename = '/data/slam/home/sinjan/fits_files/solo_L0_phi-hrt-flat_0667134081_V202103221851C_0162201100.fits'#solo_L0_phi-hrt-ilam_20200417T174529_V202004241516C_0024150020000.fits'#solo_L0_phi-hrt-flat_0667134081_V202103221851C_0162201100.fits' #solo_L0_phi-hrt-ilam_20200417T174529_V202004241516C_0024150020000.fits'#solo_L1_phi-hrt-ilam_20200417T174538_V202106111549C_0024150020.fits'#solo_L0_phi-hrt-flat_0667134081_V202103221851C_0162201100.fits'
darkfield_fits_filename = '../fits_files/solo_L0_phi-fdt-ilam_20200228T155100_V202002281636_0022210004_000.fits'
sciencedata_fits_filenames = ['/data/slam/home/sinjan/fits_files/' + i for i in sciencedata_fits_filenames]
......@@ -45,12 +45,12 @@ c_talk_params[1,0] = q_int
c_talk_params[1,1] = u_int
c_talk_params[1,2] = v_int
out_names = ['0024160031000_test_rte']#, '0024160032000_noflat', '0024160033000_noflat', '0024160034000_noflat', '0024160035000_noflat', '0024160036000_noflat', '0024160037000_noflat', '0024160038000_noflat', '0024160039000_noflat']
out_names = ['nov_17_0051170001']#, '0024160032000_noflat', '0024160033000_noflat', '0024160034000_noflat', '0024160035000_noflat', '0024160036000_noflat', '0024160037000_noflat', '0024160038000_noflat', '0024160039000_noflat']
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,
phihrt_pipe(sciencedata_fits_filenames, flat_f = flatfield_fits_filename, dark_f = darkfield_fits_filename, scale_data = True,
bit_flat = True, norm_f = True, clean_f = True, 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/', rte = '-',
out_demod_filename = out_names, out_dir = '/data/slam/home/sinjan/hrt_pipe_results/nov_17_2020/', rte = 'RTE',
out_rte_filename=None, p_milos = False, config_file = True)
"""
Input Parameters:
......
......@@ -3,6 +3,7 @@ import numpy as np
import os
import time
import subprocess
import math
class bcolors:
......@@ -114,7 +115,7 @@ def fix_path(path,dir='forward',verbose=False):
else:
pass
def cmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, start_row, start_col, out_rte_filename, out_dir):
def cmilos(data_f, hdr_arr, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, start_row, start_col, out_rte_filename, out_dir):
print(" ")
printc('-->>>>>>> RUNNING CMILOS ',color=bcolors.OKGREEN)
......@@ -142,6 +143,7 @@ def cmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, st
file_path = data_f[scan]
wave_axis = wve_axis_arr[scan]
hdr = hdr_arr[scan]
#must invert each scan independently, as cmilos only takes in one dataset at a time
......@@ -230,6 +232,24 @@ def cmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, st
del_dummy = subprocess.call("rm dummy_out.txt",shell=True)
#print(del_dummy)
"""
#vlos S/C vorrection
v_x, v_y, v_z = hdr['HCIX_VOB']/1000, hdr['HCIY_VOB']/1000, hdr['HCIZ_VOB']/1000
#need line of sight velocity, should be total HCI velocity in km/s, with sun at origin.
#need to take care for velocities moving towards the sun, (ie negative) #could use continuum position as if towards or away
if cpos_arr[scan] == 5: #moving away, redshifted
dir_factor = 1
elif cpos_arr[scan] == 0: #moving towards, blueshifted
dir_factor == -1
v_tot = dir_factor*math.sqrt(v_x**2 + v_y**2+v_z**2) #in km/s
rte_invs_noth[8,:,:] = rte_invs_noth[8,:,:] - v_tot
"""
rte_data_products = np.zeros((6,rte_invs_noth.shape[1],rte_invs_noth.shape[2]))
rte_data_products[0,:,:] = rte_invs_noth[9,:,:] + rte_invs_noth[10,:,:] #continuum
......@@ -244,8 +264,16 @@ def cmilos(data_f, wve_axis_arr, data_shape, cpos_arr, data, rte, field_stop, st
if out_rte_filename is None:
filename_root = str(file_path.split('.fits')[0][-10:])
else:
if isinstance(out_rte_filename, list):
filename_root = out_rte_filename[scan]
elif isinstance(out_rte_filename, str):
filename_root = out_rte_filename
else:
filename_root = str(file_path.split('.fits')[0][-10:])
print(f"out_rte_filename neither string nor list, reverting to default: {filename_root}")
with fits.open(file_path) as hdu_list:
hdu_list[0].data = rte_data_products
hdu_list.writeto(out_dir+filename_root+'_rte_data_products.fits', overwrite=True)
......
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