Skip to content

Commit

Permalink
Made a dummy function to test vspace data reducers
Browse files Browse the repository at this point in the history
  • Loading branch information
Horaites Konstantinos committed Aug 29, 2024
1 parent 9322d69 commit 21f54ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions pyVlsv/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,14 @@ def gyrophase_relstddev( variables, velocity_cell_data, velocity_coordinates ):
histo = pl.hist(gyrophase_data[0].data, weights=gyrophase_data[1].data, bins=36, range=[-180.0,180.0], log=False, normed=1)
return np.std(histo[0])/np.mean(histo[0])

def vspace_dummy( variables, velocity_cell_data, velocity_coordinates ):
# This reducer needs to be verified
rho = variables[0]

print('velocity_cell_data.shape = '.format(velocity_cell_data.shape))
print('velocity_coordinates.shape = '.format(velocity_coordinates.shape))
return np.sum(velocity_cell_data)

def Dng( variables ):
# This reducer needs to be verified
# This routine is still very slow due to for-loops
Expand Down Expand Up @@ -1194,6 +1202,9 @@ def makelambda(index):
v5reducers["vg_jacobian_bper"] = DataReducerVariable(["vg_dperbxvoldx","vg_dperbxvoldy","vg_dperbxvoldz","vg_dperbyvoldx","vg_dperbyvoldy","vg_dperbyvoldz","vg_dperbzvoldx","vg_dperbzvoldy","vg_dperbzvoldz"], TensorFromScalars, "T/m", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$")
v5reducers["vg_j"] = DataReducerVariable(["vg_jacobian_bper"], J, "A/m^2", 1, latex=r"$\vec{J}$",latexunits=r"$\mathrm{A}\,\mathrm{m}^{-2}$")

#reducers with useVspace
v5reducers["vg_vspace_dummy"] = DataReducerVariable(["vg_rho"], vspace_dummy, "", 1, useVspace=True) # I think this has vector length 1?

#multipopv5reducers
multipopv5reducers = {}
multipopv5reducers["pop/vg_rhom"] = DataReducerVariable(["pop/vg_rho"], rhom, "kg/m3", 1, latex=r"$\rho_{m,\mathrm{REPLACEPOP}}$",latexunits=r"$\mathrm{kg}\,\mathrm{m}^{-3}$")
Expand Down
4 changes: 2 additions & 2 deletions pyVlsv/vlsvreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ def read_attribute(self, name="", mesh="", attribute="", tag=""):
raise ValueError("Variable or attribute not found")


def read(self, name="", tag="", mesh="", operator="pass", cellids=-1):
def read(self, name="", tag="", mesh="", operator="pass", cellids=-1, pop='proton'):
''' Read data from the open vlsv file.
:param name: Name of the data array
Expand Down Expand Up @@ -1030,7 +1030,7 @@ def read(self, name="", tag="", mesh="", operator="pass", cellids=-1):
output = np.zeros(len(actualcellids))
index = 0
for singlecellid in actualcellids:
velocity_cell_data = self.read_velocity_cells(singlecellid)
velocity_cell_data = self.read_velocity_cells(singlecellid, pop=pop)
# Get cells:
vcellids = list(velocity_cell_data.keys())
# Get coordinates:
Expand Down

0 comments on commit 21f54ad

Please sign in to comment.