import os import importlib.util from intmodlib import exec_model_run,vars_to_dic import glob #available_models: # 'gaussian' # 'ring_asymm # 'ring_symm' # 'temp_grad_asymm' # 'temp_grad_symm' # 'temp_grad_flared_symm' # 'banana' # 'TGMdust' # 'TGMdust_asymm' # 'central_1D_symm' # 'central_1D_asymm' # 'temp_grad_1D_symm' # 'temp_grad_1D_asymm' # 'radimg_symm' # 'radimg_asymm' os.environ["OMP_NUM_THREADS"] = "1" T = True F = False ######################## General settings ############################## options={ 'run_MCMC': True, #default: True 'show_existing_result': True, #default: False, if True: no MCMC run is performed 'force_configfile_settings': True, #default: False, if True (makes impact when show_existing_result is True): the settings in the config file take preference over the saved settings in the pickle file 'convolve_kernel_FWHM_mas': 0.0, #default: 0.0 #this only applies to plotting 'scale_vmax': True, #default: True 'plot_without_data': False, #default: False 'fig_spatial_axis': 'spatial_freq', #'bl_length' # 'plot_annot_central_star': True, #default = False 'plot_annot_companion': False, #default = False 'make_phase_plots': False, 'make_individual_spectrum_plots': False } # all other model settings should be listed in the config file # N band FU Ori #config_dir = '/allegro6/matisse/varga/test_red/targets2_test/FU_Ori/modelling/' #config_file = config_dir+ 'FU_Ori_N_central_gaussian_config.py' # L band HD 163296 #config_dir = '/allegro6/matisse/varga/targets2/HD_163296/modelling/' #config_file = config_dir+'HD_163296_central_gaussian_plus_companion_errors_equalized_multiwl_config.py' # config_file = config_dir+'HD_163296_temp_grad_asymm_multiwl_config.py' #config_file = config_dir+'HD_163296_ring_asym_test.py' #config_file = config_dir+'HD_163296_blob_plus_circumbinary_ring_conv_Lorentz_errors_equalized_multiwl_config.py' #config_file = config_dir+'HD_163296_circumbinary_ring_conv_Lorentz_errors_equalized_multiwl_config.py' #config_file = config_dir+'HD_163296_PIONIER_ring_asym_conv_Lorentz_config.py' #config_file = config_dir+'HD_163296_PIONIER_circumbinary_ring_conv_Lorentz_config.py' #config_file = config_dir+'HD_163296_PIONIER_central_gaussian_plus_companion_config.py' #config_file = config_dir+ 'HD_163296_N_central_gaussian_errors_equalized_chi2_config.py' #config_file = config_dir+ 'HD_163296_MIDI_central_gaussian_chi2_config.py' #config_file = config_dir+'HD_163296_temp_grad_asymm_multiwl_extrapolated_config.py' #V900 Mon config_dir = '/allegro6/matisse/varga/targets_ews2/V900_Mon/modelling/' config_file = config_dir+'/V900_Mon_N_geometric_modelling_config.py' # N band FU Ori #config_dir = '/allegro6/matisse/varga/targets2/FU_Ori/modelling/' #config_file = config_dir+'FU_Ori_gaussian_config.py' #DI Cha #config_dir = '/allegro6/matisse/varga/targets_other/DI_Cha/modelling/' #config_file = config_dir+'DI_Cha_PIONIER_config.py' config_file = '/allegro6/matisse/varga/targets_other/DI_Cha/DI_Cha_PIONIER_MIDI_bestfit.py' #HD 144432 config_dir = '/allegro6/matisse/varga/targets3/HD_144432/modelling/' # config_dir = '/Users/jvarga/Data/MATISSE/targets2/HD_144432/modelling/' #config_file = config_dir+'HD_144432_N_mineralogy_fit_config.py' #CG mineralogy #config_file = config_dir+'HD_144432_N_geometric_modelling_config.py' #geometric #config_file = config_dir+'HD_144432_radimg_config.py' #radimg #config_file = config_dir+'HD_144432_opt_thin_kappa_4zones_config.py' #radimg config_file = config_dir+'HD_144432_opt_thin_kappa_config.py' #radimg #config_file = config_dir+'HD_144432_fitincl_config.py' #radimg #EX Lup #config_dir = '/allegro6/matisse/varga/targets3/EX_Lup/modelling/' #config_file = config_dir+'EX_Lup_opt_thin_kappa_config.py' #HD 142527 #config_dir = '/allegro6/matisse/varga/targets4/HD_142527/modelling/' #config_file = config_dir+'HD_142527_opt_thin_kappa_config.py' #DX Cha #config_dir = '/allegro6/matisse/varga/targets3/DX_Cha/modelling/' #config_file = config_dir+'DX_Cha_central_gaussian_plus_companion_config.py' #config_file = config_dir+'DX_Cha_LN_tempgrad_asymm_plus_2stars_config.py' #test data #config_dir = '/allegro6/matisse/varga/targets_other/test_data/modelling/' #config_file = config_dir+'test_data_config.py' ''' #HD 50138 config_dir = '/allegro6/matisse/varga/targets2/HD_50138/modelling/' config_file = config_dir+'HD_50138_ring_asym_config.py' ''' # HD 97048 #config_dir = '/allegro6/matisse/varga/targets3/HD_97048/modelling/' #config_file = config_dir+'HD_97048_new_config.py' #config_file = config_dir+'HD_97048_new_config_GKSbananas.py' ######################### Import config file ########################### print('Import config file and setup model.') config_spec = importlib.util.spec_from_file_location('modelconfig', config_file) cm = importlib.util.module_from_spec(config_spec) config_spec.loader.exec_module(cm) locals().update({v: getattr(cm, v) for v in cm.__dict__ if not v.startswith("_")}) if 'wl_min' not in model_options: if 'wl_min' in wl_dic: model_options['wl_min'] = wl_dic['wl_min'] else: model_options['wl_min'] = np.min(np.array(wl_dic['wavelengths'])) if 'wl_max' not in model_options: if 'wl_max' in wl_dic: model_options['wl_max'] = wl_dic['wl_max'] else: model_options['wl_max'] = np.max(np.array(wl_dic['wavelengths'])) #print(dir()) #print(run_name) #wls = [8.5,9.5,10.5, 11.5, 12.1] # jij=0 ''' k1s = ['fe-c','fes','c-p','c-gra'] k1_amins = [0.1, 0.1,0.11,0.001] k1_amaxss = [[0.3,1.0,1000.0], [0.2,0.3,0.5,1.0,10.0],[0.11,0.3,1.0,100.0], [0.03,0.3,10.0]] k2s = ['ol-mg50','astrosil','pyr-mg70'] k2_amins = [0.2,0.05,0.2] k2_amaxss = [[1.0,3.0,10.0,100.0],[0.1,1.0,10.0,1000.0],[1.0,3.0,10.0,100.0] ] ''' ''' k1s = ['fe-c','c-p','fes'] k1_amins = [0.1,0.11,0.1] k1_amaxss = [[0.3,1.0,1000.0],[0.11,0.3],[0.5]] k2s = ['ol-mg50','astrosil','pyr-mg70'] k2_amins = [0.2,0.05,0.2] k2_amaxss = [[10.0,100.0],[1.0,10.0],[10.0] ] ''' ''' k1s = ['fe-c'] k1_amins = [0.1] k1_amaxss = [[0.3,1.0,1000.0]] k2s = ['c-p'] k2_amins = [0.11] k2_amaxss = [[0.11,0.3]] k3s = ['ol-mg50','astrosil','pyr-mg70'] k3_amins = [0.2,0.05,0.2] k3_amaxss = [[10.0,100.0],[1.0,10.0],[10.0] ] ''' #for wli in wls: #if True: ''' for k1,k1_amin,k1_amaxs in zip(k1s,k1_amins,k1_amaxss): for k1_amax in k1_amaxs: for k2,k2_amin,k2_amaxs in zip(k2s,k2_amins,k2_amaxss): for k2_amax in k2_amaxs: #for k3,k3_amin,k3_amaxs in zip(k3s,k3_amins,k3_amaxss): #for k3_amax in k3_amaxs: ''' if True: if True: #if jij>1: dgfhgf #k1_name = k1+'_%.2f-%.2fum'%(k1_amin,k1_amax)#+'.dat' #k2_name = k2+'_%.2f-%.2fum'%(k2_amin,k2_amax)#+'.dat' #k3_name = k3+'_%.2f-%.2fum'%(k3_amin,k3_amax)#+'.dat' #run_name = '3stuff_newdata_Run%03d_%s_%s_%s'%(jij,k1_name,k2_name,k3_name) #run_name = 'newdata_Run%03d_%s_%s'%(jij,k1_name,k2_name) #qs = [k1_name+'.dat',k2_name+'.dat']*2 #,k3_name+'.dat' #print(k1_name) #print(k2_name) # model_options['qs']=qs # print(run_name) # print(model_options['qs']) #pk_name0 = 'mcmc_samples_3000_24_Run%03d_%s_%s.pk'%(0,k1_name,k2_name) #pk_name4 = 'mcmc_samples_3000_24_Run%03d_%s_%s.pk'%(4,k1_name,k2_name) #pattern = '3000_24_Run%03d_%s_%s'%(4,k1_name,k2_name) #flist = glob.glob(outputdir+'/*'+pattern+'*') #for fil in flist: # print(jij,fil) # os.rename(fil, fil.replace('Run004','Run%03d'%jij)) #print(outputdir+'/'+pk_name,os.path.exists(outputdir+'/'+pk_name)) #if not(os.path.exists(outputdir+'/'+pk_name0)) and not(os.path.exists(outputdir+'/'+pk_name4)): if True: ''' model_options['temp_cal_pm'] = [] for i in range(len(qs)): input_path = model_options['pathq'] + '/' + qs[i] cl=0 f1 = open(input_path,'r') lines = f1.readlines() for line in lines: if line[0] == '#': cl+=1 f1.close() wl_orig,opac_orig = np.loadtxt(input_path, comments="#", skiprows=cl+2, usecols=(0,1), unpack=True) #opac_orig = opac_orig*0.0+1.0 #test grey opacity nu = c0/(wl_orig*1e-6) # (Hz) Bnu_star = B_nu(T_star,nu) leftside = (R_star*0.00465047)**2*np.trapz(opac_orig*Bnu_star,x=nu) model_options['temp_cal_pm'].append({'leftside':leftside,'wl_orig':wl_orig, 'nu_orig':nu,'opac_orig':opac_orig,'Bnu_star':Bnu_star}) ''' #wl_dic['wavelengths'] = [wli] if len(wl_dic['wavelengths']) == 1 and (not model_name.startswith('TGMdust')): wl_tag = ('%.1f'%wl_dic['wavelengths'][0]).replace('.','um')+'_' else: wl_tag = '' tag = '_'+wl_tag+'%d_%d_'%(fitter_settings['nsteps'],fitter_settings['nwalkers']) + run_name try: stellar_SED_path except NameError: stellar_SED_path = '' inputs = [oifits_paths,oifits_datatypes,SEDs,instrument,correct_errors,error_terms,config_file,\ stellar_SED_path,misc_spectra,sp_labels] model_settings = [model_name,run_name,tag,wl_dic,parameter_dic,model_options] ######################### Execute model run ########################### exec_model_run(outputdir,inputs,options,fitter_settings,model_settings) jij+=1 print("EXTERMINATE!")