-
Notifications
You must be signed in to change notification settings - Fork 33
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
EAMxx variables #880
Open
chengzhuzhang
wants to merge
26
commits into
cdat-migration-fy24
Choose a base branch
from
eamxx_1024
base: cdat-migration-fy24
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
EAMxx variables #880
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9f021d0
Merge pull request #902 from E3SM-Project/cdat-migration-fy24
tomvothecoder a60ee3f
CDAT Migration Phase 2: Refactor core utilities and `lat_lon` set (#…
tomvothecoder 57353c8
update 2d 3d vars
chengzhuzhang 59849d8
add more derived vars
chengzhuzhang 82d19e5
fix attrs errors
chengzhuzhang 46f952a
more informative log
chengzhuzhang 0fb0778
Remove inadvertant rebase diffs
tomvothecoder 3f9221c
Update IOError
tomvothecoder 4eddce3
Add bounds after calculating climo for time series
tomvothecoder 3967b34
Fix unit test
tomvothecoder e810a64
fixing radiation fluxes and units
chengzhuzhang efb76c2
Add support for more land ocean var keys
tomvothecoder 14e7e4a
Refactor land sea mask methods
tomvothecoder d3e71cb
fixing for regions i.e. land_60N60S
chengzhuzhang 22a2b84
Update order of time series subsetting to improve performance
tomvothecoder 528fd2c
Revert accidental rebase changes
tomvothecoder f925add
Add fix for `convert_units` with `udunits`
tomvothecoder 6730a28
Add run script for bottleneck
tomvothecoder 18e3d67
Add FIXME comments for performance bottleneck
tomvothecoder 6f1949f
Add debug_ref_u script
tomvothecoder 24a8803
Add debug scripts
tomvothecoder f3bbc14
add run scripts examples
chengzhuzhang ffe0bca
downgrade dask version to close #892
chengzhuzhang f6fb709
address review; clean up
chengzhuzhang 5f95706
Update README.md
chengzhuzhang 181564e
Update e3sm_diags/driver/lat_lon_driver.py
tomvothecoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
auxiliary_tools/cdat_regression_testing/892-bottleneck/debug_ref_u.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
""" | ||
This script is used to debug the bottleneck issue in the reference u variable. | ||
""" | ||
|
||
# %% | ||
import timeit | ||
|
||
import xarray as xr | ||
|
||
# Perlmutter | ||
# ---------- | ||
# filepaths = [ | ||
# "/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/time-series/ERA5/ua_197901_201912.nc" | ||
# ] | ||
|
||
# LCRC | ||
# ----- | ||
filepaths = [ | ||
"/lcrc/group/e3sm/diagnostics/observations/Atm/time-series/ERA5/ua_197901_201912.nc" | ||
] | ||
time_slice = slice("1996-01-15", "1997-01-15", None) | ||
|
||
# %% | ||
# Test case 1 - OPEN_MFDATASET() + "ua" dataset (76 GB) + subsetting + `.load()` | ||
# Result: .load() hangs when using `open_mfdataset` | ||
# ------------------------------------------------------------------------------ | ||
ds_ua_omfd = xr.open_mfdataset( | ||
filepaths, | ||
decode_times=True, | ||
use_cftime=True, | ||
coords="minimal", | ||
compat="override", | ||
) | ||
ds_ua_omfd_sub = ds_ua_omfd.sel(time=time_slice) | ||
|
||
# %% | ||
start_time = timeit.default_timer() | ||
ds_ua_omfd_sub.load() | ||
elapsed = timeit.default_timer() - start_time | ||
print(f"Time taken to load ds_xc_sub: {elapsed} seconds") | ||
|
||
# %% | ||
# Test case 2 - OPEN_DATASET() + "ua" dataset (76 GB) + subsetting + `.load()` | ||
# Result: load() works fine when using `open_dataset` | ||
# ------------------------------------------------------------------------------ | ||
ds_ua_od = xc.open_dataset( | ||
filepaths[0], | ||
add_bounds=["X", "Y", "T"], | ||
decode_times=True, | ||
use_cftime=True, | ||
# coords="minimal", | ||
# compat="override", | ||
) | ||
ds_ua_od_sub = ds_ua_od.sel(time=time_slice) | ||
|
||
# %% | ||
start_time = timeit.default_timer() | ||
ds_ua_od_sub.load() | ||
elapsed = timeit.default_timer() - start_time | ||
print(f"Time taken to load ds_xc_sub: {elapsed} seconds") | ||
|
||
# %% | ||
# Test case 3 - OPEN_MFDATASET() + "pr" dataset (2 GB) + subsetting + `.load()` | ||
# Result: ds.load() works fine with pr variable, but not with ua variable | ||
# Notes: pr is 3D variable (time, lat, lon), ua is a 4D variable (time, lat, lon, plev). | ||
# ------------------------------------------------------------------------------ | ||
filepaths_pr = [ | ||
"/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/time-series/ERA5/pr_197901_201912.nc" | ||
] | ||
ds_pr = xc.open_mfdataset( | ||
filepaths_pr, | ||
add_bounds=["X", "Y", "T"], | ||
decode_times=True, | ||
use_cftime=True, | ||
coords="minimal", | ||
compat="override", | ||
) | ||
|
||
# %% | ||
# pr dataset is ~2 GB without subsetting. There is no need to subset. | ||
start_time = timeit.default_timer() | ||
ds_pr.load() | ||
elapsed = timeit.default_timer() - start_time | ||
print(f"Time taken to load ds_xc_sub_0: {elapsed} seconds") | ||
# %% |
13 changes: 13 additions & 0 deletions
13
auxiliary_tools/cdat_regression_testing/892-bottleneck/run_script.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[#] | ||
sets = ["lat_lon"] | ||
case_id = "ERA5" | ||
variables = ["U"] | ||
ref_name = "ERA5" | ||
reference_name = "ERA5 Reanalysis" | ||
seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"] | ||
plevs = [850.0] | ||
test_colormap = "PiYG_r" | ||
reference_colormap = "PiYG_r" | ||
contour_levels = [-20, -15, -10, -8, -5, -3, -1, 1, 3, 5, 8, 10, 15, 20] | ||
diff_levels = [-8, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 8] | ||
regrid_method = "bilinear" |
39 changes: 39 additions & 0 deletions
39
auxiliary_tools/cdat_regression_testing/892-bottleneck/run_script.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
import os | ||
from e3sm_diags.parameter.core_parameter import CoreParameter | ||
from e3sm_diags.run import runner | ||
|
||
param = CoreParameter() | ||
|
||
|
||
param.reference_data_path = ( | ||
"/global/cfs/cdirs/e3sm/diagnostics/observations/Atm/time-series" | ||
) | ||
param.test_data_path = "/global/cfs/cdirs/e3sm/chengzhu/eamxx/post/data/rgr" | ||
param.test_name = "eamxx_decadal" | ||
param.seasons = ["ANN"] | ||
# param.save_netcdf = True | ||
|
||
param.ref_timeseries_input = True | ||
# Years to slice the ref data, base this off the years in the filenames. | ||
param.ref_start_yr = "1996" | ||
param.ref_end_yr = "1996" | ||
|
||
prefix = "/global/cfs/cdirs/e3sm/www/cdat-migration-fy24/892-bottleneck" | ||
param.results_dir = os.path.join(prefix, "eamxx_decadal_1996_1107_edv3") | ||
|
||
cfg_path = "auxiliary_tools/cdat_regression_testing/892-bottleneck/run_script.cfg" | ||
sys.argv.extend(["--diags", cfg_path]) | ||
|
||
runner.sets_to_run = [ | ||
"lat_lon", | ||
"zonal_mean_xy", | ||
"zonal_mean_2d", | ||
"zonal_mean_2d_stratosphere", | ||
"polar", | ||
"cosp_histogram", | ||
"meridional_mean_2d", | ||
"annual_cycle_zonal_mean", | ||
] | ||
|
||
runner.run_diags([param]) |
20 changes: 20 additions & 0 deletions
20
auxiliary_tools/cdat_regression_testing/892-bottleneck/xr_mvce_e3sm_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# %% | ||
import timeit | ||
|
||
import xarray as xr | ||
|
||
filepaths = [ | ||
"/lcrc/group/e3sm/diagnostics/observations/Atm/time-series/ERA5/ua_197901_201912.nc" | ||
] | ||
|
||
ds = xr.open_mfdataset(filepaths) | ||
|
||
ds_sub = ds.sel(time=slice("1996-01-15", "1997-01-15", None)) | ||
|
||
# %% | ||
start_time = timeit.default_timer() | ||
ds_sub.ua.load() | ||
elapsed = timeit.default_timer() - start_time | ||
print(f"Time taken to load ds_xc_sub: {elapsed} seconds") | ||
|
||
# %% |
48 changes: 48 additions & 0 deletions
48
auxiliary_tools/cdat_regression_testing/892-bottleneck/xr_mvce_gh.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# %% | ||
import numpy as np | ||
import pandas as pd | ||
import xarray as xr | ||
import timeit | ||
|
||
import dask.array as da | ||
|
||
# %% | ||
# Define the dimensions | ||
time = 12 | ||
plev = 37 | ||
lat = 721 | ||
lon = 1440 | ||
|
||
# Create the data arrays using dask. | ||
data = da.random.random(size=(time, plev, lat, lon), chunks=(12, 37, 721, 1440)).astype( | ||
np.float32 | ||
) | ||
|
||
# Create the coordinates. | ||
times = pd.date_range("2000-01-01", periods=time) | ||
plevs = np.linspace(100000, 10, plev) | ||
lats = np.linspace(-90, 90, lat) | ||
lons = np.linspace(0, 360, lon, endpoint=False) | ||
|
||
# Create the dataset and write out to a file. | ||
ds = xr.Dataset( | ||
{"data": (["time", "plev", "lat", "lon"], data)}, | ||
coords={"time": times, "plev": plevs, "lat": lats, "lon": lons}, | ||
) | ||
# %% | ||
ds.to_netcdf("dask_bottleneck.nc") | ||
|
||
# %% | ||
# Open the dataset. | ||
ds_open = xr.open_mfdataset("dask_bottleneck.nc") | ||
|
||
# %% | ||
# Load the dataset into memory | ||
start_time = timeit.default_timer() | ||
ds.load() | ||
end_time = timeit.default_timer() | ||
|
||
print(f"Time taken to load the dataset: {end_time - start_time} seconds") | ||
|
||
|
||
# %% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chengzhuzhang @xylar FYI I was notified the performance issue will be fixed in
dask=2025.1.0
, dask/community#410 via dask/dask#11638 .I think we should still constrain the dask version for now until 2025.1.0 is released and we do some more testing during the RC testing phase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be reasonable to change this to
dask !=2024.12.0,!=2024.12.1
? I guess it's fine either way but that seems like we're we're likely to end up, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think either way would be fine. Before we are able to test 2025.1.0, I think
dask <2024.12.0
is safer for now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can update this constraint to
dask !=2024.12.0,!=2024.12.1
in a separate PR so we can test2025.1.0
to confirm it is indeed fixed.