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

Explicitly close xr.Dataset in VarHandler.cmorize() #244

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e3sm_to_cmip/cmor_handlers/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def cmorize(
else:
self._cmor_write_with_time(ds, cmor_var_id, time_dim, cmor_ips_id)

ds.close()

# NOTE: It is important to close the CMOR module AFTER CMORizing all of
# the variables. Otherwise, the IDs of cmor objects gets wiped after
# every loop.
Expand Down
35 changes: 35 additions & 0 deletions scripts/debug/549_zppy_debug/549_zppy_ts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from e3sm_to_cmip.__main__ import E3SMtoCMIP

# e3sm_to_cmip --output-path ~/test -v 'lai' --realm lnd --input-path /lcrc/group/e3sm/ac.zhang40/zppy_test_complete_run_output/test-main2-20240216/v2.LR.historical_0201_try7/post/lnd/180x360_aave/ts/monthly/2yr --user-metadata ~/zppy/zppy/templates/e3sm_to_cmip/default_metadata.json --tables-path /lcrc/group/e3sm/diagnostics/cmip6-cmor-tables/Tables --num-proc 12

# This version of CMOR_TABLES_DIR is outdated and fails with `default_metadata.json`
# CMOR_TABLES_DIR = "/lcrc/group/e3sm/diagnostics/cmip6-cmor-tables/Tables"
CMOR_TABLES_DIR = "/home/ac.tvo/E3SM-Project/cmip6-cmor-tables/Tables"
INPUT_DIR = "/lcrc/group/e3sm/ac.zhang40/zppy_test_complete_run_output/test-main2-20240216/v2.LR.historical_0201_try7/post/lnd/180x360_aave/ts/monthly/2yr"
OUTPUT_PATH = "/home/ac.tvo/E3SM-Project/e3sm_to_cmip/scripts/debug/549_zppy_ts"

# e3sm_to_cmip version
METADATA_PATH = "/home/ac.tvo/E3SM-Project/e3sm_to_cmip/e3sm_to_cmip/resources/default_metadata.json"


args = [
"--output-path",
OUTPUT_PATH,
"--var-list",
"lai",
"--realm",
"lnd",
"--input-path",
INPUT_DIR,
"--user-metadata",
METADATA_PATH,
"--num-proc",
"12",
"--tables-path",
CMOR_TABLES_DIR,
# "--serial",
]

run = E3SMtoCMIP(args)

run.run()
Loading