Skip to content

Commit

Permalink
[Refactor]: CDAT Migration Phase 3: testing and documentation update (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Oct 29, 2024
1 parent cfc766d commit 6a0fb91
Show file tree
Hide file tree
Showing 39 changed files with 25,845 additions and 1,366 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[#]
sets = ["lat_lon"]
case_id = "Cloud ISCCP"
variables = ["CLDTOT_TAU1.3_ISCCP"]
ref_name = "ISCCPCOSP"
reference_name = "ISCCP"
# seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
seasons = ["ANN"]
test_colormap = "Blues"
reference_colormap = "Blues"
diff_colormap = "RdBu"
contour_levels = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
diff_levels = [-30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30]


[#]
sets = ["lat_lon"]
case_id = "Cloud ISCCP"
variables = ["CLDTOT_TAU1.3_9.4_ISCCP"]
ref_name = "ISCCPCOSP"
reference_name = "ISCCP"
# seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
seasons = ["ANN", ]
test_colormap = "Blues"
reference_colormap = "Blues"
diff_colormap = "RdBu"
contour_levels = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
diff_levels = [-30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30]


[#]
sets = ["lat_lon"]
case_id = "Cloud ISCCP"
variables = ["CLDTOT_TAU9.4_ISCCP"]
ref_name = "ISCCPCOSP"
reference_name = "ISCCP"
# seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
seasons = ["ANN"]
test_colormap = "Blues"
reference_colormap = "Blues"
diff_colormap = "RdBu"
contour_levels = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
diff_levels = [-30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import xarray as xr
import xcdat as xc

filepath = "/global/cfs/cdirs/e3sm/e3sm_diags/obs_for_e3sm_diags/climatology/ISCCPCOSP/ISCCPCOSP_ANN_climo.nc"

# %%
ds_xc = xc.open_dataset(filepath)
# ValueError: Non-integer years and months are ambiguous and not currently supported.

ds_xr = xr.open_dataset(filepath)
# ValueError: Failed to decode variable 'time': unable to decode time units 'months since 1983-06' # with 'the default calendar'. Try opening your dataset with decode_times=False or installing
# cftime if it is not installed.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# %%
from datetime import datetime
from dateutil import parser
from dateutil import relativedelta as rd

import numpy as np
import xarray as xr
import xcdat as xc


# %%
# Reproduce error: ValueError: Non-integer years and months are ambiguous and not currently supported.
# -------------------------------------------------------------------------------------------

filepath = "/global/cfs/cdirs/e3sm/e3sm_diags/obs_for_e3sm_diags/climatology/ISCCPCOSP/ISCCPCOSP_ANN_climo.nc"
ds = xc.open_dataset(filepath, decode_times=True)


# %%
# Debug -- issue is that the time value is a float representing middle of the month (150.5).
# relativedelta expects a time value at the beginning of the month (e.g,. 150).
# -----

flat_offsets = np.array([150.5])
ref_date = "1983-06"
units_type = "months"

ref_datetime: datetime = parser.parse(ref_date, default=datetime(2000, 1, 1))


# ValueError: Non-integer years and months are ambiguous and not currently supported.
times = np.array(
[
ref_datetime + rd.relativedelta(**{units_type: offset})
for offset in flat_offsets
],
dtype="object",
)

# %%
# Fix error -- replace 150.5 (middle month float) with 150 (integer month)
# -----------------------------------------------------------------------------
ds = xc.open_dataset(filepath, decode_times=False)
ds.time.values[:] = 150
ds.to_netcdf(filepath)

# %%
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

[#]
sets = ["lat_lon"]
case_id = "Cloud ISCCP"
variables = ["CLDTOT_TAU1.3_ISCCP"]
ref_name = "ISCCPCOSP"
reference_name = "ISCCP"
# seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
seasons = ["ANN"]
test_colormap = "Blues"
reference_colormap = "Blues"
diff_colormap = "RdBu"
contour_levels = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
diff_levels = [-30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30]


[#]
sets = ["lat_lon"]
case_id = "Cloud ISCCP"
variables = ["CLDTOT_TAU1.3_9.4_ISCCP"]
ref_name = "ISCCPCOSP"
reference_name = "ISCCP"
# seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
seasons = ["ANN", ]
test_colormap = "Blues"
reference_colormap = "Blues"
diff_colormap = "RdBu"
contour_levels = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
diff_levels = [-30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30]


[#]
sets = ["lat_lon"]
case_id = "Cloud ISCCP"
variables = ["CLDTOT_TAU9.4_ISCCP"]
ref_name = "ISCCPCOSP"
reference_name = "ISCCP"
# seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
seasons = ["ANN"]
test_colormap = "Blues"
reference_colormap = "Blues"
diff_colormap = "RdBu"
contour_levels = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]
diff_levels = [-30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30]
Loading

0 comments on commit 6a0fb91

Please sign in to comment.