From 21f54ad606c88886d66ec33b959f7299a89587ca Mon Sep 17 00:00:00 2001 From: Horaites Konstantinos Date: Thu, 29 Aug 2024 09:39:08 +0300 Subject: [PATCH 1/3] Made a dummy function to test vspace data reducers --- pyVlsv/reduction.py | 11 +++++++++++ pyVlsv/vlsvreader.py | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index 7ee6d9ab..f47d9502 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -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 @@ -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}$") diff --git a/pyVlsv/vlsvreader.py b/pyVlsv/vlsvreader.py index 6d2b8f27..19f61df7 100644 --- a/pyVlsv/vlsvreader.py +++ b/pyVlsv/vlsvreader.py @@ -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 @@ -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: From c97b7d1b9e6055de4aaef85403343b6b9419675a Mon Sep 17 00:00:00 2001 From: Horaites Konstantinos Date: Thu, 29 Aug 2024 14:06:10 +0300 Subject: [PATCH 2/3] Made dummy data reducer with useVspace --- pyVlsv/reduction.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index 88f1b4b3..d0623294 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -689,11 +689,11 @@ def gyrophase_relstddev( variables, velocity_cell_data, velocity_coordinates ): 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) + B = variables[0] + print('B: ', B.shape) + print('vcelldata: ', list(velocity_cell_data.keys())[0], list(velocity_cell_data.values())[0]) + print('vcoord: ', velocity_coordinates.shape) + return np.sum(velocity_coordinates) def Dng( variables ): # This reducer needs to be verified @@ -1204,7 +1204,7 @@ def makelambda(index): 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? +v5reducers["vg_vspace_dummy"] = DataReducerVariable(["vg_b_vol"], vspace_dummy, "", 1, useVspace=True) # I think this has vector length 1? #multipopv5reducers multipopv5reducers = {} From c099eba9925710f85a8bece6ffeb2b96b20f30fc Mon Sep 17 00:00:00 2001 From: kostahoraites Date: Mon, 7 Oct 2024 10:46:10 +0300 Subject: [PATCH 3/3] minor changes, playing around with vlsv data reducer --- pyVlsv/reduction.py | 15 ++++++++++----- pyVlsv/vlsvreader.py | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pyVlsv/reduction.py b/pyVlsv/reduction.py index d0623294..74a215b0 100644 --- a/pyVlsv/reduction.py +++ b/pyVlsv/reduction.py @@ -689,10 +689,15 @@ def gyrophase_relstddev( variables, velocity_cell_data, velocity_coordinates ): def vspace_dummy( variables, velocity_cell_data, velocity_coordinates ): # This reducer needs to be verified - B = variables[0] - print('B: ', B.shape) - print('vcelldata: ', list(velocity_cell_data.keys())[0], list(velocity_cell_data.values())[0]) - print('vcoord: ', velocity_coordinates.shape) + #B = variables[0] + #print('B: ', B.shape) + velocity_cellids = np.array(list(velocity_cell_data.keys())) + psd = np.array(list(velocity_cell_data.values())) + print(velocity_cellids.shape) + print(psd.shape) + print(velocity_coordinates.shape) + #print('vcelldata: ', list(velocity_cell_data.keys())[0], list(velocity_cell_data.values())[0]) + #print('vcoord: ', velocity_coordinates.shape) return np.sum(velocity_coordinates) def Dng( variables ): @@ -1204,7 +1209,7 @@ def makelambda(index): 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_b_vol"], vspace_dummy, "", 1, useVspace=True) # I think this has vector length 1? +v5reducers["vg_vspace_dummy"] = DataReducerVariable([], vspace_dummy, "", 1, useVspace=True) #multipopv5reducers multipopv5reducers = {} diff --git a/pyVlsv/vlsvreader.py b/pyVlsv/vlsvreader.py index f81f38d7..4d6cef07 100644 --- a/pyVlsv/vlsvreader.py +++ b/pyVlsv/vlsvreader.py @@ -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, pop='proton'): + def read(self, name="", tag="", mesh="", operator="pass", cellids=-1): ''' Read data from the open vlsv file. :param name: Name of the data array @@ -1030,7 +1030,7 @@ def read(self, name="", tag="", mesh="", operator="pass", cellids=-1, pop='proto output = np.zeros(len(actualcellids)) index = 0 for singlecellid in actualcellids: - velocity_cell_data = self.read_velocity_cells(singlecellid, pop=pop) + velocity_cell_data = self.read_velocity_cells(singlecellid) # Get cells: vcellids = list(velocity_cell_data.keys()) # Get coordinates: