Chimp package
kaipy.chimp.chimph5p module
- kaipy.chimp.chimph5p.bndTPs(fname)
Get the number of particles and the minimum/maximum particle IDs from the H5Part file.
- Parameters:
fname (str) – The path to the H5Part file.
- Returns:
A tuple containing the number of particles (Np), the minimum particle ID (nS), and the maximum particle ID (nE).
- Return type:
tuple
- kaipy.chimp.chimph5p.cntTPs(fname)
Count the number of particles in the given H5Part file.
- Parameters:
fname (str) – The path to the H5Part file.
- Returns:
The number of particles in the H5Part file.
- Return type:
int
- kaipy.chimp.chimph5p.getH5p(fname, vId, Mask=None)
Retrieve a time series of a specified variable for a subset of particles from an H5Part file.
- Parameters:
fname (str) – The file path of the H5Part file.
vId (str) – The variable ID to create a time series of.
Mask (ndarray, optional) – An optional mask to select a subset of particles to include.
- Returns:
An array of time values. ndarray: A 2D array of the time series of the selected variable.
Dimensions: Nt x Np, where Nt is the length of the time series and Np is the number of particles that satify the Mask.
- Return type:
ndarray
If Mask is not provided, the function returns the time series for all particles within the H5Part file. If Mask is provided, the function returns the time series for particles with the applied mask.
- kaipy.chimp.chimph5p.getH5pT(fname, vID='isIn', nStp=0)
Retrieve a specific variable from an H5Part file for all particles at a given time step.
- Parameters:
fname (str) – The path to the H5Part file.
vID (str) – The name of the variable to retrieve. Default is “isIn”.
nStp (int) – The step number to pull the data from. Default is 0.
- Returns:
Np - number of particles in the H5Part file.
- Return type:
1D array containing the variable a the given step. Dimensions
- kaipy.chimp.chimph5p.getH5pid(fname, vId, pid)
Retrieve a time series of a specified variable for a given particle from an H5Part file.
- Parameters:
fname (str) – The path to the H5Part file.
vId (str) – The variable ID to create a time series of.
pid (int) – The particle ID to retrieve.
- Returns:
A tuple containing two arrays - the time array and the time series of the specified variable.
- Return type:
tuple
- kaipy.chimp.chimph5p.locPID(fname, pid)
Find the array index of a particle with a given ID in the H5Part file.
- Parameters:
fname (str) – The path to the H5Part file.
pid (int) – The ID of the particle to find.
- Returns:
The array index of the specified particle or None if the given particle ID is not found in the H5Part file.
- Return type:
int or None
kaipy.chimp.chimpviz module
- kaipy.chimp.chimpviz.AddTPs(xyz, V=None, vIDs=None, fOut='tps.h5', nStp=0)
Add selected test particle outputto an HDF5 file.
- Parameters:
xyz (numpy.ndarray) – The coordinates of the TPs. Shape (Nt, Np, Nd).
V (numpy.ndarray, optional) – The values associated with the TPs. Shape (Nt, Np, Nv).
vIDs (list of str, optional) – The desired variable IDs to add.
fOut (str, optional) – The output file path.
nStp (int, optional) – The step number.
- Returns:
None
kaipy.chimp.kCyl module
- kaipy.chimp.kCyl.PIso(fIn, nStp=0, pCut=0.001, doAsym=False)
Calculate the pressure anisotropy for a given input file.
- Parameters:
fIn (str) – The input file path.
nStp (int, optional) – The number of steps. Default is 0.
pCut (float, optional) – The minimum pressure value to consider. Default is 1.0e-3.
doAsym (bool, optional) – Flag to calculate Pxy/Pz-1, otherwise it will return Pxy/(Pxy+Pz). Default is False.
- Returns:
The calculated isotropy parameter.
- Return type:
pR (numpy.ndarray)
- kaipy.chimp.kCyl.getEQGrid(fIn, doCenter=False, doWrap=False)
Get the equatorial grid coordinates from an HDF5 file.
- Parameters:
fIn (str) – The path to the HDF5 file.
doCenter (bool) – Flag indicating whether to output the cell centered grid coordinates. Default is False.
doWrap (bool) – Flag indicating whether to add an extra layer in phi to the cell-centered grid coordinates. Useful for contour plots in polar coordinates. Default is False.
- Returns:
- xx (ndarray): The x-coordinates of the grid at the cell edges.
yy (ndarray): The y-coordinates of the grid at the cell edges.
- If doCenter is True and doWrap is False:
xxc (ndarray): The cell centered x-coordinates of the grid. yyc (ndarray): The cell centered y-coordinates of the grid.
- If doWrap is True:
xxc (ndarray): The wrapped and cell centered x-coordinates of the grid. yyc (ndarray): The wrapped and cell centered y-coordinates of the grid.
- Return type:
If doCenter is False
- kaipy.chimp.kCyl.getGrid(fIn, do4D=False)
Retrieve grid data (2D equatorial location, energy, pitch angle) from an HDF5 file containing PSD output.
- Parameters:
fIn (str) – The path to the PSD HDF5 file.
do4D (bool, optional) – Flag indicating whether to retrieve 4D grid (including pitch angle). Default is False.
- Returns:
X-coordinates of the equatorail grid. yy (ndarray): Y-coordinates of the equatorail grid. Ki (ndarray): 1D array of energy grid at cell edges. Kc (ndarray): 1D array of energy grid at cell centers. Ai (ndarray, optional): 1D array of pitch angle grid at cell edges. Only returned if do4D is True. Ac (ndarray, optional): 1D array of pitch angle grid at cell centers. Only returned if do4D is True.
- Return type:
xx (ndarray)
- kaipy.chimp.kCyl.getSlc(fIn, nStp=0, vID='jPSD', doWrap=False)
Retrieve a specified variable at a given time step of data from an HDF5 file.
- Parameters:
fIn (str) – The path to the HDF5 file.
nStp (int) – The step number.
vID (str) – The variable ID.
doWrap (bool) – Flag indicating whether to add an extra layer in phi to the cell-centered grid coordinates. Useful for contour plots in polar coordinates. Default is False.
- Returns:
The retrieved slice of data.
- Return type:
V (ndarray)