Package 'azmetr'

Title: Access Arizona Weather Data from the AZMet API
Description: Provides R functions to access the Arizona Meteorological Network (AZMet) API. Functions are more than just "thin wrappers" and do some parsing of input parameters and wrangling of output data.
Authors: Jeremy Weiss [aut, cre, cph] , Eric Scott [aut]
Maintainer: Jeremy Weiss <[email protected]>
License: MIT + file LICENSE
Version: 0.4.0
Built: 2024-09-21 04:53:45 UTC
Source: https://github.com/cct-datascience/azmetr

Help Index


Retrieve 15-minute Weather Data from AZMet

Description

Retrieves 15-minute data from the AZMet (Arizona Meteorological Network) API. For a list of weather stations and their locations see station_info, or visit https://azmet.arizona.edu/about.

Usage

az_15min(station_id = NULL, start_date_time = NULL, end_date_time = NULL)

Arguments

station_id

Station ID can be supplied as numeric vector (e.g. station_id = c(8, 37)) or as character vector with the prefix "az" and two digits (e.g. station_id = c("az08", "az37")). If left blank, data for all stations will be returned.

start_date_time

A length-1 vector of class POSIXct or character in YYYY-MM-DD HH:MM:SS format, in AZ time. If only a date (YYYY-MM-DD) is supplied, data will be requested starting at 00:00:01 of that day.

end_date_time

A length-1 vector of class POSIXct or character in YYYY-MM-DD HH:MM:SS format, in AZ time. If only a date (YYYY-MM-DD) is supplied, data will be requested through the end of that day (23:59:59). Defaults to the current date and time if left blank and start_date_time is specified.

Details

If neither start_date_time nor end_date_time are supplied, the most recent datetime of data will be returned. If only start_date_time is supplied, then end_date_time defaults to the current time. Supplying only end_date_time will result in an error.

Value

A tibble. For units and other metadata, see https://azmet.arizona.edu/about

Note

If station_id is supplied as a vector, multiple successive calls to the API will be made. You may find better performance getting data for all the stations by leaving station_id blank and subsetting the resulting dataframe. Only the most recent 48 hours of 15-minute data are stored in the AZMet API.

Source

https://azmet.arizona.edu/

See Also

az_daily(), az_heat(), az_hourly(), az_lw15min(), az_lwdaily()

Examples

## Not run: 
# Most recent 15-minute data for all stations:
az_15min()

# Specify stations:
az_15min(station_id = c(1, 2))
az_15min(station_id = c("az01", "az02"))

# Specify dates:
az_15min(start_date_time = "2022-09-25 01:00:00")
az_15min(start_date_time = "2022-09-25 01:00:00", end_date_time = "2022-09-25 07:00:00")

## End(Not run)

Assign units using the units package

Description

Assigns correct units to the output of az_hourly(), az_daily(), and az_heat() using the units package.

Usage

az_add_units(x)

Arguments

x

A tibble output by az_hourly(), az_daily(), or az_heat()

Value

A tibble with columns of class "units"

Examples

## Not run: 
daily <- az_daily()

daily_units <-
  az_add_units(daily)

#unit conversions with `units::set_units()`
daily_units$sol_rad_total %>% units::set_units("kW h m-2")

#units carry through calculations
climatic_balance <-
  daily_units$precip_total_mm - daily_units$eto_pen_mon
climatic_balance

## End(Not run)

Retrieve Daily Weather Data from AZMET

Description

Retrieves daily data from the Arizona Meteorological Network API. For a list of weather stations and their locations see station_info, or visit https://azmet.arizona.edu/about.

Usage

az_daily(station_id = NULL, start_date = NULL, end_date = NULL)

Arguments

station_id

station ID can be supplied as numeric vector (e.g. station_id = c(8, 37)) or as character vector with the prefix "az" and two digits (e.g. station_id = c("az08", "az37")). If left blank, data for all stations will be returned.

start_date

A length-1 vector of class Date, POSIXct, or character in YYYY-MM-DD format. Will be rounded down to the nearest day if more precision is supplied. Defaults to the day before the current date (i.e., the most recent complete day) if left blank.

end_date

A length-1 vector of class Date, POSIXct, or character in YYYY-MM-DD format. Will be rounded down to the nearest day if more precision is supplied. Defaults to the day before the current date (i.e., the most recent complete day) if left blank.

Details

If neither start_date nor end_date are supplied, the most recent day of data will be returned. If only start_date is supplied, then the end date defaults to the day before the current date (i.e., the most recent complete day). Supplying only end_date will result in an error.

Value

A tibble. For units and other metadata, see https://azmet.arizona.edu/about

Note

If station_id is supplied as a vector, multiple successive calls to the API will be made. You may find better performance getting data for all the stations by leaving station_id blank and subsetting the resulting dataframe. Requests for data from all stations for more than 6-12 months may take considerable time.

