if (FALSE) {
# lets work with the cuevas station
path <- system.file('extdata', package = 'hydrotoolbox')
# use the build method
hm_cuevas <-
hm_create() %>%
hm_build(bureau = 'ianigla', path = path,
file_name = 'ianigla_cuevas.csv',
slot_name = c('tair', 'rh', 'patm',
'precip', 'wspd', 'wdir',
'kin', 'hsnow', 'tsoil'),
by = 'hour',
out_name = c('tair(°C)', 'rh(%)', 'patm(mbar)',
'p(mm)', 'wspd(km/hr)', 'wdir(°)',
'kin(kW/m2)', 'hsnow(cm)', 'tsoil(°C)' )
)
# let's start by making a single variable static plot
hm_plot(obj = hm_cuevas, slot_name = 'tair',
col_name = list('tair(°C)') )
# we add labels, change color, line type and we focus
# on specific date range
hm_plot(obj = hm_cuevas, slot_name = 'tair',
col_name = list('tair(°C)'),
line_type = 'longdash',
line_color = 'dodgerblue',
x_lab = 'Date time', y_lab = 'T(°C)',
title_lab = 'Hourly temperature at Cuevas',
legend_lab = 'Tair',
from = ISOdate(2020, 7, 1),
to = ISOdate(2020, 7, 5))
# compare air with soil temperature
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'tsoil'),
col_name = list('tair(°C)', 'tsoil(°C)'),
line_type = c('longdash', 'solid'),
line_color = c('dodgerblue', 'tan4'),
x_lab = 'Date time', y_lab = 'T(°C)',
title_lab = 'Hourly temperature at Cuevas',
legend_lab = c('Tair', 'Tsoil'),
from = ISOdate(2020, 7, 1),
to = ISOdate(2020, 7, 5))
# let's add relative humidity on the right y-axis
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'tsoil', 'rh'),
col_name = list('tair(°C)', 'tsoil(°C)', 'rh(%)'),
line_type = c('longdash', 'solid', 'solid'),
line_color = c('dodgerblue', 'tan4', 'red'),
x_lab = 'Date time', y_lab = c('T(°C)', 'RH(%)'),
title_lab = 'Hourly meteo data at Cuevas',
legend_lab = c('Tair', 'Tsoil', 'RH'),
dual_yaxis = c('left', 'left', 'right'),
from = ISOdate(2020, 7, 1),
to = ISOdate(2020, 7, 5))
# we decide to analize the previous variables in detail
# with a dynamic plot
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'tsoil', 'rh'),
col_name = list('tair(°C)', 'tsoil(°C)', 'rh(%)'),
line_color = c('dodgerblue', 'tan4', 'red'),
x_lab = 'Date time', y_lab = c('T(°C)', 'RH(%)'),
title_lab = 'Hourly meteo data at Cuevas',
legend_lab = c('Tair', 'Tsoil', 'RH'),
dual_yaxis = c('left', 'left', 'right'),
interactive = TRUE)
# click on the Zoom icon and play a little...
# suppose now that we want to make a scatter plot to show
# the negative correlation between air temperature and
# relative humidity
hm_plot(obj = hm_cuevas, slot_name = c('tair', 'rh'),
col_name = list('tair(°C)', 'rh(%)'),
line_color = 'dodgerblue',
x_lab = 'Tair', y_lab = 'RH',
scatter = c('x', 'y') )
}
Run the code above in your browser using DataLab