ConnectTool
 All Classes Namespaces Files Functions Variables Pages
Variables
make_video Namespace Reference

Convert some connectivity images into a video. More...

Variables

int ndays_past = 10
 
tuple log_id = module_io.open_log(__file__)
 
tuple time_0 = datetime.datetime.today()
 
string help_message
 
list scrafts = []
 
string background = 'mag'
 
 perihelion = False
 
 orbit = False
 
int n_perihelion = -1
 
int n_orbit = -1
 
tuple error_hmodel = module_io.check_hmodel(module_io.hmodel )
 
tuple error_cmodel = module_io.check_cmodel(module_io.cmodel )
 
tuple error_magtype = module_io.check_magtype(module_io.magtype)
 
tuple error_reftime = module_io.check_reftime(module_io.reftime)
 
dictionary error_scraft = {}
 
dictionary sc_ref = {}
 
tuple date_in = module_timespace.Time()
 
tuple video_dir = module_io.output_videodir()
 
tuple png2mp4_log_file = os.path.join(video_dir,'log_file')
 
tuple png2mp4_err_file = os.path.join(video_dir,'err_file')
 
tuple video_name = module_io.output_globalname(module_io.hmodel,module_io.cmodel,module_io.reftime,scraft,module_io.magtype)
 
list date_begin = module_orbito.perihelion[sc_ref[scraft]]
 
list date_end = module_orbito.perihelion[sc_ref[scraft]]
 
 delta = date_end-date_begin
 
 ndays = delta.days
 
list dates = [ date_begin + i*datetime.timedelta(days=1) for i in range(0,delta.days+1) ]
 
dictionary error_db = {}
 
dictionary error_background_mag = {}
 
dictionary error_background_euv171 = {}
 
dictionary error_background_euv193 = {}
 
dictionary error_layer_frame = {}
 
dictionary error_layer_connectivity = {}
 
dictionary error_layer_subpoint = {}
 
dictionary error_layer_hcs = {}
 
dictionary error_layer_visible_disk = {}
 
dictionary simu_db = {}
 
dictionary path_background_mag = {}
 
dictionary path_background_euv171 = {}
 
dictionary path_background_euv193 = {}
 
dictionary path_layer_frame = {}
 
dictionary path_layer_connectivity = {}
 
dictionary path_layer_subpoint = {}
 
dictionary path_layer_hcs = {}
 
dictionary path_layer_visible_disk = {}
 
dictionary path_image = {}
 
tuple results
 
 present_folder = True
 
