Skip to content

Commit

Permalink
Add options for more plots
Browse files Browse the repository at this point in the history
  • Loading branch information
svenseeberg committed Dec 3, 2023
1 parent 125d5ec commit fdec830
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
3 changes: 2 additions & 1 deletion opendrift_leeway_webgui/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#: .. warning::
#: Never deploy a site into production with :setting:`DEBUG` turned on!
DEBUG = bool(strtobool(os.environ.get("LEEWAY_DEBUG", "False")))
DEBUG = True

#: The secret key for this particular Django installation (see :setting:`django:SECRET_KEY`)
#:
Expand Down Expand Up @@ -330,7 +331,7 @@

#: The email address that error messages come from (see :setting:`django:SERVER_EMAIL`)
SERVER_EMAIL = os.environ.get("LEEWAY_SERVER_EMAIL")

SERVER_EMAIL = "Foo"
#: Default email address to use for various automated correspondence from the site manager(s)
#: (see :setting:`django:DEFAULT_FROM_EMAIL`)
DEFAULT_FROM_EMAIL = SERVER_EMAIL
Expand Down
4 changes: 4 additions & 0 deletions opendrift_leeway_webgui/leeway/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class Meta:
"start_time",
"duration",
"radius",
"send_trajectories",
"send_heatmap",
"send_animation_wind",
"send_animation_sea",
]
help_texts = {
"duration": "Length of simulation in hours.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 4.2.7 on 2023-12-03 14:59

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [("leeway", "0008_leewaysimulation_traceback")]

operations = [
migrations.AddField(
model_name="leewaysimulation",
name="send_animation_sea",
field=models.BooleanField(
default=False,
help_text="Attach Gif to e-mail with animation of particles with sea currents.",
),
),
migrations.AddField(
model_name="leewaysimulation",
name="send_animation_wind",
field=models.BooleanField(
default=False,
help_text="Attach Gif to e-mail with animation of particles and wind fields.",
),
),
migrations.AddField(
model_name="leewaysimulation",
name="send_heatmap",
field=models.BooleanField(
default=False,
help_text="Attach PNG to e-mail with heat map of final particle locations.",
),
),
migrations.AddField(
model_name="leewaysimulation",
name="send_trajectories",
field=models.BooleanField(
default=True,
help_text="Attach PNG to e-mail with particle trajectories.",
),
),
]
12 changes: 12 additions & 0 deletions opendrift_leeway_webgui/leeway/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ class LeewaySimulation(models.Model):
simulation_started = models.DateTimeField(null=True)
simulation_finished = models.DateTimeField(null=True)
radius = models.IntegerField(default=1000)
send_trajectories = models.BooleanField(
default=True,
help_text="Attach PNG to e-mail with particle trajectories.")
send_heatmap = models.BooleanField(
default=False,
help_text="Attach PNG to e-mail with heat map of final particle locations.")
send_animation_wind = models.BooleanField(
default=False,
help_text="Attach Gif to e-mail with animation of particles and wind fields.")
send_animation_sea = models.BooleanField(
default=False,
help_text="Attach Gif to e-mail with animation of particles with sea currents.")
img = models.FileField(
null=True, storage=simulation_storage, verbose_name=_("Image file")
)
Expand Down
9 changes: 9 additions & 0 deletions opendrift_leeway_webgui/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,18 @@ def main():
simulation.run(
duration=timedelta(hours=args.duration), time_step=600, outfile=f"{outfile}.nc"
)


simulation.plot(
fast=True, legend=True, filename=f"{outfile}.png", linecolor="age_seconds"
)

simulation.plot(
background=simulation.get_density_array(pixelsize_m=3000),
clabel='Probability of origin [%]', fast=True, markersize=.5, lalpha=.02,
outfile=f"{outfile}-density.png"
)

print(f"Success: {outfile}.png written.")


Expand Down

0 comments on commit fdec830

Please sign in to comment.