This is the base class for all data imported via the API. A HydroImport contains public raw data and private metadata.
Public fields
data
Imported data via the API tool. Uses data.table.
rating
Rating parameters. Uses data.table. At the moment only 1 rating can be applied
peaks
Calculated peaks, initialised by "$findPeaks"
Methods
Method new()
Initialise the new HydroImport object
Usage
HydroImportFactory$new(
data = NA,
rating = NULL,
peaks = NULL,
dataType = "Raw Import",
modifications = NA,
stationName = NA,
riverName = NA,
WISKI = NA,
RLOID = NA,
stationGuide = NA,
baseURL = NA,
dataURL = NA,
measureURL = NA,
idNRFA = NA,
urlNRFA = NA,
easting = NA,
northing = NA,
latitude = NA,
longitude = NA,
area = NA,
parameter = NA,
unitName = NA,
unit = NA,
datum = NA,
boreholeDepth = NA,
aquifer = NA,
start = NA,
end = NA,
timeStep = NA,
timeZone = NA,
records = NA
)
Arguments
data
Raw data
rating
Set to blank, if data requires a rating add to here
peaks
Set to blank, if you calculate peaks they can be stored here
dataType
Details the type of data in this environment
modifications
Details modifications made to the data
stationName
Name of gauge
riverName
River name
WISKI
WISKI ID
RLOID
River Levels on the Internet ID
stationGuide
Station Unique Identifier
baseURL
Base URL used in the API
dataURL
End of URL that downloaded the raw data
measureURL
Primarily used in gaining the metadata
idNRFA
National River Flow Archive station identifier
urlNRFA
National River Flow Archive station URL
easting
Easting coordinate
northing
Northing coordinate
latitude
Latitude coordinate
longitude
Longitude coordinate
area
Catchment area of flow/level gauge
parameter
Details the collected data e.g. flow, level etc.
unitName
Unit name used
unit
Details on the unit of measurement
datum
Datum of the gauge, if available
boreholeDepth
Depth of borehole recording
aquifer
Details on the aquifer type
start
Function calculates the date of the first imported record
end
Function calculates the date of the last imported record
timeStep
Function that calculates the timestep in seconds
timeZone
Time zone used in data, defaults to GMT
records
Function calculates the number of records
Method methods()
Display the methods available in the R6 object
Examples
data(bewdley)
bewdley$methods()
Method asVol()
Calculate the volume of water for flow or rainfall data
Method hydroYearDay()
Calculate hydrological year and day
Method rmVol()
Remove the calculated volume
Method rmHY()
Remove the calculated hydroYear
Method rmHYD()
Remove the calculated hydrological day
Method findPeaks()
Detect peaks within the HydroImport or HydroAggs objects
Arguments
levels
The number of thresholds to apply against the time series. Defaults to 100
from
Set the location from where the thresholds should start. Defaults to the bottom 10% value.
to
Set the location from where the thresholds should end Defaults to the maximum observed value.
gaps
Used to pad out the run length encoding, prevents wobbly data showing multiple exceedances. Set to 96.
Method rateFlow()
Converts stage to flow using the supplied rating. It uses the following equation; Q = C(h - a)^b
Method rateStage()
Converts flow to stage using the supplied rating. It uses the following equation; h = ((Q/a)^(1/C))- b
Method window()
Extract windows of data from object using start and end date/times
Arguments
start
Function calculates the date of the first imported record
end
Function calculates the date of the last imported record
export
Set as "dt", this exports a data.table of public data. If set to "snip" then the R6 object is modified.
from
Start date/time
to
end date/time, if kept blank will default to last time step
Method dataAgg()
Return aggregated data
Method rollingAggs()
Return the different user selecting rolling aggregations
Usage
HydroImportFactory$rollingAggs(
method = "mean",
rolls = c(1, 2, 3, 4, 8, 24, 120),
interval = 0.25
)
Method meta()
Returns the metadata as a data.table
Arguments
transform
Set to FALSE. If TRUE the data.table is transformed which increases readability in the console.
Examples
data(bewdley)
bewdley$meta()
Method dayStats()
Daily statistics for imported data
Method plot()
Plot the data by years
Arguments
wrap
Set to 3, use this to specify how many of columns of graphs there should be
cumul
Used to provide cumulative rainfall totals on rainfall
title
Used to add a plot title and subtitle
theme
Used to decide on EA colour them
dir
Use this to save the plots
Examples
data(bewdley)
bewdley$plot()
Method flowDuration()
Flow duration curve of data
Usage
HydroImportFactory$flowDuration(perc = c(5, 25, 75, 95))
Method quality()
Displays the number of observations under each quality flag
Examples
data(bewdley)
bewdley$quality()
Method exceed()
Shows threshold exceedance statistics
Arguments
threshold
The threshold at which to test against
gapWidth
This allows you to ignore a set number of time steps beneath a threshold between two or more events
.
(ignored).
Examples
data(bewdley)
bewdley$exceed(threshold = 200, gapWidth = 20)
Examples
## ------------------------------------------------
## Method `HydroImportFactory$methods`
## ------------------------------------------------
data(bewdley)
bewdley$methods()
#> ┌ Methods ───────────────────────────────────────────────────────────────────────────────────┐
#> │ obj$data → Returns the raw data imported via the API │
#> │ obj$rating → Returns the user imported rating details │
#> │ obj$meta() → Returns the metadata associated with the object │
#> │ obj$asVol() → Calculates the volume of water relative to the time step, see ?asVol │
#> │ obj$hydroYearDay() → Calculates the hydrological year and day, see ?hydroYearDay │
#> │ obj$rmVol() → Removes the volume column │
#> │ obj$rmHY() → Removes the hydroYear column │
#> │ obj$rmHYD() → Removes the hydroYearDay column │
#> │ obj$summary() → Provides a quick summary of the raw data │
#> │ obj$coords() → Returns coordinates from the metadata │
#> │ obj$nrfa() → Returns the NRFA data from the metadata │
#> │ obj$dataAgg() → Aggregate data by, hour, day, month calendar year and hydroYear │
#> │ obj$rollingAggs() → Uses user specified aggregation timings, see ?rollingAggs │
#> │ obj$dayStats() → Daily statistics of flow, carried out on hydrological or calendar … │
#> │ obj$quality() → Provides a quick summary table of the data quality flags │
#> │ obj$missing() → Quickly finds the positions of missing data points │
#> │ obj$exceed → Show how many times observed data exceed a given threshold │
#> │ obj$plot() → Create a plot of each year of data, by hydrological year │
#> │ obj$window() → Extracts the subset of data observed between the times start and end │
#> │ obj$rateFlow() → Converts stage into a rated flow using the specified rating table │
#> │ obj$rateStage() → Converts flow into a rated stage using the specified rating table │
#> └────────────────────────────────────────────────────────────────────────────────────────────┘
## ------------------------------------------------
## Method `HydroImportFactory$summary`
## ------------------------------------------------
data(bewdley)
bewdley$summary()
#> hydroLoad:
#> Data Type: Raw Import
#> Station ID: 2001
#> Start: 2008-10-01 09:00:00
#> End: 2022-10-01 08:45:00
#> Time Zone: GMT
#> Observations: 490848
#> Parameter: Flow
#> Unit Type: m3/s
#> Unit: http://qudt.org/1.1/vocab/unit#CubicMeterPerSecond
## ------------------------------------------------
## Method `HydroImportFactory$coords`
## ------------------------------------------------
data(bewdley)
bewdley$coords()
#> stationName WISKI Easting Northing Latitude Longitude
#> <char> <char> <int> <int> <num> <num>
#> 1: Bewdley 2001 378235 276165 52.38307 -2.321186
## ------------------------------------------------
## Method `HydroImportFactory$nrfa`
## ------------------------------------------------
data(bewdley)
bewdley$nrfa()
#> WISKI codeNRFA urlNRFA
#> <char> <char> <char>
#> 1: 2001 54001 https://nrfa.ceh.ac.uk/data/station/info/54001.html
## ------------------------------------------------
## Method `HydroImportFactory$meta`
## ------------------------------------------------
data(bewdley)
bewdley$meta()
#> dataType modifications stationName riverName WISKI RLOID stationGuide
#> <char> <lgcl> <char> <char> <char> <char> <lgcl>
#> 1: Raw Import NA Bewdley River Severn 2001 2001 NA
#> baseURL
#> <char>
#> 1: http://environment.data.gov.uk/hydrology/id/measures/
#> dataURL
#> <char>
#> 1: 8820d897-a09e-4857-8095-5834fee6962f-flow-i-900-m3s-qualified/readings.json?_limit=2000000&mineq-date=2008-10-01&max-date=2022-10-02
#> measureURL idNRFA
#> <char> <char>
#> 1: 8820d897-a09e-4857-8095-5834fee6962f-flow-i-900-m3s-qualified 54001
#> urlNRFA easting northing
#> <char> <int> <int>
#> 1: https://nrfa.ceh.ac.uk/data/station/info/54001.html 378235 276165
#> latitude longitude area parameter unitName
#> <num> <num> <num> <char> <char>
#> 1: 52.38307 -2.321186 4325 Flow m3/s
#> unit datum boreholeDepth
#> <char> <lgcl> <lgcl>
#> 1: http://qudt.org/1.1/vocab/unit#CubicMeterPerSecond NA NA
#> aquifer start end timeStep timeZone records
#> <lgcl> <POSc> <POSc> <num> <char> <int>
#> 1: NA 2008-10-01 09:00:00 2022-10-01 08:45:00 900 GMT 490848
## ------------------------------------------------
## Method `HydroImportFactory$plot`
## ------------------------------------------------
data(bewdley)
bewdley$plot()
#> Error in bewdley$plot(): hydroYear field is not present in the data.table
## ------------------------------------------------
## Method `HydroImportFactory$quality`
## ------------------------------------------------
data(bewdley)
bewdley$quality()
#> quality count
#> <char> <int>
#> 1: Good 457101
#> 2: Estimated 12019
#> 3: Suspect 669
#> 4: Unchecked 21059
## ------------------------------------------------
## Method `HydroImportFactory$missing`
## ------------------------------------------------
data(bewdley)
bewdley$missing()
#> Empty data.table (0 rows and 6 cols): id,startTime,endTime,startPos,endPos,timeSteps
## ------------------------------------------------
## Method `HydroImportFactory$exceed`
## ------------------------------------------------
data(bewdley)
bewdley$exceed(threshold = 200, gapWidth = 20)
#> Start End timeSteps
#> <POSc> <POSc> <num>
#> 1: 2008-10-07 20:30:00 2008-10-08 22:00:00 102
#> 2: 2008-11-11 12:00:00 2008-11-11 12:15:00 1
#> 3: 2008-11-11 18:45:00 2008-11-11 22:45:00 16
#> 4: 2008-11-12 12:45:00 2008-11-12 13:00:00 1
#> 5: 2009-11-20 03:00:00 2009-12-02 23:30:00 1234
#> 6: 2010-01-17 07:30:00 2010-01-20 12:30:00 308
#> 7: 2011-01-14 12:15:00 2011-01-16 10:00:00 183
#> 8: 2011-01-16 15:15:00 2011-01-16 15:30:00 1
#> 9: 2011-01-17 07:00:00 2011-01-19 07:00:00 192
#> 10: 2011-02-07 13:45:00 2011-02-10 17:45:00 304
#> 11: 2012-01-05 06:30:00 2012-01-09 00:45:00 361
#> 12: 2012-04-28 03:30:00 2012-04-29 05:00:00 102
#> 13: 2012-04-29 11:30:00 2012-05-03 02:00:00 346
#> 14: 2012-07-14 03:00:00 2012-07-14 07:00:00 16
#> 15: 2012-07-15 14:00:00 2012-07-15 19:30:00 22
#> 16: 2012-09-25 17:00:00 2012-09-28 23:00:00 312
#> 17: 2012-11-24 18:45:00 2012-11-30 22:15:00 590
#> 18: 2012-12-08 19:30:00 2012-12-09 00:45:00 21
#> 19: 2012-12-16 23:15:00 2012-12-17 16:00:00 67
#> 20: 2012-12-20 06:00:00 2013-01-05 11:45:00 1559
#> 21: 2013-01-27 19:15:00 2013-02-03 13:15:00 648
#> 22: 2013-02-11 17:45:00 2013-02-13 03:15:00 134
#> 23: 2013-02-15 01:00:00 2013-02-17 10:15:00 229
#> 24: 2013-05-16 16:45:00 2013-05-18 04:30:00 143
#> 25: 2013-12-23 04:00:00 2013-12-29 14:45:00 619
#> 26: 2014-01-01 14:45:00 2014-01-13 09:45:00 1132
#> 27: 2014-01-20 10:00:00 2014-01-21 04:15:00 73
#> 28: 2014-01-27 23:00:00 2014-02-21 04:15:00 2325
#> 29: 2014-12-12 15:00:00 2014-12-16 15:00:00 384
#> 30: 2014-12-20 16:30:00 2014-12-22 07:15:00 155
#> 31: 2015-01-17 00:30:00 2015-01-19 03:15:00 203
#> 32: 2015-12-02 20:00:00 2015-12-07 18:15:00 473
#> 33: 2015-12-14 16:15:00 2015-12-18 05:00:00 339
#> 34: 2015-12-18 10:45:00 2015-12-18 11:00:00 1
#> 35: 2015-12-24 23:00:00 2015-12-26 21:15:00 185
#> 36: 2015-12-27 03:30:00 2015-12-31 08:45:00 405
#> 37: 2016-01-01 10:45:00 2016-01-01 11:00:00 1
#> 38: 2016-01-01 16:45:00 2016-01-06 11:15:00 458
#> 39: 2016-01-09 15:15:00 2016-01-16 04:00:00 627
#> 40: 2016-02-08 14:15:00 2016-02-13 17:00:00 491
#> 41: 2017-03-04 21:45:00 2017-03-04 22:00:00 1
#> 42: 2017-12-15 11:45:00 2017-12-18 05:00:00 261
#> 43: 2018-01-05 02:00:00 2018-01-05 06:45:00 19
#> 44: 2018-01-05 18:00:00 2018-01-07 00:00:00 120
#> 45: 2018-01-23 05:30:00 2018-01-27 18:45:00 437
#> 46: 2018-04-03 19:15:00 2018-04-06 23:00:00 303
#> 47: 2018-12-22 21:15:00 2018-12-25 20:15:00 284
#> 48: 2019-03-16 16:00:00 2019-03-21 06:45:00 443
#> 49: 2019-06-13 08:45:00 2019-06-17 22:45:00 440
#> 50: 2019-10-01 15:30:00 2019-10-05 12:45:00 373
#> 51: 2019-10-26 10:45:00 2019-10-31 22:30:00 527
#> 52: 2019-11-09 18:15:00 2019-11-11 03:15:00 132
#> 53: 2019-11-13 07:15:00 2019-11-19 21:45:00 634
#> 54: 2019-12-13 19:45:00 2019-12-23 07:15:00 910
#> 55: 2020-01-14 19:15:00 2020-01-17 09:45:00 250
#> 56: 2020-02-10 20:30:00 2020-03-06 05:30:00 2340
#> 57: 2020-03-11 20:30:00 2020-03-14 10:15:00 247
#> 58: 2020-12-18 19:15:00 2021-01-01 10:00:00 1307
#> 59: 2021-01-20 15:15:00 2021-01-27 04:45:00 630
#> 60: 2021-01-28 03:30:00 2021-02-07 10:45:00 989
#> 61: 2021-02-22 10:15:00 2021-02-24 06:45:00 178
#> 62: 2021-03-15 00:00:00 2021-03-16 16:00:00 160
#> 63: 2021-12-10 15:45:00 2021-12-13 04:00:00 241
#> 64: 2022-02-17 07:15:00 2022-02-27 06:15:00 956
#> Start End timeSteps