rustychris / stomel

Spatial tools for ocean modeling in python
GNU General Public License v2.0
10 stars 6 forks source link

Convert SMS grid file into suntans #4

Open JacobZhao opened 5 years ago

JacobZhao commented 5 years ago

Hello, I'm trying to use this repo to convert grid file form SMS to SUNTANS use. Unfortunately, I didn't find any docs about it. I have tried using trigrid.py to convert grid. (One of few files have keywords *.grd)

I got two errors. One: module compiled against API version 0xa but this version of numpy is 0x9 Two: global name 'gca' is not defined.

I have installed the stomel with anaconda python2.7 and add pythonpath with src folder.

Would you mind give me some help?

Yours, Zhao

rustychris commented 5 years ago

stomel has mostly been superceded by stompy. Among other things, the main grid class in stompy allows for arbitrary polygons in meshes, and has a command line interface for things like simple conversion of grid formats. That said, I have not ported the SMS reader over from stomel to stompy. If you're able to send me a sample sms file for testing, I'd be happy to do this, though.

JacobZhao commented 5 years ago

Of course. You can access it from this link https://drive.google.com/file/d/11fGTwPr_4YoZAy3kbnWdsOrpKERrhBGB/view?usp=sharing

Sorry, I can't attach the file in the comment.

This file is no longer available.

rustychris commented 5 years ago

Great -- can you try stompy? Once installed and on your python path, this command line will do the conversion: python -m stompy.grid.cli -i sms:0509.grd -o suntans_classic:.

(note that suntans_classic and suntans_hybrid are both options, i.e. triangle-only vs. arbitrary polygon grids).

JacobZhao commented 5 years ago

The code works fine with me. One error happens. The original type-2 boundaries become type-3 boundaries. I think it is due to edgemark_change

One more question, I generate the grid file (*.grd) using SMS, but some triangles are not good. The voronoi points are outside of triangles. (See the attached figure) error grid

It seems to be able to directly generate suntans grid file. Is there any command? If so, What kind of raw file I should prepare?

Once again, thanks for your help.

rustychris commented 5 years ago

I changed the default edge marker for the sms conversion (a4491f9e1ab5391d0f73af113bf2131c63d00d8d). I don't know SMS too well, though. In particular, all I see in SMS is land or open boundary, while SUNTANS has the notion open boundary and velocity boundary. Regardless, hopefully defaulting to edge marker 2 will be better than defaulting to 3.

Some details on generating triangular grids with stompy are here: https://stompy.readthedocs.io/en/latest/stompy.grid.html