── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.3 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.3 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: xts
######################### Warning from 'xts' package ##########################
# #
# The dplyr lag() function breaks how base R's lag() function is supposed to #
# work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
# source() into this session won't work correctly. #
# #
# Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
# conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
# dplyr from breaking base R's lag() function. #
# #
# Code in packages is not affected. It's protected by R's namespace mechanism #
# Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
# #
###############################################################################
Attaching package: 'xts'
The following objects are masked from 'package:dplyr':
first, last
The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, will retire in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
The sp package is now running under evolution status 2
(status 2 uses the sf package in place of rgdal)
Please note that 'maptools' will be retired during October 2023,
plan transition at your earliest convenience (see
https://r-spatial.org/r/2023/05/15/evolution4.html and earlier blogs
for guidance);some functionality will be moved to 'sp'.
Checking rgeos availability: FALSE
Attaching package: 'hydroTSM'
The following object is masked from 'package:tidyr':
extract
baro review
Setup
Site Gauges
<-tibble::tribble(
gauge_loc~Gauge, ~Lat, ~Lon,
"G01", 47.10191667, 75.4545,
"G02", 47.10069444, 75.45394444,
"G03", 46.79672222, 75.48727778,
"G04", 46.796, 75.48763889,
"G05", 46.98530556, 75.10533333
)
::pandoc.table(gauge_loc) pander
Gauge | Lat | Lon |
---|---|---|
G01 | 47.1 | 75.45 |
G02 | 47.1 | 75.45 |
G03 | 46.8 | 75.49 |
G04 | 46.8 | 75.49 |
G05 | 46.99 | 75.11 |
Capturing hourly records from MERRA2
PS
reanalysis_fn(file = here::here("data","MERRA","MERRA2_hly_ps.nc"),
par = "PS",fun = mean,yrs = 2000:2022)
<-pbapply::pblapply(1:nrow(gauge_loc),FUN=function(x){
gauge_ps_z
<-nc2z_fn(Longitude = gauge_loc[x,3] %>% pull(),
ps_zLatitude = gauge_loc[x,2] %>% pull(),
source = "MERRA2") %>%
::ud.convert(.,"Pa","kPa")*0.102 #conversion from Kpa to meters of head
udunits2
%>% do.call(merge,.)
})
names(gauge_ps_z)<-gauge_loc$Gauge
plot(gauge_ps_z,main="Hourly records for PS from MERRA2[m Head]")
Air Temperature
reanalysis_fn(file = here::here("data","MERRA","MERRA2_hly_t2m.nc"),
par = "T2M",
fun = mean,yrs = 2000:2022)
<-pbapply::pblapply(1:nrow(gauge_loc),FUN=function(x){
gauge_t2m_z
<-nc2z_fn(Longitude = gauge_loc[x,3] %>% pull(),
ps_zLatitude = gauge_loc[x,2] %>% pull(),
source = "MERRA2") %>%
::ud.convert(.,"K","degC")
udunits2
%>% do.call(merge,.)
})
names(gauge_t2m_z)<-gauge_loc$Gauge
plot(gauge_t2m_z,main="Hourly records for Air Temperature from MERRA2[degC]")
Comparison of results
<- read_csv(here::here("data","csv","1037A_Baro.csv"),
baro_tbl col_types = cols(Date = col_date(format = "%Y-%m-%d"),
Time = col_time(format = "%H:%M:%S")),
skip = 10)
<-zoo(baro_tbl$LEVEL,ymd_hms(paste0(baro_tbl$Date," ",baro_tbl$Time)))
baro_ps_z
plot(baro_ps_z,main="Barometric Pressure measured at Barologger")
<-zoo(baro_tbl$TEMPERATURE,ymd_hms(paste0(baro_tbl$Date," ",baro_tbl$Time)))
baro_t2m_z
plot(baro_t2m_z,main="Air Temperature measured at Barologger")
PS
merge(baro_ps_z-4.25,
"MERRA2@G01"=gauge_ps_z$G01) %>%
na.approx() %>%
::dygraph(ylab = "m of Head") dygraphs
merge("baro-4.25m"=baro_ps_z-4.25,
"MERRA2"=gauge_ps_z) %>%
subdaily2daily(FUN=mean) %>%
as.data.frame() %>%
::filter(complete.cases(.)) %>%
dplyr::hydropairs() hydroTSM
Air Temperature
merge(baro_t2m_z,
"MERRA2@G01"=gauge_t2m_z$G01) %>%
na.approx() %>%
::dygraph(ylab = "m of Head") dygraphs
merge("air_temp_baro"=baro_t2m_z,
"MERRA2"=gauge_t2m_z) %>%
subdaily2daily(FUN=mean) %>%
as.data.frame() %>%
::filter(complete.cases(.)) %>%
dplyr::hydropairs() hydroTSM