Compute connectivity maps between some or all spacecrafts and planets and solar surface.
More...
Compute connectivity maps between some or all spacecrafts and planets and solar surface.
Define a scraft reference for ALL case.
Overwrite fieldlines for scraft in scrafts: ifile = open('QSLsquasher/output/fieldline_s_s_min.ascii'%(scraft,times_sc[scraft][0].datetime.strftime('YmdTHMS')),'r') fieldlines[scraft][0:module_connectivity.nproba] = ascii_fieldline.read_v0(ifile) ifile.close() ifile = open('QSLsquasher/output/fieldline_s_s_max.ascii'%(scraft,times_sc[scraft][0].datetime.strftime('YmdTHMS')),'r') fieldlines[scraft][module_connectivity.nproba:] = ascii_fieldline.read_v0(ifile) ifile.close()
Get the footpoint on source surface of a magnetic fieldline passing through a point in the heliosphere and compute propagation delays. Get solar wind velocity Vhelio for a specific time and position in the heliosphere.
If available in SW Timeserie Database, take the measured value. Insitu mode.
If not available, assumed a minimum and maximum for slow and fast solar wind (cf module_heliosphere). Not insitu mode.
Timeserie Database is composed of AMDA timeseries : solar wind speed at some SC/planet. Only AMDA database, not updated.
Add data from ACE Science Center + Discovr real solar wind data deep space climate.
.
- 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 connect_tool.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 connect_tool 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) |
Orbitography.
SPICE library is used to get the position of a spacecraft (SC) or a planet in the HelioGraphic Coordinate system (HGC).
Module_orbito is the interface between Connect_tool and SPICE.
- Parameters
-
[in] | module_io.scraft | |
[in] | times_sc | |
[out] | positions_sc | |
Heliospheric reconstruction
About the in_situ mode.
If Vhelio found, insitu mode. All variables are a 1-element list (positions_ss[sc], times_ss[sc], density_maps[sc]) or a Nproba-element list (seedpoints_ss[sc], fieldlines[sc], footpoints[sc]).
Else, Vhelio = [Vslow,Vfast]. All variables are a 2-element list (positions_ss[sc], times_ss[sc], density_maps[sc]) or a 2Nproba-element list (seedpoints_ss[sc], fieldlines[sc], footpoints[sc]).
Set module_heliosphere parameters.
Call wanted heliospheric model through the interface_heliosphere.
Get the footpoint on the source surface (positions_ss[sc]) of an heliospheric magnetic fieldline ending at the position of SC/Planet (positions_sc[sc]). Uses different models:
- Parker model: see model_parker. If in situ measurement is available in the Timeserie Database, Parker spiral is computed using in situ solar wind speed. Otherwise, Parker spiral uses a minimum and maximum solar wind configuration.
- Hmodel2: to be implemented in the long term...
Compute propagation delays (dt_helio[sc]) between source surface and SC/planet.
- Parameters
-
[in] | module_io.hmodel | |
[in] | times_sc | |
[in] | positions_sc | |
[out] | velio | |
[out] | insitu | |
[out] | ts_path,ts_date | |
[out] | positions_ss | |
[out] | dt_helio | |
Boundary condition
Get propagation delay between Sc/Planet and solar surface (dt_prop[sc]).
Propagation delay between Source Surface and Sun surface is not neglected. Vcorona = module_corona.vcorona (100 km/s).
dt_corona[sc] = 2.5 Rs/Vcorona
dt_prop[sc] = dt_helio[sc] + dt_corona[sc]
Get time on solar surface (times_surf[sc]), according to reftime_mode.
- Sc, BWÂ : times_surf[sc] = times_sc[sc] = date_in.
- Sun, BW : times_surf[sc] = times_sc[sc] – dt_prop[sc] = date_in - dt_prop[sc]
- Sun, FWÂ : times_surf[sc] = date_in.
Get the good Magmap/Magcube according to time_surf.
- Sc,BW. magdata[sc] is the same.
- Sun,BW and operation_mode[sc] != Extended. magdata[sc] are not the same.
- Sun,BW and operation_mode[sc] = Extended. magdata[sc] is the same (the most recent).
- Sun,FW. magdata[sc] is the same.
Set operation mode. According time_today, time_surf and Magmap/Cube3D availability.
Extended Forecast. If Magmap/Cube3D not available, take the most recent. Up to Nextended.
Get the good euv/white light maps according to time_surf.
Read magnetic data and euv/white light maps.
Get magnetogram data at solar surface.
For PFSS coronal reconstruction : magsurf[sc] = magmap[sc]
For CUBE coronal reconstruction : magsurf[sc] = magcube[sc][level = 0 + epsilon]
- Parameters
-
[in] | module_io.reftime,module_io.magtype | |
[in] | times_sc | |
[in] | dt_helio | |
[out] | times_surf | = times_sc (if reftime = SCTIME) or time_surf = times_ss (if reftime = SUNTIME) |
[out] | operation_mode | |
[out] | mag_db,mag_data,mag_identical | |
[out] | euv171_db,euv171_data,euv171_identical,...,wl_db,wl_data,wl_identical | |
[out] | mag_surf | |
Uncertainty
Compute a point distribution on source surface to assess uncertainties of heliospheric reconstruction.
This leads to the creation of some seed points on the source surface for corona reconstruction.
Seedpoint list has Nproba points (in_situ mode) or 2*Nproba points (not in_situ mode).
- Method 1. This method builds some probability distribution around the footpoint on the source surface. Arbitrary gaussian is used.
- Method 2Â ? By Rui...
- Parameters
-
[in] | positions_ss | |
[out] | seed_points_ss[0:module_connectivity.nproba] | list of Coordinate objects in vhelio-measured case. |
[out] | seed_points_ss[0:2 | * module_connectivity.nproba] list of Coordinate objects in vhelio-min and vhelio-max case. |
Coronal reconstruction
Compute the magnetic fieldlines starting from seed points on the source surface, down to solar surface.
Set coronal model parameters (magmap/magcube, seedpoint_ss).
Call wanted coronal model through interface_corona.
Compute coronal fieldlines corresponding to the given seedpoint_ss.
Compute the magnetic field at the source surface (needed for HCS computing)
- Parameters
-
Connectivity
Compute fieldline polarity and connectivity probability on this hardcoded grid.
Rearrange all the footpoints of coronal fieldlines into 2D bins on solar surface and associates a probability density.
For each bin of this hardcoded grid, its associated density is: .
- Parameters
-
[in] | fieldlines | |
[out] | densitymaps[0] | in vhelio-measured case. |
[out] | densitymaps[0:1] | for vhelio-min and vhelio-max case. |
[out] | footpoints | |
[out] | main_connect_point | |
[out] | polarities | |
Database
Add this simulation to the DB. Each Sc/planet is its own sc_ref. Ohterwise, define a scraft reference for ALL case. See All case sc_ref.
If sc_ref not found in ALL case, continue with module_io.all_mode desactivated
Outputs
Ccreate outputs arborescence:
Local connectivity file
Write a file containing all footpoint of the connectivity map and their associated density.
Footpoints are regrouped on this hardcoded grid.
Footpoint coordinates given with HelioGraphic Coordinate system and HelioProjective Coordinate system.
If not in_situ, footpoint for slow solar wind then footpoint for fast solar wind.
Footpoints are sorted with decreasing probability.
Format is defined here.
- Parameters
-
[in] | densitymaps | |
[out] | file_connectivity,: | localdir/localname + connectivity + .ascii or .tar |
Footpoints file
Write the list of all fieldline footpoints.
These footpoints are ordered like this: [fp(sc0,vhelio measured),...] or [fp(sc0,vhelio min),fp(sc0,vhelio max),...].
Only for developpers (to re-compute an image), not for CONNECT_WEB.
- Parameters
-
[out] | file_footpoint,: | localdir/localname + _fp + .ascii |
Local fieldline file
Write a file containing all fieldline computed.
Format is defined here.
Simulation parameters file
This file contains all important variables used for image computing.
Structure for Sc/Planet case: 'scName': dict
Structure for ALL case: 'scName1': dict, 'scNameN': dict
Dictionnary has some key values: scraft, hmodel, cmodel...
- Parameters
-
[out] | file_parameter,: | localdir/localname + _param + .yml |
Background images
Build background layer using plot_common.map2D routine.
Error supported:
- If no image to read, then error
Subpoint layer
No error supported in Sc/Planet case.
Errors supported in ALL case:
- if merge_images raise a ToolboxFileError, then error
Connectivity layer
No error supported in Sc/Planet case.
Errors supported in ALL case:
- if merge_images raise a ToolboxFileError, then error
Visible disk layer and file
No error supported in Sc/Planet case.
Errors supported in ALL case:
- if sc_ref vd had an error
HCS layer and file
No error supported in Sc/Planet case.
Errors supported in ALL case:
- if sc_ref hcs had an error
Frame layer
Build frame (axis + title + legend) No error supported.
Final images
Total image with background mag/euv171/euv193: Merge all previous layers into a non transparent image.
Error supported:
- If no background image, then error
- If all layers do not exist, merge_images raise a ToolboxFileError exception, then error
- If transparent final layer was not created, transparent2white raise a ToolboxFileError exception, then error
Flare layer and file
Look for flare. No error supported in Sc/Planet case.
Errors supported in ALL case:
- if merge_images raise a ToolboxFileError, then error
X-Flare layer and file
Look for X-flare. No error supported in Sc/Planet case.
Errors supported in ALL case:
- if merge_images raise a ToolboxFileError, then error
CME layer and file
Look for cme. No error supported in Sc/Planet case.
Errors supported in ALL case:
- if merge_images raise a ToolboxFileError, then error
Coronal hole layer
Look for coronal data. No error supported in Sc/Planet and All case.
Coronal hole file
Write the list of all coronal holes.
- Parameters
-
[out] | file_coronalhole,: | localdir/localname + _filecoronalhole + .ascii |
Database feeding and output summary
Fill all the fields of the Output DB. Recap about output files/layers errors
Close
Close orbitography and log files.
Initialisation
Log ID: Open log file logs/log_YYYYMMDD.
Input
Usage:
python connect_tool.py -hmodel heliospheric_model -cmodel coronal_model -magtype magnetic_type -reftime reference_time -y year -m month -d day -H hour
where:
- -h : brief help
- sc_name : SC/Planet name. May have multiple names. 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 connect_tool arguments in module_io.
Compute the input date
Init Spice orbitography
- Parameters
-
[in] | input | arguments |
[out] | times_sc | |
[out] | module_io | simulation variables (all_mode, hmodel, cmodel, magtype, reftime, year, month, day, hour, all_mode) |
Heliospheric reconstruction
About the in_situ mode.
If Vhelio found, insitu mode. All variables are a 1-element list (positions_ss[sc], times_ss[sc], density_maps[sc]) or a Nproba-element list (seedpoints_ss[sc], fieldlines[sc], footpoints[sc]).
Else, Vhelio = [Vslow,Vfast]. All variables are a 2-element list (positions_ss[sc], times_ss[sc], density_maps[sc]) or a 2Nproba-element list (seedpoints_ss[sc], fieldlines[sc], footpoints[sc]).
Set module_heliosphere parameters.
Call wanted heliospheric model through the interface_heliosphere.
Get the footpoint on the source surface (positions_ss[sc]) of an heliospheric magnetic fieldline ending at the position of SC/Planet (positions_sc[sc]). Uses different models:
- Parker model: see model_parker. If in situ measurement is available in the Timeserie Database, Parker spiral is computed using in situ solar wind speed. Otherwise, Parker spiral uses a minimum and maximum solar wind configuration.
- Hmodel2: to be implemented in the long term...
Compute propagation delays (dt_helio[sc]) between source surface and SC/planet.
- Parameters
-
[in] | module_io.hmodel | |
[in] | times_sc | |
[in] | positions_sc | |
[out] | velio | |
[out] | insitu | |
[out] | positions_ss | |
[out] | dt_helio | |
Connectivity
Compute connectivity probability on this hardcoded grid.
Rearrange all the footpoints of coronal fieldlines into 2D bins on solar surface and associates a probability density.
For each bin of this hardcoded grid, its associated density is: .
- Parameters
-
[out] | fieldlines | |
[in] | densitymaps[0] | in vhelio-measured case. |
[in] | densitymaps[0:1] | for vhelio-min and vhelio-max case. |
[in] | footpoints | |
Outputs
Define scraft reference for ALL case and create outputs arborescence.
See All case sc_ref. If sc_ref not found, continue with module_io.all_mode desactivated
Footpoints file
Write the list of all fieldline footpoints.
These footpoints are ordered like this: [fp(sc0,vhelio measured),...] or [fp(sc0,vhelio min),fp(sc0,vhelio max),...].
Only for developpers (to re-compute an image), not for CONNECT_WEB.
- Parameters
-
[out] | file_fp,: | localdir/localname + _fp + .ascii |
Simulation parameters file
This file contains all important variables used for image computing.
- Parameters
-
[out] | file_param,: | localdir/localname + _param + .ascii |
Images
Final connectivity image with plotmap_type background.
- Parameters
-
[out] | XXX_plot,: | Artist object |
[out] | XXX_path,: | Absolute path of the created image |
[out] | XXX_error,: | dictonnary ('error': boolean + 'message: string) |
[out] | background_mag_XXX[sc,all] | Magnetic background |
[out] | layer_connectivity_XXX[sc,all] | Layer with connectivity points |