Source

https://azmet.arizona.edu/

See Also

az_15min(), az_heat(), az_hourly(), az_lw15min(), az_lwdaily()

Examples

## Not run: 
# Most recent data for all stations:
az_daily()

# Specify stations:
az_daily(station_id = c(1, 2))
az_daily(station_id = c("az01", "az02"))

# Specify dates:
az_daily(start_date = "2022-09-25")
az_daily(start_date = "2022-09-25", end_date = "2022-09-26")

## End(Not run)

Retrieve Accumulated Heat Units and Evapotranspiration

Description

Retrieves accumulated heat units and reference evapotranspiration units from the Arizona Meteorological Network API. By default, returned values are cumulative since January 1 of the current year. For a list of weather stations and their locations see station_info, or visit https://azmet.arizona.edu/about.

Usage

az_heat(station_id = NULL, start_date = NULL, end_date = NULL)

Arguments

station_id

station ID can be supplied as numeric vector (e.g. station_id = c(8, 37)) or as character vector with the prefix "az" and 2 digits (e.g. station_id = c("az08", "az37")) If left blank data for all stations will be returned

start_date

A length-1 vector of class Date, POSIXct, or character in YYYY-MM-DD format. Will be rounded down to the nearest day if more precision is supplied.

end_date

A length-1 vector of class Date, POSIXct, or character in YYYY-MM-DD format. Will be rounded down to the nearest day if more precision is supplied. Defaults to the current date if left blank. If only an end_date is supplied, then data will be cumulative from the start of the year of end_date.

Details

Unlike az_daily(), only one row of data per station is returned, regardless of start_date and end_date. However, the data returned is cumulative over the time period specified by start_date and end_date.

Value

A tibble. For units and other metadata, see https://azmet.arizona.edu/about

Note

If station_id is supplied as a vector, multiple successive calls to the API will be made. You may find better performance getting data for all the stations by leaving station_id blank and subsetting the resulting dataframe.

Source

https://azmet.arizona.edu/

See Also

az_15min(), az_daily(), az_hourly(), az_lw15min(), az_lwdaily()

Examples

## Not run: 
# Most recent data for all stations:
az_heat()

# Specify stations:
az_heat(station_id = c(1, 2))
az_heat(station_id = c("az01", "az02"))

# Specify dates:
## Cumulative since October 2022
az_heat(start_date = "2022-10-01")

## Cumulative from the first of the year through March
yr <- format(Sys.Date(), "%Y")

az_heat(end_date = paste(yr, "03", "31", sep = "-"))

## End(Not run)

Retrieve Hourly Weather Data

Description

Retrieves hourly weather data from the Arizona Meteorological Network API. For a list of weather stations and their locations see station_info, or visit https://azmet.arizona.edu/about.

Usage

az_hourly(station_id = NULL, start_date_time = NULL, end_date_time = NULL)

Arguments

station_id

station ID can be supplied as numeric vector (e.g. station_id = c(8, 37)) or as character vector with the prefix "az" and 2 digits (e.g. station_id = c("az08", "az37")) If left blank, data for all stations will be returned

start_date_time

A length-1 vector of class POSIXct or character in YYYY-MM-DD HH format, in AZ time. Will be rounded down to the nearest hour if more precision is supplied. If only a date (YYYY-MM-DD) is supplied, data will be requested starting at 01:00:00 of that day

end_date_time

A length-1 vector of class POSIXct or character in YYYY-MM-DD HH format, in AZ time. Will be rounded down to the nearest hour if more precision is supplied. If only a date (YYYY-MM-DD) is supplied, data will be requested through the end of that day (23:59:59). Defaults to the current date and time if left blank and start_date_time is specified.

Details

If neither start_date_time nor end_date_time are supplied, the most recent hour of data will be returned. If only start_date_time is supplied, then end_date_time defaults to the current time. Supplying only end_date_time will result in an error.

Value

A tibble. For units and other metadata, see https://azmet.arizona.edu/about

Note

If station_id is supplied as a vector, multiple successive calls to the API will be made. You may find better performance getting data for all the stations by leaving station_id blank and subsetting the resulting dataframe. Requests for data from all stations for more than 10-15 days may take considerable time.

Source

https://azmet.arizona.edu/

See Also

az_15min(), az_daily(), az_heat(), az_lw15min(), az_lwdaily()

Examples

## Not run: 
# Most recent data for all stations:
az_hourly()

# Specify stations:
az_hourly(station_id = c(1, 2))
az_hourly(station_id = c("az01", "az02"))

# Specify dates:
az_hourly(start_date_time = "2022-09-25 01")
az_hourly(start_date_time = "2022-09-25 01", end_date = "2022-09-25 20")

