|
tuple | job_scheduler_file = os.path.join('dir.output','job_scheduler.out') |
|
tuple | log_id = module_toolbox_file.open_log('logs','jobs',__file__,'CONNECTIVITY TOOL V3',module_common.utc_today) |
|
int | npast_days = 3 |
|
int | nupdate_days = 3 |
|
int | nforecast_days = 3 |
|
list | mode = ['ALL'] |
|
list | dates_6h = [None] |
|
tuple | nearest_date_6h = module_toolbox_num.nearest(dates_6h,module_common.utc_today) |
|
list | hmodels = ['PARKER'] |
|
list | cmodels = ['PFSS'] |
|
list | reftimes = ['SCTIME','SUNTIME'] |
|
list | magtypes = ['NSO','ADAPT'] |
|
list | scrafts = ['PSP','EARTH','STA','ALL'] |
|
dictionary | dates = {} |
|
list | missing_simus_past = [] |
|
tuple | date_begin = nearest_date_6h-datetime.timedelta(days=npast_days) |
|
| date_end = nearest_date_6h |
|
| delta = date_end-date_begin |
|
int | step = 6 |
|
tuple | nstep = int(delta.days*24/step) |
|
tuple | id_simu = IDSimu(date=date_in,hmodel=hmodel,cmodel=cmodel,reftime=reftime,magtype=magtype,scrafts=[]) |
|
tuple | results |
|
list | missing_simus_udpate_ts = [] |
|
tuple | path_param = os.path.join(results[0]['dirname'],results[0]['file_parameter']) |
|
tuple | stream = open(path_param,'r') |
|
tuple | data_param = yaml.load(stream,Loader=yaml.FullLoader) |
|
tuple | time_surf = datetime.datetime.strptime(data_param[scraft]['time_surf'],'%Y-%b-%d %H:%M:%S') |
|
tuple | db_element = database_timeserie.datetime2file(table_name,date_in,h_accuracy = 1) |
|
list | missing_simus_udpate_mag = [] |
|
tuple | time_in = module_timespace.Time() |
|
list | missing_simus_udpate_euv171 = [] |
|
list | euv171_table_names = ['OBS_MAPS_EUV2CARMAP_SDOSTA_171','OBS_MAPS_SDO_AIA_171'] |
|
list | missing_simus_forecast = [] |
|
tuple | missing_simus = np.array(missing_simus_past + missing_simus_forecast + missing_simus_udpate_ts + missing_simus_udpate_mag + missing_simus_udpate_euv171) |
| DB table name if magtype == 'ADAPT' : table_name = 'OBS_MAPS_ADAPT40' elif magtype == 'NSO' : table_name = 'OBS_MAPS_NSO' elif magtype == 'WSO' : table_name = 'OBS_MAPS_WSO_ORIGIN' else: continue id_simu = IDSimu(date=date_in,hmodel=hmodel,cmodel=cmodel,reftime=reftime,magtype=magtype,scrafts=[]) for scraft in scrafts: #Find corresponding simulation in Output DB results = module_db.datetime2output(module_db.database_table,connector,cursor,\ scraft = scraft,\ heliospheric_model = hmodel,\ coronal_model = cmodel,\ reference_time = reftime,\ magnetogram_type = magtype,\ date = date_in.strftime('Y-m-d H:M:S'),\ orderby='ASC',ordercol='operation_mode_id') #If simulation does not exist, launch it if len(results) == 0: id_simu.scrafts.append(scraft) #Else, launch it if newest magnetogram in SWD is newer than the one used in previous connectivity simulation else: #Read parameter file path_param = os.path.join(results[0]['dirname'],results[0]['file_parameter']) if not os.path.isfile(path_param): log_id.write('Error: No param file in this simulation s. More...
|
|
list | remove_index = [] |
|
tuple | duplicated = np.where(missing_simus[i+1:] == simu_id) |
|
int | index = j+i+1 |
|
list | unic_simus = [] |
|
list | duplicated_simus = [] |
|
tuple | ifile = open(job_scheduler_file,'w') |
|
string | command = 'cat %s' |
|
DB table name if magtype == 'ADAPT' : table_name = 'OBS_MAPS_ADAPT40' elif magtype == 'NSO' : table_name = 'OBS_MAPS_NSO' elif magtype == 'WSO' : table_name = 'OBS_MAPS_WSO_ORIGIN' else: continue id_simu = IDSimu(date=date_in,hmodel=hmodel,cmodel=cmodel,reftime=reftime,magtype=magtype,scrafts=[]) for scraft in scrafts: #Find corresponding simulation in Output DB results = module_db.datetime2output(module_db.database_table,connector,cursor,\ scraft = scraft,\ heliospheric_model = hmodel,\ coronal_model = cmodel,\ reference_time = reftime,\ magnetogram_type = magtype,\ date = date_in.strftime('Y-m-d H:M:S'),\ orderby='ASC',ordercol='operation_mode_id') #If simulation does not exist, launch it if len(results) == 0: id_simu.scrafts.append(scraft) #Else, launch it if newest magnetogram in SWD is newer than the one used in previous connectivity simulation else: #Read parameter file path_param = os.path.join(results[0]['dirname'],results[0]['file_parameter']) if not os.path.isfile(path_param): log_id.write('Error: No param file in this simulation s.
'%(results[0]['dirname'])); continue else: stream = open(path_param,'r') data_param = yaml.load(stream,Loader=yaml.FullLoader) stream.close() #Read map2D_mag_date if not isinstance(data_param[scraft]['map2D_mag_date'],datetime.datetime): map2D_mag_date = datetime.datetime.strptime(data_param[scraft]['map2D_mag_date'],'Y-b-d H:M:S') else: map2D_mag_date = data_param[scraft]['map2D_mag_date'] #Get most recent map2D magnetogram in SWD db_newest = database_map2D.newest_map(table_name) try: newest_date = datetime.datetime.strptime(db_newest['date_end'],'Y-m-d H:M:S.f') except: newest_date = datetime.datetime.strptime(db_newest['date_end'],'Y-m-d H:M:S') #Relaunch if if newest magnetogram in SWD is newer print(id_simu) print(map2D_mag_date) print(newest_date) if newest_date > map2D_mag_date: print('Relaunch it'); id_simu.scrafts.append(scraft) else: print('No need to relaunch'); continue Add this simu if some scraft is missing if id_simu.scrafts != []: missing_simus_forecast.append(id_simu)