string command = ''
 Remove date with errors for date in dates[:]: if error_db[date].error or error_layer_frame[date].error: dates.remove(date) log_id.write(' s from list'date) If errors and no more valid date, get out! if dates == []: log_id.write('No valid date for Sc/Planet s, skip it. More...
 
tuple time_tmp = module_timespace.Time()
 
list layers = []
 
tuple ifile = open(png2mp4_log_file,'r')
 
tuple lines = ifile.readlines()
 
tuple time_2 = datetime.datetime.today()
 

Detailed Description

Convert some connectivity images into a video.

Update database if not os.path.isfile(path_layer_polarity): log_id.write('Error: layer not created s
'%(path_layer_polarity)) continue else: module_db.update_element(module_db.database_table,connector,cursor,simu_db[date_in.datetime]['id'],layer_polarity=os.path.basename(path_layer_polarity)) log_id.write('Layer created and added to DB (ID=d).

Input

Usage:
python make_video.py -hmodel heliospheric_model -cmodel coronal_model -magtype magnetic_type -reftime reference_time -sc sc_name -y year -m month -d day -H hour –mag –euv171 –euv193 –perihelion N –orbit M
where:

Find output and create video.

For date in [date-Npast,date], find corresponding simulation in Output DB and merge all its images.
Build the video with all the merged images from different dates.


'%(simu_db[date_in.datetime]['id']))

Close

Close orbitography and log files.

Variable Documentation

string make_video.background = 'mag'
string make_video.command = ''

Remove date with errors for date in dates[:]: if error_db[date].error or error_layer_frame[date].error: dates.remove(date) log_id.write(' s from list'date) If errors and no more valid date, get out! if dates == []: log_id.write('No valid date for Sc/Planet s, skip it.


'scraft); continue If date_in is not valid, do not get out if error_db[date_in.datetime].error: log_id.write('Main date s is not a valid simulation for Sc/Planet s, skip it.
'%(date_in.datetime,scraft)); continue

tuple make_video.date_begin = module_orbito.perihelion[sc_ref[scraft]]
list make_video.date_end = module_orbito.perihelion[sc_ref[scraft]]
tuple make_video.date_in = module_timespace.Time()
list make_video.dates = [ date_begin + i*datetime.timedelta(days=1) for i in range(0,delta.days+1) ]
make_video.delta = date_end-date_begin
dictionary make_video.error_background_euv171 = {}
dictionary make_video.error_background_euv193 = {}
dictionary make_video.error_background_mag = {}
tuple make_video.error_cmodel = module_io.check_cmodel(module_io.cmodel )
dictionary make_video.error_db = {}
tuple make_video.error_hmodel = module_io.check_hmodel(module_io.hmodel )
dictionary make_video.error_layer_connectivity = {}
dictionary make_video.error_layer_frame = {}
dictionary make_video.error_layer_hcs = {}
dictionary make_video.error_layer_subpoint = {}
dictionary make_video.error_layer_visible_disk = {}
tuple make_video.error_magtype = module_io.check_magtype(module_io.magtype)
tuple make_video.error_reftime = module_io.check_reftime(module_io.reftime)
dictionary make_video.error_scraft = {}
string make_video.help_message
Initial value:
1 = """
2 Usage :\n
3 python make_video.py -sc sc_name -hmodel heliospheric_model -cmodel coronal_model -magtype magnetic_type -reftime reference_time -sc sc_name -y year -m month -d day -H hour --mag --euv171 --euv193 --perihelion N --orbit M
4 [-h] : brief help
5 scName : SC/Planet name. May have multiple names (-sc Name1 -sc Name2...). PSP,STA,EARTH,ALL. Default PSP
6 heliospheric_model : Heliospheric model. PARKER. Default PARKER.
7 coronal_model : Coronal model. PFSS,MFM. Default PFSS.
8 magnetic_type : Type of magnetic data. WSO,NSO,ADAPT for PFSS coronal model. Default WSO. DUMFRIC for MFM coronal model. Default DUMFRIC.
9 reference_time : Referential time. SCTIME,SUNTIME. Default SCTIME.
10 year : year in UTC. Default today UTC year.
11 month : month in UTC. Default today UTC month.
12 day : day in UTC. Default today UTC day.
13 hour : hour in UTC. Default 0.
14 --mag : background is magnetic data (default)
15 --euv171 : background is euv171 map
16 --euv193 : background is euv193 map
17 --perihelion N : dates correspond to [Nth perihelion - 10 days, Nth perihelion + 10 days] with dt = 1day
18 --orbit M : dates correspond to Mth orbit [perihelion[i-1],perihelion[i]] with dt=10day
19 """
tuple make_video.ifile = open(png2mp4_log_file,'r')
list make_video.layers = []
tuple make_video.lines = ifile.readlines()
tuple make_video.log_id = module_io.open_log(__file__)
tuple make_video.n_orbit = -1
tuple make_video.n_perihelion = -1
make_video.ndays = delta.days
int make_video.ndays_past = 10
make_video.orbit = False
dictionary make_video.path_background_euv171 = {}
dictionary make_video.path_background_euv193 = {}
dictionary make_video.path_background_mag = {}
dictionary make_video.path_image = {}
dictionary make_video.path_layer_connectivity = {}
dictionary make_video.path_layer_frame = {}
dictionary make_video.path_layer_hcs = {}
dictionary make_video.path_layer_subpoint = {}
dictionary make_video.path_layer_visible_disk = {}
make_video.perihelion = False
tuple make_video.png2mp4_err_file = os.path.join(video_dir,'err_file')
tuple make_video.png2mp4_log_file = os.path.join(video_dir,'log_file')
make_video.present_folder = True
tuple make_video.results
Initial value:
1 = module_db.datetime2output(module_db.database_table,connector,cursor,\
2  scraft = scraft,\
3  heliospheric_model = module_io.hmodel,\
4  coronal_model = module_io.cmodel,\
5  reference_time = module_io.reftime,\
6  magnetogram_type = module_io.magtype,\
7  date = date.strftime('%Y-%m-%d %H:%M:%S'),\
8  orderby='ASC',ordercol='operation_mode_id')
def datetime2output
Look for the corresponding output around a given date (depending on h_accuracy).
Definition: module_db.py:281
dictionary make_video.sc_ref = {}
list make_video.scrafts = []
dictionary make_video.simu_db = {}
tuple make_video.time_0 = datetime.datetime.today()
tuple make_video.time_2 = datetime.datetime.today()
tuple make_video.time_tmp = module_timespace.Time()
tuple make_video.video_dir = module_io.output_videodir()