{ "cells": [ { "cell_type": "markdown", "id": "cfab1a00", "metadata": {}, "source": [ "# Create SLAM-formatted dataset for REVI clips\n", "OVEN already exists as standalone dataset\n", "\n", "extract clips and make table with distance information" ] }, { "cell_type": "code", "execution_count": 87, "id": "4db4d354", "metadata": {}, "outputs": [], "source": [ "from opensoundscape import Audio, Spectrogram, CNN, BoxedAnnotations\n", "\n", "import numpy as np\n", "import pandas as pd\n", "from glob import glob\n", "from pathlib import Path\n", "\n", "from matplotlib import pyplot as plt\n", "plt.rcParams['figure.figsize']=[15,5] #for big visuals\n", "%config InlineBackend.figure_format = 'retina'\n", "plt.rcParams['pdf.fonttype'] = 42\n", "plt.rcParams['ps.fonttype'] = 42\n", "\n", "from tqdm.autonotebook import tqdm\n", "import json" ] }, { "cell_type": "code", "execution_count": null, "id": "b77e45a9", "metadata": {}, "outputs": [], "source": [ "try:\n", " from redacted_paths import REDACTED_OUTPUT_DIR, REDACTED_DATA_ROOT\n", "except ImportError:\n", " print(\"redacted paths not available\")\n", " REDACTED_OUTPUT_DIR = \"\"\n", " REDACTED_DATA_ROOT = \"\"" ] }, { "cell_type": "code", "execution_count": null, "id": "25399f28", "metadata": {}, "outputs": [], "source": [ "revi_clips = pd.read_csv(\n", " f\"{REDACTED_OUTPUT_DIR}/extracted_localized_clips/sbt_clips_reviewed.csv\",\n", " parse_dates=[\"start_timestamp\"],\n", ")\n", "# inconsistent timestamp formatting -> apply by row\n", "revi_clips[\"start_timestamp\"] = revi_clips.start_timestamp.apply(\n", " lambda x: pd.to_datetime(x)\n", ")\n", "\n", "# revi_clips[\"class_name\"] = \"Red-eyed Vireo\"\n", "revi_clips[\"json_idx\"] = revi_clips.index.values\n", "# fix grid names\n", "revi_clips[\"grid_id\"] = revi_clips[\"grid_id\"].apply(\n", " lambda x: \"-\".join(x.split(\"-\")[:-1])\n", ")\n", "clips = revi_clips.reset_index(drop=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "be9b952c", "metadata": {}, "outputs": [ { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "event_id", "rawType": "object", "type": "string" }, { "name": "grid_id", "rawType": "object", "type": "string" }, { "name": "start_timestamp", "rawType": "datetime64[ns, UTC-06:00]", "type": "datetime" }, { "name": "event_position_x", "rawType": "float64", "type": "float" }, { "name": "event_position_y", "rawType": "float64", "type": "float" }, { "name": "distance_m", "rawType": "float64", "type": "float" }, { "name": "nearest_recorder", "rawType": "object", "type": "unknown" }, { "name": "aiid_label_sl", "rawType": "object", "type": "string" }, { "name": "notes_sl", "rawType": "object", "type": "unknown" }, { "name": "aiid_label_cc", "rawType": "float64", "type": "float" }, { "name": "notes_cc", "rawType": "object", "type": "unknown" }, { "name": "aiid_label", "rawType": "float64", "type": "float" }, { "name": "data_split", "rawType": "object", "type": "string" }, { "name": "clip_name", "rawType": "object", "type": "string" }, { "name": "folder", "rawType": "object", "type": "string" }, { "name": "rel_path", "rawType": "object", "type": "string" }, { "name": "class_name", "rawType": "object", "type": "string" }, { "name": "json_idx", "rawType": "int64", "type": "integer" }, { "name": "clip_file", "rawType": "object", "type": "string" }, { "name": "start_time", "rawType": "float64", "type": "float" }, { "name": "event_position_z", "rawType": "float64", "type": "float" }, { "name": "receiver_position_x", "rawType": "float64", "type": "float" }, { "name": "receiver_position_y", "rawType": "float64", "type": "float" }, { "name": "receiver_position_z", "rawType": "float64", "type": "float" }, { "name": "receiver_id", "rawType": "object", "type": "unknown" }, { "name": "temp", "rawType": "float64", "type": "float" }, { "name": "duration", "rawType": "float64", "type": "float" }, { "name": "low_f", "rawType": "int64", "type": "integer" }, { "name": "high_f", "rawType": "int64", "type": "integer" }, { "name": "include", "rawType": "object", "type": "unknown" }, { "name": "low_f_narrow", "rawType": "int64", "type": "integer" }, { "name": "high_f_narrow", "rawType": "int64", "type": "integer" } ], "ref": "23ea750f-ed27-4b49-b946-ce45fc9d03e8", "rows": [ [ "0", "SBT-6-76_oven_0000", "SBT-6-76", "2016-06-21 05:35:51-06:00", "280.8485598", "100.1056474", "35.39889021523758", "False", "31", null, "1.0", null, "1.0", "test", "0000_oven01.mp3", "oven01", "audio/SBT-6-76/oven01/0000_oven01.mp3", "Ovenbird", "0", "/home/kitzeslab/data/localization_dataset_labeled_clips/audio/SBT-6-76/oven01/0000_oven01.mp3", "4.0", null, null, null, null, null, null, null, "3000", "8000", null, "4500", "5500" ] ], "shape": { "columns": 32, "rows": 1 } }, "text/html": [ "
| \n", " | event_id | \n", "grid_id | \n", "start_timestamp | \n", "event_position_x | \n", "event_position_y | \n", "distance_m | \n", "nearest_recorder | \n", "aiid_label_sl | \n", "notes_sl | \n", "aiid_label_cc | \n", "... | \n", "receiver_position_y | \n", "receiver_position_z | \n", "receiver_id | \n", "temp | \n", "duration | \n", "low_f | \n", "high_f | \n", "include | \n", "low_f_narrow | \n", "high_f_narrow | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "SBT-6-76_oven_0000 | \n", "SBT-6-76 | \n", "2016-06-21 05:35:51-06:00 | \n", "280.84856 | \n", "100.105647 | \n", "35.39889 | \n", "False | \n", "31 | \n", "NaN | \n", "1.0 | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "3000 | \n", "8000 | \n", "NaN | \n", "4500 | \n", "5500 | \n", "
1 rows × 32 columns
\n", "