Skip to contents

Creates fields for hydrological year and hydrological day.

Speed is slow, needs conversion to C++ in future iterations.

Usage

hydroYearDay(x, calendar = "oct_us_gb", ...)

# S3 method for data.table
hydroYearDay(x, calendar = "oct_us_gb")

# S3 method for POSIXct
hydroYearDay(x, calendar = "oct_us_gb")

Arguments

x

Array of dates of class Date

calendar

hydrological year calendar. Set to 'oct_us_gb' (USA and UK), but can also be 'sep_br' (Brazil), 'apr_cl' (Chille).

Value

Creates a hydrological year and hydrological day column

Examples

## Load bewdley dataset
data(bewdley)

## Inspect the data
bewdley$data
#>                    dateTime value quality  qcode
#>                      <POSc> <num>  <char> <char>
#>      1: 2008-10-01 09:00:00  25.3    Good   <NA>
#>      2: 2008-10-01 09:15:00  25.5    Good   <NA>
#>      3: 2008-10-01 09:30:00  25.6    Good   <NA>
#>      4: 2008-10-01 09:45:00  25.6    Good   <NA>
#>      5: 2008-10-01 10:00:00  25.7    Good   <NA>
#>     ---                                         
#> 490844: 2022-10-01 07:45:00  12.0    Good   <NA>
#> 490845: 2022-10-01 08:00:00  11.8    Good   <NA>
#> 490846: 2022-10-01 08:15:00  11.6    Good   <NA>
#> 490847: 2022-10-01 08:30:00  11.6    Good   <NA>
#> 490848: 2022-10-01 08:45:00  11.6    Good   <NA>

## Add hydrological year and hydrological day columns
bewdley$hydroYearDay()
#>  Calculating hydrological year and day
#>  Calculating hydrological year and day [6s]
#> 

## Print the bewdley dataset
bewdley
#> 
#> ── Class: HydroImport ──────────────────────────────────────────────────────────
#> 
#> ── Metadata: ──
#> 
#> Data Type: Raw Import
#> Station name: Bewdley
#> WISKI ID: 2001
#> Parameter Type: Flow
#> Modifications: NA
#> Start: 2008-10-01 09:00:00
#> End: 2022-10-01 08:45:00
#> Time Step: 900
#> Observations: 490848
#> Easting: 378235
#> Northing: 276165
#> Longitude: -2.321186
#> Latitude: 52.383072
#> 
#> 
#> ── Observed data: ──
#> 
#>                    dateTime value quality  qcode hydroYear hydroYearDay
#>                      <POSc> <num>  <char> <char>     <num>        <num>
#>      1: 2008-10-01 09:00:00  25.3    Good   <NA>      2009            1
#>      2: 2008-10-01 09:15:00  25.5    Good   <NA>      2009            1
#>      3: 2008-10-01 09:30:00  25.6    Good   <NA>      2009            1
#>      4: 2008-10-01 09:45:00  25.6    Good   <NA>      2009            1
#>      5: 2008-10-01 10:00:00  25.7    Good   <NA>      2009            1
#>     ---                                                                
#> 490844: 2022-10-01 07:45:00  12.0    Good   <NA>      2022          365
#> 490845: 2022-10-01 08:00:00  11.8    Good   <NA>      2022          365
#> 490846: 2022-10-01 08:15:00  11.6    Good   <NA>      2022          365
#> 490847: 2022-10-01 08:30:00  11.6    Good   <NA>      2022          365
#> 490848: 2022-10-01 08:45:00  11.6    Good   <NA>      2022          365
#> 
#> 
#> 
#> For more details use the $methods() function, the format should be as
#> `Object_name`$methods()