calculations

This is a module that includes most, if not all, calculations within the analysator. Please type “.” and press tab to see which functions this module includes.

Example: import analysator as pt

pt.calculations. #press tab

#Output: list of functions

pt.calculations.fourier? #Press Enter

analysator.calculations.cut3d(vlsvReader, xmin, xmax, ymin, ymax, zmin, zmax, variable, operator='pass', trim_array=False)

Retrieves variables for the given 3d cut

Parameters:
  • vlsvReader (vlsvfile.VlsvReader) – Some VlsvReader with a file open

  • xmin – The minimum x coordinate of the 2d cut

  • xmax – The maximum x coordinate of the 2d cut

  • ymin – The minimum y coordinate of the 2d cut

  • ymax – The maximum y coordinate of the 2d cut

  • zmin – The minimum z coordinate of the 2d cut

  • zmax – The maximum z coordinate of the 2d cut

  • variable – Some variable to read from the vlsv file

  • operator – The variable operator

  • trim_array – If true, shapes the array into an array with minimum amount of dimensions, e.g. if the cut is zmax-zmin=0 then this will return a 2d array

Example:
import analysator as pt
f = pt.vlsvfile.VlsvReader('example.vlsv')
three_cut = pt.calculations.cut3d( vlsvReader=f, xmin=1e6, xmax=4e6, ymin=1e6, xmax=4e6, zmin=0, zmax=0, variable="rho" )
import numpy as np
# Now three_cut is a three-dimensional array (x,y,z), but we can transform it into a 2-d array (x,y) with:
dimensions = np.shape( three_cut )
two_cut = np.reshape( three_cut, dimensions[0:2] )
analysator.calculations.fourier(t, y, kaiserwindowparameter=0)

Function for returning fourier series and frequencies of some given arrays t and y

Parameters:
  • t – Time

  • y – Some variable data

Returns:

the frequencies, new time variables and frequencies

Note

return format: [FFT, frequencies, t, y]

Note

t must have a constant time stepping

Example usage:
fourier_data = fourier( t=np.arange(0,500,0.5), y=rho_data, kaiserwindowparameter=14 )
analysator.calculations.lineout(vlsvReader, point1, point2, variable, operator='pass', interpolation_order=1, points=100)

Returns a line cut-through from a given VLSV file for distance, coordinates and variable values. The main difference between this and cut_through is that this function interpolates a given variable.

Parameters:
  • vlsvReader (vlsvfile.VlsvReader) – Some open VlsvReader

  • point1 – The starting point of a cut-through line

  • point2 – The ending point of a cut-through line

  • variable – Variable to return

  • operator – The operator for the variable, for example “x” for x-component or “magnitude” for magnitude

  • interpolation_order – Order of interpolation (0 or 1), defaults to 1

  • points – Number of points to return

Returns:

A tuple with output: (distance, coordinates, variable_values)

# Example:
import analysator as pt # import analysator

vlsvReader = pt.vlsvfile.VlsvReader("testfile.vlsv") # Open a vlsv file
lineout_rho = pt.calculations.lineout( vlsvReader=vlsvReader, point1=[1.0e5, 1.0e6, 0], point2=[2.0e5, 2.0e6, 0], variable="rho", interpolation_order=1, points=100 )
distance = lineout_rho[0]
coordinates = lineout_rho[1]
values = lineout_rho[2]