SantanderMetGroup / climate4R.climdex

A climate4R package for calculation of the ETCCDI core climate indices (part of the climate4R bundle)
https://github.com/SantanderMetGroup/climate4R
GNU General Public License v3.0
2 stars 4 forks source link

climdexGrid() function returns monthly outputs instead of yearly when crossing season is specified #7

Closed fmsangi closed 2 years ago

fmsangi commented 2 years ago

I am trying to calculate climate change indices for a specific crossing season (October to April) from 1981 to 2020 but I get results as months instead of the season year. For the given period 1981 to 2020, I expected the output to have 39 seasons layers but it returns 273 monthly layers. Is there a way for me to specify that a year is defined after 212 days(days between October and April no leap)?

Please find my code below and attached data

Calculating the indices

ds1<-"/Volumes/Untitled 2/Daily kk/Daily2_pr19812020.nc"

ppt.eobs <- loadGridData(dataset = ds1, var = "ppt", years = 1982:2020, season = c(10,11,12,1,2,3,4))

PRCPTOT.indices=climdexGrid('PRCPTOT',pr =ppt.eobs,input.arg.list = list(base.range=c(1982,2020),northern.hemisphere=FALSE),cal = "365_day") Daily2_pr19812020.nc.zip

miturbide commented 2 years ago

Hi fmsangi The climate4R.climdex package is a wrapper of the PCICt package, which by definition works with complete annual series. However, you can use the following approach instead:

library(transformeR) library(loadeR)

ds1<-"Daily2_pr19812020.nc"

ppt.eobs <- loadGridData(dataset = ds1, var = "ppt", years = 1982:2020, season = c(10,11,12,1,2,3,4))

aux.fun <- function(x){ sum(x[x >= 1]) }

prcptot <- aggregateGrid(ppt.eobs, aggr.y = list(FUN = aux.fun))

fmsangi commented 2 years ago

Hi miturbide

Thank you very much for the clarification and suggested approach it solved my problem