gcpy icon indicating copy to clipboard operation
gcpy copied to clipboard

Update mass conservation tables to include Ref & Dev in the same file

Open yantosca opened this issue 1 year ago • 22 comments
trafficstars

Name and Institution (Required)

Name: Bob Yantosca Institution: Harvard + GCST

Confirm you have reviewed the following documentation

Describe the update

This PR updates the mass conservation table benchmark code as follows:

  1. A new module gcpy/benchmark/modules/benchmark_mass_conc_table.py has been created. This contains the code from the make_benchmark_mass_conservation_tables in the benchmark_funcs.py module. The code has been refactored for clarity. It now accepts arguments from both Ref and Dev versions.

  2. Total masses and statistics from Ref and Dev model versions are now printed in the same file.

  3. TransportTracers benchmark script run_1yr_tt_benchmark.py now imports routine make_benchmark_mass_conservation_table from benchmark_mass_conc_table.py.

  4. The old make make_benchmark_mass_conservation_table has now been removed

Expected changes

Prior to this change, the mass conservation table looked like this:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  Global Mass of Passive Tracer in 14.2.0-rc.1/GCClassic/TransportTracers  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Date        Mass [Tg]
 ----------  ----------------
 2019-01-01   17.6561658812290
 2019-02-01   17.6561659006875
 2019-03-01   17.6561658888524
 2019-04-01   17.6561659034459
 2019-05-01   17.6561658979651
 2019-06-01   17.6561658832719
 2019-07-01   17.6561658830644
 2019-08-01   17.6561658772005
 2019-09-01   17.6561658896849
 2019-10-01   17.6561658980134
 2019-11-01   17.6561658915458
 2019-12-01   17.6561658810218
 
 Summary
 ------------------------------
 Max mass =   17.6561659034459 Tg
 Min mass =   17.6561658772005 Tg
 Abs diff =         26245.367 g
 Pct diff =      0.0000001486 %

With the updates in this PR, it now looks like this:

===============================================================================
Global mass of PassiveTracer

Ref = gcc-14.2.0-rc.0
Dev = gcc-14.2.0-rc.2
===============================================================================

 Date & Time                  Ref mass [Tg]             Dev mass [Tg]
 -----------------     --------------------      --------------------
 2019-01-01 00:00          17.6561658812290          17.6561658812290
 2019-02-01 00:00          17.6561659006875          17.6561659006875
 2019-03-01 00:00          17.6561658888524          17.6561658888524
 2019-04-01 00:00          17.6561659034459          17.6561659034459
 2019-05-01 00:00          17.6561658979651          17.6561658979651
 2019-06-01 00:00          17.6561658832719          17.6561658832719
 2019-07-01 00:00          17.6561658830644          17.6561658830644
 2019-08-01 00:00          17.6561658772005          17.6561658772005
 2019-09-01 00:00          17.6561658896849          17.6561658896849
 2019-10-01 00:00          17.6561658980134          17.6561658980134
 2019-11-01 00:00          17.6561658915458          17.6561658915458
 2019-12-01 00:00          17.6561658810218          17.6561658810218
 
 Summary                                Ref                       Dev
 -----------------     --------------------      --------------------
 Maximum mass [Tg]         17.6561659034459          17.6561659034459
 Minimum mass [Tg]         17.6561658772005          17.6561658772005
 Abs diff [g]           26245.3667687623238       26245.3667687623238
 % difference               0.0000001486470           0.0000001486470

Reference(s)

If this is a science update, please provide a literature citation.

Related Github Issue(s)

  • This PR partially addresses #308.

yantosca avatar Mar 26 '24 20:03 yantosca

@lizziel @msulprizio: Also note I expanded the date tag to date & time so that you can do mass conservation tests for shorter intervals (1 month, 1 week) with archived estarts for every 6 or 12 hours if you wish.

yantosca avatar Mar 26 '24 21:03 yantosca

This is a very useful update! Is it possible to have a column for difference? This will help see if the difference goes up and down, or if there is a steady bias. We also sometimes see a jump between the first and second entries due to the restart file.

lizziel avatar Mar 27 '24 15:03 lizziel

