In [25]:
%matplotlib inline
%pylab inline
import numpy as np
import pandas as pd
import xarray as xr
import seaborn as sns
import os
import matplotlib.pyplot as plt
import xarray.plot as xplot
pylab.rcParams['figure.figsize'] = (20, 12)
In [19]:
chlor_a_dir = "chlor_a"
In [20]:
sst_dir = "sst"
In [144]:
#%timeit
chlor_a = xr.open_mfdataset(os.path.join(chlor_a_dir, "*.nc"))
sst = xr.open_dataset(os.path.join(sst_dir, "20100101120000-ESACCI-L4_GHRSST-SSTdepth-OSTIA-GLOB_LT-v02.0-fv01.1.nc") ,mask_and_scale=False, decode_cf=False)
#sst = xr.open_mfdataset(os.path.join(sst_dir, "*.nc") ,mask_and_scale=False, decode_cf=False)
soil = xr.open_dataset("SoilMoisture.ESACCI-L3S.2004.v2_1.nc")
In [8]:
chlor_a_var = chlor_a['chlor_a']
chlor_a_subset = chlor_a_var.sel(lat=slice(60,30),lon=slice(0,30))
In [9]:
chlor_a_subset
Out[9]:
In [10]:
def mycorr(x,y,dim=None):
return (((x-x.mean(dim=dim))*(y-y.mean(dim=dim))).sum(dim=dim)/x[dim].size)/(x.std(dim=dim)*y.std(dim=dim))
In [13]:
cov_chlra = mycorr(chlor_a_subset, chlor_a_subset, dim='time')
In [14]:
cov_chlra.plot()
Out[14]:
In [16]:
cov_chlra.min()
Out[16]:
In [17]:
cov_chlra.max()
Out[17]:
In [145]:
sst_var = sst['analysed_sst']
In [159]:
sst_var.isel(time=0,lat=0,lon=-180)
Out[159]:
In [158]:
sst_var[0].values
Out[158]:
In [160]:
sst_real = (((sst_var.isel(time=0) + 32768) / 65536) * 4800 ) - 300
In [161]:
sst_real.max()
Out[161]:
In [163]:
sst_subset = sst_var.isel(time=0, lat=slice(1800,2100), lon=slice(0,300))
sst_subset_real = (sst_subset * 0.01) + 273
xplot.imshow((sst_real * 0.01) + 273)
Out[163]: