|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
| 5 | + "execution_count": null, |
5 | 6 | "id": "initial_id", |
6 | 7 | "metadata": { |
7 | 8 | "collapsed": true |
8 | 9 | }, |
| 10 | + "outputs": [], |
9 | 11 | "source": [ |
10 | 12 | "from pathlib import Path\n", |
11 | 13 | "\n", |
12 | | - "from pandas import Timedelta, Timestamp, read_csv\n", |
13 | | - "\n", |
| 14 | + "import matplotlib.pyplot as plt\n", |
14 | 15 | "from osekit.utils.timestamp_utils import strptime_from_text\n", |
| 16 | + "from pandas import Timedelta, Timestamp, read_csv\n", |
15 | 17 | "\n", |
16 | | - "from post_processing.utils.glider_utils import load_glider_nav, plot_detections_with_nav_data, \\\n", |
17 | | - " compute_acoustic_diversity, export_gpx\n", |
18 | | - "import matplotlib.pyplot as plt" |
19 | | - ], |
20 | | - "outputs": [], |
21 | | - "execution_count": null |
| 18 | + "from post_processing.utils.glider_utils import (\n", |
| 19 | + " compute_acoustic_diversity,\n", |
| 20 | + " export_gpx,\n", |
| 21 | + " load_glider_nav,\n", |
| 22 | + " plot_detections_with_nav_data,\n", |
| 23 | + ")" |
| 24 | + ] |
22 | 25 | }, |
23 | 26 | { |
24 | | - "metadata": {}, |
25 | 27 | "cell_type": "markdown", |
26 | | - "source": "### Load data", |
27 | | - "id": "429edfb71ec618a" |
| 28 | + "id": "429edfb71ec618a", |
| 29 | + "metadata": {}, |
| 30 | + "source": "### Load data" |
28 | 31 | }, |
29 | 32 | { |
30 | | - "metadata": {}, |
31 | 33 | "cell_type": "code", |
| 34 | + "execution_count": null, |
| 35 | + "id": "3014915fe657e321", |
| 36 | + "metadata": {}, |
| 37 | + "outputs": [], |
32 | 38 | "source": [ |
33 | 39 | "input_dir = Path(r\"resource\\OHAGEODAMS_nav\")\n", |
34 | 40 | "nav = load_glider_nav(input_dir)\n", |
35 | | - "nav = nav[nav['Timestamp'] > Timestamp('2024-02-21', tz='UTC')]\n", |
36 | | - "df = read_csv(Path(r\"resource\\OHAGEODAMS_results.csv\"), parse_dates=['start_datetime', 'end_datetime']).dropna(subset=['annotation']).reset_index(drop=True)" |
37 | | - ], |
38 | | - "id": "3014915fe657e321", |
39 | | - "outputs": [], |
40 | | - "execution_count": null |
| 41 | + "nav = nav[nav[\"Timestamp\"] > Timestamp(\"2024-02-21\", tz=\"UTC\")]\n", |
| 42 | + "df = read_csv(Path(r\"resource\\OHAGEODAMS_results.csv\"), parse_dates=[\"start_datetime\", \"end_datetime\"]).dropna(subset=[\"annotation\"]).reset_index(drop=True)" |
| 43 | + ] |
41 | 44 | }, |
42 | 45 | { |
43 | | - "metadata": {}, |
44 | 46 | "cell_type": "markdown", |
45 | | - "source": "### Plot detection with nav data", |
46 | | - "id": "303cd23d5b4d12dd" |
| 47 | + "id": "303cd23d5b4d12dd", |
| 48 | + "metadata": {}, |
| 49 | + "source": "### Plot detection with nav data" |
47 | 50 | }, |
48 | 51 | { |
49 | | - "metadata": {}, |
50 | 52 | "cell_type": "code", |
| 53 | + "execution_count": null, |
| 54 | + "id": "7b478cccaf1c70eb", |
| 55 | + "metadata": {}, |
| 56 | + "outputs": [], |
51 | 57 | "source": [ |
52 | | - "ticks = Timedelta('1d')\n", |
| 58 | + "ticks = Timedelta(\"1d\")\n", |
53 | 59 | "\n", |
54 | 60 | "# plot specific labels\n", |
55 | | - "plot_detections_with_nav_data(df=df[df['annotation'].isin([\"Sperm_Whale\", \"Delphinids clics\"])], nav=nav, criterion='Depth', ticks=ticks)\n", |
| 61 | + "plot_detections_with_nav_data(df=df[df[\"annotation\"].isin([\"Sperm_Whale\", \"Delphinids clics\"])], nav=nav, criterion=\"Depth\", ticks=ticks)\n", |
56 | 62 | "plt.show()\n", |
57 | 63 | "\n", |
58 | 64 | "# plot all labels\n", |
59 | | - "plot_detections_with_nav_data(df=df, nav=nav, criterion='Depth', ticks=ticks)\n", |
| 65 | + "plot_detections_with_nav_data(df=df, nav=nav, criterion=\"Depth\", ticks=ticks)\n", |
60 | 66 | "plt.show()" |
61 | | - ], |
62 | | - "id": "7b478cccaf1c70eb", |
63 | | - "outputs": [], |
64 | | - "execution_count": null |
| 67 | + ] |
65 | 68 | }, |
66 | 69 | { |
67 | | - "metadata": {}, |
68 | 70 | "cell_type": "markdown", |
69 | | - "source": "### Compute acoustic diversity", |
70 | | - "id": "798518fc43a69afc" |
| 71 | + "id": "798518fc43a69afc", |
| 72 | + "metadata": {}, |
| 73 | + "source": "### Compute acoustic diversity" |
71 | 74 | }, |
72 | 75 | { |
73 | | - "metadata": {}, |
74 | 76 | "cell_type": "code", |
| 77 | + "execution_count": null, |
| 78 | + "id": "395af53656d318b4", |
| 79 | + "metadata": {}, |
| 80 | + "outputs": [], |
75 | 81 | "source": [ |
76 | | - "task_status_filenames = read_csv(r\"resource\\OHAGEODAMS_status.csv\")['filename']\n", |
77 | | - "time_vector = [strptime_from_text(f, \"%Y_%m_%d_%H_%M_%S\").tz_localize('UTC') for f in task_status_filenames]\n", |
| 82 | + "task_status_filenames = read_csv(r\"resource\\OHAGEODAMS_status.csv\")[\"filename\"]\n", |
| 83 | + "time_vector = [strptime_from_text(f, \"%Y_%m_%d_%H_%M_%S\").tz_localize(\"UTC\") for f in task_status_filenames]\n", |
78 | 84 | "\n", |
79 | 85 | "df_acoustic_div = compute_acoustic_diversity(df=df, nav=nav, time_vector=time_vector)\n", |
80 | 86 | "\n", |
81 | 87 | "# df_acoustic_div.to_csv(Path(r'\\output\\path\\acoustic_diversity.csv'), index=False)" |
82 | | - ], |
83 | | - "id": "395af53656d318b4", |
84 | | - "outputs": [], |
85 | | - "execution_count": null |
| 88 | + ] |
86 | 89 | }, |
87 | 90 | { |
88 | | - "metadata": {}, |
89 | 91 | "cell_type": "markdown", |
90 | | - "source": "### Export navigation data to GPX", |
91 | | - "id": "aa6d95c921329545" |
| 92 | + "id": "aa6d95c921329545", |
| 93 | + "metadata": {}, |
| 94 | + "source": "### Export navigation data to GPX" |
92 | 95 | }, |
93 | 96 | { |
94 | | - "metadata": {}, |
95 | 97 | "cell_type": "code", |
96 | | - "source": "export_gpx(nav=nav, output_dir=Path(r\"\\output\\path\"), output_file=\"test_trace\")", |
| 98 | + "execution_count": null, |
97 | 99 | "id": "54f691859e36b232", |
| 100 | + "metadata": {}, |
98 | 101 | "outputs": [], |
99 | | - "execution_count": null |
| 102 | + "source": [ |
| 103 | + "export_gpx(nav=nav, output_dir=Path(r\"\\output\\path\"), output_file=\"test_trace\")" |
| 104 | + ] |
100 | 105 | } |
101 | 106 | ], |
102 | 107 | "metadata": { |
|
0 commit comments