Along these lines, if it is easy to do I think we should have metrics at the bottom for mean, variance, and difference between start and stop. Something like this (I added columns for difference and % difference too).

 Summary                                Ref                       Dev                Difference    % Difference
 -----------------     --------------------      --------------------      --------------------   --------------------


 Maximum mass [Tg]         17.6561659034459          17.6561659034459
 Minimum mass [Tg]         17.6561658772005          17.6561658772005
 Abs diff [g]           26245.3667687623238       26245.3667687623238
 % difference               0.0000001486470           0.0000001486470

 Start mass [Tg]            value here                value here
 End mass [Tg]              value here                value here
 Abs diff [g]               value here                value here
 % difference               value here                value here
 
 Mean mass [Tg]             value here                value here
 Variance [Tg]              value here                value here

lizziel avatar Mar 27 '24 15:03 lizziel

@lizziel: I will try to implement your suggestions. It should not be that difficult to do.

yantosca avatar Mar 27 '24 17:03 yantosca

@lizziel: In commit 5c8df1325 I added the extra statistics output you requested. The table now looks like:

===============================================================================
Global mass of PassiveTracer

Ref = alpha.9
Dev = PR_2072
===============================================================================

 Date & Time                  Ref mass [Tg]             Dev mass [Tg]
 -----------------     --------------------      --------------------
 2019-01-01 00:00          17.6563096646018          17.6563096646018
 2019-01-02 00:00          17.6563097334271          17.6563097334271
 2019-01-03 00:00          17.6563096472464          17.6563096472464
 2019-01-04 00:00          17.6563097381031          17.6563097381031
 2019-01-05 00:00          17.6563096420086          17.6563096420086
 2019-01-06 00:00          17.6563096769969          17.6563096769969
 2019-01-07 00:00          17.6563097517587          17.6563097517587
 2019-01-08 00:00          17.6563096589453          17.6563096589453
 2019-01-09 00:00          17.6563096255438          17.6563096255438
 2019-01-10 00:00          17.6563096669641          17.6563096669641
 2019-01-11 00:00          17.6563095824931          17.6563095824931
 2019-01-12 00:00          17.6563096810990          17.6563096810990
 2019-01-13 00:00          17.6563097035783          17.6563097035783
 2019-01-14 00:00          17.6563096224065          17.6563096224065
 2019-01-15 00:00          17.6563097281873          17.6563097281873
 2019-01-16 00:00          17.6563096448919          17.6563096448919
 2019-01-17 00:00          17.6563096999110          17.6563096999110
 2019-01-18 00:00          17.6563096911278          17.6563096911278
 2019-01-19 00:00          17.6563096524387          17.6563096524387
 2019-01-20 00:00          17.6563096730235          17.6563096730235
 2019-01-21 00:00          17.6563096880015          17.6563096880015
 2019-01-22 00:00          17.6563096931819          17.6563096931819
 2019-01-23 00:00          17.6563096625323          17.6563096625323
 2019-01-24 00:00          17.6563096789355          17.6563096789355
 2019-01-25 00:00          17.6563096582845          17.6563096582845
 2019-01-26 00:00          17.6563096609817          17.6563096609817
 2019-01-27 00:00          17.6563096687468          17.6563096687468
 2019-01-28 00:00          17.6563096712458          17.6563096712458
 2019-01-29 00:00          17.6563096699832          17.6563096699832
 2019-01-30 00:00          17.6563096648479          17.6563096648479
 2019-01-31 00:00          17.6563096684741          17.6563096684741
 2019-02-01 00:00          17.6563096665982          17.6563096665982
 
 Summary                                Ref                       Dev      Abs Diff  % Diff
 -----------------     --------------------      -------------------- ------------- -------
 Maximum mass [Tg]         17.6563097517587          17.6563097517587      0.000000   0.000
 Minimum mass [Tg]         17.6563095824931          17.6563095824931      0.000000   0.000 
 Abs diff [g]          169265.6539376002911      169265.6539376002911      0.000000   0.000
 % difference               0.0000009586695           0.0000009586695      0.000000   0.000

 Start mass [Tg]           17.6563096646018          17.6563096646018      0.000000   0.000
 End mass [Tg]             17.6563096665982          17.6563096665982      0.000000   0.000
 Abs diff [g]            1996.3231068231835        1996.3231068231835      0.000000   0.000
 % difference               0.0000000113066           0.0000000113066      0.000000   0.000

 Mean mass [Tg]            17.6563096730177          17.6563096730177      0.000000   0.000
 Variance [Tg]              0.0000000000000           0.0000000000000      0.000000   0.000

yantosca avatar Mar 27 '24 20:03 yantosca

