data reducer gyrophase_relstddev() broken.
Opened this issue · 0 comments
kostahoraites commented
I tried to use this function in a new v5 data reducer, in reduction.py :
f = pt.vlsvfile.VlsvReader('/wrk-vakka/group/spacephysics/vlasiator/3D/FHA/bulk1/bulk1.0001200.vlsv')
v5reducers["vg_gyrophase_relstddev"] = DataReducerVariable(["vg_v", "vg_b_vol"], gyrophase_relstddev, "", 1, useVspace=True)
But the function does not seem to work. Even if you pass 2 cell ids that have velocity space data, cellid1 and cellid2, it gives an error:
f.read_variable("vg_gyrophase_relstddev", cellids=[cellid1, cellid2])
File "<stdin>", line 1, in <module>
File "/proj/horakons/analysator/pyVlsv/vlsvreader.py", line 1738, in read_variable
return self.read(mesh="SpatialGrid", name=name, tag="VARIABLE", operator=operator, cellids=cellids)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/proj/horakons/analysator/pyVlsv/vlsvreader.py", line 1041, in read
output[index] = reducer.operation( tmp_vars , velocity_cell_data, velocity_coordinates )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/proj/horakons/analysator/pyVlsv/reduction.py", line 686, in gyrophase_relstddev
histo = pl.hist(gyrophase_data[0].data, weights=gyrophase_data[1].data, bins=36, range=[-180.0,180.0], log=False, normed=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/wrk-vakka/appl/easybuild/opt/Anaconda3/2023.09-0/lib/python3.11/site-packages/matplotlib/pyplot.py", line 2645, in hist
return gca().hist(
^^^^^^^^^^^
File "/wrk-vakka/appl/easybuild/opt/Anaconda3/2023.09-0/lib/python3.11/site-packages/matplotlib/__init__.py", line 1446, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/wrk-vakka/appl/easybuild/opt/Anaconda3/2023.09-0/lib/python3.11/site-packages/matplotlib/axes/_axes.py", line 6944, in hist
p._internal_update(kwargs)
File "/wrk-vakka/appl/easybuild/opt/Anaconda3/2023.09-0/lib/python3.11/site-packages/matplotlib/artist.py", line 1223, in _internal_update
return self._update_props(
^^^^^^^^^^^^^^^^^^^
File "/wrk-vakka/appl/easybuild/opt/Anaconda3/2023.09-0/lib/python3.11/site-packages/matplotlib/artist.py", line 1197, in _update_props
raise AttributeError(
AttributeError: Rectangle.set() got an unexpected keyword argument 'normed'
So the function gyrophase_relstddev() in reduction.py needs to be debugged, if it is to be used at all. The function itself indicates it 'needs to be verified', indicating that it may never have been tested:
def gyrophase_relstddev( variables, velocity_cell_data, velocity_coordinates ):
# This reducer needs to be verified
bulk_velocity = variables[0]
B = variables[1]
B_unit = B / np.linalg.norm(B)
gyrophase_data = gyrophase_angles(bulk_velocity, B_unit, 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])