ARCCSS-extremes / climpact2

Combining climdex.pcic and climpact @ UNSW
GNU General Public License v3.0
36 stars 26 forks source link

Non-standard timestamping #2

Closed tammasloughran closed 9 years ago

tammasloughran commented 9 years ago

The git clone command wouldn't work for me. Instead, I used: git clone https://github.com/heroldn/climpact2.git

I have run the test script Nick provided and it works with the narclim data. Values look reasonable for TXX.

I tried to use some AWAP data with the following testing template.

# Testing template for climpact.loader
source("climpact2_0.1.r")

indices=c("txx")
minfilename = "/srv/ccrc/data35/z5032520/AWAP/daily/tmin/tmin_2000.nc"
maxfilename = "/srv/ccrc/data35/z5032520/AWAP/daily/tmax/tmax_2000.nc"
#precfilename = "/srv/ccrc/data43/z3506872/datasets/sample_narclim/CCRC_NARCliM_DAY_1950-2009_pracc_fl.nc"

climpact.loader(
tsminfile=minfilename,
tsmaxfile=maxfilename,
#precname="pracc_fl",
tsminname="tmin",
tsmaxname="tmax",
indices=indices,
identifier="AWAP_tmax_test")

I get an error:

z5032520@cyclone:~/climpact2$ Rscript test.climpact2.r 
Loading required package: PCICt
Loading required package: methods
Error in as.POSIXlt.character(x, tz, format, ...) : 
  character string is not in a standard unambiguous format
Calls: climpact.loader ... as.PCICt.default -> as.PCICt -> as.POSIXlt -> as.POSIXlt.character
Execution halted

It looks like the time formatting is incorrect in my file. They are dates as YYYYMMDD (eg. 20000101, 20000102, etc...) and not a 'days since...' format. So, my files have non-standard timestamps. Do you want to support timestamps?

heroldn commented 9 years ago

So I put in a somewhat adhoc fix that should allow you to have timestamps of any particular flavour. Or most any. I've uploaded a new climpact2_0.2.r file with it. To get the functionality to work you need to specify the "time_format" parameter when calling climpact.loader.

e.g. for your AWAP data it would be: time_format = "%Y%m%d" Other combinations can be chosen as per strptime http://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html

If you don't specify time_format you'll get the same error about ambiguity as before.