@lizziel: I added abs diff & % diff columns as such in 0c3bca7:

===============================================================================
Global mass of PassiveTracer

Ref = alpha.9
Dev = PR_2072
===============================================================================

 Date & Time                  Ref mass [Tg]             Dev mass [Tg]      Abs Diff  % Diff
 -----------------     --------------------      -------------------- ------------- -------
 2019-01-01 00:00          17.6563096646018          17.6563096646018      0.000000   0.000
 2019-01-02 00:00          17.6563097334271          17.6563097334271      0.000000   0.000
 2019-01-03 00:00          17.6563096472464          17.6563096472464      0.000000   0.000
 2019-01-04 00:00          17.6563097381031          17.6563097381031      0.000000   0.000
 2019-01-05 00:00          17.6563096420086          17.6563096420086      0.000000   0.000
 2019-01-06 00:00          17.6563096769969          17.6563096769969      0.000000   0.000
 2019-01-07 00:00          17.6563097517587          17.6563097517587      0.000000   0.000
 2019-01-08 00:00          17.6563096589453          17.6563096589453      0.000000   0.000
 2019-01-09 00:00          17.6563096255438          17.6563096255438      0.000000   0.000
 2019-01-10 00:00          17.6563096669641          17.6563096669641      0.000000   0.000
 2019-01-11 00:00          17.6563095824931          17.6563095824931      0.000000   0.000
 2019-01-12 00:00          17.6563096810990          17.6563096810990      0.000000   0.000
 2019-01-13 00:00          17.6563097035783          17.6563097035783      0.000000   0.000
 2019-01-14 00:00          17.6563096224065          17.6563096224065      0.000000   0.000
 2019-01-15 00:00          17.6563097281873          17.6563097281873      0.000000   0.000
 2019-01-16 00:00          17.6563096448919          17.6563096448919      0.000000   0.000
 2019-01-17 00:00          17.6563096999110          17.6563096999110      0.000000   0.000
 2019-01-18 00:00          17.6563096911278          17.6563096911278      0.000000   0.000
 2019-01-19 00:00          17.6563096524387          17.6563096524387      0.000000   0.000
 2019-01-20 00:00          17.6563096730235          17.6563096730235      0.000000   0.000
 2019-01-21 00:00          17.6563096880015          17.6563096880015      0.000000   0.000
 2019-01-22 00:00          17.6563096931819          17.6563096931819      0.000000   0.000
 2019-01-23 00:00          17.6563096625323          17.6563096625323      0.000000   0.000
 2019-01-24 00:00          17.6563096789355          17.6563096789355      0.000000   0.000
 2019-01-25 00:00          17.6563096582845          17.6563096582845      0.000000   0.000
 2019-01-26 00:00          17.6563096609817          17.6563096609817      0.000000   0.000
 2019-01-27 00:00          17.6563096687468          17.6563096687468      0.000000   0.000
 2019-01-28 00:00          17.6563096712458          17.6563096712458      0.000000   0.000
 2019-01-29 00:00          17.6563096699832          17.6563096699832      0.000000   0.000
 2019-01-30 00:00          17.6563096648479          17.6563096648479      0.000000   0.000
 2019-01-31 00:00          17.6563096684741          17.6563096684741      0.000000   0.000
 2019-02-01 00:00          17.6563096665982          17.6563096665982      0.000000   0.000
 
 Summary                                Ref                       Dev      Abs Diff  % Diff
 -----------------     --------------------      -------------------- ------------- -------
 Maximum mass [Tg]         17.6563097517587          17.6563097517587      0.000000   0.000
 Minimum mass [Tg]         17.6563095824931          17.6563095824931      0.000000   0.000 
 Abs diff [g]          169265.6539376002911      169265.6539376002911      0.000000   0.000
 % difference               0.0000009586695           0.0000009586695      0.000000   0.000

 Start mass [Tg]           17.6563096646018          17.6563096646018      0.000000   0.000
 End mass [Tg]             17.6563096665982          17.6563096665982      0.000000   0.000
 Abs diff [g]            1996.3231068231835        1996.3231068231835      0.000000   0.000
 % difference               0.0000000113066           0.0000000113066      0.000000   0.000

 Mean mass [Tg]            17.6563096730177          17.6563096730177      0.000000   0.000
 Variance [Tg]              0.0000000000000           0.0000000000000      0.000000   0.000

