def regr_map_standard(run, index): assert run in ['ctrl', 'rcp', 'lpd', 'lpi'] assert index in ['SOM', 'AMO', 'TPI'] SST_regr_standard(index) ds = xr.open_dataset(f'{path_results}/SST/{index}_regr_{run}.nc', decode_times=False) regr_map(ds=ds, index=index, run=run) return
def plot_yrly_regr_maps(self, run): assert run in ['ctrl', 'lpd', 'had'] tslices = [''] if run == 'ctrl': tslices.extend(['_100_248', '_151_299']) elif run == 'lpd': tslices.extend(['_268_416', '_417_565']) for j, tslice in enumerate(tslices): print(j) fn = f'{path_samoc}/SST/{self.index}_regr{tslice}_{run}.nc' ds = xr.open_dataset(fn) regr_map(ds=ds, index=self.index, run=run, fn=tslice)
def plot_regression_map(self, run=None): self.load_regression_files() if run is None: for run in ['ctrl', 'rcp', 'lpd', 'lpi', 'had']: regr_map(ds=self.all_regrs[run], index=self.index, run=run, fn=None) else: assert run in ['ctrl', 'rcp', 'lpd', 'lpi', 'had'] regr_map(ds=self.all_regrs[run], index=self.index, run=run, fn=None)
def regr_map_diff_times(run, index): assert run in ['lpd', 'lpi'] assert index in ['SOM', 'AMO', 'TPI'] if run == 'lpd': times = ['200_1', '200_2', '412'] SST_regr_lpd(index) elif run == 'lpi': times = ['800_1', '800_2', '1480'] SST_regr_lpi(index) for i in range(3): ds = xr.open_dataset( f'{path_results}/SST/{index}_regr_{run}_{times[i]}.nc', decode_times=False) regr_map(ds=ds, index=index, run=run, fn=times[i]) return
assert os.path.exists(fn) ds = xr.open_dataset(fn, decode_times=False) except: print( f'{idx} file for segment {tslice[0]}-{tslice[1]} does not exist.' ) continue # visualization print('plotting') fn_map = f'{path_results}/SST/{idx}_regr_map_{run}_{tslice[0]}_{tslice[1]}' try: assert os.path.exists(fn_map) except: regr_map(ds=ds, index=idx, run=run, fn=fn_map) # compare to observations print('calculating spatial correlations') segment = ds.slope if run == 'ctrl': segment.coords['TLAT'] = TLAT da.values[k] = AF().spatial_correlation(field_A=had, field_B=segment, selection=region) da.to_netcdf(fn_new) # spatial correlation plot plt.figure()