Skip to contents

Interpolates non-standard calendars (360 and noleap) to the standard Gregorian. Assumes daily data as input.

Usage

map_non_standard_calendar(times)

Arguments

times

Vector of class PCICt (will be truncated to days).

Value

A data.table with columns:

  • dates_full: sequence of standard dates from min to max date in input times as data.table::IDate

  • dates_pcict_inter: which dates in PCICt from times correspond to the standard dates

  • idx_pcict: the index associated to the input times to be used for mapping e.g. values

See also

Can be used internally in rotpole_nc_point_to_dt and nc_grid_to_dt by setting the respective arguments.

Examples

# example data from EURO-CORDEX (cropped for size)
# non-standard calendar (360)
fn2 <- system.file("extdata", "test2.nc", package = "eurocordexr")
ncobj <- ncdf4::nc_open(fn2)

# read as PCICt-class
times <- ncdf4.helpers::nc.get.time.series(ncobj, "tasmin")
str(times)
#>  'PCICt' num [1:390(1d)] 1949-12-01 12:00:00 1949-12-02 12:00:00 1949-12-03 12:00:00 1949-12-04 12:00:00 ...
#>  - attr(*, "cal")= chr "360"
#>  - attr(*, "months")= num [1:12] 30 30 30 30 30 30 30 30 30 30 ...
#>  - attr(*, "dpy")= num 360
#>  - attr(*, "tzone")= chr "GMT"
#>  - attr(*, "units")= chr "secs"

dtx <- map_non_standard_calendar(times)
dtx[58:64]
#>    dates_full dates_pcict_inter idx_pcict
#>        <Date>            <char>     <num>
#> 1: 1950-01-27        1950-01-27        57
#> 2: 1950-01-28        1950-01-28        58
#> 3: 1950-01-29        1950-01-29        59
#> 4: 1950-01-30        1950-01-30        60
#> 5: 1950-01-31        1950-02-01        61
#> 6: 1950-02-01        1950-02-02        62
#> 7: 1950-02-02        1950-02-03        63