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

Modern diag manager does not save time bounds in legacy average_(DT|T1|T2) variables #36

Open
ceblanton opened this issue Jun 4, 2024 · 1 comment

Comments

@ceblanton
Copy link
Collaborator

Calculating time averages requires the time bounds. Traditionally, FMS history files contained the time bounds information in 3 variables: average_T1, average_T2, and average_DT

average_T1 is the start time for the averaging period (in the same time units as time)
average_T2 is the end time for the averaging period
average_DT is the length of the averaging period, in days

These 3 variables are referenced as a variable attribute in each diagnostic. e.g.

	dis_liq:time_avg_info = "average_T1,average_T2,average_DT" ;

The modern diag manager does not save the time bounds in that non-standard format. It uses the CF convention, which is to point to the time bounds in the "bounds" attribute to time. e.g.

	time:bounds = "time_bnds" ;

The time bounds variable contains the start/end period for each time. https://cfconventions.org/Data/cf-conventions/cf-conventions-1.11/cf-conventions.html#cell-boundaries

double nv(nv) ;
	nv:long_name = "vertex number" ;
double time_bnds(time, nv) ;
	time_bnds:units = "days since 1979-01-01 00:00:00" ;
	time_bnds:long_name = "time axis boundaries" ;

The old diag manager saved both sets of time bounds and the new/modern diag manager saves only the CF standard time bounds.

In some places, the code is looking for average_DT which will need to be updated to be compatible with output from the new/modern diag manager.

grep -RPin average_DT 

gfdlvitals/averagers/cubesphere.py:65:            weights = dset.average_DT.astype("float") * _masked_area
gfdlvitals/averagers/ice.py:139:            weights = dset.average_DT.astype("float")
gfdlvitals/averagers/land_lm4.py:114:                weights = dset.average_DT.astype("float") * _masked_area
gfdlvitals/averagers/latlon.py:60:            weights = dset.average_DT.astype("float") * _masked_area
gfdlvitals/averagers/tripolar.py:65:            weights = dset.average_DT.astype("float") * _masked_area
gfdlvitals/util/average.py:47:    average_dt : np.ma.masked_array
gfdlvitals/util/average.py:67:        average_dt=None,
gfdlvitals/util/average.py:83:        self.average_dt = average_dt
gfdlvitals/util/average.py:122:                    var, axis=0, weights=data_file[0].variables["average_DT"][:]
gfdlvitals/util/average.py:130:                var, axis=0, weights=data_file[0].variables["average_DT"][:]
gfdlvitals/util/average.py:149:                    var, axis=0, weights=fdata.variables["average_DT"][:]
gfdlvitals/util/average.py:159:            var = np.ma.average(var, axis=0, weights=fdata.variables["average_DT"][:])
gfdlvitals/util/average.py:164:            var = np.ma.average(var, axis=0, weights=fdata["average_DT"][:])
gfdlvitals/util/average.py:204:                np.ma.average(_v, axis=0, weights=variable.average_dt),
gfdlvitals/util/extract_ocean_scalar.py:22:    ignore_list = ["time_bounds", "time_bnds", "average_T2", "average_T1", "average_DT"
@jkrasting
Copy link
Owner

Thanks @ceblanton. Hopefully we'll be able to leverage xarray's built-in time accessors to recover the same behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants