In [1]:
import ect

In [2]:
# Couldn't figure out quickly how to properly use ect io
# with my own folder, hence:
import xarray as xr
import os

def read_data(path):
    """
    Read in multiple netCDF files and combine them in an xarray dataset.

    :rtype: xr.Dataset
    :param path: Path to the folder
    :return: The resulting dataset
    """
    path = path + os.sep + '*.nc'
    print(path)
    dataset = xr.open_mfdataset(path, concat_dim='time')
    return dataset

In [3]:
xrdataset_clouds = read_data('/home/ccitbx/cci_data/cloud/2008')


/home/ccitbx/cci_data/cloud/2008/*.nc

In [4]:
xrdataset_aerosol = read_data('/home/ccitbx/cci_data/aerosol/2008_monthly')


/home/ccitbx/cci_data/aerosol/2008_monthly/*.nc

In [5]:
# Convert the xrdatasets to ECT CDM objects
ect_clouds = ect.core.cdm_xarray.XArrayDatasetAdapter(xrdataset_clouds)
ect_aerosol = ect.core.cdm_xarray.XArrayDatasetAdapter(xrdataset_aerosol)

In [9]:
# Filter the datasets to select the desired ECV variables
clouds_filter = tuple(['cc_total'])
aerosol_filter = tuple(['AOD550_mean'])

ect_clouds = ect_clouds.filter_dataset(clouds_filter)
ect_aerosol = ect_aerosol.filter_dataset(aerosol_filter)

In [ ]: