ropensci / tidyhydat

An R package to import Water Survey of Canada hydrometric data and make it tidy
https://docs.ropensci.org/tidyhydat
Apache License 2.0
70 stars 19 forks source link

Water temperature data availability #193

Open elizabethng opened 1 year ago

elizabethng commented 1 year ago

Are historical temperature data available through tidyhydat?

I've searched the code base and other issues for information on whether temperature data are available, but it looks like they may only be available when stations also have sediment samples (i.e., through hy_sed_samples). However the station I'm looking at doesn't have sediment samples.

Looking on the Water Survey of Canada website, I'm able to see real-time temperature data (e.g., here) but can't seem to be able to obtain historical temperature data from either tidyhydat, manual downloads from the website, or through the ECCCDataExplorer. Are these data available anywhere?

boshek commented 1 year ago

Hi! A luck would have it, I am just working on something that will help with this (a bit). It is over in the add-ws branch right now. It accesses the ECCC webservice. You can install it and it should work fine but I can't guarantee that yet. I'm not finished testing it etc. But try this code:

## remotes::install_github("ropensci/tidyhydat", ref = "add-ws")

library(tidyhydat)

print(param_id, n = nrow(param_id))
#> # A tibble: 42 × 7
#>    Parameter Code  Unit  Name_En                         Name_Fr Descr…¹ Descr…²
#>        <dbl> <chr> <chr> <chr>                           <chr>   <chr>   <chr>  
#>  1        46 HG    m     Water level (primary sensor)    Niveau… Height… Hauteu…
#>  2        16 HG2   m     Water level (secondary sensor,… Niveau… Height… Hauteu…
#>  3        11 HG22  m     Water level (secondary sensor)  Niveau… Height… Hauteu…
#>  4        52 HG3   m     Water level (tertiary sensor, … Niveau… Height… Hauteu…
#>  5        13 HG33  m     Water level (tertiary sensor)   Niveau… Height… Hauteu…
#>  6         3 HGD   m     Water level (daily mean)        Niveau… Provis… niveau…
#>  7        39 HGH   m     Water level (hourly mean)       Niveau… Provis… Niveau…
#>  8        14 HL    m     Elevation, natural lake         Élévat… Elevat… Élévat…
#>  9        42 HR    m     Elevation, lake or reservoir r… Élévat… Elevat… Élévat…
#> 10        17 PA    kPa   Atmospheric pressure            Pressi… Pressu… Pressi…
#> 11        18 PC    mm    Accumulated precipitation       Précip… Precip… Précip…
#> 12        19 PP    mm    Incremental precipitation       Précip… Precip… Précip…
#> 13        47 QR    m3/s  Discharge (primary sensor deri… Debit … Discha… Débit …
#> 14         7 QR2   m3/s  Discharge (secondary sensor de… Debit … Discha… Debit,…
#> 15        10 QR3   m3/s  Discharge (tertiary sensor der… Debit … Discha… Debit,…
#> 16         6 QRD   m3/s  Discharge (daily mean)          Débit … Provis… Débit …
#> 17        40 QRH   m3/s  Discharge (hourly mean)         Débit … Provis… Débit …
#> 18         8 QRS   m3/s  Discharge (sensor)              Debit … Discha… Débit …
#> 19        50 SD    cm    Snow depth                      Épaiss… Snow, … Neige,…
#> 20        51 SF    cm    Snow depth, new snowfall        Épaiss… Snow, … Neige,…
#> 21         1 TA    °C    Air temperature                 Tempér… Temper… Tempér…
#> 22         5 TW    °C    Water temperature               Tempér… Temper… Tempér…
#> 23        41 TW2   °C    Secondary water temperature     Tempér… Temper… Tempér…
#> 24        34 UD    deg   Wind direction                  Direct… Wind, … Vent, …
#> 25        35 US    m/s   Wind speed                      Vitess… Wind, … Vent, …
#> 26         2 VB    V     Battery voltage                 Tensio… Batter… Tensio…
#> 27        20 WB    RFU   Blue-green algae                Algues… Water,… Eau, a…
#> 28        21 WC    S     Conductance                     Conduc… Water,… Eau, c…
#> 29        26 WLA   mg/l  Total dissolved solids          Matièr… Water,… Eau, m…
#> 30        43 WNB   mg/l  Dissolved nitrate               Nitrat… Water,… Eau, n…
#> 31        22 WO    mg/l  Dissolved oxygen                Oxygèn… Water,… Eau, o…
#> 32        24 WP    <NA>  pH                              pH      Water,… Eau, pH
#> 33        25 WT    NTU   Turbidity                       Turbid… Water,… Eau, t…
#> 34         9 WV    m/s   Water velocity                  Vitess… Water,… Eau, v…
#> 35        37 WVX   m/s   Water velocity, x               Vitess… Water,… Eau, v…
#> 36        38 WVY   m/s   Water velocity, y               Vitess… Water,… Eau, v…
#> 37        23 WX    %     Oxygen saturation               Satura… Water,… Eau, o…
#> 38        49 WY    ug/L  Chlorophyll                     Chloro… Water,… Eau, c…
#> 39        28 XR    %     Relative humidity               Humidi… Humidi… Humidi…
#> 40        36 YE    m     Cell end                        Fin de… Distan… Distan…
#> 41         4 YI    °C    Internal equipment temperature  Tempér… Intern… Tempér…
#> 42        12 YP    psi   Tank pressure                   Pressi… Tank p… Pressi…
#> # … with abbreviated variable names ¹​Description_En, ²​Description_Fr

realtime_ws("08MF005", parameters = 5)
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> All station successfully retrieved
#> All parameters successfully retrieved
#> # A tibble: 744 × 10
#>    STATIO…¹ Date                Name_En Value Unit  Grade Symbol Appro…² Param…³
#>    <chr>    <dttm>              <chr>   <dbl> <chr> <chr> <chr>    <int>   <dbl>
#>  1 08MF005  2023-01-15 00:00:00 Water …  2.38 °C    -1    <NA>        NA       5
#>  2 08MF005  2023-01-15 01:00:00 Water …  2.36 °C    -1    <NA>        NA       5
#>  3 08MF005  2023-01-15 02:00:00 Water …  2.31 °C    -1    <NA>        NA       5
#>  4 08MF005  2023-01-15 03:00:00 Water …  2.31 °C    -1    <NA>        NA       5
#>  5 08MF005  2023-01-15 04:00:00 Water …  2.29 °C    -1    <NA>        NA       5
#>  6 08MF005  2023-01-15 05:00:00 Water …  2.25 °C    -1    <NA>        NA       5
#>  7 08MF005  2023-01-15 06:00:00 Water …  2.24 °C    -1    <NA>        NA       5
#>  8 08MF005  2023-01-15 07:00:00 Water …  2.25 °C    -1    <NA>        NA       5
#>  9 08MF005  2023-01-15 08:00:00 Water …  2.25 °C    -1    <NA>        NA       5
#> 10 08MF005  2023-01-15 09:00:00 Water …  2.27 °C    -1    <NA>        NA       5
#> # … with 734 more rows, 1 more variable: Code <chr>, and abbreviated variable
#> #   names ¹​STATION_NUMBER, ²​Approval, ³​Parameter

Of course the station has to have temperature sensors for this to be useful but more and more seem to have them. There are lots of other parameters too. If you encounter any problems let me know. If it is helpful to have someone try this out.

bevingtona commented 11 months ago

This is excellent! Any option for accessing historic water temperature data?

boshek commented 11 months ago

This is excellent! Any option for accessing historic water temperature data?

@bevingtona just what is available through the webservice, so like 18 month back. HYDAT doesn't have a table for temperature data (though that would be nice!)