4
4
====================
5
5
"""
6
6
7
+ from datetime import datetime , timedelta
8
+ import numpy as np
9
+ import matplotlib .pyplot as plt
10
+ import opendrift
7
11
from opendrift .models .openberg import OpenBerg
8
- from datetime import datetime ,timedelta
9
-
10
- o = OpenBerg ()
11
12
12
- # The user can overwrite the default setup using set_config method
13
- o .set_config ('drift:vertical_profile' , False ) # use surface currents for this test
13
+ #%%
14
+ # Currents and wind forcing
15
+ forcing = ['https://thredds.met.no/thredds/dodsC/fou-hi/barents_eps_zdepth_be' ,
16
+ 'https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd' ]
14
17
15
- o .add_readers_from_list ([
16
- 'https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml' ,
17
- 'https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd' ])
18
+ #%%
19
+ # A permutation of iceberg sizes/dimensions
20
+ n = 10
21
+ lengths = np .linspace (50 , 500 , n )
22
+ widths = np .linspace (20 , 200 , n )
23
+ sails = np .linspace (5 , 50 , n )
24
+ drafts = np .linspace (2 , 120 , n )
25
+ lengths , widths , sails , drafts = np .meshgrid (lengths , widths , sails , drafts )
18
26
27
+ icebergs = {'lon' : 19.8 , 'lat' : 74.3 , 'time' : datetime .now (),
28
+ 'number' : lengths .size , 'radius' : 500 ,
29
+ 'sail' : sails , 'draft' : drafts , 'length' : lengths , 'width' : widths }
19
30
20
- o .seed_elements (lon = - 56 , lat = 72 , time = datetime .now (),
21
- number = 100 , radius = 500 ,
22
- sail = 10 ,draft = 50 ,length = 90 ,width = 40 )
31
+ #%%
32
+ # Simulating drift for 48 hours
33
+ outfile = 'icebergs.nc'
34
+ if False :
35
+ o = OpenBerg ()
36
+ o .set_config ('drift:vertical_profile' , False )
37
+ o .add_readers_from_list (forcing )
38
+ o .seed_elements (** icebergs )
39
+ o .run (duration = timedelta (days = 2 ), outfile = outfile )
40
+ else :
41
+ o = opendrift .open (outfile )
23
42
24
- o .run (duration = timedelta (days = 3 ))
25
- o .plot (fast = True )
26
- o .plot_property ('draft' )
43
+ o .animation (color = 'draft' )
44
+
45
+ #%%
46
+ # .. image:: /gallery/animations/example_openberg_0.gif
47
+
48
+ o .plot ()
49
+
50
+ #%%
51
+ # Plotting the speed of icebergs
52
+ iceberg_speed = np .sqrt (o .result .iceb_x_velocity ** 2 + o .result .iceb_y_velocity ** 2 )
53
+ iceberg_speed .plot .line (x = 'time' , add_legend = False , color = 'gray' )
54
+ plt .ylabel ('Iceberg speed [m/s]' )
55
+ plt .show ()
0 commit comments