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

Missing reference times in CF output #1347

Open
infotroph opened this issue Apr 13, 2017 · 7 comments
Open

Missing reference times in CF output #1347

infotroph opened this issue Apr 13, 2017 · 7 comments
Assignees

Comments

@infotroph
Copy link
Member

Several functions in data.atmosphere produce invalid CF output because they give time in units of "sec", with no internal indication what time the file started.

Description

cd ~/github_forks/pecan/modules/data.atmosphere/R
grep -R '"sec"' .
./debias.met.R:  time <- ncdf4::ncdim_def(name = "time", units = "sec", vals = (1:reso_len) *
./download.CRUNCEP_Global.R:    time <- ncdf4::ncdim_def(name = "time", units = "sec", vals = (1:ntime) * 21600,
./download.GFDL.R:    time <- ncdf4::ncdim_def(name = "time", units = "sec", vals = (1:2920) * 10800,
./download.GLDAS.R:                      units = "sec",
./download.MACA.R:    time <- ncdf4::ncdim_def(name='time', units="sec", vals=(1:365)*86400, create_dimvar=TRUE, unlim=TRUE)
./download.MsTMIP_NARR.R:                      units = "sec",
./download.NLDAS.R:    time <- ncdf4::ncdim_def(name = "time", units = "sec",
./met_temporal_downscale.Gaussian_ensemble.R:    time <- ncdf4::ncdim_def(name = "time", units = "sec", vals = seq_len(reso_len) *
./upscale_met.R:  time <- ncdf4::ncdim_def(name = "time", units = "sec", vals = (1:reso_len) *

Context

The CF format conventions require that time variables always include a reference time in their units attribute, and the PEcAn documentation at least implies that times should be days since 1700-01-01 00:00:00 UTC. Enforcing this at the CF conversion stage would simplify the logic of all the met2model.MODEL functions, and would be more reliable than assuming filenames contain start dates.

Possible Implementation

@infotroph
Copy link
Member Author

infotroph commented Apr 13, 2017

An issue to be aware of while fixing this: If adding or subtracting large numbers of seconds to calculate reference time with something like lubridate::ymd("1700-01-01") + lubridate::seconds(x$dim$time$val), look out forupdate your copy of lubridate to avoid integer overflows in the date math.

@ankurdesai
Copy link
Contributor

@jsimkins2 I think this is mostly in your functions. Can you take a look?

@dlebauer
Copy link
Member

I think this is fixed for CRUNCEP in #1357. Could code from that PR be reused, or generalized and applied to all of the met2CF functions?

@jsimkins2
Copy link

@dlebauer Yes, that can be reused and applied to other data.atmosphere functions. The only difference is the reference date. This varies per source, download.MACA references 1900-01-01, while download.GFDL references 1861-01-01

@github-actions
Copy link

This issue is stale because it has been open 365 days with no activity.

@infotroph
Copy link
Member Author

Unstaling: Still needs to be done. Shouldn't be too hard, just need to make sure we fix all instances.

@github-actions
Copy link

This issue is stale because it has been open 365 days with no activity.

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

No branches or pull requests

4 participants