Compute connectivity maps between some or all spacecrafts and planets and solar surface.
More...
|
tuple | log_id = module_io.open_log(__file__) |
|
tuple | time_0 = datetime.datetime.today() |
|
string | help_message |
|
list | scrafts = [] |
|
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 = {} |
|
tuple | date_in = module_timespace.Time() |
|
dictionary | times_sc = {} |
|
tuple | date_begin = date_in.datetime-datetime.timedelta(days=10) |
|
| delta = date_in.datetime-date_begin |
|
| ndays = delta.days |
|
list | dates = [ date_begin + i*datetime.timedelta(days=2) for i in range(0,1) ] |
|
list | polarities = [None] |
|
dictionary | ts_table = {} |
|
dictionary | ts_table_velocity = {} |
|
dictionary | error_db = {} |
|
dictionary | error_hcs = {} |
|
dictionary | error_fieldline = {} |
|
dictionary | error_param = {} |
|
dictionary | error_connectivity = {} |
|
dictionary | error_mag = {} |
|
dictionary | error_velocity = {} |
|
dictionary | error_polarity = {} |
|
dictionary | data_db = {} |
|
dictionary | data_param = {} |
|
dictionary | point_hcs = {} |
|
dictionary | point_connectivity = {} |
|
dictionary | data_mag = {} |
|
dictionary | data_velocity = {} |
|
dictionary | data_polarity = {} |
|
dictionary | path_db = {} |
|
dictionary | path_hcs = {} |
|
dictionary | path_param = {} |
|
dictionary | path_connectivity = {} |
|
dictionary | layer_connectivity = {} |
|
dictionary | layer_hcs = {} |
|
dictionary | ss_points = {} |
|
tuple | results |
|
| present_folder = True |
|
tuple | stream = open(path_param[date],'r') |
|
tuple | path_fieldline = os.path.join(data_db[date]['dirname'],data_db[date]['file_fieldline']) |
| Read its HCS file if error_db[date].error: error_hcs[date].error = True; error_hcs[date].message = 'No output found. More...
|
|
tuple | fieldlines = ascii_fieldline.read(path_fieldline) |
|
list | item_names = [] |
| Measured polarity: sign(Br) polarity_real = np.sign(data_mag[date][0]) For Slow SW, Fast SW, Measured SW for i,mode in enumerate(['SSW','FSW','M']): if ss_point[mode] is None: continue #Corresponding HCS latitude point_hcs[date][i] = module_timespace.Coordinate() point_hcs[date][i].lon = ss_point[mode].lon point_hcs[date][i].lat = module_toolbox_num.interpolation1D([point_hcs.lon for point_hcs in points_hcs],[point_hcs.lat for point_hcs in points_hcs],point_hcs[date][i].lon) #Computed polarity: sign(lat_connectivity-lat_hcs) polarity_computed = np.sign(ss_point[mode].lat-point_hcs[date][i].lat) #Check data_polarity[date][i] = (polarity_real * polarity_computed) > 0. More...
|
|
list | item_errors = [] |
|
int | nerror = 0 |
|
list | item_error = item_errors[i] |
|
list | operation_mode = data_db[date_in.datetime] |
|
tuple | output_dirname = module_io.output_localdir(module_io.hmodel,module_io.cmodel,module_io.reftime,operation_mode,scraft,module_io.magtype,date_in.datetime) |
|
tuple | output_basename = module_io.output_localname(module_io.hmodel,module_io.cmodel,module_io.reftime,scraft,module_io.magtype,operation_mode,date_in.datetime) |
|
tuple | path_layer_polarity = os.path.join(output_dirname,output_basename + '_layerpolarity.png') |
|
list | color = module_plot.color_connectivity[scraft] |
|
string | title = 'Parameter file path:' |
|
tuple | time_2 = datetime.datetime.today() |
|
Compute connectivity maps between some or all spacecrafts and planets and solar surface.
Connectivity file if data_param[date][scraft]['insitu']: log_id.write('(%6.2f,%6.2f) %24s '%(point_connectivity[date][2].lon,point_connectivity[date][2].lat,'')) else: log_id.write('(%6.2f,%6.2f),(%6.2f,%6.2f) %8s '%(point_connectivity[date][0].lon,point_connectivity[date][0].lat,point_connectivity[date][1].lon,point_connectivity[date][1].lat,'')) Mag data.
- Author
- M. Indurain
-
R. Pinto
- Date
- 2019
Initialisation
Log ID: Open log file logs/log_YYYYMMDD and write header log.
Connection to Output DB. If does not exist, create it.
Input
Usage:
python check_polarity.py -hmodel heliospheric_model -cmodel coronal_model -magtype magnetic_type -reftime reference_time -sc sc_name -y year -m month -d day -H hour
where:
- -h : brief help
- sc_name : SC/Planet name. May have multiple names (-sc Name1 -sc Name2...). PSP,STA,EARTH,ALL. Default PSP
- heliospheric_model : Heliospheric model, one of interface_heliosphere.info. Default PARKER.
- coronal_model : Coronal model, one of interface_corona.info. Default PFSS.
- magnetic_type : Type of magnetic data. WSO,NSO,ADAPT for PFSS coronal model. Default WSO. DUMFRIC or QSLSQUASHER for MFM coronal model. Default DUMFRIC.
- reference_time : Referential time. SCTIME,SUNTIME. Default SCTIME.
- year : year in UTC. Default today UTC year.
- month : month in UTC. Default today UTC month.
- day : day in UTC. Default today UTC day.
- hour : hour in UTC. Default 0.
Read and check check_polarity arguments in module_io.
Compute the input date.
Init Spice orbitography.
Add a new simulation if Output DB.
- Parameters
-
[in] | input | arguments |
[out] | times_sc | |
[out] | module_io | simulation variables (all_mode, hmodel, cmodel, magtype, reftime, year, month, day, hour, all_mode) |
Check past polarities.
For date in [date-N,date], find corresponding simulation in Output DB.
Read HCS file, Connectivity file, insitu magnetic field.
Check polarity
Close
Close orbitography and log files.
tuple check_polarity.path_fieldline = os.path.join(data_db[date]['dirname'],data_db[date]['file_fieldline']) |
Read its HCS file if error_db[date].error: error_hcs[date].error = True; error_hcs[date].message = 'No output found.
' else: path_hcs[date] = os.path.join(data_db[date]['dirname'],data_db[date]['file_hcs']) if not os.path.isfile(path_hcs[date]): error_hcs[date].error = True; error_hcs[date].message = 'No HCS file in this simulation.' else: points_hcs = ascii_coordinate.read(path_hcs[date])
ss_point = {'SSW':None,'FSW':None,'M':None} for i,mode in enumerate(['SSW','FSW','M']): if data_param[date][scraft]['ss_point'][mode] is None: continue else: ss_point[mode] = module_timespace.Coordinate() ss_point[mode].lon = data_param[date][scraft]['ss_point'][mode][0] ss_point[mode].lat = data_param[date][scraft]['ss_point'][mode][1]
Read its connectivity file and find mean connectivity points if error_db[date].error: error_connectivity[date].error = True; error_connectivity[date].message = 'No output found.' else: path_connectivity[date] = os.path.join(data_db[date]['dirname'],data_db[date]['file_connectivity']) if not os.path.isfile(path_connectivity[date]): error_connectivity[date].error = True; error_connectivity[date].message = 'No connectivity file in this simulation s.'%(data_db[date]['dirname']) else: ifile = open(path_connectivity[date],'r') connects_all = ascii_connectivitypoint.read(ifile) #Return (connects_ssw,connects_fsw,connects_measured) ifile.close() #Find mean connectivity points point_connectivity[date] = [None,None,None] #For Slow SW, Fast SW, Measured SW for i,connects in enumerate(connects_all): if connects == []: continue points = [connect.point for connect in connects] print(stats.norm.fit([ point.lon for point in points ])) #Mean connectivity point point_connectivity[date][i] = module_timespace.Coordinate() point_connectivity[date][i].lon = np.mean([ point.lon for point in points ]) point_connectivity[date][i].lat = np.mean([ point.lat for point in points ])