#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Fri May 20 17:11:27 EDT 2022 if __name__ == '__main__': import sys from misc.timer import Timer tt = Timer('start ' + ' '.join(sys.argv)) import sys, os.path, os, glob, datetime import xarray as xr, numpy as np, pandas as pd, matplotlib.pyplot as plt #more imports # if __name__ == '__main__': tt.check('end import') # #start from here ifile = 'model_output/t_ref_FLOR_CTL1990_v201905_tigercpu_intelmpi_18_576PE_0101-0300_monthly.nc' da0 = xr.open_dataarray(ifile).load() ifile = 'model_output/t_ref_FLOR_CTL1990_v201905_2xCO2_m1p7pctSolar_tigercpu_intelmpi_18_576PE_0101-0263_monthly.nc' da = xr.open_dataarray(ifile).load() ifile = 'model_output/t_ref_FLOR_CTL1990_v201905_2xCO2_tigercpu_intelmpi_18_576PE_0101-0262_monthly.nc' da1 = xr.open_dataarray(ifile).load() daa = da.mean('time') - da0.mean('time') daa1 = da1.mean('time') - da0.mean('time') if __name__ == '__main__': from wyconfig import * #my plot settings from geoplots import mapplot import geoxarray fig, ax = plt.subplots() daa.plot(levels=21) mapplot() fig, ax = plt.subplots() da0.geo.fldmean().groupby('time.year').mean('time').plot(label='ctl global') da1.geo.fldmean().groupby('time.year').mean('time').plot(label='2xco2 global') da.geo.fldmean().groupby('time.year').mean('time').plot(label='sg2xco2 global') da0.sel(lat=slice(-30,30)).geo.fldmean().groupby('time.year').mean('time').plot(label='ctl tropics') da1.sel(lat=slice(-30,30)).geo.fldmean().groupby('time.year').mean('time').plot(label='2xco2 tropics') da.sel(lat=slice(-30,30)).geo.fldmean().groupby('time.year').mean('time').plot(label='sg2xco2 tropics') ax.legend() fig, ax = plt.subplots() da0.mean('time').mean('lon').plot(label='ctl') da1.mean('time').mean('lon').plot(label='2xc02') da.mean('time').mean('lon').plot(label='sg2xc02') ax.legend() #savefig if len(sys.argv)>1 and 'savefig' in sys.argv[1:]: figname = __file__.replace('.py', f'.png') if 'overwritefig' in sys.argv[1:]: wysavefig(figname, overwritefig=True) else: wysavefig(figname) tt.check(f'**Done**') print() if 'notshowfig' in sys.argv: pass else: plt.show()