Skip to content

Loading and Plotting simulation data

Michael Hirsch, Ph.D edited this page Jan 4, 2019 · 4 revisions

Either MATLAB or GNU Octave is required to load the output file via scripts in the vis/ directory. The results for an entire simulation can be plotted using plotall.m.

These also illustrates how to read in a sequence of files from a simulation.
This script prints a copy of the output plots into the simulation output directory. Finer-level output control can be achieve by using the 'plotframe.m' and 'loadframe.m' scripts to plot and load data from individual simulation output frames, respectively.

The particular format of the output files is specified by the user in the input config.ini file. There are three options:

  1. full output - output all state variables; very large file sizes will results, but this is required for building initial conditions and for some analysis that require detailed composition and temperature information.
  2. average state parameter output - species averaged temperature and velocity; electron density. Probably best for most uses
  3. density only output - only electron density output. Best for high-res instability runs where only the density is needed and the output cadence is high

The organization of the data in the MATLAB/octave workspace, after a single frame is loaded via 'loadframe.m', is as follows. MKSA units are used throughout:

Time variables:

simdate - a six element vector containing year, month, day, UT hour, UT minute, and UT seconds of the present frame

Grid variables:

  • structure xg - members xg.x1,2,3 are the position variables, xg.h* are the metric factors, xg.dx* are the finite differences,
  • xg.glat,glon are the latitudes and longitudes (degrees geographic) of each grid point, xg.alt is the altitude of each grid point.
  • xg.r,theta,phi - for each grid point: radial distance (from ctr of Earth), magnetic colatitude (rads.), and magnetic longitude (rads.)

The grid structure, by itself, can be read in by the MATLAB function 'readgrid.m'; this is automatically invoked with 'loadframe.m' so there is not need to separately load the grid and output frame data.

Temperature variable:

Ts

  • first three dimensions have size lxs
  • 4th dimension is species index: 1=O+,2=NO+,3=N2+,4=O2+,5=N+, 6=H+,7=e-)

Density variable:

ns (same indexing as temperature)

Drifts:

vs1 (same indexing as temperature)

  • x2-drift component: v2 (same for all species, so this is just size lxs and is a 3D array)
  • x3-drift component: v3

Electromagnetic variables:

  • current density: J1, J2, J3
  • potential: Phitop (EFL potential)

Note that the electric field is not included in the output file, but that it can be calculated from this output by taking -vxB at an altitude above about 200 km or by differentiating the top boundary electric potential 'Phitop' with respect to the x2 and x3 variables; however, note that if a curvilinear grid is used the derivatives must include the appropriate metric factors.

Computing total electron content (TEC)

TEC and magnetic field variations can be calculated as a post-processing step in which the simulation data are read in and interpolated onto a regular geographic grid and then integrated accordingly using scripts in the './vis' directory - see TECcalc.m.
An example of how to plot TEC computed by this script is included in TECplot_map.m (requires MATLAB mapping toolbox).

Visualizing magnetic field perturbations computed by magcalc.f90

The example script magplot_fort_map.m shows an example of how to load the results of running magcalc.

Clone this wiki locally