|
| 1 | + |
| 2 | +R version 4.4.3 (2025-02-28) -- "Trophy Case" |
| 3 | +Copyright (C) 2025 The R Foundation for Statistical Computing |
| 4 | +Platform: x86_64-conda-linux-gnu |
| 5 | + |
| 6 | +R is free software and comes with ABSOLUTELY NO WARRANTY. |
| 7 | +You are welcome to redistribute it under certain conditions. |
| 8 | +Type 'license()' or 'licence()' for distribution details. |
| 9 | + |
| 10 | +R is a collaborative project with many contributors. |
| 11 | +Type 'contributors()' for more information and |
| 12 | +'citation()' on how to cite R or R packages in publications. |
| 13 | + |
| 14 | +Type 'demo()' for some demos, 'help()' for on-line help, or |
| 15 | +'help.start()' for an HTML browser interface to help. |
| 16 | +Type 'q()' to quit R. |
| 17 | + |
| 18 | +- Project '~/research/weather-data-collector-spain' loaded. [renv 1.1.4] |
| 19 | +- One or more packages recorded in the lockfile are not installed. |
| 20 | +- Use `renv::status()` for more details. |
| 21 | +> # get_historical_data.R |
| 22 | +> # ---------------------- |
| 23 | +> # Purpose: Download and update historical daily weather data for Spain from the AEMET OpenData API. |
| 24 | +> # |
| 25 | +> # This script fetches historical daily climatological data using the 7 core variables |
| 26 | +> # that are compatible across current observations, historical data, and forecast endpoints. |
| 27 | +> # |
| 28 | +> # Core Variables (Standardized): |
| 29 | +> # - ta: Air temperature (°C) - from tmed |
| 30 | +> # - tamax: Maximum temperature (°C) - from tmax |
| 31 | +> # - tamin: Minimum temperature (°C) - from tmin |
| 32 | +> # - hr: Relative humidity (%) - from hrMedia |
| 33 | +> # - prec: Precipitation (mm) - from prec |
| 34 | +> # - vv: Wind speed (km/h) - from velmedia |
| 35 | +> # - pres: Atmospheric pressure (hPa) - from presMax |
| 36 | +> # |
| 37 | +> # Concurrency Control: |
| 38 | +> # - Set PREVENT_CONCURRENT_RUNS = TRUE to enable lockfile-based run prevention |
| 39 | +> # - Set PREVENT_CONCURRENT_RUNS = FALSE (default) to allow multiple concurrent runs |
| 40 | +> # |
| 41 | +> # Main Steps: |
| 42 | +> # 1. Load dependencies and API key. |
| 43 | +> # 2. Determine which dates are missing from the local dataset. |
| 44 | +> # 3. Download missing data in chunks, handling API rate limits and errors. |
| 45 | +> # 4. Append new data to the historical dataset. |
| 46 | +> # |
| 47 | +> # Usage: |
| 48 | +> # - Requires a valid API key in 'auth/keys.R' as 'my_api_key'. |
| 49 | +> # - Run as an R script. Output is written to 'data/output/daily_station_historical.csv.gz'. |
| 50 | +> # |
| 51 | +> # Dependencies: tidyverse, lubridate, data.table, curl, jsonlite |
| 52 | +> # |
| 53 | +> # Author: John Palmer |
| 54 | +> # Date: 2025-08-22 (Updated for 7-variable standardization) |
| 55 | +> |
| 56 | +> # Title #### |
| 57 | +> # For downloading and preparing historical weather data. |
| 58 | +> |
| 59 | +> rm(list=ls()) |
| 60 | +> |
| 61 | +> ####Dependencies#### |
| 62 | +> library(tidyverse) |
| 63 | +Error in library(tidyverse) : there is no package called ‘tidyverse’ |
| 64 | +Execution halted |
0 commit comments