<jupyter_start><jupyter_text><jupyter_code># !apt-get update -qqq && apt-get dist-upgrade -qqq -y
# https://github.com/googlecolab/colabtools/issues/85#issuecomment-372532728
!apt-get install libproj-dev proj-data proj-bin -qqq -y
!apt-get install libgeos-dev -qqq -y
!pip install -q -U cython
!pip install -q -U cartopy
!pip install -q -U geopandas
!pip install -q -U geoplot
# https://gadm.org/about.html
!wget -q "https://biogeo.ucdavis.edu/data/gadm3.6/shp/gadm36_BRA_shp.zip"
!unzip -qq -u gadm36_BRA_shp.zip
import geopandas as gpd
import geoplot as gplt

br = gpd.read_file('gadm36_BRA_1.shp')
import pandas as pd

# pca_vals = pd.read_csv("https://raw.githubusercontent.com/vitorsr/ccd/master/data/pca_values_08-19.csv?token=<KEY>")

pca_vals = pd.read_csv("https://raw.githubusercontent.com/vitorsr/ccd/master/data/pc1_2019.csv?token=<KEY>")
pca_vals.head(1)
import numpy as np
(np.min(pca_vals["0"].to_numpy()[:]), np.max(pca_vals["0"].to_numpy()[:]))
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from matplotlib.cm import ScalarMappable
from matplotlib.colors import Normalize

lons = pca_vals["lon"].to_numpy()[:]
lats = pca_vals["lat"].to_numpy()[:]
data = pca_vals["0"].to_numpy()[:] # 0th princomp

fig_pc = plt.figure()

ax = plt.axes(projection=ccrs.Miller())

lb = -5; ub = 5; lv = 20 # lower bound, upper bound, levels

plt.tricontourf(lons, lats, data, np.linspace(lb, ub, lv),
                cmap="coolwarm", extend="both")

gplt.polyplot(br, edgecolor="dimgray", linewidth=0.5, zorder=1, ax=ax)

plt.colorbar(ScalarMappable(norm=Normalize(lb, ub), cmap="coolwarm"), ax=ax)

plt.show()

fig_pc.savefig("pca_princomp1_20190819.png", dpi=300)
metadata = pd.read_csv("https://onedrive.live.com/download?cid=BCBADB0836C97273&resid=BCBADB0836C97273%21115089&authkey=AN3WuZnSKh9jgC8")
temp_aug = pd.read_csv("https://raw.githubusercontent.com/vitorsr/ccd/master/data/baseline.csv?token=<KEY>")
temp_vals = pd.merge(metadata, temp_aug.groupby(by="id").mean(), on="id")
temp_vals.head(1)
temp_vals = temp_vals[temp_vals["tair"] == temp_vals["tair"]]
(np.min(temp_vals["tair"].to_numpy()[:]), np.max(temp_vals["tair"].to_numpy()[:]))
lons = temp_vals["lon"].to_numpy()[:]
lats = temp_vals["lat"].to_numpy()[:]
data = temp_vals["tair"].to_numpy()[:]

fig_tair = plt.figure()

ax = plt.axes(projection=ccrs.Miller())

lb = 13; ub = 31; lv = 20 # lower bound, upper bound, levels

plt.tricontourf(lons, lats, data, np.linspace(lb, ub, lv),
                cmap="coolwarm", extend="both")

gplt.polyplot(br, edgecolor="dimgray", linewidth=0.5, zorder=1, ax=ax)

plt.colorbar(ScalarMappable(norm=Normalize(lb, ub), cmap="coolwarm"), ax=ax)

plt.show()

fig_tair.savefig("tair_baseline.png", dpi=300)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1806615776081425, 'fraction_numerical': 0.034532897128316975, 'mean_word_length': 5.712195121951219, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '421461', 'license': 'MIT', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1168, 'n_words': 188, 'path': 'new_maps.ipynb', 'repo_name': 'vitorsr/ccd', 'size': '2823'}