In [1]:
import glob
import iris
import iris.coord_categorisation
from iris.experimental.equalise_cubes import equalise_attributes
#import warnings
#warnings.filterwarnings('ignore')
import xarray as xr
In [3]:
model = 'NorESM1-M'
thetao_files = '/g/data/ua6/DRSv2/CMIP5/%s/piControl/mon/ocean/r1i1p1/thetao/latest/thetao_Omon_%s_piControl_r1i1p1_*.nc' %(model, model)
thetao_file_list = glob.glob(thetao_files)
The documentation for using dask on a single machine can be found here.
(In running this notebook I only execute one of the next three cells, depending on which approach I want to use.)
In [2]:
#from dask.distributed import Client, progress, LocalCluster
#client = LocalCluster()
#client
from dask.distributed import Client
client = Client()
client
Out[2]:
In [2]:
import dask
import dask.multiprocessing
dask.set_options(get=dask.multiprocessing.get)
In [1]:
import dask
import dask.threaded
dask.set_options(get=dask.threaded.get)
In [3]:
ds = xr.open_mfdataset(thetao_files)
thetao = ds['thetao']
In [5]:
thetao
Out[5]:
In [6]:
# the number of GB involved in the reduction
ds.thetao.nbytes/1e9
Out[6]:
In [4]:
test = thetao.groupby('time.year').mean('time').load()
test
In [6]:
cube = iris.load(thetao_file_list, 'sea_water_potential_temperature')
equalise_attributes(cube)
cube = cube.concatenate_cube()
iris.coord_categorisation.add_year(cube, 'time')
In [ ]:
cube = cube.aggregated_by(['year'], iris.analysis.MEAN)
In [ ]: