|
30 | 30 | "driftdepth = 1000 # maximum depth in m\n", |
31 | 31 | "maxdepth = 2000 # maximum depth in m\n", |
32 | 32 | "vertical_speed = 0.10 # sink and rise speed in m/s\n", |
33 | | - "cycletime = (\n", |
34 | | - " 10 * 86400\n", |
35 | | - ") # total time of cycle in seconds # TODO update to \"timedelta64[s]\"\n", |
| 33 | + "cycletime = 10 * 86400 # total time of cycle in seconds\n", |
36 | 34 | "drifttime = 9 * 86400 # time of deep drift in seconds\n", |
37 | 35 | "\n", |
38 | 36 | "\n", |
39 | 37 | "def ArgoPhase1(particles, fieldset):\n", |
40 | | - " dt = particles.dt / np.timedelta64(1, \"s\") # convert dt to seconds\n", |
41 | | - "\n", |
42 | 38 | " def SinkingPhase(p):\n", |
43 | 39 | " \"\"\"Phase 0: Sinking with vertical_speed until depth is driftdepth\"\"\"\n", |
44 | | - " p.dz += vertical_speed * dt\n", |
| 40 | + " p.dz += vertical_speed * particles.dt\n", |
45 | 41 | " p.cycle_phase = np.where(p.z + p.dz >= driftdepth, 1, p.cycle_phase)\n", |
46 | 42 | " p.dz = np.where(p.z + p.dz >= driftdepth, driftdepth - p.z, p.dz)\n", |
47 | 43 | "\n", |
48 | 44 | " SinkingPhase(particles[particles.cycle_phase == 0])\n", |
49 | 45 | "\n", |
50 | 46 | "\n", |
51 | 47 | "def ArgoPhase2(particles, fieldset):\n", |
52 | | - " dt = particles.dt / np.timedelta64(1, \"s\") # convert dt to seconds\n", |
53 | | - "\n", |
54 | 48 | " def DriftingPhase(p):\n", |
55 | 49 | " \"\"\"Phase 1: Drifting at depth for drifttime seconds\"\"\"\n", |
56 | | - " p.drift_age += dt\n", |
| 50 | + " p.drift_age += particles.dt\n", |
57 | 51 | " p.cycle_phase = np.where(p.drift_age >= drifttime, 2, p.cycle_phase)\n", |
58 | 52 | " p.drift_age = np.where(p.drift_age >= drifttime, 0, p.drift_age)\n", |
59 | 53 | "\n", |
60 | 54 | " DriftingPhase(particles[particles.cycle_phase == 1])\n", |
61 | 55 | "\n", |
62 | 56 | "\n", |
63 | 57 | "def ArgoPhase3(particles, fieldset):\n", |
64 | | - " dt = particles.dt / np.timedelta64(1, \"s\") # convert dt to seconds\n", |
65 | | - "\n", |
66 | 58 | " def SecondSinkingPhase(p):\n", |
67 | 59 | " \"\"\"Phase 2: Sinking further to maxdepth\"\"\"\n", |
68 | | - " p.dz += vertical_speed * dt\n", |
| 60 | + " p.dz += vertical_speed * particles.dt\n", |
69 | 61 | " p.cycle_phase = np.where(p.z + p.dz >= maxdepth, 3, p.cycle_phase)\n", |
70 | 62 | " p.dz = np.where(p.z + p.dz >= maxdepth, maxdepth - p.z, p.dz)\n", |
71 | 63 | "\n", |
72 | 64 | " SecondSinkingPhase(particles[particles.cycle_phase == 2])\n", |
73 | 65 | "\n", |
74 | 66 | "\n", |
75 | 67 | "def ArgoPhase4(particles, fieldset):\n", |
76 | | - " dt = particles.dt / np.timedelta64(1, \"s\") # convert dt to seconds\n", |
77 | | - "\n", |
78 | 68 | " def RisingPhase(p):\n", |
79 | 69 | " \"\"\"Phase 3: Rising with vertical_speed until at surface\"\"\"\n", |
80 | | - " p.dz -= vertical_speed * dt\n", |
| 70 | + " p.dz -= vertical_speed * particles.dt\n", |
81 | 71 | " p.temp = fieldset.thetao[p.time, p.z, p.lat, p.lon]\n", |
82 | 72 | " p.cycle_phase = np.where(p.z + p.dz <= fieldset.mindepth, 4, p.cycle_phase)\n", |
83 | 73 | " p.dz = np.where(\n", |
|
100 | 90 | "\n", |
101 | 91 | "\n", |
102 | 92 | "def ArgoPhase6(particles, fieldset):\n", |
103 | | - " dt = particles.dt / np.timedelta64(1, \"s\") # convert dt to seconds\n", |
104 | | - " particles.cycle_age += dt # update cycle_age" |
| 93 | + " particles.cycle_age += particles.dt # update cycle_age" |
105 | 94 | ] |
106 | 95 | }, |
107 | 96 | { |
|
211 | 200 | "x = ds_particles[\"lon\"][:].squeeze()\n", |
212 | 201 | "y = ds_particles[\"lat\"][:].squeeze()\n", |
213 | 202 | "z = ds_particles[\"z\"][:].squeeze()\n", |
214 | | - "time = (\n", |
215 | | - " (ds_particles[\"time\"][:].squeeze() - fieldset.time_interval.left).astype(float)\n", |
216 | | - " / 1e9\n", |
217 | | - " / 86400\n", |
218 | | - ") # convert time to days\n", |
| 203 | + "time = ds_particles[\"time\"][:].squeeze()\n", |
219 | 204 | "temp = ds_particles[\"temp\"][:].squeeze()" |
220 | 205 | ] |
221 | 206 | }, |
|
0 commit comments