Commit 540637e5 authored by Arthur Vigan's avatar Arthur Vigan
Browse files

Minor cosmetic modifications

parent b294e868
......@@ -14,10 +14,10 @@ from utils_basic import minterp2d, DISPER, VECT, VECT1, BEAMSHIFT, ELEVATION, PA
start_time = time.time()
HARMONI_DIR = '/Users/avigan/Work/HARMONI/Simulations/harmoni-hc/hrm-hc/'
COM_DIR = '/Users/avigan/Work/HARMONI/Simulations/harmoni-hc/hrm-hc/COMMON_FILES/'
# HARMONI_DIR = '/Users/carlotal/harmoni-hc/hrm-hc'
# COM_DIR = '/Users/carlotal/harmoni-hc/hrm-hc/COMMON_FILES/'
# HARMONI_DIR = '/Users/avigan/Work/HARMONI/Simulations/harmoni-hc/hrm-hc/'
# COM_DIR = '/Users/avigan/Work/HARMONI/Simulations/harmoni-hc/hrm-hc/COMMON_FILES/'
HARMONI_DIR = '/Users/carlotal/harmoni-hc/hrm-hc'
COM_DIR = '/Users/carlotal/harmoni-hc/hrm-hc/COMMON_FILES/'
# Artifical dispersion corrector (dispersion is gamma times what it should be)
gamma = 1#%0.1;%1;
......@@ -651,7 +651,7 @@ for i in range(len(HA_vect)):
WF_NCPA_0 = np.squeeze(WF_NCPA_0)
WF_0=(WF_CP_0-WF_corr_0+EELT_phase_0+WF_NCPA_0)
DSP_V,DSP_I = DSP(WF_0,BigD/D,np.transpose(ORIGINAL_PUPIL),0,1000)
DSP_V, DSP_I = DSP(WF_0, BigD/D, np.transpose(ORIGINAL_PUPIL), 0, 1000)
log.info('HA={0}: Aberration level (0-1000 lambda/D) at {1} nm: {2} nm'.format(HA_0, lambda_vect[k]*1e9, 1e9*DSP_V))
#DSP_V, DSP_I = DSP(WF_CP_0+EELT_phase_0+WF_NCPA_0, 1132/1024, PUPILLE_0, 2, 30)
......@@ -662,11 +662,11 @@ for i in range(len(HA_vect)):
OWA = MAS2LD(FOV, 38.542, lambda_vect[k])/2
if ADC_flag == 1:
#alpha_disp_0 = MAS2LD(1000*DISPER_ADC(1.45,lambda_vect[k]*1e6,90-ELEVATION(DEC,HA_0),z_min,z_max),38.542,lambda_vect[k])-MAS2LD(1000*DISPER_ADC(1.45,lambda_vect[-1]*1e6,90-ELEVATION(DEC,HA_0),z_min,z_max),38.542,lambda_vect[k])
alpha_disp_0 = MAS2LD(1000*DISPER_ADC(lambda_vect[0]*1e6,lambda_vect[k]*1e6,90-ELEVATION(DEC,HA_0),z_min,z_max),38.542,lambda_vect[k])
#alpha_disp_0 = MAS2LD(1000*DISPER_ADC(1.45, lambda_vect[k]*1e6, 90-ELEVATION(DEC, HA_0), z_min, z_max), 38.542, lambda_vect[k])-MAS2LD(1000*DISPER_ADC(1.45, lambda_vect[-1]*1e6, 90-ELEVATION(DEC, HA_0), z_min, z_max), 38.542, lambda_vect[k])
alpha_disp_0 = MAS2LD(1000*DISPER_ADC(lambda_vect[0]*1e6, lambda_vect[k]*1e6, 90-ELEVATION(DEC, HA_0), z_min, z_max), 38.542, lambda_vect[k])
else:
#alpha_disp_0 = MAS2LD(1000*DISPER(1.45,lambda_vect[k]*1e6,90-ELEVATION(DEC,HA_0)),38.542,lambda_vect[k])-MAS2LD(1000*DISPER(1.45,lambda_vect[-1]*1e6,90-ELEVATION(DEC,HA_0)),38.542,lambda_vect[k])
alpha_disp_0 = MAS2LD(1000*DISPER(lambda_vect[0]*1e6,lambda_vect[k]*1e6,90-ELEVATION(DEC,HA_0)),38.542,lambda_vect[k])
#alpha_disp_0 = MAS2LD(1000*DISPER(1.45, lambda_vect[k]*1e6, 90-ELEVATION(DEC, HA_0)), 38.542, lambda_vect[k])-MAS2LD(1000*DISPER(1.45, lambda_vect[-1]*1e6, 90-ELEVATION(DEC, HA_0)), 38.542, lambda_vect[k])
alpha_disp_0 = MAS2LD(1000*DISPER(lambda_vect[0]*1e6, lambda_vect[k]*1e6, 90-ELEVATION(DEC, HA_0)), 38.542, lambda_vect[k])
#log.info('Differential dispersion angle with 2.45um: {0}'.format(alpha_disp_0))
x, X, Y, R, T = VECT(len(SP), 1132/1024)
......@@ -702,12 +702,12 @@ for i in range(len(HA_vect)):
FTO_tel_0 = ft(I_s_0, 1, 2*OWA, 2*OWA, DiamFTO, DiamFTO, 1, len(dsp), len(dsp))
I_s_post_0 = np.abs(ft(FTO_tel_0*FTO_atm, 1, DiamFTO, DiamFTO, 2*OWA, 2*OWA, 1, N_im, N_im))
I_s_0_ForSR = np.abs(ft(np.transpose(ORIGINAL_PUPIL),1,BigD/D,BigD/D,2*OWA,2*OWA,1,len(dsp),len(dsp)))**2
FTO_tel_0_ForSR = ft(I_s_0_ForSR,1,2*OWA,2*OWA,DiamFTO,DiamFTO,1,len(dsp),len(dsp))
SR[i,k] = np.sum(np.abs(FTO_tel_0_ForSR*FTO_atm))/np.sum(np.abs(FTO_tel_0_ForSR))
I_s_0_ForSR = np.abs(ft(np.transpose(ORIGINAL_PUPIL), 1, BigD/D, BigD/D, 2*OWA, 2*OWA, 1, len(dsp), len(dsp)))**2
FTO_tel_0_ForSR = ft(I_s_0_ForSR, 1, 2*OWA, 2*OWA, DiamFTO, DiamFTO, 1, len(dsp), len(dsp))
SR[i, k] = np.sum(np.abs(FTO_tel_0_ForSR*FTO_atm))/np.sum(np.abs(FTO_tel_0_ForSR))
log.info('Wavelength {:4d}/{:4d} - {:.2f} min left'.format(k+1, N_LD, t_left))
log.info(' => Strehl at {:4.2f}nm: {:4.2f}'.format(lambda_vect[k]*1e9,SR[i,k]))
log.info(' => Strehl at {:4.2f}nm: {:4.2f}'.format(lambda_vect[k]*1e9, SR[i, k]))
#Normalization of I_s_post_0 to reflect a unit energy arriving on
#the pupil, i.e., we just have to multiply the PSF by the number of
......@@ -747,9 +747,9 @@ for i in range(len(HA_vect)):
I_temp = APPLY_CROSSTALK(I_temp)
if ADC_flag == 1:
shift_pix_FPM = 0.5*(LD2MAS(IWA_SP,38.542,lambda_vect[N_LD-1])-LD2MAS(IWA_SP,38.542,lambda_vect[0]) + 1000*DISPER_ADC(lambda_vect[0]*1e6,lambda_vect[N_LD-1]*1e6,z_max,z_min,z_max))
DISPER_MAX = DISPER_ADC(lambda_vect[0]*1e6,lambda_vect[N_LD-1]*1e6,z_max,z_min,z_max)
DISPER_Z = DISPER_ADC(lambda_vect[0]*1e6,lambda_vect[N_LD-1]*1e6,90-ELEVATION(DEC,HA_0),z_min,z_max)
shift_pix_FPM = 0.5*(LD2MAS(IWA_SP, 38.542, lambda_vect[N_LD-1])-LD2MAS(IWA_SP, 38.542, lambda_vect[0]) + 1000*DISPER_ADC(lambda_vect[0]*1e6, lambda_vect[N_LD-1]*1e6, z_max, z_min, z_max))
DISPER_MAX = DISPER_ADC(lambda_vect[0]*1e6, lambda_vect[N_LD-1]*1e6, z_max, z_min, z_max)
DISPER_Z = DISPER_ADC(lambda_vect[0]*1e6, lambda_vect[N_LD-1]*1e6, 90-ELEVATION(DEC, HA_0), z_min, z_max)
shift_pix_FPM *= (DISPER_MAX-DISPER_Z)/DISPER_MAX
# Mask offset ; non-zero when mask is *not* the one that should be ideally be used (required because of limited number of slots in FPM wheel)
......@@ -758,31 +758,31 @@ for i in range(len(HA_vect)):
# Conversion from mas to pixel
shift_pix_FPM /= MASperPIXEL
else:
shift_pix_FPM = 0.5*(LD2MAS(IWA_SP,38.542,lambda_vect[N_LD-1])-LD2MAS(IWA_SP,38.542,lambda_vect[0]) + 1000*DISPER(lambda_vect[0]*1e6,lambda_vect[N_LD-1]*1e6,z_max))
DISPER_MAX = DISPER(lambda_vect[0]*1e6,lambda_vect[N_LD-1]*1e6,z_max)
DISPER_Z = DISPER(lambda_vect[0]*1e6,lambda_vect[N_LD-1]*1e6,90-ELEVATION(DEC,HA_0))
shift_pix_FPM = 0.5*(LD2MAS(IWA_SP, 38.542, lambda_vect[N_LD-1])-LD2MAS(IWA_SP, 38.542, lambda_vect[0]) + 1000*DISPER(lambda_vect[0]*1e6, lambda_vect[N_LD-1]*1e6, z_max))
DISPER_MAX = DISPER(lambda_vect[0]*1e6, lambda_vect[N_LD-1]*1e6, z_max)
DISPER_Z = DISPER(lambda_vect[0]*1e6, lambda_vect[N_LD-1]*1e6, 90-ELEVATION(DEC, HA_0))
shift_pix_FPM *= (DISPER_MAX-DISPER_Z)/DISPER_MAX
shift_pix_FPM /= MASperPIXEL
#print('FPM offset: {:f}'.format(shift_pix_FPM))
#MASK_temp = MASK
MASK_temp = shift(MASK, [-shift_pix_FPM,0], output=None, order=1, mode='constant', cval=0.0, prefilter=True)
MASK_temp = shift(MASK, [-shift_pix_FPM, 0], output=None, order=1, mode='constant', cval=0.0, prefilter=True)
for k in range(N_LD):
if ADC_flag == 1:
shift_value = 1000*DISPER_ADC(lambda_vect[0]*1e6,lambda_vect[k]*1e6,90-ELEVATION(DEC,HA_0),z_min,z_max)
shift_value = 1000*DISPER_ADC(lambda_vect[0]*1e6, lambda_vect[k]*1e6, 90-ELEVATION(DEC, HA_0), z_min, z_max)
shift_value /= MASperPIXEL
else:
shift_value = 1000*DISPER(lambda_vect[0]*1e6,lambda_vect[k]*1e6,90-ELEVATION(DEC,HA_0))
shift_value = 1000*DISPER(lambda_vect[0]*1e6, lambda_vect[k]*1e6, 90-ELEVATION(DEC, HA_0))
shift_value /= MASperPIXEL
#print(shift_value*MASperPIXEL)
I_temp[k,:,:] = I_temp[k,:,:]*np.flipud(MASK_temp)
I_temp[k, :, :] = I_temp[k, :, :]*np.flipud(MASK_temp)
I_temp[k,:,:] = shift(I_temp[k,:,:], [shift_value,0], output=None, order=1, mode='constant', cval=0.0, prefilter=True)
I_temp[k, :, :] = shift(I_temp[k, :, :], [shift_value, 0], output=None, order=1, mode='constant', cval=0.0, prefilter=True)
image_filename = path_directory + 'PSF_HALO_ON_masked_centered_Nexp{0:04d}.fits'.format(i)
image_filename_nomask = path_directory + 'PSF_HALO_ON_notmasked_centered_Nexp{0:04d}.fits'.format(i)
......@@ -792,7 +792,7 @@ for i in range(len(HA_vect)):
fits.setval(image_filename, 'TELESCOP', value='ESO-ELT')
fits.setval(image_filename, 'INSTRUME', value='HARMONI')
fits.setval(image_filename, 'EXPTIME', value='{:.3f}'.format(T_exp*3600))
fits.setval(image_filename, 'AIRMASS', value='{:.3f}'.format(1/np.cos(np.pi/180*(90-ELEVATION(DEC*1.0,HA_0)))))
fits.setval(image_filename, 'AIRMASS', value='{:.3f}'.format(1/np.cos(np.pi/180*(90-ELEVATION(DEC*1.0, HA_0)))))
fits.setval(image_filename, 'PI-COI', value='NIRANJAN')
fits.setval(image_filename, 'DISPELEM', value=BAND)
fits.setval(image_filename, 'APODIZER', value=APODIZER)
......@@ -803,7 +803,7 @@ for i in range(len(HA_vect)):
fits.setval(image_filename_nomask, 'TELESCOP', value='ESO-ELT')
fits.setval(image_filename_nomask, 'INSTRUME', value='HARMONI')
fits.setval(image_filename_nomask, 'EXPTIME', value='{:.3f}'.format(T_exp*3600))
fits.setval(image_filename_nomask, 'AIRMASS', value='{:.3f}'.format(1/np.cos(np.pi/180*(90-ELEVATION(DEC*1.0,HA_0)))))
fits.setval(image_filename_nomask, 'AIRMASS', value='{:.3f}'.format(1/np.cos(np.pi/180*(90-ELEVATION(DEC*1.0, HA_0)))))
fits.setval(image_filename_nomask, 'PI-COI', value='NIRANJAN')
fits.setval(image_filename_nomask, 'DISPELEM', value=BAND)
fits.setval(image_filename_nomask, 'APODIZER', value=APODIZER)
......
Supports Markdown
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