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

polygon oil spill #165

Open
jieAmple opened this issue Nov 15, 2024 · 11 comments
Open

polygon oil spill #165

jieAmple opened this issue Nov 15, 2024 · 11 comments

Comments

@jieAmple
Copy link

I have downloaded zip file for polygon oil spilling from https://www.ospo.noaa.gov/products/ocean/marinepollution/

May I know how it work in pygnome ? I have no idea how to write the proper command lines by referring to
gnome.spills.release.PolygonRelease(filename=None, features=None, polygons=None, weights=None, thicknesses=None, **kwargs)

@coconnor8
Copy link
Contributor

The only parameter you need to pass in for the PolygonRelease is filename. If you don't have a shapefile with all the information you would have to pass in the polygons instead.

import gnome.scripting as gs
release = gs.PolygonRelease(filename = 'shapefilename.zip')
spill = gs.Spill(release = release)
model.spills += spill

There are other parameters you might want to include, depending on your scenario (like release_time or substance), which are described in the documentation - https://gnome.orr.noaa.gov/doc/pygnome/index.html

@jieAmple
Copy link
Author

thanks a lot !

@jieAmple
Copy link
Author

I have run the PolygonRelease successfully (without an error or warning) and obtained the animation output in .gif as enclosed.
P1_anim
I also output the pygnome result as .gnome as I would like to visualize the result in webgnome. However, when I uploaded this .gnome file to webgnome, the screen kept black
webgnome.

May I know if it is due to the .gnome file issue or the webgnome website? I am sorry I cannot upload my .gnome file here in github as attachement

@AmyMacFadyen
Copy link
Contributor

Could you please email the .gnome file to [email protected]

That will be the easiest way for us to troubleshoot.

@coconnor8
Copy link
Contributor

The polygon spill does not work in WebGnome at the moment. We are working on the issue. In the meantime you could try setting up your release as a NESDISRelease with the same parameters. That should load in, but let us know if you notice any issues with it.

@jieAmple
Copy link
Author

Hi AmyMacFadyen, I have emailed you my .gnome file to [email protected] for your investigation.

Hi coconnor8, I have tried gs.PolygonRelease(filename = 'shapefilename.zip') as you suggested with myself defined polgyon shape file which worked in pygnome and I can get the .gif animation as shown here. Thanks for that!

for your information: I have previously downloaded a polygon zip file from https://www.ospo.noaa.gov/products/ocean/marinepollution/
and I uploaded this zip file to webgnome and it works. The downloaded file is .gnome which worked when I uploaded it again back to webgnome. So I believe if my pygnome script output .gnome file shall be working in webgnome.

To me it seems the webgnome works with polygon oil release. Pls correct me if I am wrong.
more info: I uploaded 'z20180123_1626.zip' to webgnome, with a point constant wind then the model can run correctly. the two screenshots below for your reference of what I did.
image
image

@coconnor8
Copy link
Contributor

What is not working correctly is setting up the PolygonRelease in a script, making a save file, and loading it into WebGnome. The NESDIS release works in WebGnome, and that is what is created when you upload your zip file to WebGnome. The PolygonRelease is slightly different so we need to change a few things to make that work as well.

@jieAmple
Copy link
Author

I got your point. thanks.
I have tried to use NESDIS to replace PolygonRelease simply as follows:

import gnome.scripting as gs
release = gs.NESDISRelease(num_elements=2000,
release_time="2024-06-02 00:00:00",
filename = 'plastic_debris.zip'
)
spill = gs.Spill(release = release)
model.spills += spill

however, I got an error:
AttributeError: module 'gnome.scripting' has no attribute 'NESDISRelease'

I also tried: "from gnome.spills import NESDISRelease" which gave me:
ImportError: cannot import name 'NESDISRelease' from 'gnome.spills' (C:\Users\anaconda3\envs\gnome\lib\site-packages\gnome\spills_init_.py)

I went to the _init_py. but did not find the 'NESDISRelease' in
from .spill import (Spill,
SpillSchema,
surface_point_line_spill,
subsurface_spill,
grid_spill,
spatial_release_spill,
polygon_release_spill)
I am unsure how to use this NESDIS correctly :(

@coconnor8
Copy link
Contributor

Sorry about that, I added NESDISRelease to scripting locally. You would need to import it -
from gnome.spills.release import NESDISRelease

@jieAmple
Copy link
Author

Thanks. It works for me now. And I want to point out here for other users who might encounter this usage issue of NESDISRelease that it needs to set the timeformat as:
release_time_obj = datetime.strptime(release_time, "%Y-%m-%d %H:%M:%S")
and
release = NESDISRelease(filename = 'your zip file',
num_elements=1000,
release_time = release_time_obj)
instead of
release_time = “year-month-day hh:mm:sec"

I also realize in the release.py code there are feature variables "weights" and "thicknesses" in the NESDISRelease that we can set for the substance property. May I know how to use them as well? like what are the units of weights and thickness? are these two values user defined or if I define one like weight for a special type of oil, the thickness shall be calculated by myself based on the oil volume and the polygon surface area?

@coconnor8
Copy link
Contributor

The NESDIS release does not allow you to set the thicknesses and weights (they will be ignored if you pass them in). It sets thickness based on 'oil_type' of 'thin' or 'thick' and defaults to 'thin'. You would have to use the PolygonRelease to pass in thicknesses or weights, and we are still working on how that will work in WebGnome (hopefully that should be working soon). You can pass in either weights or thicknesses but not both -
:param weights: (optional) LE placement probability weighting for each polygon. Must be the same length as the polygons kwarg, and must sum to 1. If None, weights are generated at runtime based on area proportion.

Thickness wasn't included in the documentation but should be in meters, also the same length as polygons, and our defaults for the NESDISRelease are 50e-6 for 'thick' and 5e-6 for 'thin'.

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