yantosca avatar Mar 29 '24 18:03 yantosca

Thanks @yantosca. We might need to increase precision on the diff column to capture the actual differences. Does it expand automatically if diffs are non-zero?

lizziel avatar Mar 29 '24 19:03 lizziel

I also wonder why the variance is zero. Is there a mistake there?

lizziel avatar Mar 29 '24 19:03 lizziel

@lizziel: I used np.var to compute the variance. Maybe I used the wrong argument to that. Let me check.

yantosca avatar Mar 29 '24 19:03 yantosca

@lizziel: I've now made the abs diff in scientific notation, since those numbers may be very small. Also the variance was very small so that's why it was showing up as zero. Changing it to scientific notation fixes that. See commit 486185b.

===============================================================================
Global mass of PassiveTracer

Ref = alpha.9
Dev = PR_2072
===============================================================================

 Date & Time                  Ref mass [Tg]             Dev mass [Tg]      Abs Diff    % Diff
 -----------------     --------------------      -------------------- -------------  --------
 2019-01-01 00:00          17.6563096646018          17.6563096646018    0.0000e+00     0.000
 2019-01-02 00:00          17.6563097334271          17.6563097334271    0.0000e+00     0.000
 2019-01-03 00:00          17.6563096472464          17.6563096472464    0.0000e+00     0.000
 2019-01-04 00:00          17.6563097381031          17.6563097381031    0.0000e+00     0.000
 2019-01-05 00:00          17.6563096420086          17.6563096420086    0.0000e+00     0.000
 2019-01-06 00:00          17.6563096769969          17.6563096769969    0.0000e+00     0.000
 2019-01-07 00:00          17.6563097517587          17.6563097517587    0.0000e+00     0.000
 2019-01-08 00:00          17.6563096589453          17.6563096589453    0.0000e+00     0.000
 2019-01-09 00:00          17.6563096255438          17.6563096255438    0.0000e+00     0.000
 2019-01-10 00:00          17.6563096669641          17.6563096669641    0.0000e+00     0.000
 2019-01-11 00:00          17.6563095824931          17.6563095824931    0.0000e+00     0.000
 2019-01-12 00:00          17.6563096810990          17.6563096810990    0.0000e+00     0.000
 2019-01-13 00:00          17.6563097035783          17.6563097035783    0.0000e+00     0.000
 2019-01-14 00:00          17.6563096224065          17.6563096224065    0.0000e+00     0.000
 2019-01-15 00:00          17.6563097281873          17.6563097281873    0.0000e+00     0.000
 2019-01-16 00:00          17.6563096448919          17.6563096448919    0.0000e+00     0.000
 2019-01-17 00:00          17.6563096999110          17.6563096999110    0.0000e+00     0.000
 2019-01-18 00:00          17.6563096911278          17.6563096911278    0.0000e+00     0.000
 2019-01-19 00:00          17.6563096524387          17.6563096524387    0.0000e+00     0.000
 2019-01-20 00:00          17.6563096730235          17.6563096730235    0.0000e+00     0.000
 2019-01-21 00:00          17.6563096880015          17.6563096880015    0.0000e+00     0.000
 2019-01-22 00:00          17.6563096931819          17.6563096931819    0.0000e+00     0.000
 2019-01-23 00:00          17.6563096625323          17.6563096625323    0.0000e+00     0.000
 2019-01-24 00:00          17.6563096789355          17.6563096789355    0.0000e+00     0.000
 2019-01-25 00:00          17.6563096582845          17.6563096582845    0.0000e+00     0.000
 2019-01-26 00:00          17.6563096609817          17.6563096609817    0.0000e+00     0.000
 2019-01-27 00:00          17.6563096687468          17.6563096687468    0.0000e+00     0.000
 2019-01-28 00:00          17.6563096712458          17.6563096712458    0.0000e+00     0.000
 2019-01-29 00:00          17.6563096699832          17.6563096699832    0.0000e+00     0.000
 2019-01-30 00:00          17.6563096648479          17.6563096648479    0.0000e+00     0.000
 2019-01-31 00:00          17.6563096684741          17.6563096684741    0.0000e+00     0.000
 2019-02-01 00:00          17.6563096665982          17.6563096665982    0.0000e+00     0.000
 
 Summary                                Ref                       Dev      Abs Diff    % Diff
 -----------------     --------------------      -------------------- -------------  --------
 Maximum mass [Tg]         17.6563097517587          17.6563097517587    0.0000e+00     0.000
 Minimum mass [Tg]         17.6563095824931          17.6563095824931    0.0000e+00     0.000
 Abs diff [g]          169265.6539376002911      169265.6539376002911    0.0000e+00     0.000
 % difference               0.0000009586695           0.0000009586695    0.0000e+00     0.000

 Start mass [Tg]           17.6563096646018          17.6563096646018    0.0000e+00     0.000
 End mass [Tg]             17.6563096665982          17.6563096665982    0.0000e+00     0.000
 Abs diff [g]            1996.3231068231835        1996.3231068231835    0.0000e+00     0.000
 % difference               0.0000000113066           0.0000000113066    0.0000e+00     0.000

 Mean mass [Tg]            17.6563096730177          17.6563096730177    0.0000e+00     0.000
 Variance [Tg]          1.1452659234774e-15       1.1452659234774e-15    0.0000e+00     0.000

