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

Add opendrift command line tool for doing a subset of simulations #739

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gauteh
Copy link
Member

@gauteh gauteh commented Oct 18, 2021

  • opendrift.py: add opendrift command line
  • add opendrift.py to setup.py

@vegardb: Let's see if this happens.

@gauteh gauteh changed the title cli Add opendrift command line tool for doing a subset of simulations Oct 18, 2021
@knutfrode
Copy link
Collaborator

Interesting!

@gauteh
Copy link
Member Author

gauteh commented Oct 18, 2021

This is the tool written by @vegardb for drifty. We have discussed moving it into opendrift for a while, which makes sense. If we constrain ourselves to supporting a limited set of features it should be feasible to make it generic.

@vegardb
Copy link

vegardb commented Oct 18, 2021

Nice!

Maybe replace set_config_override with some config file mechanism, though?

@knutfrode
Copy link
Collaborator

Possibility to do opendrift.py -f <config_file.ini> would be nice.

@gauteh
Copy link
Member Author

gauteh commented Oct 18, 2021

Yes, I think it should take a template file in yaml or toml, and let the command line override that so that you easily tweak a per-defined simulation. ini should work for the config values, but it has some limitations in data-types and ambiguity that are better specified in json/yaml/toml, which could possibly all be supported.

@knutfrode
Copy link
Collaborator

Yes, I was more thinking of a config-file with both config-settings as well as other things like seeding, readers etc.
And it could very well be e.g. yaml: opendrift.py -f <config_file.yml>

@gauteh
Copy link
Member Author

gauteh commented Oct 18, 2021

Tests can be added with: https://click.palletsprojects.com/en/8.0.x/testing/, did not look like you already tested this way @vegardb ?

@vegardb
Copy link

vegardb commented Oct 18, 2021

No, no tests so far.

}


plots = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but further down the road it would be nice to generalize this functionality, so that "any" postprocessing method can be applied. That requires some careful thinking.
Then also post-processing methods could be made available through Drifty.

@knutfrode
Copy link
Collaborator

I had earlier in mind that any OpenDrift module could be called the same way as this script, i.e.

>>> openoil.py <options>
>>> leeway.py <options>

I don't know whether that is feasible, or whether it is better than having a dedicated script opendrift.py as here.

'heatmap': lambda model, filename: model.write_netcdf_density_map(filename=filename),
'text': lambda model, filename: model.export_ascii(filename),
'oil_budget': lambda model, filename: model.plot_oil_budget(filename=filename)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: there already exists methods to produce plot or animation from a saved netCDF file, like this:

$ opendrift_animate.py openoil.nc -f anim.mp4

$ opendrift_plot.py openoil.nc -f plot.png

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

Successfully merging this pull request may close these issues.

3 participants