<jupyter_start><jupyter_text>Comparing Two Climate ModelsIn this notebook, I will be comparing two climate reanalysis models:* NCEP-DOE Reanalysis 2: Surface* ERA5I will be looking at the following variables:* Surface Pressure* Mean Sea Level Pressure* Total Column WaterThe idea is simple: these two models should have very similar properties. I will be trying to user RBIG in order to assess how similar these models are. I'll be looking at the following IT measures* Entropy* Total Correlation* Mutual InformationIf these climate models are that similar, then they should exhibit similar IT measures.  Data - Climate Models<jupyter_code>import os, sys
cwd = os.getcwd()
source_path = f"{cwd}/../../../"
sys.path.insert(0, f'{source_path}')

import numpy as np


# Data Loaders
from src.data.climate.amip import DataDownloader
from src.data.climate.amip import DataLoader
from src.features.climate.build_features import get_time_overlap

# ESDC tools
sys.path.insert(0, f'/home/emmanuel/code/py_esdc')
from esdc.standardize import normalize_temporal
from esdc.transform import regrid_data
from esdc.utils import check_time_coords

import pandas as pd
import xarray as xr
from tqdm import tqdm
from sklearn import preprocessing

import seaborn as sns
import matplotlib.pyplot as plt
plt.style.use('ggplot')
%matplotlib inline

%load_ext autoreload
%autoreload 2
amip_data_path = f"/home/emmanuel/projects/2020_rbig_rs/data/climate/raw/amip/"
era5_path = f"/home/emmanuel/projects/2020_rbig_rs/data/climate/raw/era5/"
ncep_path = f"/home/emmanuel/projects/2020_rbig_rs/data/climate/raw/ncep/"
results_path = f"/home/emmanuel/projects/2020_rbig_rs/data/climate/results/"
fig_path = f"/home/emmanuel/projects/2020_rbig_rs/reports/figures/climate/"<jupyter_output><empty_output><jupyter_text>Dataset - CMIP5<jupyter_code>loader = DataLoader()

dataset = 'ipsl_cm5b_lr'

cmip5_data = loader.load_amip_data(dataset)

cmip5_data<jupyter_output><empty_output><jupyter_text>ERA5<jupyter_code>era5_data = xr.open_mfdataset(f"{era5_path}*.nc", combine="by_coords")
era5_data = era5_data.rename({'msl': 'mslp', 'latitude': 'lat', 'longitude': 'lon'})
# era5_data = era5_data.rename({'latitude': 'lat'})
# era5_data.attrs['model_id'] = 'era5'
# rescale model from 0.25 to 2.5 degrees
# era5_data = era5_data.coarsen(lat=10, lon=10, boundary='pad').mean()
era5_data.attrs['model_id'] = 'era5'
era5_data = era5_data.rename({'mslp': 'psl'})
era5_data<jupyter_output><empty_output><jupyter_text>Time Coords Overlap<jupyter_code>era5_data, cmip5_data = get_time_overlap(era5_data, cmip5_data)
era5_data
cmip5_data<jupyter_output><empty_output><jupyter_text>NCEP<jupyter_code>ncep_data = xr.open_mfdataset(f"{ncep_path}*mon.mean.nc", combine="by_coords")
ncep_data = ncep_data.rename({'mslp': 'psl'})
ncep_data.attrs['model_id'] = 'ncar_ncep_doe_2'
ncep_data<jupyter_output><empty_output><jupyter_text>CMIP5<jupyter_code>loader = DataLoader()

dataset = 'ipsl_cm5b_lr'

cmip5_data = loader.load_amip_data(dataset)

cmip5_data
ncep_data, cmip5_data = get_time_overlap(ncep_data, cmip5_data)
ncep_data
cmip5_data<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11274823830877642, 'fraction_numerical': 0.02242152466367713, 'mean_word_length': 7.069767441860465, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '51247', 'license': 'MIT', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1174, 'n_words': 239, 'path': 'notebooks/climate/amip/2_time_overlap.ipynb', 'repo_name': 'jejjohnson/2019_rbig_rs', 'size': '3122'}