yantosca avatar Mar 29 '24 19:03 yantosca

I just tested this out with some recent 14.3.1 GCHP data courtesy of @yuanjianz. This is what I see.

Screenshot 2024-04-10 at 4 54 43 PM

Here are my thoughts on the format:

  • I think the mass in Tg should have 12 digits beyond the decimal, so equivalent to whole numbers of grams
  • Abs difference could be in whole grams (no decimal) and aligned right
  • Both % difference and variance in all places could be scientific notation with 4 digits past the decimal for consistency

Aside: if you are wondering why there is such a huge jump after the start.... I think it's because the run uses a 2019 restart file to start in 2022.

Also note that the times printed to the file are the file times and not the times in the filename. This is a limitation that could be addressed later on.

lizziel avatar Apr 10 '24 21:04 lizziel

Thanks @lizziel for the great suggestions. I think the table is looking really nice now!

===============================================================================
Global mass of PassiveTracer

Ref = gcc-14.2.0-rc.2
Dev = gchp-14.2.0-rc.2
===============================================================================

 Date & Time               Ref mass [Tg]        Dev mass [Tg]      Abs Diff         % Diff
 -----------------     -----------------    ----------------- -------------  -------------
 2019-01-01 00:00        17.656165881229      17.656280192674    1.1431e-04     6.4743e-04
 2019-02-01 00:00        17.656165900687      17.656119120463   -4.6780e-05    -2.6495e-04
 2019-03-01 00:00        17.656165888852      17.656119334500   -4.6554e-05    -2.6367e-04
 2019-04-01 00:00        17.656165903446      17.656119237693   -4.6666e-05    -2.6430e-04
 2019-05-01 00:00        17.656165897965      17.656119239163   -4.6659e-05    -2.6426e-04
 2019-06-01 00:00        17.656165883272      17.656119120917   -4.6762e-05    -2.6485e-04
 2019-07-01 00:00        17.656165883064      17.656119294423   -4.6589e-05    -2.6387e-04
 2019-08-01 00:00        17.656165877200      17.656119153148   -4.6724e-05    -2.6463e-04
 2019-09-01 00:00        17.656165889685      17.656119076444   -4.6813e-05    -2.6514e-04
 2019-10-01 00:00        17.656165898013      17.656119174781   -4.6723e-05    -2.6463e-04
 2019-11-01 00:00        17.656165891546      17.656119148337   -4.6743e-05    -2.6474e-04
 2019-12-01 00:00        17.656165881022      17.656119245409   -4.6636e-05    -2.6413e-04
 
 Summary                             Ref                  Dev      Abs Diff         % Diff
 -----------------     -----------------    ----------------- -------------  -------------
 Maximum mass [Tg]       17.656165903446      17.656280192674    1.1429e-04     6.4730e-04
 Minimum mass [Tg]       17.656165877200      17.656119076444   -4.6801e-05    -2.6507e-04
 Abs diff [g]                      26245            161116229    1.6109e+08     6.1378e+05
 % difference             0.000000148647       0.000912523463    9.1237e-04     6.1379e+05

 Start mass [Tg]         17.656165881229      17.656280192674    1.1431e-04     6.4743e-04
 End mass [Tg]           17.656165881022      17.656119245409    1.1431e-04     6.4743e-04
 Abs diff [g]                       -207           -160947264   -1.6095e+08     7.7677e+07
 % difference            -0.000000001174      -0.000911558172   -9.1156e-04     7.7676e+07

 Mean mass [Tg]          17.656165889665      17.656132611496   -3.3278e-05    -1.8848e-04
 Variance [Tg]        6.998878437967e-17   1.980023970141e-09    1.9800e-09     2.8291e+09

