#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Fri Aug 21 16:16:33 EDT 2020 if __name__ == '__main__': from misc.timer import Timer tt = Timer(f'start {__file__}') import sys, os.path, os, glob import xarray as xr, numpy as np, pandas as pd #import matplotlib.pyplot as plt #more imports import seaborn as sns import statsmodels.formula.api as smf # if __name__ == '__main__': tt.check('end import') # #start from here ifile = 'q2m.validate.2019.nc' year = ifile.split('.')[-2] ds = xr.open_dataset(ifile) df = ds.to_dataframe() * 1000 # units from kg/kg to g/kg if __name__ == '__main__': from wyconfig import * #my plot settings figname = __file__.replace('.py', f'_{tt.today()}.png') plt.close() xlim = (-2, 2) ylim = xlim g = sns.jointplot(x='anom', y='anom_true', data=df, kind='hex', xlim=xlim, ylim=ylim) ax = g.ax_joint ax.grid('on') ax.plot(xlim, ylim, color='lightgray') ax.set_xlabel(f'ERA5 {year} q2m anom [g/kg]: constant RH') ax.set_ylabel(f'ERA5 {year} q2m anom [g/kg]: true') plt.savefig(figname) print('[saved]:', figname) tt.check(f'**Done**') plt.show()