Skip to content

Commit

Permalink
Rename output variable name now we have hierarchical outputs.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 732213030
  • Loading branch information
Nush395 authored and Torax team committed Feb 28, 2025
1 parent 0554b3c commit 6d3e323
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions torax/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ class ToraxSimOutputs:
JTOT = "jtot"
JTOT_FACE = "jtot_face"
JOHM = "johm"
# TODO(b/338033916): rename when we have a solution for hierarchical outputs.
# Add `core_profiles` prefix here to avoid name clash with
# core_sources.generic_current.
CORE_PROFILES_EXTERNAL_CURRENT = "external_current_source"
EXTERNAL_CURRENT = "external_current_source"
J_BOOTSTRAP = "j_bootstrap"
J_BOOTSTRAP_FACE = "j_bootstrap_face"
I_BOOTSTRAP = "I_bootstrap"
Expand Down Expand Up @@ -308,7 +305,7 @@ def _get_core_profiles(
xr_dict[JTOT] = self.core_profiles.currents.jtot
xr_dict[JTOT_FACE] = self.core_profiles.currents.jtot_face
xr_dict[JOHM] = self.core_profiles.currents.johm
xr_dict[CORE_PROFILES_EXTERNAL_CURRENT] = (
xr_dict[EXTERNAL_CURRENT] = (
self.core_profiles.currents.external_current_source
)

Expand Down
4 changes: 2 additions & 2 deletions torax/plotting/plotruns_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _transform_data(ds: xr.Dataset):
output.JTOT: 1e6, # A/m^2 to MA/m^2
output.JOHM: 1e6, # A/m^2 to MA/m^2
output.J_BOOTSTRAP: 1e6, # A/m^2 to MA/m^2
output.CORE_PROFILES_EXTERNAL_CURRENT: 1e6, # A/m^2 to MA/m^2
output.EXTERNAL_CURRENT: 1e6, # A/m^2 to MA/m^2
'generic_current_source': 1e6, # A/m^2 to MA/m^2
output.I_BOOTSTRAP: 1e6, # A to MA
output.IP_PROFILE_FACE: 1e6, # A to MA
Expand Down Expand Up @@ -331,7 +331,7 @@ def _transform_data(ds: xr.Dataset):
johm=core_profiles_dataset[output.JOHM].to_numpy(),
j_bootstrap=core_profiles_dataset[output.J_BOOTSTRAP].to_numpy(),
external_current_source=core_profiles_dataset[
output.CORE_PROFILES_EXTERNAL_CURRENT
output.EXTERNAL_CURRENT
].to_numpy(),
j_ecrh=get_optional_data(
core_sources_dataset, 'electron_cyclotron_source_j', 'cell'
Expand Down
4 changes: 2 additions & 2 deletions torax/tests/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def test_core_profiles_are_recomputable(self, test_config, halfway):
output.J_BOOTSTRAP,
output.J_BOOTSTRAP_FACE,
output.JOHM,
output.CORE_PROFILES_EXTERNAL_CURRENT,
output.EXTERNAL_CURRENT,
output.JTOT,
output.JTOT_FACE,
output.I_BOOTSTRAP,
Expand Down Expand Up @@ -822,7 +822,7 @@ def verify_core_profiles(ref_profiles, index, core_profiles):
)
np.testing.assert_allclose(
core_profiles.currents.external_current_source,
ref_profiles[output.CORE_PROFILES_EXTERNAL_CURRENT][index, :],
ref_profiles[output.EXTERNAL_CURRENT][index, :],
)
np.testing.assert_allclose(
core_profiles.currents.johm, ref_profiles[output.JOHM][index, :]
Expand Down

0 comments on commit 6d3e323

Please sign in to comment.