pyroms grid missing libgridgen, unable to solve

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
Timh37
Posts: 15
Joined: Thu May 09, 2019 3:25 pm
Location: NIOZ

pyroms grid missing libgridgen, unable to solve

#1 Unread post by Timh37 »

Dear all,

I've been trying to install pyroms on Mac OS10.13.6. I'm running Python 3.7.

Whatever strategy I'm using to install pyroms, it's not working. I tried pip install, or running python setup.py build, python setup-.py install. I've got all the required packages except for SCRIP, but I think that shouldn't be required for running pyroms.grid. I can use pyroms_toolbox and bathy_smoother succesfully though. Also importing pyroms doesn't give me errors. I've tried pretty much all hints on other forum posts about the following issue with pyroms.grid that I'm getting:
hgrd = pyroms.grid.Gridgen(lonp, latp, beta, (Mm+3, Lm+3), proj=map)
File "/opt/anaconda3/lib/python3.7/site-packages/pyroms/hgrid.py", line 1046, in __init__
self._libgridgen = np.ctypeslib.load_library('libgridgen', pyroms.__path__[0])
File "/opt/anaconda3/lib/python3.7/site-packages/numpy/ctypeslib.py", line 157, in load_library
raise OSError("no file with expected extension")
OSError: no file with expected extension
Exception ignored in: <function Gridgen.__del__ at 0x10e6dbae8>
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.7/site-packages/pyroms/hgrid.py", line 1163, in __del__
self._libgridgen.gridnodes_destroy(self._gn)
AttributeError: 'Gridgen' object has no attribute '_libgridgen'
I've manually tried to install and copy libgridgen.so to my python path '/opt/anaconda3/lib/python3.7/site-packages/pyroms', but this isn't working. I'm confused about what's going wrong here. Is there someone willing to help me and/or provide me with a foolproof explanation of how to install this package? Thanks.

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: pyroms grid missing libgridgen, unable to solve

#2 Unread post by kate »

If it is grid generation you are after, I suggest you check out pygridgen and pygridtools. I'm sorry this happened, but pyroms installation has always been troublesome and Mark Hadfield has offered to work on cleaning things up. There has been progress, but there are bumps in the road, as you can see.

If you'd like to have last year's problems and features, you have the full history with git. Doing "git log" or "gitk", you can see when things changed and check out a prior version.

Timh37
Posts: 15
Joined: Thu May 09, 2019 3:25 pm
Location: NIOZ

Re: pyroms grid missing libgridgen, unable to solve

#3 Unread post by Timh37 »

Hi Kate,

I'm indeed looking to generate/modify a grid. Do the pygridgen/pygridtool modules support the same capabilities as grid generation in pyroms? E.g. creating a vertical grid with terrain-following coordinates? Thanks a lot for the help, it's highly appreciated.

Best,

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: pyroms grid missing libgridgen, unable to solve

#4 Unread post by kate »

Most people separate the vertical grid from the horizontal grid. The ROMS grid file really only has the horizontal grid information while the vertical grid comes from the stretching parameters, THETA_S and so forth. You should be able to create a horizontal grid file with those other tools, then read it in with Python. I don't know if it will be exactly in the ROMS grid format, though.

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: pyroms grid missing libgridgen, unable to solve

#5 Unread post by m.hadfield »

For the libgridgen problem, take a look at this issue of GitHub:

https://github.com/ESMG/pyroms/issues/26

The original poster on that issue found a solution that involved installing gridgen and its dependencies from the Git repositories. Alternatively, you can install these packages with Conda, but then you need to tell the pyroms code where to find them.

In the medium term we should change pyroms to use something like pygridgen, Pavl Sakov's Python interface to gridgen.

Before I attempt these things I want to set up some example code and/or automated tests.

Timh37
Posts: 15
Joined: Thu May 09, 2019 3:25 pm
Location: NIOZ

Re: pyroms grid missing libgridgen, unable to solve

#6 Unread post by Timh37 »

Thanks for this reference! Per bhattvihang's post I added the extension to libgridgen in loading the library in hgrid.py:

<self._libgridgen = np.ctypeslib.load_library('libgridgen', pyroms.__path__[0])
>self._libgridgen = np.ctypeslib.load_library('libgridgen.so', pyroms.__path__[0])

This fixed my error :D.

I already had 'libgridgen.so' copied into my pyroms directory from installing it through nn, csa, gridutils and gridgen (for the last two I had to define flags as was done here: http://houstonthereisaproblem.blogspot. ... -1072.html).

In contrast with others in the github thread the double underscore __path__ is working for me though.
Hope this can also be of some help for others.

Post Reply