NOAA-ORR-ERD / PyGnome

The General NOAA Operational Modeling Environment
https://gnome.orr.noaa.gov/doc/pygnome/index.html
Other
58 stars 44 forks source link

issue with wind inputs #41

Open bhattvihang opened 6 years ago

bhattvihang commented 6 years ago

Apologies for the previous blank post. I am trying to put gridded winds for gnome forcing. However I get following error with gridwindmover function.

C:\ProgramData\Anaconda2\envs\gnome\lib\site-packages\pygnome-0.5.1-py2.7-win-amd64.egg\gnome\movers\wind_movers.pyc in init(self, filename, topology_file, extrapolate, time_offset, kwargs) 398 super(GridWindMover, self).init(**kwargs) 399 --> 400 self.mover.text_read(filename, topology_file) 401 402 self.real_data_start = sec_to_datetime(self.mover.get_start_time())

gnome\cy_gnome\cy_gridwind_mover.pyx in gnome.cy_gnome.cy_gridwind_mover.CyGridWindMover.text_read (gnome/cy_gnome\cy_gridwind_mover.cpp:2087)()**

OSError: GridWindMover_c.TextRead returned an error.

The header file for the wind data is as follows netcdf gnome_winds_file { dimensions: x = 22 ; y = 18 ; time = UNLIMITED ; // (124 currently) variables: double lon(y, x) ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; double lat(y, x) ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; double time(time) ; time:long_name = "time" ; time:units = "hours since 1987-01-01 00:00:00" ; double air_u(time, y, x) ; air_u:long_name = "eastward air velocity" ; air_u:units = "m/s" ; double air_v(time, y, x) ; air_v:long_name = "northward air velocity" ; air_v:units = "m/s" ; // global attributes: :grid_type = "curvilinear" ; }

I tried to view the gridded wind forcing script (script_sf_wind) that works fine.

I am curious where I have an issue my datafile.

Hoping for some suggestions.

Vihang Bhatt

bhattvihang commented 6 years ago

Hi,

The problem is with netcdf4 files for input as pygnome can read only netcdf3 files. I am just curious why this is so when python supports netcdf4. Can developers give hint where it is looking for netcdf file format for reading? It is not that difficult to fix this small issue.

Regards,

Vihang Bhatt

ChrisBarker-NOAA commented 6 years ago

pygmome should read netcd4 just fine.

Though some of the code is in C++ - but that should be linked against netcf4 as well.

But looking at your error, it’s retiring out trying to read a topology file — which should be a text file.

I think you may not be creating the mover correctly.

If you post your code, and ideally a link to your data file, we can take a look.

bhattvihang commented 6 years ago

Hi, thank you for your reply. The same wind file converted from netcdf4 to netcdf3 worked fine without any topology file specification. What I noticed is that some functions can work with netcdf4 some can not. I don't understand why. I will post you the wind datafile that I created. There is no code error as I tried with individual command to read the winds and create the object which failed.

Vihang Bhatt

ChrisBarker-NOAA commented 6 years ago

Thanks for testing. I thought we shipped a netcdf4 dll with teh code, so it should be supported.

@coconnor8 : could you confirm?

Meanwhile, it's possible that you are netcdf3 on your system somewhere, and the linker is finding that one before it finds the one we ship :-(

There is pure python code reading netcdf, which uses the netCDF4 package, which, obviously, should be netcdf4 compatible.

There is also C++ code that reads netcdf, and that is using the netcdf.dll -- so if it's finding a older version of that, then you'll only get netcdf3 support -- oddly, UNidata calls both version 3 and 4 versions netcdf.dll -- makes for confusion!

However, I think there is now a pure-python way to do gridded winds from netcdf:

@jay-hennen: could you confirm? and if so, let @bhattvihang know how to use it?

@bhattvihang: if you could post your data file somewhere, we can check it out.

bhattvihang commented 6 years ago

Hi, Please find attached two netcdf files. The problem of reading winds does not occur for winds_072007_3.nc that was made using nccopy -3 winds_072007.nc

input_files.zip

ChrisBarker-NOAA commented 6 years ago

@coconnor8: Could you take a look?