if(!require(devtools)){
install.packages('devtools')
}
if(!require(worldmet)){
devtools::install_github('openair-project/worldmet')
}Downloading Meteorological Data
During the process of analyzing certain logger data streams we will need meteorological data such as barometric pressure, rainfall, air temperature, etc. This is particularly useful to converting pressure transducer readings to stream depth or for calculating the saturation point of dissolved gases such as oxygen.
Generally this is acquired one of two ways:
Through co-located in-stream and out-of-stream pressure transducers
Through measured barometric pressure from a nearby weather station
The general rule-of-thumb is that the barometric measurements should be measured within 10 miles of the stream logger.
Hickory Creek near the UNT Water Research Field Station is located near to the Denton Municipal Airport which has an associated weather station. This page outlines the process to access and download meteorological data from the Denton Municipal Airport using the worldmet package.
First make sure the worldmet package is installed from github. To do so we will also need to have devtools installed:
Make sure to load the package with library(worldmet).
The Denton airport is ID: USW00003991
To get the hourly meteorological data, we can use the import_ghcn_hourly() function. The function downloads the entire year data for the station.
Rows: 7776 Columns: 8
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): station_id, station_name
dbl (5): air_temp, atmos_pres, sea_pres, altimeter, precip
dttm (1): date
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
met_DMA = import_ghcn_hourly(station = "USW00003991",
year = 2025,
extra = TRUE)
# station: string, station_id
# year: numeric, year to download data
# extra: logical, should extra columns be included?Rows: 7,776
Columns: 8
$ station_id <chr> "USW00003991", "USW00003991", "USW00003991", "USW00003991…
$ station_name <chr> "DENTON MUNICPAL AP", "DENTON MUNICPAL AP", "DENTON MUNIC…
$ date <dttm> 2025-01-01 00:00:00, 2025-01-01 01:00:00, 2025-01-01 02:…
$ air_temp <dbl> 7.8, 3.9, 5.0, 3.3, 3.3, 3.9, 3.3, 2.2, 3.9, 1.7, 2.2, 0.…
$ atmos_pres <dbl> 997.5, 998.2, 998.5, 999.5, 1000.5, 1000.8, 1001.5, 1002.…
$ sea_pres <dbl> 1021.0, 1021.7, 1022.0, 1023.2, 1024.0, 1024.3, 1024.8, 1…
$ altimeter <dbl> 1021.0, 1021.7, 1022.0, 1023.0, 1024.0, 1024.4, 1025.1, 1…
$ precip <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
This has a lot of information, most of which is unnecessary for our needs. We can subset this data to:
only include the relevant date range, and
only include the relevant columns
To only download the current year (the function operates on data years currently), we just create a year variable to pass to the function with ‘current_year = format(Sys.Date(), “%Y”)’ = 2025. Then we subset the data columns to only include relevant information:
‘station_id’: The station ID of the met station
‘station_name’: The name of the met station
‘date’: The date-time of the readings
‘air_temp’: air temperature reading at the station in oC
‘atmos_pres’: barometric pressure in units of hPa
‘sea_press’: Estimated pressure at sea level directly below the station using actual atomosphere profile (hPa)
‘altimeter’: Pressure reduced to mean sea level using standard atmosphere profile (hPa)
‘precip’: Total liquid precipitation (rain or melted snow) for the hour in mm
met_DMA = met_DMA %>%
dplyr::select(station_id, station_name, date, air_temp, atmos_pres, sea_pres, altimeter, precip)We then save this as a csv file in the ‘/data’ folder.
write_csv(met_DMA, file = here::here("data/met_DMA.csv"),
quote = "none",
append = TRUE)After this original file is written the file is updated automatically every month through a github action: get-merge-met-data.yml. This action calls the script, get-merge-met-data.R to download new data and merge it into the met_DMA.csv file.
Therefore, this process does not have to be repeated for the Denton Municipal Airport unless we need to change the variables. If other stations are desired, repeat this initiation process for new stations and update get-merge-met-data.R to include new station data.
The last time the data was downloaded was 2025-12-08 00:00:00.