yearlength: Year length associated with a model calendar

Description Usage Arguments Details Value Examples

View source: R/yearlength.R

Description

Returns the length of year (in days) associated with a particular calendar. The input can be a string naming a type of calendar, or a variable with an attribute named 'calendar' holding such a string.

Usage

1

Arguments

time

A variable with an attribute named 'calendar' or a string. The value of the attribute should be a string denoting the type of calendar according to the CF Metdata Conventions.

Details

Climate models often use a year with a length other than the real-world value of 365.2425 days. In netCDF files that comply with the CF Metadata Standard, this is recorded as the 'calendar' attribute of the time coordinate variable. Valid calendars are:

standard, gregorian: 365.2425 days
proleptic_gregorian: 365.2425 days
julian: 365.25 days
noleap, 365_day: 365 days
all_leap, 366_day: 366 days
360_day: 360 days

Note that although the real-world Gregorian calendar is a Julian calendar before October 15, 1582, accounting for this change would be challenging and would frequently run contrary to common usage, and so this function does not do so.

Value

The length of the year for the given calendar, in days. If the calendar is unknown, a warning is thrown and NA is returned. If time is a variable without a calendar, the default year length of 365.2425 days is returned.

Examples

1
2
3
4
5
6
7
yearlength("gregorian")
x <- seq(100)
yearlength(x)
x@calendar <- "noleap"
yearlength(x)
x@calendar <- "martian"
yearlength(x)

sethmcg/climod documentation built on Nov. 19, 2021, 11:12 p.m.