Downloads raw daily data for a given SMN station, filters it by a date window,
attaches station coordinates, and returns a cleaned table in either full or
reduced format. This is the basic building block used by higher-level
functions (e.g., smn_dl_daily_batch or the hybrid workflow).
Arguments
- station
Character or numeric SMN station code (e.g.,
"15101").- start_date
Start date (inclusive).
Dateorcharacter. Default"1961-01-01".- end_date
End date (inclusive).
Dateorcharacter. DefaultSys.Date().- output_format
Output format:
"full"(default) or"reduced".full:
station, latitude, longitude, altitude, date, prec, evap, tmax, tminreduced:
date, prec, evap, tmax, tmin
- del_na
"no"(default) or"yes". If"yes", rows containingNAare dropped at the end.
Value
A data.frame with the columns defined by output_format, ordered by date.
If no rows fall within the requested window or the download fails, returns an
empty data frame with the appropriate columns for the chosen format.
Details
The function:
Downloads raw daily data via
smn_dl_daily_raw(best effort).Filters by
start_date <= date <= end_date.Ensures variables
prec, evap, tmax, tminexist (filling missing ones withNA).Attaches coordinates using
smn_int_extract_coordinates(falls back toNAon failure).
The goal is to deliver a stable, tidy-ready table for downstream analyses and for integration with auxiliary sources (e.g., NASA POWER) in hybrid workflows.
Examples
if (FALSE) { # \dontrun{
# Minimal example (short window) with 'full' output
df_full <- smn_dl_daily_single(
station = "15101",
start_date = "2020-01-01",
end_date = "2020-01-07",
output_format = "full",
del_na = "no"
)
head(df_full)
# Same interval but 'reduced' output
df_red <- smn_dl_daily_single(
station = "15101",
start_date = "2020-01-01",
end_date = "2020-01-07",
output_format = "reduced"
)
head(df_red)
} # }