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

Generic plotting for global time series #400

Merged
merged 2 commits into from
Apr 11, 2024
Merged

Generic plotting for global time series #400

merged 2 commits into from
Apr 11, 2024

Conversation

forsyth2
Copy link
Collaborator

@forsyth2 forsyth2 commented Feb 3, 2023

Generic plotting for global time series. One option from #399. Resolves #399. Also resolves #562. Also resolves #569.

@forsyth2 forsyth2 added the semver: new feature New feature (will increment minor version) label Feb 3, 2023
@forsyth2
Copy link
Collaborator Author

forsyth2 commented Feb 3, 2023

Committed with --no-verify for now because of the following errors with pre-commit run --all-files:

zppy/templates/coupled_global.py:480:1: C901 'run' is too complex (21)
zppy/templates/coupled_global.py:574:13: E722 do not use bare 'except'
zppy/templates/coupled_global.py:639:17: E722 do not use bare 'except'

frequency = "monthly"
input_files = "eam.h0"
input_subdir = "archive/atm/hist"
mapping_file = "glb"
vars = "FSNTOA,FLUT,FSNT,FLNT,FSNS,FLNS,SHFLX,QFLX,TAUX,TAUY,PRECC,PRECL,PRECSC,PRECSL,TS,TREFHT,CLDTOT,CLDHGH,CLDMED,CLDLOW,U,CO2,CO2_FFF,CO2_OCN,CO2_LND,TMCO2,TMCO2_FFF,TMCO2_LND,TMCO2_OCN,TOTSOMC,TOTECOSYSC,NEE,TOTVEGC"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The extra variables cause the following errors for the atm_monthly_glb subtask of ts:

ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_LND' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTSOMC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_OCN' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTECOSYSC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_FFF' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_OCN' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_LND' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTVEGC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_FFF' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'NEE' is not in and/or does not match contents of input file

Copy link
Collaborator

Choose a reason for hiding this comment

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

These variables I believe are specialized BGC/HES output, the error is expected if the variables are not included in the test datasets.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe @BunnyVon could provide some datasets for testing here.

Copy link

Choose a reason for hiding this comment

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

Certainly. I have the CBGCv2 spin-up and production runs on chrysalis:
production run: /lcrc/group/e3sm/ac.sfeng1/E3SM_Simulations/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis' spinup run: /lcrc/group/e3sm/ac.sfeng1/E3SM_Simulations/20221219.CBGCv1.LR.BGC-LNDATM.20TR.ne30_oECv3.chrysalis'

The relevant zppy configuration files are in /home/ac.sfeng/zppy

try:
plot_generic(ax, xlim, exps, extra_plots[counter_extra_plots])
except:
print(f"Invalid var={extra_plots[counter_extra_plots]}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Initially, I tried running without adding the variables to ts above (which also had issues, see above comment).

That causes the following plots to not generate:

Invalid var=CO2
Invalid var=CO2_FFF
Invalid var=CO2_OCN
Invalid var=CO2_LND
Invalid var=TMCO2
Invalid var=TMCO2_FFF
Invalid var=TMCO2_LND
Invalid var=TMCO2_OCN
Invalid var=TOTSOMC
Invalid var=TOTECOSYSC
Invalid var=NEE
Invalid var=TOTVEGC

"var": lambda exp: np.array(exp["annual"][var_name]),
"verbose": False,
"vol": False,
"ylabel": "???",
Copy link
Collaborator Author

@forsyth2 forsyth2 Feb 3, 2023

Choose a reason for hiding this comment

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

No way to know the units unless we were to have users pass in tuples of (var_name, ylabel)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps it would be possible to extract the units once we get the variable from the v = ts.globalAnnual(var) line?

Copy link
Collaborator

@chengzhuzhang chengzhuzhang Feb 9, 2023

Choose a reason for hiding this comment

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

The var_name and units should preserve in cdms2's TransientVariable (in current implementation) or xarry's DataArray (after migrating to xarray). I suspect that the units were stripped of in readTS.py, and it should possible to get it back, i think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, my latest commit 5fd2055 appears to allow units to be deduced automatically.

@forsyth2 forsyth2 force-pushed the glb-ts-plots branch 3 times, most recently from 42d2452 to 5fd2055 Compare April 14, 2023 18:41
@forsyth2
Copy link
Collaborator Author

forsyth2 commented May 5, 2023

Latest analysis of variables (code not pushed yet). I need to further investigate these failures.

From global_time_series_1850-1860.o output file:

var=RESTOM units=None
var=RESSURF units=None
var=TREFHT units=K
var=FSNTOA units=W/m2
var=FLUT units=W/m2
var=PRECC units=m/s
var=PRECL units=m/s
var=QFLX units=kg/m2/s
var=TS units=K
var=FSNT units=W/m2
var=FLNT units=W/m2
var=RESTOM units=None
globalAnnual failed. Invalid var = CO2
globalAnnual failed. Invalid var = CO2_FFF
globalAnnual failed. Invalid var = CO2_OCN
globalAnnual failed. Invalid var = CO2_LND
globalAnnual failed. Invalid var = TMCO2
globalAnnual failed. Invalid var = TMCO2_FFF
globalAnnual failed. Invalid var = TMCO2_LND
globalAnnual failed. Invalid var = TMCO2_OCN
globalAnnual failed. Invalid var = TOTSOMC
globalAnnual failed. Invalid var = TOTECOSYSC
globalAnnual failed. Invalid var = NEE
globalAnnual failed. Invalid var = TOTVEGC

The output file also includes the following failures:

plot_generic failed. Invalid var=TS
plot_generic failed. Invalid var=FSNT
plot_generic failed. Invalid var=FLNT
plot_generic failed. Invalid var=RESTOM
plot_generic failed. Invalid var=CO2
plot_generic failed. Invalid var=CO2_FFF
plot_generic failed. Invalid var=CO2_OCN
plot_generic failed. Invalid var=CO2_LND
plot_generic failed. Invalid var=TMCO2
plot_generic failed. Invalid var=TMCO2_FFF
plot_generic failed. Invalid var=TMCO2_LND
plot_generic failed. Invalid var=TMCO2_OCN
plot_generic failed. Invalid var=TOTSOMC
plot_generic failed. Invalid var=TOTECOSYSC
plot_generic failed. Invalid var=NEE
plot_generic failed. Invalid var=TOTVEGC

The last 12 appear to fail because of globalAnnual failing earlier. The first 4 appear to be failing because of an issue involving the callable function.

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 5, 2024

I rebased off the latest main and made some updates. Currently getting the following error:

Exception: globalAnnual could not be computed for these variables: ['CO2', 'CO2_FFF', 'CO2_OCN', 'CO2_LND', 'TMCO2', 'TMCO2_FFF', 'TMCO2_LND', 'TMCO2\
_OCN', 'TOTSOMC', 'TOTECOSYSC', 'NEE', 'TOTVEGC']

Note that the extra plots we're adding are:

extra_plots = "TS,FSNT,FLNT,RESTOM,CO2,CO2_FFF,CO2_OCN,CO2_LND,TMCO2,TMCO2_FFF,TMCO2_LND,TMCO2_OCN,TOTSOMC,TOTECOSYSC,NEE,TOTVEGC"

I will debug further.

@BunnyVon
Copy link

BunnyVon commented Mar 5, 2024

@forsyth2 , for those variables that can't be plotted. Those variables that have filenames including "CO2" are 3D variables. My experience was that zppy had a hard time handling 3D variables back then, not sure if that's still the case. as for those with "TOT", they are elm variables. do they need to be handled separately from eam variables?

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 5, 2024

I tried adding the variables to the tsstep too, but get:

ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_LND' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_FFF' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_LND' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTVEGC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_OCN' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_OCN' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'RESTOM' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_FFF' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTECOSYSC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'NEE' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTSOMC' is not in and/or does not match contents of input file

Are these variables just not available in the simulation I'm using as input??

@BunnyVon
Copy link

BunnyVon commented Mar 5, 2024

I think ts only can correctly work with 2D variables (no levels). it can process the files, but the output variables from ts still have levels; it doesn't compress the variables into a true ts. would this cause the errors like that?

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 5, 2024

@BunnyVon Possibly? I'm wondering if "does not match contents of input file" indicates a difference in dimension as you suggest. Unfortunately, that error message isn't terribly informative. I do see a block to specifically remove U since its a 3D variable:

{% if mapping_file == 'glb' -%}
vars={{ vars }}
# https://unix.stackexchange.com/questions/237297/the-fastest-way-to-remove-a-string-in-a-variable
# https://stackoverflow.com/questions/26457052/remove-a-substring-from-a-bash-variable
# Remove U, since it is a 3D variable and thus will not work with rgn_avg
vars=${vars//,U}
{%- else %}
vars={{ vars }}
{%- endif %}

@chengzhuzhang @czender Do either of you have any thoughts here? My two guesses at this point are 1) @BunnyVon's suggestion of a dimension mismatch and 2) the variable data wasn't saved for the input I'm using (a v2 water cycle run -- see test_debug_chrysalis.cfg in the diff.

@czender
Copy link

czender commented Mar 5, 2024

I do remember removing U from timeseries generation of regional averages. IIRC, it was because U is 3-D (unstructured) or 4-D (structured). That made the rgn_avg code difficult to write, and Chris G. agreed that it did not make much sense to compute the regional average timeseries for 3-D variables (basically because that would make the array of regional average timeseries 3-D instead of 2-D). BTW, the error "and/or does not match contents of input file" applies when the variable name is a regular expression that does not match any of the variables in the input file. If you run in timeseries mode and turn-off regional averages then 3-D variables work fine. Does that help? Feedback welcome.

@chengzhuzhang
Copy link
Collaborator

Do either of you have any thoughts here? My two guesses at this point are 1) @BunnyVon's suggestion of a dimension mismatch and 2) the variable data wasn't saved for the input I'm using (a v2 water cycle run -- see test_debug_chrysalis.cfg in the diff.

I agree with your assessment here. For now, we perhaps should limit to applying ts_global to 2d variables. And many BGC land variables don't exist in the v2 water cycle run. For testing purpose, I think you could try those 2d variables available from the elm.h0 from the v2.historical run that you have been using..

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 5, 2024

If you run in timeseries mode and turn-off regional averages then 3-D variables work fine

Hmm I tried running the ts_land_monthly subtask too (not just the ts_land_monthly_glb one) and that fails with the same errors. (--rgn_avg is only applied in the glb subtask).

ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CLDMED' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'U' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CLDHGH' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'SHFLX' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_FFF' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTECOSYSC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'NEE' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTSOMC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CLDTOT' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_LND' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_FFF' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_LND' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CLDLOW' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'FSNTOA' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'FLNT' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'FSNS' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'RESTOM' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'PRECSL' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TOTVEGC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'QFLX' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'PRECC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'FSNT' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'PRECSC' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'FLUT' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TS' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TREFHT' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'PRECL' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'CO2_OCN' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'TMCO2_OCN' is not in and/or does not match contents of input file
ncrcat: ERROR nco_xtr_mk() reports user-supplied variable name or regular expression 'FLNS' is not in and/or does not match contents of input file

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 5, 2024

$ cd  /lcrc/group/e3sm/ac.forsyth2/E3SMv2/v2.LR.historical_0201/archive/lnd/hist
# Check what variables are available in the input I'm using
$ ncdump -h v2.LR.historical_0201.elm.h0.1850-01.nc | grep float
	float levgrnd(levgrnd) ;
	float levlak(levlak) ;
	float levdcmp(levdcmp) ;
	float time(time) ;
	float lon(lndgrid) ;
	float lat(lndgrid) ;
	float area(lndgrid) ;
	float topo(lndgrid) ;
	float landfrac(lndgrid) ;
	float ZSOI(levgrnd, lndgrid) ;
	float DZSOI(levgrnd, lndgrid) ;
	float WATSAT(levgrnd, lndgrid) ;
	float SUCSAT(levgrnd, lndgrid) ;
	float BSW(levgrnd, lndgrid) ;
	float HKSAT(levgrnd, lndgrid) ;
	float ZLAKE(levlak, lndgrid) ;
	float DZLAKE(levlak, lndgrid) ;
	float BCDEP(time, lndgrid) ;
	float BTRAN(time, lndgrid) ;
	float BUILDHEAT(time, lndgrid) ;
	float DEFICIT(time, lndgrid) ;
	float DSTDEP(time, lndgrid) ;
	float DSTFLXT(time, lndgrid) ;
	float DWB(time, lndgrid) ;
	float EFLX_DYNBAL(time, lndgrid) ;
	float EFLX_GRND_LAKE(time, lndgrid) ;
	float EFLX_LH_TOT(time, lndgrid) ;
	float EFLX_LH_TOT_R(time, lndgrid) ;
	float EFLX_LH_TOT_U(time, lndgrid) ;
	float ELAI(time, lndgrid) ;
	float ERRH2O(time, lndgrid) ;
	float ERRH2OSNO(time, lndgrid) ;
	float ERRSEB(time, lndgrid) ;
	float ERRSOI(time, lndgrid) ;
	float ERRSOL(time, lndgrid) ;
	float ESAI(time, lndgrid) ;
	float FCEV(time, lndgrid) ;
	float FCOV(time, lndgrid) ;
	float FCTR(time, lndgrid) ;
	float FGEV(time, lndgrid) ;
	float FGR(time, lndgrid) ;
	float FGR12(time, lndgrid) ;
	float FGR_R(time, lndgrid) ;
	float FGR_U(time, lndgrid) ;
	float FH2OSFC(time, lndgrid) ;
	float FIRA(time, lndgrid) ;
	float FIRA_R(time, lndgrid) ;
	float FIRA_U(time, lndgrid) ;
	float FIRE(time, lndgrid) ;
	float FIRE_R(time, lndgrid) ;
	float FIRE_U(time, lndgrid) ;
	float FLDS(time, lndgrid) ;
	float FPSN(time, lndgrid) ;
	float FPSN_WC(time, lndgrid) ;
	float FPSN_WJ(time, lndgrid) ;
	float FPSN_WP(time, lndgrid) ;
	float FROST_TABLE(time, lndgrid) ;
	float FSA(time, lndgrid) ;
	float FSAT(time, lndgrid) ;
	float FSA_R(time, lndgrid) ;
	float FSA_U(time, lndgrid) ;
	float FSDS(time, lndgrid) ;
	float FSDSND(time, lndgrid) ;
	float FSDSNDLN(time, lndgrid) ;
	float FSDSNI(time, lndgrid) ;
	float FSDSVD(time, lndgrid) ;
	float FSDSVDLN(time, lndgrid) ;
	float FSDSVI(time, lndgrid) ;
	float FSDSVILN(time, lndgrid) ;
	float FSH(time, lndgrid) ;
	float FSH_G(time, lndgrid) ;
	float FSH_NODYNLNDUSE(time, lndgrid) ;
	float FSH_R(time, lndgrid) ;
	float FSH_U(time, lndgrid) ;
	float FSH_V(time, lndgrid) ;
	float FSM(time, lndgrid) ;
	float FSM_R(time, lndgrid) ;
	float FSM_U(time, lndgrid) ;
	float FSNO(time, lndgrid) ;
	float FSNO_EFF(time, lndgrid) ;
	float FSR(time, lndgrid) ;
	float FSRND(time, lndgrid) ;
	float FSRNDLN(time, lndgrid) ;
	float FSRNI(time, lndgrid) ;
	float FSRVD(time, lndgrid) ;
	float FSRVDLN(time, lndgrid) ;
	float FSRVI(time, lndgrid) ;
	float GC_HEAT1(time, lndgrid) ;
	float GC_ICE1(time, lndgrid) ;
	float GC_LIQ1(time, lndgrid) ;
	float H2OCAN(time, lndgrid) ;
	float H2OSFC(time, lndgrid) ;
	float H2OSNO(time, lndgrid) ;
	float H2OSNO_TOP(time, lndgrid) ;
	float H2OSOI(time, levgrnd, lndgrid) ;
	float HC(time, lndgrid) ;
	float HCSOI(time, lndgrid) ;
	float HEAT_FROM_AC(time, lndgrid) ;
	float INT_SNOW(time, lndgrid) ;
	float LAISHA(time, lndgrid) ;
	float LAISUN(time, lndgrid) ;
	float LAKEICEFRAC(time, levlak, lndgrid) ;
	float LAKEICETHICK(time, lndgrid) ;
	float OCDEP(time, lndgrid) ;
	float PARVEGLN(time, lndgrid) ;
	float PBOT(time, lndgrid) ;
	float PCO2(time, lndgrid) ;
	float PCT_LANDUNIT(time, ltype, lndgrid) ;
	float PCT_NAT_PFT(time, natpft, lndgrid) ;
	float Q2M(time, lndgrid) ;
	float QBOT(time, lndgrid) ;
	float QCHARGE(time, lndgrid) ;
	float QDRAI(time, lndgrid) ;
	float QDRAI_PERCH(time, lndgrid) ;
	float QDRAI_XS(time, lndgrid) ;
	float QDRIP(time, lndgrid) ;
	float QFLOOD(time, lndgrid) ;
	float QFLX_ICE_DYNBAL(time, lndgrid) ;
	float QFLX_LIQ_DYNBAL(time, lndgrid) ;
	float QH2OSFC(time, lndgrid) ;
	float QINFL(time, lndgrid) ;
	float QINTR(time, lndgrid) ;
	float QIRRIG_GRND(time, lndgrid) ;
	float QIRRIG_ORIG(time, lndgrid) ;
	float QIRRIG_REAL(time, lndgrid) ;
	float QIRRIG_SURF(time, lndgrid) ;
	float QIRRIG_WM(time, lndgrid) ;
	float QOVER(time, lndgrid) ;
	float QRGWL(time, lndgrid) ;
	float QRUNOFF(time, lndgrid) ;
	float QRUNOFF_NODYNLNDUSE(time, lndgrid) ;
	float QRUNOFF_R(time, lndgrid) ;
	float QRUNOFF_U(time, lndgrid) ;
	float QSNOMELT(time, lndgrid) ;
	float QSNWCPICE(time, lndgrid) ;
	float QSNWCPICE_NODYNLNDUSE(time, lndgrid) ;
	float QSOIL(time, lndgrid) ;
	float QVEGE(time, lndgrid) ;
	float QVEGT(time, lndgrid) ;
	float RAIN(time, lndgrid) ;
	float RH2M(time, lndgrid) ;
	float RH2M_R(time, lndgrid) ;
	float RH2M_U(time, lndgrid) ;
	float SABG(time, lndgrid) ;
	float SABG_PEN(time, lndgrid) ;
	float SABV(time, lndgrid) ;
	float SNOBCMCL(time, lndgrid) ;
	float SNOBCMSL(time, lndgrid) ;
	float SNODSTMCL(time, lndgrid) ;
	float SNODSTMSL(time, lndgrid) ;
	float SNOINTABS(time, lndgrid) ;
	float SNOOCMCL(time, lndgrid) ;
	float SNOOCMSL(time, lndgrid) ;
	float SNOW(time, lndgrid) ;
	float SNOWDP(time, lndgrid) ;
	float SNOWICE(time, lndgrid) ;
	float SNOWLIQ(time, lndgrid) ;
	float SNOW_DEPTH(time, lndgrid) ;
	float SNOW_SINKS(time, lndgrid) ;
	float SNOW_SOURCES(time, lndgrid) ;
	float SOILICE(time, levgrnd, lndgrid) ;
	float SOILICE_ICE(time, levgrnd, lndgrid) ;
	float SOILLIQ(time, levgrnd, lndgrid) ;
	float SOILLIQ_ICE(time, levgrnd, lndgrid) ;
	float SOILWATER_10CM(time, lndgrid) ;
	float SUPPLY(time, lndgrid) ;
	float SoilAlpha(time, lndgrid) ;
	float SoilAlpha_U(time, lndgrid) ;
	float TAUX(time, lndgrid) ;
	float TAUY(time, lndgrid) ;
	float TBOT(time, lndgrid) ;
	float TBUILD(time, lndgrid) ;
	float TG(time, lndgrid) ;
	float TG_R(time, lndgrid) ;
	float TG_U(time, lndgrid) ;
	float TH2OSFC(time, lndgrid) ;
	float THBOT(time, lndgrid) ;
	float TKE1(time, lndgrid) ;
	float TLAI(time, lndgrid) ;
	float TLAKE(time, levlak, lndgrid) ;
	float TREFMNAV(time, lndgrid) ;
	float TREFMNAV_R(time, lndgrid) ;
	float TREFMNAV_U(time, lndgrid) ;
	float TREFMXAV(time, lndgrid) ;
	float TREFMXAV_R(time, lndgrid) ;
	float TREFMXAV_U(time, lndgrid) ;
	float TSA(time, lndgrid) ;
	float TSAI(time, lndgrid) ;
	float TSA_R(time, lndgrid) ;
	float TSA_U(time, lndgrid) ;
	float TSOI(time, levgrnd, lndgrid) ;
	float TSOI_10CM(time, lndgrid) ;
	float TSOI_ICE(time, levgrnd, lndgrid) ;
	float TV(time, lndgrid) ;
	float TWS(time, lndgrid) ;
	float TWS_MONTH_BEGIN(time, lndgrid) ;
	float TWS_MONTH_END(time, lndgrid) ;
	float U10(time, lndgrid) ;
	float URBAN_AC(time, lndgrid) ;
	float URBAN_HEAT(time, lndgrid) ;
	float VOLR(time, lndgrid) ;
	float VOLRMCH(time, lndgrid) ;
	float WA(time, lndgrid) ;
	float WASTEHEAT(time, lndgrid) ;
	float WIND(time, lndgrid) ;
	float ZBOT(time, lndgrid) ;
	float ZWT(time, lndgrid) ;
	float ZWT_PERCH(time, lndgrid) ;
