This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import marimo | |
| __generated_with = "0.16.5" | |
| app = marimo.App(width="medium") | |
| @app.cell | |
| def _(mo): | |
| mo.md( | |
| r""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| # ERA5 | |
| e5 = read_csv('reanalysis-era5-single-levels-timeseries-sfc9vc2xo5f.csv') |> | |
| mutate( | |
| t2m = t2m - 273.15 | |
| ) |> | |
| group_by( | |
| valid_time = floor_date(valid_time, unit = "days") | |
| ) |> | |
| summarise( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% [markdown] | |
| # https://planetarycomputer.microsoft.com/dataset/cil-gdpcir-cc-by#overview | |
| # %% | |
| # required to locate and authenticate with the stac collection | |
| import planetary_computer | |
| import pystac_client | |
| # required to load a zarr array using xarray | |
| import xarray as xr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% | |
| import xarray as xr | |
| import numpy as np | |
| import geopandas as gpd | |
| import regionmask | |
| # %% | |
| gd = xr.open_dataset("C:/Users/matte/data/tasmax_day_ACCESS-CM2_historical_r1i1p1f1_gn_1999.nc") | |
| # gd.coords['lon'] = (gd.coords['lon'] + 180) % 360 - 180 | |
| # gd = gd.sortby(gd.lon) | |
| # %% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(countrycode) | |
| library(scico) | |
| library(patchwork) | |
| library(ggtext) | |
| mapdata <- map_data("world") |> | |
| mutate(iso3_code = countrycode(region, "country.name", "iso3c")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% | |
| import xarray as xr | |
| import pandas as pd | |
| # %% | |
| df = ( | |
| xr.open_mfdataset("C:/Users/matte/data/CPC/preci*") | |
| .resample(time = "MS").sum() | |
| .load() | |
| ) | |
| # %% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(lubridate) | |
| library(tidyverse) | |
| library(zoo) | |
| read_station <- function(filename) { | |
| read_csv(filename, | |
| col_types = cols(DATE = col_datetime(format = "%Y%m%d")), | |
| skip = 20 | |
| ) | |
| } | |
| station_files <- c( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| color_palette = c( | |
| 'Biomass' = '#7daf4bff', | |
| 'Coal' = '#af4b91b2', | |
| 'Gas' = '#d7642dff', | |
| 'Hydro-power' = '#00a0e1ff', | |
| 'Nuclear' = '#466eb4ff', | |
| 'Oil' = '#af4b91ff', | |
| 'Other' = '#b9c33799', | |
| 'Solar' = '#e6a532ff', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Before you start install all the referenced packages below | |
| # including the development release of ecmwfr you will also | |
| # need the rnaturalearthdata in addition to the normal package | |
| # To run the code copy and paste segments as this is still | |
| # rough around the edges and requires user interaction to | |
| # set your CDS API key. | |
| # load libraries | |
| if(!require(devtools)){install.packages("devtools")} | |
| devtools::install_github("khufkens/ecmwfr") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| df <- read_csv("ItalianCovidData/Daily Covis19 Italian Data Cumulative") %>% | |
| select(1:5) %>% | |
| gather(type, value, -Date, -Region) %>% | |
| group_by(Date, Region) | |
| total <- df %>% | |
| dplyr::filter(Date == max(df$Date)) %>% | |
| group_by( |
NewerOlder