diff --git a/pyVlsv/vlsvreader.py b/pyVlsv/vlsvreader.py index 34a41d67..b0264085 100644 --- a/pyVlsv/vlsvreader.py +++ b/pyVlsv/vlsvreader.py @@ -1004,6 +1004,25 @@ def calcLocalSize(globalCells, ntasks, my_n): return np.squeeze(orderedData) + + def read_variable_shaped(self, name, operator="pass"): + ''' 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: @@ -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)