yantosca avatar Apr 11 '24 14:04 yantosca

@lizziel: We now get the datetimes from the restart file names in commit b889d2e4348883f9a52c888c01628c9e387b8845,

yantosca avatar Apr 11 '24 15:04 yantosca

@lizziel: I added a function replace_whitespace to util.py that will replace any whitespace character with a supplied character (_ is default). Then I added spaces to the version labels:

data:
  ref:
    gcc:
      version: gcc 14.2.0 rc 0
      ...
    gchp:
      version: gchp 14.2.0 rc 0
  ...
  dev:
    gcc:
      version: gcc 14.2.0 rc 2
      ...
    gchp:
      version: gchp 14.2.0 rc 2
       ...

The code generated a file Passive_mass.gcc_14.2.0_rc_0_vs_gcc_14.2.0_rc_2.txt that looks like this:

===============================================================================
Global mass of PassiveTracer

Ref = gcc_14.2.0_rc_0
Dev = gcc_14.2.0_rc_2
===============================================================================

 Date & Time               Ref mass [Tg]        Dev mass [Tg]      Abs Diff         % Diff
 -----------------     -----------------    ----------------- -------------  -------------
 2019-01-01 00:00        17.656165881229      17.656165881229    0.0000e+00     0.0000e+00
 2019-02-01 00:00        17.656165900687      17.656165900687    0.0000e+00     0.0000e+00
 2019-03-01 00:00        17.656165888852      17.656165888852    0.0000e+00     0.0000e+00
 2019-04-01 00:00        17.656165903446      17.656165903446    0.0000e+00     0.0000e+00
 2019-05-01 00:00        17.656165897965      17.656165897965    0.0000e+00     0.0000e+00
 2019-06-01 00:00        17.656165883272      17.656165883272    0.0000e+00     0.0000e+00
 2019-07-01 00:00        17.656165883064      17.656165883064    0.0000e+00     0.0000e+00
 2019-08-01 00:00        17.656165877200      17.656165877200    0.0000e+00     0.0000e+00
 2019-09-01 00:00        17.656165889685      17.656165889685    0.0000e+00     0.0000e+00
 2019-10-01 00:00        17.656165898013      17.656165898013    0.0000e+00     0.0000e+00
 2019-11-01 00:00        17.656165891546      17.656165891546    0.0000e+00     0.0000e+00
 2019-12-01 00:00        17.656165881022      17.656165881022    0.0000e+00     0.0000e+00
 
 Summary                             Ref                  Dev      Abs Diff         % Diff
 -----------------     -----------------    ----------------- -------------  -------------
 Maximum mass [Tg]       17.656165903446      17.656165903446    0.0000e+00     0.0000e+00
 Minimum mass [Tg]       17.656165877200      17.656165877200    0.0000e+00     0.0000e+00
 Abs diff [g]                      26245                26245    0.0000e+00     0.0000e+00
 % difference             0.000000148647       0.000000148647    0.0000e+00     0.0000e+00

 Start mass [Tg]         17.656165881229      17.656165881229    0.0000e+00     0.0000e+00
 End mass [Tg]           17.656165881022      17.656165881022    0.0000e+00     0.0000e+00
 Abs diff [g]                       -207                 -207    0.0000e+00    -0.0000e+00
 % difference            -0.000000001174      -0.000000001174    0.0000e+00    -0.0000e+00

 Mean mass [Tg]          17.656165889665      17.656165889665    0.0000e+00     0.0000e+00
 Variance [Tg]        6.998878437967e-17   6.998878437967e-17    0.0000e+00     0.0000e+00

So this will make sure the generated file doesn't have spaces in it.

yantosca avatar Apr 22 '24 20:04 yantosca

This looks great. I think it is good to go except that I couldn't get it to work for GCHP vs GCC tables. I'll troubleshoot that with my data and let you know what I find.

lizziel avatar Apr 22 '24 21:04 lizziel

Thanks @lizziel. For what it's worth, I was able to get GCHP vs GCC output with my sample data:

===============================================================================
Global mass of PassiveTracer

