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

Fix formatting of mass & emission tables; add mass table option to 1-year TransportTracers benchmarks #238

Merged
merged 4 commits into from
Jul 21, 2023

Conversation

yantosca
Copy link
Contributor

Name and Institution (Required)

Name: Bob Yantosca
Institution: Harvard + GCST

Confirm you have reviewed the following documentation

Describe the update

This fixes the problem in the mass table output described by @msulprizio in #237. This was most apparent in the TransportTracers benchmarks, where underflow was causing several entries to show up as zero even though they were very small numbers.

This PR adds the following features:

  • Add routine format_number_for_table, which generates a format string for numbers used in mass table and emission table output. If the number is larger or smaller than supplied thresholds, it will be printed in scientific notation instead of floating-point notation.
  • Species and diagnostic names mass tables and emissions tables are truncated to prevent columns from not being aligned.
  • When formatting species and diagnostic names for display, strings are split only to the first _ character. This will ensure that certain species names (such as TransportTracers species CO_25) will be printed properly.
  • Added the mass_table option to gcpy/benchmark/config/1yr_tt_benchmark.yml configuration file.
  • Added python code to print mass tables in gcpy/benchmark/modules/run_1yr_tt_benchmark.py.

Expected changes

Mass table output with very small & very large numbers now looks like this (e.g. the TransportTracers mass table):

#########################################################################################
### Global mass (Gg) at end of simulation (Trop + Strat)                              ###
###                                                                                   ###
### Ref = GCC_ref                                                                     ###
### Dev = GCC_dev                                                                     ###
###                                                                                   ###
### Dev and Ref show 8 differences                                                    ###
#########################################################################################
                                    Ref                 Dev     Dev - Ref    % diff diffs
Be10               :     2.66473250e-07      2.66473250e-07         0.000     0.000  
Be10s              :     2.54115760e-07      2.54115760e-07         0.000     0.000  
Be7                :     2.00170962e-08      2.00170962e-08   -1.3764e-21  -6.9e-12   * 
Be7s               :     1.68048853e-08      1.68048853e-08         0.000     0.000  
CH3I               :     3.68623921e-07      1.50224460e-09   -3.6712e-07   -99.592   * 
CLOCK              :     6.42508074e+19                 nan           nan       nan  
COUniformEmis25dayT:     1.64866620e+08                 nan           nan       nan  
CO_25              :       40622.143731          119.484126   -4.0503e+04   -99.706   * 
CO_50              :       78936.667877          119.903490   -7.8817e+04   -99.848   * 
PassiveTracer      :       17656.169678        17656.169678         0.000     0.000  
Pb210              :     2.96838610e-07      2.96838610e-07         0.000     0.000  
Pb210s             :     5.08194860e-09      5.08194860e-09   -1.0588e-22  -2.1e-12   * 
Rn222              :     2.06571294e-07      2.06571294e-07         0.000     0.000  
SF6                :         261.488003          261.488003         0.000     0.000  
aoa                :                nan      3.25828342e+12           nan       nan  
aoa_bl             :                nan      3.25917692e+12           nan       nan  
aoa_nh             :                nan      3.25917692e+12           nan       nan  
e90                :       14223.136187        13512.936825      -710.199    -4.993   * 
e90_n              :       14167.130101        13512.936798      -654.193    -4.618   * 
e90_s              :       14288.237337        13512.936798      -775.301    -5.426   * 

Related Github Issues:

yantosca added 4 commits July 20, 2023 16:39
gcpy/util.py
- Added routine "format_number_for_table", which returns a format
  string to be used in routine "print_totals".  This will convert
  small and large numbers to scientific notation in benchmark
  mass and emissions tables.
- Routine print_totals now calls "format_number_for_table".
- Now truncate species & diagnostics names in benchmark mass tables
  and emissions tables to 20 characters to improve readability

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <[email protected]>
gcpy/emission_inventories.yml
gcpy/emission_species.yml
- Add relevant entries for the TransportTracers benchmark

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <[email protected]>
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]>
benchmark/config/1yr_tt_benchmark.yml
- Change restart_directories from "restarts" to "Restarts"
- Add toggle for mass table output

benchmark/modules/run_1yr_tt_benchmark.py
- Import routines from joblib package
- Add *_refrstdir paths for GCC vs. GCC, GCHP vs. GCC, GCHP vs. GCHP
- Add extra time & date variables for Ref & Dev
- Print a message when mass table output is selected
- Add calls to bmk.make_benchmark_mass_tables (following what is
  done in run_1yr_fullchem_benchmark.py

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca added category: Feature Request New feature or request topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output labels Jul 21, 2023
@yantosca yantosca added this to the 1.4.0 milestone Jul 21, 2023
@yantosca yantosca requested a review from msulprizio July 21, 2023 15:33
@yantosca yantosca self-assigned this Jul 21, 2023
Copy link
Contributor

@msulprizio msulprizio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to merge. Thanks @yantosca!

@yantosca yantosca merged commit 0ae1143 into dev Jul 21, 2023
@yantosca yantosca deleted the feature/mass-table-transport-tracers branch July 21, 2023 17:53
hannahnesser pushed a commit to hannahnesser/gcpy that referenced this pull request Jan 22, 2024
This merge brings PR geoschem#238 (Fix formatting of mass & emission tables;
add mass table option to 1-year TransportTracers benchmarks, by @yantosca)
into the GCPy 1.4.0 development stream.

Important features added:

- Large and small numbers in mass & emissions tables are printed
  in scientific notation format instead of floating-point format.
- Species and diagnostic names mass tables and emissions tables are
  truncated to prevent columns from not being aligned.
- Species and diagnostic names with more than one underscore are
  now handled properly.
- Added mass table option to the 1yr TransportTracersBenchmark output

Signed-off-by: Bob Yantosca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Feature Request New feature or request topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants