"
],
"text/plain": [
""
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import xarray\n",
"from tqdm.auto import tqdm\n",
"import climtas.nci\n",
"\n",
"climtas.nci.GadiClient()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can use a loop to load each member individually, storing the members' data in the array `dss`. `tqdm()` here just adds a progress bar, so we can see where the load has gotten to.\n",
"\n",
"One of the files in this dataset has latitude values slightly different to the others, from inspection of the file they're just stored at a higher precision. I've used `join='override'` to take the _lat_ and _lon_ coordinate values from the first file."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3c15d0d3a2854528b99c3fa8e2ed2c2f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/80 [00:00, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"dss = []\n",
"for mem in tqdm(range(1,81)):\n",
"\n",
" path = f'/g/data/ua8/C20C/v3/member_monthly/TMPS/*/TMPS.*.mnmean_mem{mem:03d}.nc'\n",
" ds = xarray.open_mfdataset(\n",
" path,\n",
" combine='nested',\n",
" concat_dim='time',\n",
" join='override',\n",
" coords='minimal',\n",
" parallel=True,\n",
" )\n",
" dss.append(ds)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With all the files read, we can combine them along a new 'member' dimension with `xarray.concat`."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"ds = xarray.concat(dss, dim='member')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A quick check of the input chunking - this is smaller than we'd like at only 6 MB, however that is a limitation of the input data - this is monthly data with one year per file, so only 12 timesteps in each file."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"