#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Wed Sep 18 23:01:01 EDT 2019 #import os.path, sys, os import matplotlib.pyplot as plt import xarray as xr, numpy as np, pandas as pd figname = 'fig.lines.png' figsize = None#(8,4) savefig = True ylabel = 'mm/day' title = 'Mozambique annual max/percentiles of spatial-mean daily precip' plt.figure(figsize=figsize) # ctl label = 'CHIRPS' ifile = 'data/chirps.p05.Mozambique.masked.fldmean.nc' da = xr.open_dataarray(ifile) #ts = da.groupby('time.year').min('time') #ts.plot(label=label+'-min') ts = da.groupby('time.year').max('time') ts.plot(label=label+'-max') ts = da.groupby('time.year').quantile(0.99, dim='time') ts.plot(label=label+'-99') #ts = da.groupby('time.year').mean('time') #ts.plot(label=label+'-mean') plt.legend() if title is not None: plt.title(title) if ylabel is not None: plt.ylabel(ylabel) plt.tight_layout() if savefig: plt.savefig(figname, dpi=128)