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 = cacheNORA3_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:Usersmy_file_path_to_the_python_3_environmentLibrarybinncks’,
‘-O’, ‘-v’, ‘wind_speed,wind_direction,longitude,latitude’, ‘-d’,
‘x,3082360.8’, ‘-d’, ‘y,-367476.97’,
‘–output=cacheNORA3_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?
Eric Rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
This is a convoluted question so it is difficult to know the root cause. However, you do say that the string passed to ncks
includes this
opt = ['-O -v wind_speed, wind_direction, longitude, latitude -d x,3082360.8 -d y,-367476.97']
There should be no spaces in the list of variable names passed to the -v
option. Hence, opt
should be
opt = ['-O -v wind_speed,wind_direction,longitude,latitude -d x,3082360.8 -d y,-367476.97']
This might explain the behavior you observed.