228228 "output_type": "stream",
229229 "text": [
230230 "INFO: Output files are stored in EddyParticles.zarr.\n",
231- "100%|██████████| 518400.0/518400.0 [00:02 <00:00, 187445.76it /s]\n"
231+ "100%|██████████| 518400.0/518400.0 [00:03 <00:00, 172443.78it /s]\n"
232232 ]
233233 }
234234 ],
569569 "</style>\n",
570570 "\n",
571571 "<div class=\"animation\">\n",
572- " <img id=\"_anim_img8bfbea7abfae4cbf885a957f3f62a93b \">\n",
572+ " <img id=\"_anim_img39fc9ac9ecc54c368c0d0e047c7673e6 \">\n",
573573 " <div class=\"anim-controls\">\n",
574- " <input id=\"_anim_slider8bfbea7abfae4cbf885a957f3f62a93b \" type=\"range\" class=\"anim-slider\"\n",
574+ " <input id=\"_anim_slider39fc9ac9ecc54c368c0d0e047c7673e6 \" type=\"range\" class=\"anim-slider\"\n",
575575 " name=\"points\" min=\"0\" max=\"1\" step=\"1\" value=\"0\"\n",
576- " oninput=\"anim8bfbea7abfae4cbf885a957f3f62a93b .set_frame(parseInt(this.value));\">\n",
576+ " oninput=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .set_frame(parseInt(this.value));\">\n",
577577 " <div class=\"anim-buttons\">\n",
578- " <button title=\"Decrease speed\" aria-label=\"Decrease speed\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .slower()\">\n",
578+ " <button title=\"Decrease speed\" aria-label=\"Decrease speed\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .slower()\">\n",
579579 " <i class=\"fa fa-minus\"></i></button>\n",
580- " <button title=\"First frame\" aria-label=\"First frame\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .first_frame()\">\n",
580+ " <button title=\"First frame\" aria-label=\"First frame\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .first_frame()\">\n",
581581 " <i class=\"fa fa-fast-backward\"></i></button>\n",
582- " <button title=\"Previous frame\" aria-label=\"Previous frame\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .previous_frame()\">\n",
582+ " <button title=\"Previous frame\" aria-label=\"Previous frame\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .previous_frame()\">\n",
583583 " <i class=\"fa fa-step-backward\"></i></button>\n",
584- " <button title=\"Play backwards\" aria-label=\"Play backwards\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .reverse_animation()\">\n",
584+ " <button title=\"Play backwards\" aria-label=\"Play backwards\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .reverse_animation()\">\n",
585585 " <i class=\"fa fa-play fa-flip-horizontal\"></i></button>\n",
586- " <button title=\"Pause\" aria-label=\"Pause\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .pause_animation()\">\n",
586+ " <button title=\"Pause\" aria-label=\"Pause\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .pause_animation()\">\n",
587587 " <i class=\"fa fa-pause\"></i></button>\n",
588- " <button title=\"Play\" aria-label=\"Play\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .play_animation()\">\n",
588+ " <button title=\"Play\" aria-label=\"Play\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .play_animation()\">\n",
589589 " <i class=\"fa fa-play\"></i></button>\n",
590- " <button title=\"Next frame\" aria-label=\"Next frame\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .next_frame()\">\n",
590+ " <button title=\"Next frame\" aria-label=\"Next frame\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .next_frame()\">\n",
591591 " <i class=\"fa fa-step-forward\"></i></button>\n",
592- " <button title=\"Last frame\" aria-label=\"Last frame\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .last_frame()\">\n",
592+ " <button title=\"Last frame\" aria-label=\"Last frame\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .last_frame()\">\n",
593593 " <i class=\"fa fa-fast-forward\"></i></button>\n",
594- " <button title=\"Increase speed\" aria-label=\"Increase speed\" onclick=\"anim8bfbea7abfae4cbf885a957f3f62a93b .faster()\">\n",
594+ " <button title=\"Increase speed\" aria-label=\"Increase speed\" onclick=\"anim39fc9ac9ecc54c368c0d0e047c7673e6 .faster()\">\n",
595595 " <i class=\"fa fa-plus\"></i></button>\n",
596596 " </div>\n",
597- " <form title=\"Repetition mode\" aria-label=\"Repetition mode\" action=\"#n\" name=\"_anim_loop_select8bfbea7abfae4cbf885a957f3f62a93b \"\n",
597+ " <form title=\"Repetition mode\" aria-label=\"Repetition mode\" action=\"#n\" name=\"_anim_loop_select39fc9ac9ecc54c368c0d0e047c7673e6 \"\n",
598598 " class=\"anim-state\">\n",
599- " <input type=\"radio\" name=\"state\" value=\"once\" id=\"_anim_radio1_8bfbea7abfae4cbf885a957f3f62a93b \"\n",
599+ " <input type=\"radio\" name=\"state\" value=\"once\" id=\"_anim_radio1_39fc9ac9ecc54c368c0d0e047c7673e6 \"\n",
600600 " >\n",
601- " <label for=\"_anim_radio1_8bfbea7abfae4cbf885a957f3f62a93b \">Once</label>\n",
602- " <input type=\"radio\" name=\"state\" value=\"loop\" id=\"_anim_radio2_8bfbea7abfae4cbf885a957f3f62a93b \"\n",
601+ " <label for=\"_anim_radio1_39fc9ac9ecc54c368c0d0e047c7673e6 \">Once</label>\n",
602+ " <input type=\"radio\" name=\"state\" value=\"loop\" id=\"_anim_radio2_39fc9ac9ecc54c368c0d0e047c7673e6 \"\n",
603603 " checked>\n",
604- " <label for=\"_anim_radio2_8bfbea7abfae4cbf885a957f3f62a93b \">Loop</label>\n",
605- " <input type=\"radio\" name=\"state\" value=\"reflect\" id=\"_anim_radio3_8bfbea7abfae4cbf885a957f3f62a93b \"\n",
604+ " <label for=\"_anim_radio2_39fc9ac9ecc54c368c0d0e047c7673e6 \">Loop</label>\n",
605+ " <input type=\"radio\" name=\"state\" value=\"reflect\" id=\"_anim_radio3_39fc9ac9ecc54c368c0d0e047c7673e6 \"\n",
606606 " >\n",
607- " <label for=\"_anim_radio3_8bfbea7abfae4cbf885a957f3f62a93b \">Reflect</label>\n",
607+ " <label for=\"_anim_radio3_39fc9ac9ecc54c368c0d0e047c7673e6 \">Reflect</label>\n",
608608 " </form>\n",
609609 " </div>\n",
610610 "</div>\n",
614614 " /* Instantiate the Animation class. */\n",
615615 " /* The IDs given should match those used in the template above. */\n",
616616 " (function() {\n",
617- " var img_id = \"_anim_img8bfbea7abfae4cbf885a957f3f62a93b \";\n",
618- " var slider_id = \"_anim_slider8bfbea7abfae4cbf885a957f3f62a93b \";\n",
619- " var loop_select_id = \"_anim_loop_select8bfbea7abfae4cbf885a957f3f62a93b \";\n",
617+ " var img_id = \"_anim_img39fc9ac9ecc54c368c0d0e047c7673e6 \";\n",
618+ " var slider_id = \"_anim_slider39fc9ac9ecc54c368c0d0e047c7673e6 \";\n",
619+ " var loop_select_id = \"_anim_loop_select39fc9ac9ecc54c368c0d0e047c7673e6 \";\n",
620620 " var frames = new Array(29);\n",
621621 " \n",
622622 " frames[0] = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArwAAAH0CAYAAADfWf7fAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90\\\n",
1315613156 " /* set a timeout to make sure all the above elements are created before\n",
1315713157 " the object is initialized. */\n",
1315813158 " setTimeout(function() {\n",
13159- " anim8bfbea7abfae4cbf885a957f3f62a93b = new Animation(frames, img_id, slider_id, 100.0,\n",
13159+ " anim39fc9ac9ecc54c368c0d0e047c7673e6 = new Animation(frames, img_id, slider_id, 100.0,\n",
1316013160 " loop_select_id);\n",
1316113161 " }, 0);\n",
1316213162 " })()\n",
1320113201 "output_type": "stream",
1320213202 "text": [
1320313203 "INFO: Output files are stored in EddyParticles_Bwd.zarr.\n",
13204- "100%|██████████| 518400.0/518400.0 [00:02<00:00, 188464.76it /s]\n"
13204+ "100%|██████████| 518400.0/518400.0 [00:02<00:00, 176426.86it /s]\n"
1320513205 ]
1320613206 }
1320713207 ],
1332313323 "output_type": "stream",
1332413324 "text": [
1332513325 "INFO: Output files are stored in EddyParticles_WestVel.zarr.\n",
13326- "100%|██████████| 172800.0/172800.0 [00:00<00:00, 180626.58it /s]\n"
13326+ "100%|██████████| 172800.0/172800.0 [00:00<00:00, 179532.85it /s]\n"
1332713327 ]
1332813328 }
1332913329 ],
1350313503 "output_type": "stream",
1350413504 "text": [
1350513505 "INFO: Output files are stored in GlobCurrentParticles.zarr.\n",
13506- "100%|██████████| 864000.0/864000.0 [00:00<00:00, 1104294.63it /s]\n"
13506+ "100%|██████████| 864000.0/864000.0 [00:00<00:00, 1072517.72it /s]\n"
1350713507 ]
1350813508 }
1350913509 ],
1359213592 "cell_type": "markdown",
1359313593 "metadata": {},
1359413594 "source": [
13595- "Now define a new `Particle` class that has an extra `Variable`: the pressure. We initialise this by sampling the `fieldset.P` field.\n"
13595+ "Now define a new `Particle` class that has an extra `Variable`: the pressure. This `particle.p` can be used to store the values of the `fieldset.P` field at the particle locations .\n"
1359613596 ]
1359713597 },
1359813598 {
1360113601 "metadata": {},
1360213602 "outputs": [],
1360313603 "source": [
13604- "class SampleParticle(JITParticle):\n",
13605- " \"\"\"Define a new particle class with variable 'p'\n",
13606- " initialised by sampling the pressure\"\"\"\n",
13607- "\n",
13608- " p = Variable(\"p\")"
13604+ "SampleParticle = JITParticle.add_variable(\"p\")"
1360913605 ]
1361013606 },
1361113607 {
1368813684 "output_type": "stream",
1368913685 "text": [
1369013686 "INFO: Output files are stored in PeninsulaPressure.zarr.\n",
13691- "100%|██████████| 72000.0/72000.0 [00:00<00:00, 157840.98it /s]\n"
13687+ "100%|██████████| 72000.0/72000.0 [00:00<00:00, 143717.52it /s]\n"
1369213688 ]
1369313689 }
1369413690 ],
1376813764 "cell_type": "markdown",
1376913765 "metadata": {},
1377013766 "source": [
13771- "First, we need to create a new `Particle` class that includes three extra variables . The `distance` variable will be written to output, but the auxiliary variables `prev_lon` and `prev_lat` won't be written to output (can be controlled using the `to_write` keyword)\n "
13767+ "First, we need to add three extra variables to the Particle Class . The `distance` variable will be written to output, but the auxiliary variables `prev_lon` and `prev_lat` won't be written to output (can be controlled using the `to_write` keyword). "
1377213768 ]
1377313769 },
1377413770 {
@@ -13777,19 +13773,13 @@
1377713773 "metadata": {},
1377813774 "outputs": [],
1377913775 "source": [
13780- "class DistParticle(JITParticle): \n",
13781- " \"\"\"Define a new particle class that contains three extra variables\"\"\" \n",
13782- "\n",
13783- " # the distance travelled by the particle \n",
13784- " distance = Variable(\"distance\", initial=0.0, dtype=np.float32) \n",
13776+ "extra_vars = [ \n",
13777+ " Variable(\"distance\", initial=0.0, dtype=np.float32), \n",
13778+ " Variable(\"prev_lon\", dtype=np.float32, to_write=False, initial=attrgetter(\"lon\")), \n",
13779+ " Variable(\"prev_lat\", dtype=np.float32, to_write=False, initial=attrgetter(\"lat\")), \n",
13780+ "] \n",
1378513781 "\n",
13786- " # the previous longitude and latitude of the particle\n",
13787- " prev_lon = Variable(\n",
13788- " \"prev_lon\", dtype=np.float32, to_write=False, initial=attrgetter(\"lon\")\n",
13789- " )\n",
13790- " prev_lat = Variable(\n",
13791- " \"prev_lat\", dtype=np.float32, to_write=False, initial=attrgetter(\"lat\")\n",
13792- " )"
13782+ "DistParticle = JITParticle.add_variables(extra_vars)"
1379313783 ]
1379413784 },
1379513785 {
1387913869 "output_type": "stream",
1388013870 "text": [
1388113871 "INFO: Output files are stored in GlobCurrentParticles_Dist.zarr.\n",
13882- "100%|██████████| 518400.0/518400.0 [00:03<00:00, 147724.13it /s]\n"
13872+ "100%|██████████| 518400.0/518400.0 [00:03<00:00, 136275.28it /s]\n"
1388313873 ]
1388413874 }
1388513875 ],
1393613926 "name": "python",
1393713927 "nbconvert_exporter": "python",
1393813928 "pygments_lexer": "ipython3",
13939- "version": "3.10.9 "
13929+ "version": "3.11.6 "
1394013930 }
1394113931 },
1394213932 "nbformat": 4,
0 commit comments