# Specifically looking for variables to be plotted:
$ ncdump -h v2.LR.historical_0201.elm.h0.1850-01.nc | grep -E "float (TS|FSNT|FLNT|RESTOM|CO2|CO2_FFF|CO2_OCN|CO2_LND|TMCO2|TMCO2_FFF|TMCO2_LND|TMCO2_OCN|TOTSOMC|TOTECOSYSC|NEE|TOTVEGC)\("
# No results
# Looks like none of the variables are directly present.
# Maybe we can derive them?
$ cd /home/ac.forsyth2/e3sm_diags
$ grep -E "\"(TS|FSNT|FLNT|RESTOM|CO2|CO2_FFF|CO2_OCN|CO2_LND|TMCO2|TMCO2_FFF|TMCO2_LND|TMCO2_OCN|TOTSOMC|TOTECOSYSC|NEE|TOTVEGC)\":" e3sm_diags/derivations/acme.py
    "FLNT": OrderedDict([(("FLNT",), rename)]),
    "RESTOM": OrderedDict(
    "TS": OrderedDict(
    "TOTVEGC": OrderedDict(
    "TOTSOMC": OrderedDict(

The derivations are as follows:

    "FLNT": OrderedDict([(("FLNT",), rename)]),
    "RESTOM": OrderedDict(
        [
            (("RESTOA",), rename),
            (("toa_net_all_mon",), rename),
            (("FSNT", "FLNT"), lambda fsnt, flnt: restom(fsnt, flnt)),
            (
                (
                    "SW_flux_dn_at_model_top",
                    "SW_flux_up_at_model_top",
                    "LW_flux_up_at_model_top",
                ),
                lambda swdn, swup, lwup: restom3(swdn, swup, lwup),
            ),  # EAMxx
            (("rtmt",), rename),
        ]
    "TS": OrderedDict(
        [
            (("ts",), rename),
            (("surf_radiative_T",), rename),  # EAMxx
        ]
    "TOTVEGC": OrderedDict(
        [(("TOTVEGC",), lambda v: convert_units(v, target_units="kgC/m^2"))]
    ),
    "TOTSOMC": OrderedDict(
        [(("TOTSOMC",), lambda v: convert_units(v, target_units="kgC/m^2"))]
    ),
# Back to input directory
$ cd  /lcrc/group/e3sm/ac.forsyth2/E3SMv2/v2.LR.historical_0201/archive/lnd/hist
$ ncdump -h v2.LR.historical_0201.elm.h0.1850-01.nc | grep -E "float (RESTOA|toa_net_all_mon|FSNT|FLNT|SW_flux_dn_at_model_top|SW_flux_up_at_model_top|LW_flux_up_at_model_top|rtmt|ts|surf_radiative_T)"
# No results. Not only are the variables not present but they also cannot be derived.

@chengzhuzhang @BunnyVon I don't think any of the variables we want extra plots of will work with this input... Is there a simulation done by the land team I should use as input instead?? Thanks.

@BunnyVon
Copy link

BunnyVon commented Mar 5, 2024

ah, I see the problem now. WC v2 didn't have active BGC. those TOT variables only exist in emission-driven with active BGC runs. @forsyth2 , you can use my output https://acme-climate.atlassian.net/wiki/spaces/EBGC/pages/3578691870/20221127.v2.LR.BGC-LNDATM.CONTROL.ne30pg2+r05+EC30to60E2r2.chrysalis

you won't have eam variables to test with other land only simulations.

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 6, 2024

you won't have eam variables

Ah this was causing an issue as I hadn't removed all the eam variables from the cfg. I'm running now with only the land variables. For future reference, the issue I encountered:

I was getting ERROR (1) on the ts jobs... the relevant portion of the bash script:

#!/bin/bash

# Running on chrysalis

#SBATCH  --job-name=ts_land_monthly_glb_1870-1871-0002
#SBATCH  --account=e3sm
#SBATCH  --nodes=1
#SBATCH  --output=/lcrc/group/e3sm/ac.forsyth2/zppy_test_debug_output/pr-400v6/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/post/scripts/ts_land_monthly_glb_1870-1871-0002.o%j
#SBATCH  --exclusive
#SBATCH  --time=00:30:00

#SBATCH  --partition=debug


source /lcrc/soft/climate/e3sm-unified/load_latest_e3sm_unified_chrysalis.sh

# Turn on debug output if needed
debug=False
if [[ "${debug,,}" == "true" ]]; then
  set -x
fi

# Script dir
cd /lcrc/group/e3sm/ac.forsyth2/zppy_test_debug_output/pr-400v6/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/post/scripts

# Get jobid
id=${SLURM_JOBID}

# Update status file
STARTTIME=$(date +%s)
echo "RUNNING ${id}" > ts_land_monthly_glb_1870-1871-0002.status

# Create temporary workdir
workdir=`mktemp -d tmp.${id}.XXXX`
cd ${workdir}

# Create symbolic links to input files
input=/lcrc/group/e3sm/ac.sfeng1/E3SM_Simulations/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/archive/atm/hist
for (( year=1870; year<=1871; year++ ))
do
  YYYY=`printf "%04d" ${year}`
  for file in ${input}/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.eam.h0.${YYYY}-*.nc
  do
    ln -s ${file} .
  done
done

ts_fmt=ts_only
echo $ts_fmt

vars=FSNTOA,FLUT,FSNT,FLNT,FSNS,FLNS,SHFLX,QFLX,TAUX,TAUY,PRECC,PRECL,PRECSC,PRECSL,TS,TREFHT,CLDTOT,CLDHGH,CLDMED,CLDLOW,U,RESTOM,TOTSOMC,TOTECOSYSC,NEE,TOTVEGC
# https://unix.stackexchange.com/questions/237297/the-fastest-way-to-remove-a-string-in-a-variable
# https://stackoverflow.com/questions/26457052/remove-a-substring-from-a-bash-variable
# Remove U, since it is a 3D variable and thus will not work with rgn_avg
vars=${vars//,U}

ls 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.eam.h0.????-*.nc > input.txt
if grep -q "*" input.txt; then
  cd /lcrc/group/e3sm/ac.forsyth2/zppy_test_debug_output/pr-400v6/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/post/scripts
  echo 'Missing input files'
  echo 'ERROR (1)' > ts_land_monthly_glb_1870-1871-0002.status
  exit 1
fi
$ cd tmp.481030.s6KW
$ ls
'20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.eam.h0.1870-*.nc'  '20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.eam.h0.1871-*.nc'   input.txt
$ grep -q "*" input.txt
# No output, success code
$ grep "*" input.txt
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.eam.h0.1870-*.nc
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.eam.h0.1871-*.nc

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 6, 2024

I was still running into issues and after running grep for eam and atm in the cfg, I realized I had:

  [[ land_monthly_glb ]]
  frequency = "monthly"
  input_files = "eam.h0"
  input_subdir = "archive/atm/hist"
  mapping_file = "glb"

I changed that to:

  [[ land_monthly_glb ]]
  frequency = "monthly"
  input_files = "elm.h0"
  input_subdir = "archive/lnd/hist"
  mapping_file = "glb"

But I'm still running into errors.

# Enter workdir
$ cd /lcrc/group/e3sm/ac.forsyth2/zppy_test_debug_output/pr-400v10/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/post/scripts/tmp.481255.ihWC
$ ls
'20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc'  '20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1871-*.nc'   input.txt
$ cat input.txt 
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1871-*.nc
# Looks like those two files are in fact present...
$ ls | grep 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc
# No results
$ ls | grep 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.n
# No results
$ ls | grep 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc
# It now matches. It's like the `n` is different between the 2...
$ ls | grep 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*
# No results again
$ ls | grep 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc
# Result returns
$ ls | grep 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc
$ ls | grep 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.187
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1871-*.nc

So I'm not exactly sure why it's not picking up that the input files are, in fact, present.

@czender
Copy link

czender commented Mar 6, 2024

@forsyth2 It looks to me like there is a mistake in the use of quotes and wildcards and stdout redirection in the above tests. The first line

ls
'20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc'  '20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1871-*.nc'   input.txt

One problem is that the single quotes turn the asterisk from a wildcard character into a string literal. So no matching is performed. The other problem is that there is no greater-than sign to redirect the output of ls into input.txt. Instead, try this:

ls
20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1870-*.nc 20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis.elm.h0.1871-*.nc > input.txt

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Mar 6, 2024

One problem is that the single quotes turn the asterisk from a wildcard character into a string literal.

Yes, I thought that was odd too. I don't know why ls was returning the file names in quotes. I don't think that happens on other runs.

The other problem is that there is no greater-than sign to redirect the output

The line you're referring to here is the output of the ls command, so there wouldn't be a > sign there.

@chengzhuzhang
Copy link
Collaborator

@forsyth2 I saw e30pg2_r05 in the filename, and guessing these output are tri-grid output. In this case I suppose it will need a different mapping file than v2. Also could you provide your config file and open the permission for output directory?

@czender
Copy link

czender commented Mar 7, 2024

@forsyth2 Please LMK if there are any unresolved questions regarding observed vs documented behavior of NCO's ncclimo in this workflow.

@forsyth2
Copy link
Collaborator Author

@chengzhuzhang @xylar After reviewing some comments earlier on this PR, I wrote a summary on how to test newer package versions in zppy at #570.

@forsyth2
Copy link
Collaborator Author

@chengzhuzhang Thanks for the cdutil.setTimeBoundsMonthly(v) fix. I'm going to add that back in separately. I think your force-push overwrote my last commit.

@chengzhuzhang
Copy link
Collaborator

chengzhuzhang commented Apr 10, 2024

@forsyth2 It appears to be a slight difference in time axis of the land global averaged file resulted the error of unmatching years. The first time bounds of the land file is time_bounds = [-0.0208333333333333, 31] (while it is [0,31] for atmopshere files), and I suspect the yearly averaging routine (v = cdutil.YEAR(v)) compute average, based on weights computed from time_bounds. I think it got confused with the negative value and produce one excessive yearly mean. With the latest commit, I'm able to create the land plots. Though it would be good to test if there is any regression for the original plots.

This time_bounds issue is perhaps only occur with the first year of piControl run. I think it perhaps is worthwhile to inform @czender about this time_bounds problem.

@forsyth2
Copy link
Collaborator Author

Thanks @chengzhuzhang! I'll test and then get the commits sorted out.

@forsyth2
Copy link
Collaborator Author

@chengzhuzhang Ok I was able to generate the plots using your one-line fix. I was also able to run debug3 (which uses Sha's land simulation). debug2 (the relevant subset of the complete-run test) however runs into an issue -- the plots once again don't match up with the expected results

Expansion of table from #400 (comment) and #400 (comment):

Plot debug2.cfg before NCO fix debug2.cfg after NCO fix debug2.cfg after TimeBounds fix Expected Results
NET TOA flux (restom) 0.81 0.16 0.81 0.16
Global surface air temperature 13.50 13.63 13.50 13.63
TOA radiation N/A N/A N/A N/A
Net atm energy imbalance 0.11 0.01 0.11 0.01
Change in ocean heat content +0.15 +0.15 +0.15 +0.15
Max MOC Atlantic streamfunction at 26.5N N/A N/A N/A N/A
Change in sea level -0.2869 -0.2869 -0.2869 -0.2869
Net atm water imbalance -0.2036 -0.0450 -0.2036 -0.0450

It now occurs to me that this one-line fix is exactly what I removed because we decided it wasn't necessary when using NCO 5.2.3.

Summary of behavior:

Case How did land plots look? How did plots_original printed values compare to the expected results?
debug2.cfg, using cdutil.setTimeBoundsMonthly(v), before NCO 5.2.3 land plots were showing up as horizontal outside a 2-3 year window Mismatch
debug2.cfg, not using cdutil.setTimeBoundsMonthly(v), before NCO 5.2.3 (it occurs to me this is the case I actually tested when I thought I was using NCO 5.2.3 but really wasn't) land plots could not be plotted, gave ValueError: x and y must have same first dimension, but have shapes (10,) and (11,) Didn't compare
debug2.cfg, not using cdutil.setTimeBoundsMonthly(v), after NCO 5.2.3 land plots were showing up -- BUT Jill's expanded list of land plots failed to plot, showing ValueError: x and y must have same first dimension, but have shapes (50,) and (51,) Match
debug2.cfg, using cdutil.setTimeBoundsMonthly(v), after NCO 5.2.3 Jill's expanded list of land plots show up Mismatch

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Apr 10, 2024

@chengzhuzhang Is it possible the values using cdutil.setTimeBoundsMonthly(v) are actually what we want? (E.g., the expected results are the wrong values)?

@chengzhuzhang
Copy link
Collaborator

chengzhuzhang commented Apr 11, 2024

@chengzhuzhang Is it possible the values using cdutil.setTimeBoundsMonthly(v) are actually what we want? (E.g., the expected results are the wrong values)?

I can confirm that using cdutil.setTimeBoundsMonthly(v) does change results. and at this point we don't really want to introduce this change that will cause mismatch. [we probably should keep investigating the reason]

I also confirmed that the time bounds induced error ValueError: x and y must have same first dimension, but have shapes (50,) and (51,) is not in other time chunks in piControl. I think this PR is good to go (revert the setMonthlyTimeBounds line), but we should file an issue to address the corner case of working with first year of piControl.

@forsyth2
Copy link
Collaborator Author

I think this PR is good to go (revert the setMonthlyTimeBounds line), but we should file an issue to address the corner case of working with first year of piControl.

@chengzhuzhang ok great, thanks! I'll clean up the PR and merge. And also file an issue for that case.

@forsyth2
Copy link
Collaborator Author

I condensed the commits and left a second commit for removing the relevant testing files (they shouldn't go into main, but I think they're decently useful to keep around on GitHub for later testing needs)

@forsyth2 forsyth2 merged commit ff3a998 into main Apr 11, 2024
4 checks passed
@forsyth2 forsyth2 deleted the glb-ts-plots branch April 11, 2024 00:52
@forsyth2
Copy link
Collaborator Author

we should file an issue to address the corner case of working with first year of piControl.

I created #571

@forsyth2
Copy link
Collaborator Author

Thanks to everyone on the PR for the help in getting this to completion! I'm planning to release a zppy RC including this feature this week.

@BunnyVon
Copy link

Thanks to everyone on the PR for the help in getting this to completion! I'm planning to release a zppy RC including this feature this week.

Thank you @forsyth2 ! Do you have a template or an instruction for me to test and analyze my output? My land-atm BGC coupled historical run is just complete.

@forsyth2
Copy link
Collaborator Author

forsyth2 commented Apr 11, 2024

@BunnyVon Thanks!

Probably a variation of my debug3 cfg would be good. Change case, input, output, www accordingly. For [ts] set environment_commands to something like "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate zppy_dev_with_nco_20240405" (see #400 (comment) for setting that up).

[default]
case = v2.LR.BGC-LNDATM.CONTRL
constraint = ""
dry_run = "False"
environment_commands = ""
input = "/lcrc/group/e3sm/ac.sfeng1/E3SM_Simulations/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis"
input_subdir = archive/atm/hist
mapping_file = "map_r05_to_cmip6_180x360_aave.20231110.nc"
# To run this test, edit `output` and `www` in this file, along with `actual_images_dir` in test_complete_run.py
output = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_debug3_output/unique_id/20221127.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis"
partition = "debug"
qos = "regular"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_debug3_www/unique_id"

[ts]
active = True
e3sm_to_cmip_environment_commands = ""
environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate zppy_dev_with_nco_20240405"
walltime = "00:30:00"

  [[ atm_monthly_glb ]]
  # Note global average won't work for 3D variables.
  frequency = "monthly"
  input_files = "eam.h0"
  input_subdir = "archive/atm/hist"
  mapping_file = "glb"
  # First 6 are for the original plots.
  vars = "TREFHT,FSNTOA,FLUT,PRECC,PRECL,QFLX,TS,FSNT,FLNT"
  years = "1880:1890:5",

  [[ lnd_monthly_glb ]]
  frequency = "monthly"
  input_files = "elm.h0"
  input_subdir = "archive/lnd/hist"
  mapping_file = "glb"
  vars = "TOTSOMC,TOTECOSYSC,NBP,TOTVEGC"
  years = "1880:1890:5",

[global_time_series]
active = True
atmosphere_only = "True"
experiment_name = "v2.LR.BGC-LNDATM.CONTRL"
figstr = "v2.LR.BGC-LNDATM.CONTRL"
plots_original = "net_toa_flux_restom,global_surface_air_temperature,toa_radiation,net_atm_energy_imbalance,net_atm_water_imbalance"
plots_atm = "RESSURF,TS,FSNT,FLNT"
plots_lnd = "TOTSOMC,TOTECOSYSC,NBP,TOTVEGC"
ts_num_years = 5
walltime = "00:30:00"
years = "1880-1890",

@forsyth2
Copy link
Collaborator Author

@BunnyVon You can also see the newly-created test env guide at #570

@BunnyVon
Copy link

@forsyth2 , I ran into an error /var/spool/slurmd/job504216/slurm_script: line 58: cdscan: command not found in /lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/zppy/post/scripts/global_time_series_1880-1890.o504216 . do you see any problem in my .cfg file below? I pretty much follow your template, I think.

[default]
case = v2.LR.BGC-LNDATM.CONTRL
constraint = "source /lcrc/soft/climate/e3sm-unified/load_latest_e3sm_unified_chrysalis.sh"
dry_run = "False"
environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh"
input = "/lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis"
input_subdir = archive/atm/hist
mapping_file = "map_r05_to_cmip6_180x360_aave.20231110.nc"
# To run this test, edit `output` and `www` in this file, along with `actual_images_dir` in test_complete_run.py
output = "/lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/zppy"
partition = "debug"
qos = "regular"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.sfeng1/zppy/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis"

[ts]
active = True
e3sm_to_cmip_environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate zppy_dev_with_nco_20240405"environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate zppy_dev_with_nco_20240405"
environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate zppy_dev_with_nco_20240405"
walltime = "00:30:00"

  [[ atm_monthly_glb ]]
  # Note global average won't work for 3D variables.
  frequency = "monthly"
  input_files = "eam.h0"
  input_subdir = "archive/atm/hist"
  mapping_file = "glb"
  # First 6 are for the original plots.
  vars = "TREFHT,FSNTOA,FLUT,PRECC,PRECL,QFLX,TS,FSNT,FLNT"
  years = "1880:1890:5",

  [[ lnd_monthly_glb ]]
  frequency = "monthly"
  input_files = "elm.h0"
  input_subdir = "archive/lnd/hist"
  mapping_file = "glb"
  vars = "TOTSOMC,TOTECOSYSC,NBP,TOTVEGC"
  years = "1880:1890:5",

[global_time_series]
active = True
atmosphere_only = "True"
experiment_name = "v2.LR.BGC-LNDATM.CONTRL"
figstr = "v2.LR.BGC-LNDATM.CONTRL"
plots_original = "net_toa_flux_restom,global_surface_air_temperature,toa_radiation,net_atm_energy_imbalance,net_atm_water_imbalance"
plots_atm = "RESSURF,TS,FSNT,FLNT"
plots_lnd = "TOTSOMC,TOTECOSYSC,NBP,TOTVEGC"
ts_num_years = 5
walltime = "00:30:00"
years = "1880-1890",

@forsyth2
Copy link
Collaborator Author

@BunnyVon Your environment_commands = "source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate zppy_dev_with_nco_20240405" needs to be altered for your own environment. You're trying to use my personal conda environment.

Luckily though, Unified 1.10.0rc1 was just released today and that has the latest NCO, so you can simply set environment_commands=source /lcrc/soft/climate/e3sm-unified/test_e3sm_unified_1.10.0rc1_chrysalis.sh instead of worrying about custom dev environments.

@BunnyVon
Copy link

Nice! it does help. Thank you @forsyth2 . However, another error showed up. This error is related to a variable FSNS. Strangely I didn't even add this variable in my variable list.

Traceback (most recent call last):
  File "/lcrc/soft/climate/e3sm-unified/base/envs/e3sm_unified_1.10.0rc1_chrysalis/lib/python3.10/site-packages/cdms2/cudsinterface.py", line 26, in __call__
    if(self.is_gridspec_grid_file() and
AttributeError: 'Dataset' object has no attribute 'is_gridspec_grid_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/zppy/post/scripts/global_time_series_1880-1890_dir/coupled_global.py", line 651, in <module>
    run_by_region(sys.argv)
  File "/lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/zppy/post/scripts/global_time_series_1880-1890_dir/coupled_global.py", line 647, in run_by_region
    run(parameters, rgn)
  File "/lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/zppy/post/scripts/global_time_series_1880-1890_dir/coupled_global.py", line 558, in run
    v = ts.globalAnnual(var)
  File "/lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/zppy/post/scripts/global_time_series_1880-1890_dir/readTS.py", line 47, in globalAnnual
    FSNS = self.globalAnnual("FSNS")
  File "/lcrc/group/e3sm2/ac.sfeng1/E3SM_Simulations/20240315.v2.LR.BGC-LNDATM.CONTRL.ne30pg2_r05_EC30to60E2r2.chrysalis/zppy/post/scripts/global_time_series_1880-1890_dir/readTS.py", line 62, in globalAnnual
    v = self.f(var)
  File "/lcrc/soft/climate/e3sm-unified/base/envs/e3sm_unified_1.10.0rc1_chrysalis/lib/python3.10/site-packages/cdms2/cudsinterface.py", line 33, in __call__
    raise CDMSError("No such variable, " + id)
cdms2.error.CDMSError: No such variable, FSNS

@forsyth2
Copy link
Collaborator Author

@BunnyVon Remove RESSURF from plots_atm. zppy is trying to derive that value using FSNS -- https://github.com/E3SM-Project/zppy/blob/main/zppy/templates/readTS.py#L49

@BunnyVon
Copy link

ah, thanks for the link. it makes a lot of sense now. I will modify it for my production run. Thank you again @forsyth2

@chengzhuzhang
Copy link
Collaborator

@BunnyVon glad to know that you are testing this new feature with your production run. I'm working on hand over a zppy configuration to coupled team. Let me know if there is a good variable list I should follow for the global time series plots for land. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: new feature New feature (will increment minor version)
Projects
None yet
7 participants