I am following a particular Machine Learning exercise using jupyter notebooks. The link to the exercise is here. I have managed to install all the necessary packages such as netCDF4
, rioxarray
, xarray
and tensorflow
. However, I am having trouble reading the netCDF4 datasets using the open_mfdataset
function of xarray
. This is the error I get if I try to run the following code:
z500 = xr.open_mfdataset('geopotential_500*.nc', combine='by_coords').isel(time=slice(None, None, 12))
z500
The error:
...
ImportError: DLL load failed while importing defs: The specified procedure could not be found.
I also loaded other dependancies of xarray
as explained here. However, I cannot proceed to the next step because of the above issue.
Here is my full code:
# Import packages
import xarray as xr
import numpy as np
# Load in the necessary python packages to train in the neural network
import tensorflow.keras as keras
import tensorflow as tf
# Unzip the data
import os
from zipfile import ZipFile
path = "C:/Users/gachuhi/gis800"
filepath = os.path.join(path, 'geopotential_500_5.625deg.zip')
with ZipFile(filepath, 'r') as zObject:
zObject.extractall(path=os.path.join(path, 'geopotential'))
z500 = xr.open_mfdataset('C:/Users/gachuhi/gis800/geopotential/geopotential_500*.nc', combine='by_coords').isel(time=slice(None, None, 12))
z500
The error ---------
C:\Users\gachuhi\anaconda3\envs\python-gis\lib\site-packages\xarray\backends\plugins.py:71: RuntimeWarning: Engine 'rasterio' loading failed:
DLL load failed while importing _version: The specified procedure could not be found.
warnings.warn(f"Engine {name!r} loading failed:\n{ex}", RuntimeWarning)
.....
--snip, too long--
.....
File h5py\h5.pyx:1, in init h5py.h5()
ImportError: DLL load failed while importing defs: The specified procedure could not be found.
I tried importing rasterio
, netCDF4
as import netCDF4
, but whatever attempt was used, it was impossible to open the dataset as intended. I think the end goal of xr.mf_dataset
is to combine the netCDF4 files into one file for further analysis but I have been unable to proceed any further with the exercise from this particular point. How do I solve this?
Full path to zip file is here