Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion pyVlsv/vlsvreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,25 @@ def calcLocalSize(globalCells, ntasks, my_n):

return np.squeeze(orderedData)


def read_variable_shaped(self, name, operator="pass"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add variable name checking here so that if someone accidentally uses this for a fg_ variable, things won't break. Also, an AMR check would be good.

''' Read variables from the open vlsv file for the full grid and reshape the output to match the grid.
Arguments:
:param name: Name of the variable
:param operator: Datareduction operator. "pass" does no operation on data
:returns: numpy array with the data

.. seealso:: :func:`read` :func:`read_variable_info`
'''
# Read variable as usual
data = self.read_variable(name, cellids=-1,operator=operator)
# sort with CellID
data = data[self.read_variable("CellID").argsort()]
# reshape to mesh size
data = data.reshape(self.get_spatial_mesh_size())
return data


def read_variable(self, name, cellids=-1,operator="pass"):
''' Read variables from the open vlsv file.
Arguments:
Expand Down Expand Up @@ -1091,7 +1110,7 @@ def read_variable_info(self, name, cellids=-1, operator="pass"):
if operator=="magnitude":
latex = r"$|$"+latex+r"$|$"
else:
latex = latex+r"{$_{"+operator+r"}$}"
latex = latex+r"${_{"+operator+r"}}$"
return VariableInfo(data_array=data, name=name + "_" + operator, units=units, latex=latex, latexunits=latexunits)
else:
return VariableInfo(data_array=data, name=name, units=units, latex=latex, latexunits=latexunits)
Expand Down