I am currently trying to utilize the meteocean-api in Python to download and use NORA3 data. This uses the nco package in the background to work with the files. I downloaded it, and all of its dependencies (including nco), simply using:
conda install -c conda-forge metocean-api
This caused a lot of headaches on my computer, including the need to reinclude the sqlite3 DLL back in the correct location, but eventually everything started to work again. Now I am trying to get a simple block of data to start analyzing, but I keep running into an error:
*** nco.nco.NCOException: (returncode:3221225781) b''
From what I understand from a lot of googling, this exact returncode might mean that I am missing DLL's? But again, I don't really know how to figure out which are missing, or if this is even the real issue.
Below you can see a reproduction of my code (deeply simplified and with numbers changed):
from metocean_api import ts
latitude = 50
longitude = 6
start_string = "2023-01-01 00:00:00+0000"
end_string = "2023-01-02 00:00:00+0000"
type = "wind_sub"
df_ts = ts.TimeSeries(lon=longitude, lat=latitude,
start_time=start_string, end_time=end_string,
product= f'NORA3_{type}')
df_ts.import_data(save_csv=True)
Note that I am using a Windows 11 machine and Python 3. I know neither of these packages were built for Windows use, but I want to try to make this work.
I dove deep into the problem and it is stemming from nco itself. The error occurs here:
nco.ncks(input=infile , output=tempfile, options=opt)
where infile = https://thredds.met.no/thredds/dodsC/nora3_subset_atmos/wind_hourly/arome3kmwind_1hr_202301.nc
tempfile = cache\NORA3_wind_sub_lon6.00000lat50.00000_20230501.nc
and opt = ['-O -v wind_speed, wind_direction, longitude, latitude -d x,3082360.8 -d y,-367476.97']
Eventually the code gets to here, within the nco call function:
proc = subprocess.Popen(
cmd,
stdin=subprocess.DEVNULL,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
env=environment,
)
Where the cmd is:
['C:\Users\my_file_path_to_the_python_3_environment\Library\bin\ncks', '-O', '-v', 'wind_speed,wind_direction,longitude,latitude', '-d', 'x,3082360.8', '-d', 'y,-367476.97', '--output=cache\NORA3_wind_sub_lon6.00000lat50.00000_20230501.nc', 'https://thredds.met.no/thredds/dodsC/nora3_subset_atmos/wind_hourly/arome3kmwind_1hr_202301.nc']
Again, I am very new to ALL of this (not a computer scientist or trained programmer myself), and just want to see if I can make this work, so we can include NORA3 data. Does anyone know how to fix this error? And how can I troubleshoot these sorts of ambiguous errors in the future myself as well?
I figured out what the problem specifically was, so posting this here in case anyone else has issues:
I was indeed missing a DLL, and the way to figrue this out was by running, in the conda prompt
ncks --version
This told me that I was indeed missing a dll, specifically the gsl-25.dll. I was able to install this:
conda install -c conda-forge gsl
This fixed the main issue in this question. Things were STILL broken afterwards, but they were broken in a way that I could then fix and handle step-by-step afterwards (mostly just package issues, newer/older versions of numpy, for example).