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

Support reading of 'rt' lasy files #371

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,17 @@ def read_field_circ( filename, iteration, field, coord,
# Extract the metainformation
coord_labels = {ii: coord.decode() for (ii,coord) in
enumerate(group.attrs['axisLabels'])}
coord_label_str = ''.join(coord_labels.values())
coord_label_str = 'm' + coord_label_str
coord_order = RZorder[coord_label_str]

if coord_order == RZorder.mrz:
if coord_labels[0] == 'r':
coord_order = RZorder.mrz
Nm, Nr, Nz = get_shape( dset )
N_pair = (Nr, Nz)
elif coord_order == RZorder.mzr:
elif coord_labels[1] == 'r':
Nm, Nz, Nr = get_shape( dset )
N_pair = (Nz, Nr)
coord_order = RZorder.mzr
else:
raise Exception(order_error_msg)

info = FieldMetaInformation( coord_labels, N_pair,
group.attrs['gridSpacing'], group.attrs['gridGlobalOffset'],
group.attrs['gridUnitSI'], dset.attrs['position'], thetaMode=True )
Expand Down Expand Up @@ -269,12 +268,6 @@ def read_field_circ( filename, iteration, field, coord,
else:

# Extract the modes and recombine them properly
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ) )
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ) )
else:
raise Exception(order_error_msg)
if m == 'all':
# Sum of all the modes
# - Prepare the multiplier arrays
Expand All @@ -290,11 +283,13 @@ def read_field_circ( filename, iteration, field, coord,
# - Sum the modes
F = get_data( dset ) # (Extracts all modes)
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ), dtype=F.dtype )
F_total[Nr:, :] = np.tensordot( mult_above_axis,
F, axes=(0, 0) )[:, :]
F_total[:Nr, :] = np.tensordot( mult_below_axis,
F, axes=(0, 0) )[::-1, :]
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ), dtype=F.dtype )
F_total[:, Nr:] = np.tensordot( mult_above_axis,
F, axes=(0, 0) )[:, :]
F_total[:, :Nr] = np.tensordot( mult_below_axis,
Expand All @@ -303,9 +298,11 @@ def read_field_circ( filename, iteration, field, coord,
# Extract mode 0
F = get_data( dset, 0, 0 )
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ), dtype=F.dtype )
F_total[Nr:, :] = F[:, :]
F_total[:Nr, :] = F[::-1, :]
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ), dtype=F.dtype )
F_total[:, Nr:] = F[:, :]
F_total[:, :Nr] = F[:, ::-1]
else:
Expand All @@ -319,9 +316,11 @@ def read_field_circ( filename, iteration, field, coord,
F_sin = get_data( dset, 2 * m, 0 )
F = cos * F_cos + sin * F_sin
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ), dtype=F.dtype )
F_total[Nr:, :] = F[:, :]
F_total[:Nr, :] = (-1) ** m * F[::-1, :]
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ), dtype=F.dtype )
F_total[:, Nr:] = F[:, :]
F_total[:, :Nr] = (-1) ** m * F[:, ::-1]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ def read_field_circ( series, iteration, field_name, component_name,
# grid spacing/offset/position

coord_labels = {ii: coord for (ii, coord) in enumerate(field.axis_labels)}
coord_label_str = ''.join(coord_labels.values())
coord_label_str = 'm' + coord_label_str
coord_order = RZorder[coord_label_str]
if coord_order is RZorder.mrz:

if coord_labels[0] == 'r':
coord_order = RZorder.mrz
Nm, Nr, Nz = component.shape
N_pair = (Nr, Nz)
elif coord_order is RZorder.mzr:
elif coord_labels[1] == 'r':
Nm, Nz, Nr = component.shape
N_pair = (Nz, Nr)
coord_order = RZorder.mzr
else:
raise Exception(order_error_msg)

Expand Down Expand Up @@ -271,12 +271,6 @@ def read_field_circ( series, iteration, field_name, component_name,
else:

# Extract the modes and recombine them properly
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ) )
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ) )
else:
raise Exception(order_error_msg)
if m == 'all':
# Sum of all the modes
# - Prepare the multiplier arrays
Expand All @@ -292,11 +286,13 @@ def read_field_circ( series, iteration, field_name, component_name,
# - Sum the modes
F = get_data( series, component ) # (Extracts all modes)
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ), dtype=F.dtype )
F_total[Nr:, :] = np.tensordot( mult_above_axis,
F, axes=(0, 0) )[:, :]
F_total[:Nr, :] = np.tensordot( mult_below_axis,
F, axes=(0, 0) )[::-1, :]
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ), dtype=F.dtype )
F_total[:, Nr:] = np.tensordot( mult_above_axis,
F, axes=(0, 0) )[:, :]
F_total[:, :Nr] = np.tensordot( mult_below_axis,
Expand All @@ -307,9 +303,11 @@ def read_field_circ( series, iteration, field_name, component_name,
# Extract mode 0
F = get_data( series, component, 0, 0 )
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ), dtype=F.dtype )
F_total[Nr:, :] = F[:, :]
F_total[:Nr, :] = F[::-1, :]
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ), dtype=F.dtype )
F_total[:, Nr:] = F[:, :]
F_total[:, :Nr] = F[:, ::-1]
else:
Expand All @@ -322,9 +320,11 @@ def read_field_circ( series, iteration, field_name, component_name,
F_sin = get_data( series, component, 2 * m, 0 )
F = cos * F_cos + sin * F_sin
if coord_order is RZorder.mrz:
F_total = np.zeros( (2 * Nr, Nz ), dtype=F.dtype )
F_total[Nr:, :] = F[:, :]
F_total[:Nr, :] = (-1) ** m * F[::-1, :]
elif coord_order is RZorder.mzr:
F_total = np.zeros( (Nz, 2 * Nr ), dtype=F.dtype )
F_total[:, Nr:] = F[:, :]
F_total[:, :Nr] = (-1) ** m * F[:, ::-1]
else:
Expand Down