Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HiPACE fixes #18

Merged
merged 6 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion visualpic/data_reading/field_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@ def _read_field_3d_cart(self, file_path, field_path, slice_i=0.5,
slice_j=0.5, slice_dir_i=None, slice_dir_j=None):
file = H5F(file_path, 'r')
fld = file[field_path]
fld = np.moveaxis(fld, 0, 2)
if slice_dir_i is not None:
fld_shape = fld.shape
axis_order = ['z', 'x', 'y']
axis_order = ['x', 'y', 'z']
slice_list = [slice(None)] * fld.ndim
axis_idx_i = axis_order.index(slice_dir_i)
axis_elements_i = fld_shape[axis_idx_i]
Expand Down
7 changes: 4 additions & 3 deletions visualpic/data_reading/folder_scanners.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def get_list_of_fields(self, folder_path):
for file in files_in_folder:
if file.endswith('.h5'):
if 'density' in file:
species_name = file.split('_')[1]
species_name = '_'.join(file.split('_')[1:-1])
if species_name not in species_names:
species_names.append(species_name)
elif 'field' in file:
Expand Down Expand Up @@ -507,7 +507,7 @@ def get_list_of_species(self, folder_path):
for file in files_in_folder:
if file.endswith('.h5'):
if 'raw' in file:
species_name = file.split('_')[1]
species_name = '_'.join(file.split('_')[1:-1])
if species_name not in species_names:
species_names.append(species_name)
available_species = []
Expand Down Expand Up @@ -653,7 +653,8 @@ def _get_files_and_timesteps(self, folder_path, files_in_folder, prefix,
A tuple with a an array of file paths and and array of timesteps.
"""
field_files = [os.path.join(folder_path, file) for file in
files_in_folder if (prefix in file) and (name in file)]
files_in_folder if ((prefix in file) and (name in file)
and (file.endswith('.h5')))]
time_steps = np.zeros(len(field_files))
for i, file in enumerate(field_files):
time_step = int(file.split('_')[-1].split('.')[0])
Expand Down
8 changes: 7 additions & 1 deletion visualpic/data_reading/particle_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def __init__(self, *args, **kwargs):

def _read_component_data(self, file_path, species, component):
with H5F(file_path, 'r') as file_handle:
data = file_handle[self.name_relations[component]]
if component in self.name_relations:
hp_name = self.name_relations[component]
else:
hp_name = component
data = file_handle[hp_name]
if component == 'tag':
# Apply Cantor pairing function
print(data)
Expand All @@ -141,6 +145,8 @@ def _read_component_metadata(self, file_path, species, component):
units = 'm_ec'
elif component == 'q':
units = 'qnorm'
else:
units = ''
metadata['units'] = units
metadata['time'] = {}
metadata['time']['value'] = file_handle.attrs['TIME'][0]
Expand Down
10 changes: 5 additions & 5 deletions visualpic/visualization/vtk_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,11 @@ def _load_data(self, timestep, only_metadata=False):
max_fld = np.max(fld_data)
self._original_data_range = [min_fld, max_fld]
fld_data = self._normalize_field(fld_data)
# Making fld_data a new numpy array fixes a crash in
# vtk_data_import.SetImportVoidPointer in some cases when trimming
# in the y or z planes is applied. It is not clear why this
# happens.
self._field_data = np.array(fld_data)
# Make sure the array is contiguous, otherwise this can lead to
# errors in vtk_data_import.SetImportVoidPointer in some cases when
# trimming in the y or z planes is applied, or when the array has
# been rearranged in the FieldReader (such as for HiPACE data).
self._field_data = np.ascontiguousarray(fld_data)
self._field_metadata = fld_md
if not only_metadata:
self._loaded_timestep = timestep
Expand Down