-
Notifications
You must be signed in to change notification settings - Fork 33
Home
NOTE: This page is mostly outdated (last updated in 2016)
- Installing Analysator
- Plotting VLSV files
- Using particle pusher
- Working in Taito
- Using Analysator on compute nodes
- Hawk guide
Here is a quick list of features one can do with python tools:
- Read VLSV files and do calculations with the data
- Write VLSV files
- Plot the real space from VLSV files with mayavi
- Plot the velocity space (both blocks and iso surface) from VLSV files by clicking in real space
- Take cut-throughs from VLSV files (both in mayavi plots and from the terminal for calculations) Note: Check the "Picker options" section.
- Take pitch angle distributions (both in terminal from VLSV files and in Mayavi by clicking with the cursor)
- Take gyrophase angle (both in terminal from VLSV files and in Mayavi by clicking with the cursor)
- Take 3d slices (for making 2d or 3d fouriers, for example)
- Take time evolution of specified variables for specified cells
- Plot variables with sub plots in a clean format
- Take fourier transforms in time (This can be done via scipy or numpy library too)
- Fit 1d polynomials to data (Not used very much and this can be done via scipy)
- Edit the code as you see fit and improve it (Python is easy)
- Do python scripts and combine all of this
This class is used to read a vlsv file. Usage:
f=pt.vlsvfile.VlsvReader(file_name="fullf.0000000.vlsv")
### VlsvWriter
This class is used to write vlsv files. Usage:
``` python
vlsvReader=pt.vlsvfile.VlsvReader(file_name="fullf.0000000.vlsv")
vlsvWriter=pt.vlsvfile.VlsvWriter(vlsvReader=vlsvReader, "new_file.vlsv")
# Read in rho:
rho = vlsvReader.read_variable('rho')
vlsvWriter.write( data=rho, name="rho", tag="VARIABLE", mesh="SpatialGrid")
This class is used to plot the data in a vlsv file as a mayavi grid The following will bring up a new window and plot the grid in the vlsv file:
grid = pt.grid.MayaviGrid(vlsvReader=f, variable="rho", operator='pass', threaded=False)
Once you have the window open you can use the picker tool in the right-upper corner and use various point-click tools for analyzing data.
Picker options:
None
Does nothing upon clicking somewhere in the grid
Velocity_space
Plots the velocity space at a specific position upon clicking somewhere in the grid Note: If the vlsv file does not have the velocity space at the position where you are clicking, this will not work
Velocity_space_iso_surface
Plots the velocity space at a specific position upon clicking somewhere in the grid in iso-surface plotting style Note: If the vlsv file does not have the velocity space at the position where you are clicking, this will not work
Velocity_space_nearest_cellid
Plots the velocity space of the closest cell id to the picking point Note: If the vlsv file does not have velocity space saved at all, this will not work
Velocity_space_nearest_cellid_iso_surface
Plots the velocity space of the closest cell id to the picking point in iso-surface plotting style Note: If the vlsv file does not have velocity space saved at all, this will not work
Pitch_angle
Plots the pitch angle distribution at the clicking position Note: If the vlsv file does not have the velocity space at the position where you are clicking, this will not work
Cut_through
Is used to plot or save the cut-through between two clicking points. This option requires you to use the args section at top-left.
To use the args section to plot variables you must write for example:
plot rho B,x E,y
Upon clicking at two points a new window would open with a cut-through plot of rho, x-component of B and y-component of E
Alternatively, you can save the cut-through to a variable in the MayaviGrid class by typing instead:
rho B,x E,y
and then going to the terminal and typing
cut_through_data = grid.cut_through
print(cut_through_data)
This class is used to hold variables with info (name, units) on them.
rho = f.read_variable_info(name='rho')
rho.units='1/m^3'
print(rho)
print(rho.units)
print(rho.name)
print(rho.data)
# Plot rho:
import numpy as np
length = len(rho.data)
figure = pt.plot.plot_variables(np.arange(length)*5, rho)
figure.show()
Includes various tools for doing calculations
pt.calculations.
Includes a couple of quick plotting functions that support the VariableInfo class
pt.plot.
Includes everything to do with plotting vlsv files with Mayavi
pt.grid.
Includes everything to do with reading and writing vlsv files
pt.vlsvfile.
f=pt.vlsvfile.VlsvReader(file_name="trunk/distfunction.0000030.vlsv")
cut=pt.calculations.cut_through(f,[-1e7,0,0],[3e7,0,0]);
#read rho and B magnitude. cut[0] contains the cellids
rho = f.read_variable("rho",cut[0].data)
B = f.read_variable_info("B",cut[0].data,"magnitude")
#plot as function of distance in cut[1]
fig=pt.plot.plot_multiple_variables([cut[1],cut[1]],[rho,B])
fig.show()