Ref = gcc_14.2.0_rc_2
Dev = gchp_14.2.0_rc_2
===============================================================================

 Date & Time               Ref mass [Tg]        Dev mass [Tg]      Abs Diff         % Diff
 -----------------     -----------------    ----------------- -------------  -------------
 2019-01-01 00:00        17.656165881229      17.656280192674    1.1431e-04     6.4743e-04
 2019-02-01 00:00        17.656165900687      17.656119120463   -4.6780e-05    -2.6495e-04
 2019-03-01 00:00        17.656165888852      17.656119334500   -4.6554e-05    -2.6367e-04
 2019-04-01 00:00        17.656165903446      17.656119237693   -4.6666e-05    -2.6430e-04
 2019-05-01 00:00        17.656165897965      17.656119239163   -4.6659e-05    -2.6426e-04
 2019-06-01 00:00        17.656165883272      17.656119120917   -4.6762e-05    -2.6485e-04
 2019-07-01 00:00        17.656165883064      17.656119294423   -4.6589e-05    -2.6387e-04
 2019-08-01 00:00        17.656165877200      17.656119153148   -4.6724e-05    -2.6463e-04
 2019-09-01 00:00        17.656165889685      17.656119076444   -4.6813e-05    -2.6514e-04
 2019-10-01 00:00        17.656165898013      17.656119174781   -4.6723e-05    -2.6463e-04
 2019-11-01 00:00        17.656165891546      17.656119148337   -4.6743e-05    -2.6474e-04
 2019-12-01 00:00        17.656165881022      17.656119245409   -4.6636e-05    -2.6413e-04
 
 Summary                             Ref                  Dev      Abs Diff         % Diff
 -----------------     -----------------    ----------------- -------------  -------------
 Maximum mass [Tg]       17.656165903446      17.656280192674    1.1429e-04     6.4730e-04
 Minimum mass [Tg]       17.656165877200      17.656119076444   -4.6801e-05    -2.6507e-04
 Abs diff [g]                      26245            161116229    1.6109e+08     6.1378e+05
 % difference             0.000000148647       0.000912523463    9.1237e-04     6.1379e+05

 Start mass [Tg]         17.656165881229      17.656280192674    1.1431e-04     6.4743e-04
 End mass [Tg]           17.656165881022      17.656119245409    1.1431e-04     6.4743e-04
 Abs diff [g]                       -207           -160947264   -1.6095e+08     7.7677e+07
 % difference            -0.000000001174      -0.000911558172   -9.1156e-04     7.7676e+07

 Mean mass [Tg]          17.656165889665      17.656132611496   -3.3278e-05    -1.8848e-04
 Variance [Tg]        6.998878437967e-17   1.980023970141e-09    1.9800e-09     2.8291e+09

yantosca avatar Apr 22 '24 21:04 yantosca

I tried again to create the table comparing GC-Classic 4x5 and GCHP C180 output. I get this warning and no table is produced:

PerformanceWarning: \
Slicing is producing a large chunk. To accept the large
chunk and silence this warning, set the option
    >>> with dask.config.set(**{'array.slicing.split_large_chunks': False}):
    ...     array[indexer]

To avoid creating the large chunks, set the option
    >>> with dask.config.set(**{'array.slicing.split_large_chunks': True}):
    ...     array[indexer]
  value = value[(slice(None),) * axis + (subkey,)]

I am able to create the separate ref and dev tables using the GCPy dev branch so this must be something new in this branch.

lizziel avatar Apr 23 '24 14:04 lizziel

@lizziel: This must be an under-the-hood xarray/dask issue due to the large size of the data. I only tested with c24 and that works OK. I"ll see if there is a published workaround.

yantosca avatar Apr 23 '24 14:04 yantosca

@lizziel: I pushed a fix in commit df1e984. Please grab this update and let me know if it works. Thanks!

yantosca avatar Apr 23 '24 14:04 yantosca

Using the updated code results in the program being killed, even when I up the memory 160G.

lizziel avatar Apr 23 '24 14:04 lizziel

@lizziel found that the problem may be due to reading all files up-front, which takes too much memory. We can try looping over each file and then purging the memory afterwards.

yantosca avatar Apr 23 '24 15:04 yantosca

@lizziel: I modified the code so that we now loop over individual files (and delete objects afterwards to force garbage collection) in commit af8ef64. Try it again and let me know if it works.

yantosca avatar Apr 23 '24 15:04 yantosca