Skip to content

Commit 8e53dd7

Browse files
committed
Minor edits and documentation updates
1 parent acfd6e3 commit 8e53dd7

8 files changed

Lines changed: 51 additions & 130 deletions

File tree

R/CFCalendar.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ CFCalendar <- R6::R6Class("CFCalendar",
151151
#' @return `TRUE` if the instance in argument `cal` is equivalent to
152152
#' `self`, `FALSE` otherwise.
153153
is_equivalent = function(cal) {
154-
sum(self$origin[1L,1L:6L] == cal$origin[1L,1L:6L]) == 6L && # Offset column is NA
154+
all(self$origin[1L,1L:6L] == cal$origin[1L,1L:6L]) && # Offset column is NA
155155
self$is_compatible(cal)
156156
},
157157

R/CFtime.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,13 @@ CFTime <- R6::R6Class("CFTime",
906906
}
907907
),
908908
active = list(
909+
#' @field calendar (read-only) The calendar of this `CFTime` instance, a
910+
#' descendant of the [CFCalendar] class.
911+
calendar = function(value) {
912+
if (missing(value))
913+
self$cal
914+
},
915+
909916
#' @field unit (read-only) The unit string of the calendar and time series.
910917
unit = function(value) {
911918
if (missing(value))

R/api.R

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -359,22 +359,6 @@ slice <- function(x, extremes, rightmost.closed = FALSE) {
359359
x$slice(extremes, rightmost.closed)
360360
}
361361

362-
#' Which time steps fall within two extreme values
363-
#'
364-
#' Avoid using this function, use [slice()] instead. This function will be
365-
#' deprecated in the near future.
366-
#'
367-
#' @param x,extremes,rightmost.closed See `slice()`.
368-
#' @returns See `slice()`.
369-
#' @export
370-
#' @examples
371-
#' t <- CFtime("hours since 2023-01-01 00:00:00", "standard", 0:23)
372-
#' slab(t, c("2022-12-01", "2023-01-01 03:00"))
373-
slab <- function(x, extremes, rightmost.closed = FALSE) {
374-
warning("Function `slab()` is deprecated. Use function `slice()` instead", call. = FALSE)
375-
x$slice(extremes, rightmost.closed)
376-
}
377-
378362
#' Equivalence of CFTime objects
379363
#'
380364
#' This operator can be used to test if two [CFTime] objects represent the same

R/deprecated.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#' | CFmonth_days() | [month_days()] |
1414
#' | CFparse() | [parse_timestamps()] |
1515
#' | CFrange() | [range()] |
16-
#' | CFsubset() | [slice()] |
16+
#' | CFsubset() | [slice()] |
17+
#' | slab() | [slice()] |
1718
#' | CFtimestamp() | [as_timestamp()] |
1819
#'
19-
#' @param t,x,format,asPOSIX,extremes See replacement functions.
20+
#' @param t,x,format,asPOSIX,extremes,rightmost.closed See replacement functions.
2021
#'
2122
#' @returns See replacement functions.
2223

@@ -46,8 +47,15 @@ CFcomplete <- function(x) {
4647
#' @rdname deprecated_functions
4748
#' @export
4849
CFsubset <- function(x, extremes) {
49-
warning("Function `CFsubset()` is deprecated. Use `slab()` instead.")
50-
slab(x, extremes)
50+
warning("Function `CFsubset()` is deprecated. Use `slice()` instead.")
51+
slice(x, extremes)
52+
}
53+
54+
#' @rdname deprecated_functions
55+
#' @export
56+
slab <- function(x, extremes, rightmost.closed = FALSE) {
57+
warning("Function `slab()` is deprecated. Use function `slice()` instead", call. = FALSE)
58+
x$slice(extremes, rightmost.closed)
5159
}
5260

5361
#' @rdname deprecated_functions

man/CFtime.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/deprecated_functions.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/slab.Rd

Lines changed: 0 additions & 22 deletions
This file was deleted.

vignettes/Conformance.Rmd

Lines changed: 23 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -14,95 +14,45 @@ knitr::opts_chunk$set(
1414
)
1515
```
1616

17-
`CFtime` is based on version 1.12 of the CF Metadata Conventions. The text for
18-
the *time coordinate* in the conventions may be consulted [here](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.12/cf-conventions.html#time-coordinate).
17+
`CFtime` is based on version 1.12 of the CF Metadata Conventions. The text for the *time coordinate* in the conventions may be consulted [here](https://cfconventions.org/Data/cf-conventions/cf-conventions-1.12/cf-conventions.html#time-coordinate).
1918

20-
> The *time coordinate* is one of four coordinate types that receive "special
21-
treatment" in the conventions. The other three are longitude, latitude and the
22-
vertical. If you require convention-compliant support for any of these three
23-
other coordinate types, please consider using package [`ncdfCF`](https://cran.r-project.org/package=ncdfCF)
24-
which supports all three coordinate types and links with `CFtime` for support of
25-
the time coordinate.
19+
> The *time coordinate* is one of four coordinate types that receive "special treatment" in the conventions. The other three are longitude, latitude and the vertical. If you require convention-compliant support for any of these three other coordinate types, please consider using package [`ncdfCF`](https://cran.r-project.org/package=ncdfCF) which supports all three coordinate types and links with `CFtime` for support of the time coordinate.
2620
27-
This document sets out how the `CFtime` package conforms to the CF Metadata
28-
Conventions, by section of the conventions. This information is mostly useful
29-
for developers and expert users.
21+
This document sets out how the `CFtime` package conforms to the CF Metadata Conventions, by section of the conventions. This information is mostly useful for developers and expert users.
3022

31-
If you have issues reading a netCDF file that is due to conformance of package
32-
`CFtime` with the CF Metadata Conventions, please [open an issue on GitHub](https://github.com/pvanlaake/CFtime/issues).
23+
If you have issues reading a netCDF file that is due to conformance of package `CFtime` with the CF Metadata Conventions, please [open an issue on GitHub](https://github.com/pvanlaake/CFtime/issues).
3324

34-
Please note that there are many netCDF files out there that are not claiming
35-
adherence to the CF Metadata Conventions but whose time coordinate can still be
36-
successfully handled by `CFtime`: the `netCDF` library itself provides the basic
37-
plumbing.
25+
Please note that there are many netCDF files out there that are not claimingadherence to the CF Metadata Conventions but whose time coordinate can still be successfully handled by `CFtime`: the `netCDF` library itself provides the basic plumbing.
3826

3927
## 4.4. Time Coordinate
4028

41-
A `CFTime` object is constructed from information that is contained in the
42-
`units` and `calendar` attributes for a time coordinate read out of a netCDF
43-
file. The package does not actually access the netCDF file, it only uses the
44-
information that was read out of the file by e.g. `ncdfCF`. Consequently, the
45-
`CFtime` package can also construct a `CFTime` object from suitable character
46-
strings.
29+
A `CFTime` object is constructed from information that is contained in the `units` and `calendar` attributes for a time coordinate read out of a netCDF file. The package does not actually access the netCDF file, it only uses the information that was read out of the file by e.g. `ncdfCF`. Consequently, the `CFtime` package can also construct a `CFTime` object from suitable character strings.
4730

48-
This package is agnostic to the orientation of the axes in any data variable
49-
that references the time coordinate. Consequently, the `standard_name` and
50-
`axis` attributes are not considered by this package (but the `ncdfCF` package
51-
handles both). Identification of a time coordinate is done by the `units`
52-
attribute, alone.
31+
This package is agnostic to the orientation of the axes in any data variable that references the time coordinate. Consequently, the `standard_name` and `axis` attributes are not considered by this package (but the `ncdfCF` package handles both). Identification of a time coordinate is done by the `units` attribute, alone.
5332

5433
## 4.4.1. Time Coordinate Units
5534

56-
The `CFtime` package fully supports the units `"second"`, `"minute"`, `"hour"`
57-
and `"day"`, including abbreviated and/or plural forms. Unit `"second"` is the
58-
SI second, a `"minute"` equals 60 seconds, an `"hour"` equals 3,600 seconds,
59-
and a `"day"` equals 86,400 seconds. This is exactly as expected, but refer to
60-
the `utc` calendar, below, for peculiarities of that calendar.
35+
The `CFtime` package fully supports the units `"second"`, `"minute"`, `"hour"` and `"day"`, including abbreviated and/or plural forms. Unit `"second"` is (nominally) the SI second, a `"minute"` equals 60 seconds, an `"hour"` equals 3,600 seconds, and a `"day"` equals 86,400 seconds. This is exactly as expected, but refer to the `utc` calendar, below, for peculiarities of that calendar.
6136

62-
The `units` `"month"` and `"year"` are accepted on input but not using their
63-
definition in UDUNITS. Instead, `"year"` is a calendar year, so either 360, 365
64-
or 366 days depending on its value and the calendar. A `"month"` is similarly a
65-
calendar month. Use of either of these time units is discouraged by the CF
66-
Metadata Conventions.
37+
The `units` `"month"` and `"year"` are accepted on input but not using their definition in UDUNITS. Instead, `"year"` is a calendar year, so either 360, 365 or 366 days depending on its value and the calendar. A `"month"` is similarly a calendar month. Use of either of these time units is discouraged by the CF Metadata Conventions.
6738

6839
Other UDUNITS time units are not supported by this package.
6940

70-
All variants of the glue word `"since"` are accepted, being `"after"`, `"from"`,
71-
`"ref"` and `"per"`.
41+
All variants of the glue word `"since"` are accepted, being `"after"`, `"from"`, `"ref"` and `"per"`.
7242

73-
The *"reference datetime string"* should be formatted using the UDUNITS broken
74-
timestamp format or following [ISO8601](https://en.wikipedia.org/wiki/ISO_8601)
75-
rules, but noting that datetimes valid in specific calendars other than
76-
Gregorian (such as `2023-02-30` in the `360_day` calendar) are acceptable as
77-
well. The UDUNITS "packed" format is not supported.
43+
The *"reference datetime string"* should be formatted using the UDUNITS broken timestamp format or following [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) rules, but noting that datetimes valid in specific calendars other than Gregorian (such as `2023-02-30` in the `360_day` calendar) are acceptable as well. The UDUNITS "packed" format is not supported.
7844

79-
Timezone information can only use `00`, `15`, `30` and `45` to indicate minutes;
80-
other minute offsets have never been used anywhere. A time zone value of `"UTC"`
81-
is accepted, as an extension to the conventions. Even though the conventions
82-
don't indicate it, the `tai` and `utc` calendars can carry no time zone
83-
indication as that does not exist for either of these calendars.
45+
Timezone information can only use `00`, `15`, `30` and `45` to indicate minutes; other minute offsets have never been used anywhere. A time zone value of `"UTC"` is accepted, as an extension to the conventions. Even though the conventions don't indicate it, the `tai` and `utc` calendars can carry no time zone indication as that does not exist for either of these calendars.
8446

8547
## 4.4.2. Calendar
8648

87-
If a `calendar` attribute is not given, `"standard"` is assumed, being the
88-
default calendar as per the conventions.
89-
90-
* `standard` (or the deprecated `gregorian`): Fully conformant, but leap seconds
91-
are never considered (see below). The combination of a *reference datetime* and
92-
other *datetimes* spanning the gap between 1582-10-05 and 1582-10-15, in either
93-
direction, is supported.
94-
* `proleptic_gregorian`: Fully conformant, but leap seconds are never considered
95-
(see below).
96-
* `julian`: Fully conformant, but, despite the suggestion in the conventions,
97-
leap seconds do not exist in this calendar and are thus never considered.
98-
* `utc`: Fully conformant. Leap seconds are always accounted so when a leap
99-
second is included, UTC time progresses like
100-
`23:59:58 ... 23:59:59 ... 23:59:60 ... 00:00:00 ... 00:00:01`.
101-
This also extends to minutes `23:59:00 ... 23:59:60 ... 00:00:59 ... 00:01:59`,
102-
always adding 60 seconds. Likewise for `hours` and `days`. Units `"year"` and
103-
`"month"` are not allowed, and neither is any time zone indication.
104-
* `tai`: Fully conformant. Units `"year"` and `"month"` are not allowed, and
105-
neither is any time zone indication.
49+
If a `calendar` attribute is not given, `"standard"` is assumed, being the default calendar as per the conventions.
50+
51+
* `standard` (or the deprecated `gregorian`): Fully conformant, but leap seconds are never considered (see below). The combination of a *reference datetime* and other *datetimes* spanning the gap between 1582-10-05 and 1582-10-15, in either direction, is supported.
52+
* `proleptic_gregorian`: Fully conformant, but leap seconds are never considered (see below).
53+
* `julian`: Fully conformant, but, despite the suggestion in the conventions, leap seconds do not exist in this calendar and are thus never considered.
54+
* `utc`: Fully conformant but with an origin of 1972-01-01T00:00:00 (earlier datetimes not allowed). Leap seconds are always accounted so when a leap second is included, UTC time progresses like `23:59:58 ... 23:59:59 ... 23:59:60 ... 00:00:00 ... 00:00:01`. This also extends to minutes `23:59:00 ... 23:59:60 ... 00:00:59 ... 00:01:59`, always adding 60 seconds. Likewise for `hours` and `days`. Units `"year"` and `"month"` are not allowed, and neither is any time zone indication.
55+
* `tai`: Fully conformant. Units `"year"` and `"month"` are not allowed, and neither is any time zone indication.
10656
* `no_leap` / `365_day`: Fully conformant.
10757
* `all_leap` / `366_day`: Fully conformant.
10858
* `360_day`: Fully conformant.
@@ -112,17 +62,9 @@ neither is any time zone indication.
11262

11363
The `utc` calendar fully supports leap seconds.
11464

115-
The `julian` calendar has no concept of leap seconds so these are never
116-
possible or considered. Using a leap second in a `julian` calendar is an error.
65+
The `julian` calendar has no concept of leap seconds so these are never possible or considered. Using a leap second in a `julian` calendar is an error.
11766

118-
In the `standard` and `proleptic_gregorian` calendars only the variant without
119-
leap seconds is considered. The `units_metadata` attribute is not considered, so
120-
assumed to be `"leap seconds: unknown"`. The assumption here is that if second
121-
accuracy for a data producer is essential, then the entire tool chain from
122-
observation equipment, to processing, to file recording will have to be of
123-
known characteristics with regards to UTC time and leap seconds and thus the
124-
`utc` calendar would be used, rather than `standard` or `proleptic_gregorian`
125-
with a caveat communicated through the `units_metdata` attribute.
67+
In the `standard` and `proleptic_gregorian` calendars only the variant without leap seconds is considered. The `units_metadata` attribute is not considered, so assumed to be `"leap seconds: unknown"`. The assumption here is that if second accuracy for a data producer is essential, then the entire tool chain from observation equipment, to processing, to file recording will have to be of known characteristics with regards to UTC time and leap seconds and thus the `utc` calendar would be used, rather than `standard` or `proleptic_gregorian` with a caveat communicated through the `units_metdata` attribute.
12668

12769
## 4.4.4. Time Coordinates with no Annual Cycle
12870

@@ -134,11 +76,6 @@ Not implemented.
13476

13577
## 7.4. Climatological statistics
13678

137-
The time coordinate with climatological bounds is fully supported, with the
138-
exception of using year 0 in the `standard` and `julian` calendars to flag
139-
climatological data (which is a deprecated practice as per the CF Metadata
140-
Conventions).
79+
The time coordinate with climatological bounds is fully supported, with the exception of using year 0 in the `standard` and `julian` calendars to flag climatological data (which is a deprecated practice as per the CF Metadata Conventions).
14180

142-
This package is agnostic to the underlying statistical operation that produced
143-
the *climatological time* so the `cell_methods` attribute is not inspected nor
144-
interpreted.
81+
This package is agnostic to the underlying statistical operation that produced the *climatological time* so the `cell_methods` attribute is not inspected nor interpreted.

0 commit comments

Comments
 (0)