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

Updated FATES output time variable to fix issue #1939. #1953

Merged
merged 3 commits into from
Jun 1, 2018
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
## [Unreleased]

### Fixes
- Fixed issue #1939 which corrects output time vector for FATES output
- Update to read.output to look for and read only PEcAn formatted .nc output based on the pecan standard filename format of YYYY.nc. Solves issues with models such as FATES and dvm-dos-tem where the original model output is also in .nc file format and was not ignored by read.output, causing errors with output parsing and plotting with Shiny. Removed deprecated function convert.outputs
- PEcAn.data.atmosphere:
- download.Geostreams is pickier about formatting start/end datess, for fewer surprises in result timestamps
Expand Down
9 changes: 5 additions & 4 deletions models/fates/R/model2netcdf.FATES.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ model2netcdf.FATES <- function(outdir) {
files <- dir(outdir, "*clm2.h0.*.nc", full.names = TRUE)
file.dates <- as.Date(sub(".nc", "", sub(".*clm2.h0.", "", files)))
years <- lubridate::year(file.dates)
init_year <- unique(years)[1]

## Loop over years
for (year in unique(years)) {
Expand Down Expand Up @@ -84,11 +85,11 @@ model2netcdf.FATES <- function(outdir) {
sitelat <- ncdf4::ncvar_get(ncin,"lat")
sitelon <- ncdf4::ncvar_get(ncin,"lon")
## time variable based on internal calc, nc$dim$time is the FATES output time
t <- ncdim_def(name = "time", units = paste0("days since ", year, "-01-01 00:00:00"),
vals = as.vector(time), calendar = "standard",
t <- ncdf4::ncdim_def(name = "time", units = paste0("days since ", init_year, "-01-01 00:00:00"),
vals = as.vector(time), calendar = "noleap",
unlim = TRUE) # a direct analog of internal FATES output dim "time"
lat <- ncdim_def("lat", "degrees_north", vals = as.numeric(sitelat), longname = "coordinate_latitude")
lon <- ncdim_def("lon", "degrees_east", vals = as.numeric(sitelon), longname = "coordinate_longitude")
lat <- ncdf4::ncdim_def("lat", "degrees_north", vals = as.numeric(sitelat), longname = "coordinate_latitude")
lon <- ncdf4::ncdim_def("lon", "degrees_east", vals = as.numeric(sitelon), longname = "coordinate_longitude")
xyt <- list(lon, lat, t)

### build netCDF data
Expand Down