Skip to content

Commit

Permalink
create_display_name only splits/replaces to the first "_" character
Browse files Browse the repository at this point in the history
gcpy/util.py
- Routine "create_display_name" only splits/replaces the first "_"
  character.  This is necessary in order to preserve certain species
  names containing underscores (such as CO_25, e_90, etc.)
- Trimmed trailing whitespace

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <[email protected]>
  • Loading branch information
yantosca committed Jul 20, 2023
1 parent b043964 commit cddf56b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed
- Generalized test for GCHP or GCClassic restart file in `regrid_restart_file.py`
- Fixed bug in transport tracer benchmark mass conservation table file write
- Routine `create_display _name` now splits on only the first `_` in species & diag names

### Removed
- Removed `gchp_is_pre_13_1` arguments & code from benchmarking routines
Expand Down
14 changes: 8 additions & 6 deletions gcpy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ def create_display_name(
# Initialize
display_name = diagnostic_name

# For restart files, just split at the first underscore and return
# the text followiong the underscore. This will preserve certain
# species names, such as the TransportTracers species CO_25, etc.
if "SpeciesRst" in display_name:
display_name = display_name.split("_")[1]
return display_name.split("_", 1)[1]

# Special handling for Inventory totals
if "INV" in display_name.upper():
Expand All @@ -152,8 +155,8 @@ def create_display_name(
for v in ["Emis", "EMIS", "emis", "Inv", "INV", "inv"]:
display_name = display_name.replace(v, "")

# Replace underscores
display_name = display_name.replace("_", " ")
# Replace only the first underscore with a space
display_name = display_name.replace("_", " ", 1)

return display_name

Expand Down Expand Up @@ -261,12 +264,11 @@ def print_totals(
# ==================================================================
# Get the diagnostic name and units
# ==================================================================
diagnostic_name = dev.name
if dev_is_all_nan:
diagnostic_name = ref.name
else:
diagnostic_name = dev.name

# Create the display name by editing the diagnostic name
# Create the display name for the table
display_name = create_display_name(diagnostic_name)

# Get the species name from the display name
Expand Down

0 comments on commit cddf56b

Please sign in to comment.