Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active March 31, 2022 15:15
Show Gist options
  • Save juanchiem/d31e547d37796f57742c8907851de23b to your computer and use it in GitHub Desktop.
Save juanchiem/d31e547d37796f57742c8907851de23b to your computer and use it in GitHub Desktop.
# Single station (Balcarce) - multiple seasons
years <- 2020:2021
seasons <- paste0(years, "-06-30")
station <- c(121.255669, 14.16742)
seasons_wth <-
map(
.x = seasons,
.f = get_wth,
lonlat = c(-37.75, -58.3),
duration = 120
)
bind_rows(seasons_wth)
# Multiple stations - Single season
stations <- tribble(
~station, ~lon, ~lat,
"Balcarce INTA", -37.75, -58.3,
"Mar del Plata AERO", -37.93, -57.58,
"Azul AERO", -36.83, -59.88,
"Benito Juarez AERO", -37.72, -59.78,
"Laprida", -37.57, -60.77,
"Barrow INTA", -38.32, -60.25,
"TANDIL AERO", -37.23, -59.25
) %>% column_to_rownames("station")
stations.list <- as.list(as.data.frame(t(stations)))
stations.list
locations_wth <-
map(
.x = stations.list,
.f = get_wth,
dates = "2021-06-30",
duration = 120
)
bind_rows(locations_wth, .id = "station")
library(tidyverse)
library(epicrop) #only tmean, prec and Rhum
# Single station (Balcarce) - multiple seasons with epicrop
years <- 2020:2021
seasons <- paste0(years, "-06-30")
station <- c(121.255669, 14.16742)
seasons_wth <-
map(
.x = seasons,
.f = get_wth,
lonlat = c(-37.75, -58.3),
duration = 120
)
bind_rows(seasons_wth)
# Multiple stations - Single season with epicrop
stations <- tribble(
~station, ~lon, ~lat,
"Balcarce INTA", -37.75, -58.3,
"Mar del Plata AERO", -37.93, -57.58,
"Azul AERO", -36.83, -59.88,
"Benito Juarez AERO", -37.72, -59.78,
"Laprida", -37.57, -60.77,
"Barrow INTA", -38.32, -60.25,
"TANDIL AERO", -37.23, -59.25
) %>% column_to_rownames("station")
stations.list <- as.list(as.data.frame(t(stations)))
stations.list
locations_wth <-
map(
.x = stations.list,
.f = get_wth,
dates = "2021-06-30",
duration = 120
)
bind_rows(locations_wth, .id = "station")
library(nasapower)
# single station - single season
get_power(
community = "AG",
lonlat = as.vector(unlist(stations[7,])),
pars = c("ALLSKY_SFC_SW_DWN", "RH2M", "T2M", "PRECTOTCORR"),
dates = c(as.Date(seasons[1]), as.Date(seasons[1])+120),
temporal_api = "DAILY"
)
power_stations <- map(
.x = stations.list,
.f = ~get_power(
lonlat = .x,
pars = c("ALLSKY_SFC_SW_DWN", "RH2M", "T2M", "PRECTOTCORR", "TMIN"),
community = "AG",
dates = c(as.Date(seasons[1]), as.Date(seasons[1])+10),
temporal_api = "DAILY")
)
power_stations
bind_rows(power_stations, .id = "station")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment