AustralianAntarcticDivision / raadtools

Tools for Synoptic Environmental Spatial Data
http://australianantarcticdivision.github.io/raadtools/
24 stars 3 forks source link

apply UTC timezone attribute to all outputs #72

Closed mdsumner closed 5 years ago

mdsumner commented 6 years ago

Set this up for all outputs with a time-attribute, so that print is always UTC-format despite system settings.

set_utc_format <- function(x) {
  attr(x, "tz") <- "UTC"
  x
}

## i.e. in readice
## https://github.com/AustralianAntarcticDivision/raadtools/blob/master/R/ice.R#L249

##--  r <- setZ(r, files$date)
##++r <- setZ(r, set_utc_format(files$date))

Probably best to apply this to all *files functions, but also check if that holds for all read functions.

Note that it's "tzone" not "tz" when setting the attribute for controlled print.

mdsumner commented 6 years ago

grep shows that all instances of setZ include "files$date" :)

mdsumner@raadsync2:~/raadtools$ grep setZ R/*.R
R/amps.R:    r <- setZ(r, files$date)
R/amps.R:    r <- setZ(r, rep(files$date, 2L))
R/amps.R:    r <- setZ(r, files$date)
R/amps.R:    r <- setZ(r, files$date)
R/chla.R:  r <- setZ(r, files$date)
R/copernicus_altimetry.R:  r0 <- setZ(r0, files$date)
R/currents.R:    r0 <- setZ(r0, files$date)
R/currents.R:      r0 <- setZ(r0, rep(files$date, 2))
R/currents.R:  if (magonly | dironly | uonly | vonly) r <- setZ(r, files$date) else r <- setZ(r, rep(files$date, 2L))
R/currents.R:    r <- setZ(r, files$date)
R/currents.R:    r <- setZ(r, rep(files$date, 2L))
R/deriv.R:  setZ(r, files$date)
R/fastice.R:    setZ(r, files$date)
R/fronts.R:  r <- if (length(l) > 1) setZ(brick(stack(l)), files$date) else setZ(l[[1L]], files$date)
R/ghrsst.R:  r0 <- setZ(r0, files$date)
R/ghrsst.R:    r0 <- setZ(r0, files$date)
R/ghrsst.R: # r0 <- setZ(r0, getZ(r0) + ISOdatetime(1981, 1, 1, 0, 0, 0, tz = "GMT")) ##1981-01-01 00:00:00)
R/ice_amsr_ssmi.R:  raster::setExtent(raster::setZ(out, files$date), ext)
R/ice.R:  r <- setZ(r, files$date)
R/ncep2.R:#     r0 <- setZ(r0, rep(files$date, 2L))
R/ncep2.R:#   if (nlayers(r0) == nrow(files)) r0 <- setZ(r0, files$date)
R/ncep2.R:#   if (magonly | dironly | uonly | vonly) r <- setZ(r, files$date) else r <- setZ(r, rep(files$date, 2L))
R/ncep2.R:#     r <- setZ(r, files$date)
R/ncep2.R:#     r <- setZ(r, rep(files$date, 2L))
R/raadtools.R:##' @importFrom raster brick crop deratify extent<- extract getZ nlayers projection projection<- raster res resample rotate setZ stack writeRaster xmax xmin ymax ymin
R/sst.R:  r0 <- setZ(r0, files$date)
R/wind.R:    r <- setZ(r, files$date)
R/wind.R:    r <- setZ(r, rep(files$date, 2L))

So, applying this to raadfiles as a template should cover it.

mdsumner commented 6 years ago

Applied in https://github.com/AustralianAntarcticDivision/raadfiles/commit/183153e5e9e0b404c0760fb543e22c271cfcb158