## End(Not run)

Retrieve 15-minute Leaf Wetness Data from AZMet

Description

Retrieves 15-minute leaf-wetness data from the AZMet (Arizona Meteorological Network) API. Currently, these data only are available from weather stations in the Yuma area. For a list of stations and their locations see station_info, or visit https://azmet.arizona.edu/about.

Usage

az_lw15min(station_id = NULL, start_date_time = NULL, end_date_time = NULL)

Arguments

station_id

Station ID can be supplied as numeric vector (e.g. station_id = c(8, 37)) or as character vector with the prefix "az" and two digits (e.g. station_id = c("az08", "az37")). If left blank, data for all stations will be returned.

start_date_time

A length-1 vector of class POSIXct or character in YYYY-MM-DD HH:MM:SS format, in AZ time. If only a date (YYYY-MM-DD) is supplied, data will be requested starting at 00:00:01 of that day.

end_date_time

A length-1 vector of class POSIXct or character in YYYY-MM-DD HH:MM:SS format, in AZ time. If only a date (YYYY-MM-DD) is supplied, data will be requested through the end of that day (23:59:59). Defaults to the current date and time if left blank and start_date_time is specified.

Details

If neither start_date_time nor end_date_time are supplied, the most recent datetime of data will be returned. If only start_date_time is supplied, then end_date_time defaults to the current time. Supplying only end_date_time will result in an error.

Value

A tibble. For units and other metadata, see https://azmet.arizona.edu/about

Note

If station_id is supplied as a vector, multiple successive calls to the API will be made. You may find better performance getting data for all the stations by leaving station_id blank and subsetting the resulting dataframe. Only the most recent 48 hours of 15-minute data are stored in the AZMet API.

Source

https://azmet.arizona.edu/

See Also

az_15min(), az_daily(), az_heat(), az_hourly(), az_lwdaily()

Examples

## Not run: 
# Most recent 15-minute leaf-wetness data for all stations:
az_lw15min()

# Specify stations:
az_lw15min(station_id = c(1, 2))
az_lw15min(station_id = c("az01", "az02"))

# Specify dates:
az_lw15min(start_date_time = "2022-09-25 01:00:00")
az_lw15min(start_date_time = "2022-09-25 01:00:00", end_date_time = "2022-09-25 07:00:00")

## End(Not run)

Retrieve Daily Leaf Wetness Data from AZMet

Description

Retrieves daily leaf wetness data from the Arizona Meteorological Network API. Currently, these data only are available from weather stations in the Yuma area. For a list of stations and their locations see station_info, or visit https://azmet.arizona.edu/about.

Usage

az_lwdaily(station_id = NULL, start_date = NULL, end_date = NULL)

Arguments

station_id

station ID can be supplied as numeric vector (e.g. station_id = c(8, 37)) or as character vector with the prefix "az" and two digits (e.g. station_id = c("az08", "az37")). If left blank, data for all stations will be returned.

start_date

A length-1 vector of class Date, POSIXct, or character in YYYY-MM-DD format. Will be rounded down to the nearest day if more precision is supplied. Defaults to the day before the current date (i.e., the most recent complete day) if left blank.

end_date

A length-1 vector of class Date, POSIXct, or character in YYYY-MM-DD format. Will be rounded down to the nearest day if more precision is supplied. Defaults to the day before the current date (i.e., the most recent complete day) if left blank.

Details

If neither start_date nor end_date are supplied, the most recent day of data will be returned. If only start_date is supplied, then the end date defaults to the day before the current date (i.e., the most recent complete day). Supplying only end_date will result in an error.

Value

A tibble. For units and other metadata, see https://azmet.arizona.edu/about

Note

If station_id is supplied as a vector, multiple successive calls to the API will be made. You may find better performance getting data for all the stations by leaving station_id blank and subsetting the resulting dataframe. Requests for data from all stations for more than 6-12 months may take considerable time.

Source

https://azmet.arizona.edu/

See Also

az_15min(), az_daily(), az_heat(), az_hourly(), az_lw15min()

Examples

## Not run: 
# Most recent data for all stations:
az_lwdaily()

# Specify stations:
az_lwdaily(station_id = c(1, 2))
az_lwdaily(station_id = c("az01", "az02"))

# Specify dates:
az_lwdaily(start_date = "2022-09-25")
az_lwdaily(start_date = "2022-09-25", end_date = "2022-09-26")

## End(Not run)

AZMet station names and locations

Description

Station names, station IDs, and location (lat, lon, elevation) of active AZMet weather stations

Usage

station_info

Format

A tibble with 30 rows and 5 columns:

meta_station_name

Station name

meta_station_id

Station ID

latitude, logitude

Station location

elev_m

Station elevation in meters