Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Incorporate a .shio File into a PyGNOME Script? #170

Open
Misiorama opened this issue Dec 19, 2024 · 3 comments
Open

How to Incorporate a .shio File into a PyGNOME Script? #170

Misiorama opened this issue Dec 19, 2024 · 3 comments

Comments

@Misiorama
Copy link

I’m currently working on a project using PyGNOME and trying to incorporate tidal data from a .shio file into my Python script. I’ve read through the GNOME documentation, but I’m still unclear on the exact steps needed to load and use a .shio file within PyGNOME.

Specifically, I’d like to understand:

What is the correct way to load a .shio file in a PyGNOME script?

I would really appreciate any guidance, tips, or example code that can help me correctly integrate this file into my workflow. Thanks in advance for your support!

Best regards,

There is my .shio file
5_Mareas.shio.txt

@ChrisBarker-NOAA
Copy link
Contributor

Sorry for the slow response -- I've been meaning to write up more in your other issue.

But the short version now:

.shio files provide the tidal constituents for tidal currents at a point.

GNOME needs a full time and spatially variable set of currents.

So the constituents are used to drive a "current pattern" -- that is a set of current vectors for a region (on a triangular mesh) that is time invariant, and then the vectors are scaled up. and down according the the constituents -- matching the currents at one point in the pattern, and then the rest are scaled up and down along with it.

This works pretty well if you have a pattern for, e.g. the flood tide, and then it can go faster an slower (and reverse for the ebb) with time.

You can see examples of this in the PyGNOME code, under:

py_gnome/scripts/testing_scripts

script_delaware_bay
script_columbia_river
script_guam

And a few others -- look for "CatsMover"

the constituents can be either currents or tidal heights -- if tidal heights, the derivative of the water level is used -- which is only appropriate in some places, but sometimes it's all that we have. If there are tidal current consituents, then they are used directly

script_delaware_bay has a good example -- here's the code:

    print('adding a cats shio mover:')

    curr_file = get_datafile(os.path.join(base_dir, 'FloodTides.cur'))
    tide_file = get_datafile(os.path.join(base_dir, 'FloodTidesShio.txt'))

    c_mover = CatsMover(curr_file, tide=Tide(tide_file))

    # this is the value in the file (default)
    c_mover.scale_refpoint = (-75.081667, 38.7995)
    c_mover.scale = True
    c_mover.scale_value = 1

    model.movers += c_mover

the scripts with auto-download the data files when you run them -- you need to be online.

The current patterns need to be in the CATS format:

https://gnome.orr.noaa.gov/doc/pygnome/file_formats/noaa_specific_currents.html#currents-cats

NOTE: the "DAGTree" section describes an in-house spatial index -- if you leave it out, PyGNOME should generate it for you.

@coconnor8: can you confirm?

As you can tell by the name, we develop these patterns with an in-house tool: Current Analysis for Trajectory Simulations (CATS), which is a 2D steady state finite element model.

It's an in house tool, and poorly documented, but we can share it if you want to give it a try.

I hope this helps ....

@ChrisBarker-NOAA
Copy link
Contributor

Oops, forgot to give you this link, which has a bit of documentation:

https://gnome.orr.noaa.gov/doc/pygnome/scripting/cats.html

@coconnor8
Copy link
Contributor

PyGnome assumes that the .cur files come from CATS so they are required to have Vertices, Topology, and DAGTree. It wouldn't be hard to allow files to leave out Topology and DAGTree and have PyGnome calculate them if that is a use case that might come up from time to time. Alternatively we could advise on how to generate them with a local build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants