'Dataset does not exist
I have been trying to open 372 datasets (aerosol) using nctoolkit for a couple of days now. I have followed some suggestions given to some people who faced similar challenge but they are not helping matters. The whole reason why I want to open with nctoolkit is that I want to regrid one dataset (precipitation) so that I can plot spatial correlation of aerosols and precipitation. Below is my code.
import netCDF4
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from scipy.stats import pearsonr
import nctoolkit as nc
da = nc.open_data('/home/bernard/Desktop/FinalphdCodes/CorrelationData/precip.mon.mean.nc') # its running perfectly
ds = nc.open_data('/home/bernard/Desktop/FinalphdCodes/CorrelationData/MERRA2_*.nc4')# line which is not running
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
/tmp/ipykernel_10207/790498178.py in <module>
----> 1 ds = nc.open_data('/home/bernard/Desktop/FinalphdCodes/CorrelationData/MERRA2_*.nc4')
~/anaconda3/lib/python3.7/site-packages/nctoolkit/api.py in open_data(x, checks, **kwargs)
538
539 else:
--> 540 raise FileNotFoundError("Data set " + x + " does not exist!")
541
542 if checks:
FileNotFoundError: Data set /home/bernard/Desktop/FinalphdCodes/CorrelationData/MERRA2_*.nc4 does not exist!
Your help/assistance will be highly appreciated.
Solution 1:[1]
nctoolkit developer here. I've noticed the package does not currently handle wild cards properly for nc4 extensions. I will fix this shortly. For now, you should be able to solve the problem using glob:
import glob
ds = nc.open_data(glob.glob('/home/bernard/Desktop/FinalphdCodes/CorrelationData/MERRA2_*.nc4'))# line which is not running
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Robert Wilson |
