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 05db02e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
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 05db02e

Please sign in to comment.