#!/usr/bin/env python # Wenchang Yang (wenchang@princeton.edu) # Fri Jun 5 14:43:06 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 # if __name__ == '__main__': tt.check('end import') # #start from here ds = xr.open_dataset('HadISST.sstindex.187001-201912.nc') #monthly sst index dsa = ds.groupby('time.month') - ds.groupby('time.month').mean('time') #monthly anomaly #ssta Jun-Nov dsa.where((dsa.time.dt.month>=6)&(dsa.time.dt.month<=11)).groupby('time.year').mean('time').to_dataframe().to_csv('HadISST.sstaindex.JJASON.csv') #ssta Aug-Oct dsa.where((dsa.time.dt.month>=8)&(dsa.time.dt.month<=10)).groupby('time.year').mean('time').to_dataframe().to_csv('HadISST.sstaindex.ASO.csv') #ssta annual mean dsa.groupby('time.year').mean('time').to_dataframe().to_csv('HadISST.sstaindex.annual.csv') if __name__ == '__main__': #from wyconfig import * #my plot settings tt.check(f'**Done**')