Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions docs/tutorials/BinauralAnalysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"from pathlib import Path\n",
"\n",
"import warnings\n",
"\n",
"warnings.filterwarnings(\"ignore\")"
]
},
Expand Down Expand Up @@ -375,7 +376,9 @@
"binaural_wav = wav_folder.joinpath(\"CT101.wav\")\n",
"decibel = (levels[\"CT101\"][\"Left\"], levels[\"CT101\"][\"Right\"])\n",
"\n",
"single_file_result = analysis.analyze_file(binaural_wav, calibration_levels=decibel, resample=48000)\n",
"single_file_result = analysis.analyze_file(\n",
" binaural_wav, calibration_levels=decibel, resample=48000\n",
")\n",
"single_file_result"
]
},
Expand Down Expand Up @@ -1130,11 +1133,13 @@
"\n",
"start = time.perf_counter()\n",
"\n",
"folder_results = analysis.analyze_folder(wav_folder, calibration_file=levels_file, resample=48000)\n",
"folder_results = analysis.analyze_folder(\n",
" wav_folder, calibration_file=levels_file, resample=48000\n",
")\n",
"\n",
"end = time.perf_counter()\n",
"print(f\"Time taken: {end-start:.2f} seconds\")\n",
"folder_results\n"
"folder_results"
]
},
{
Expand Down Expand Up @@ -1205,13 +1210,7 @@
}
],
"source": [
"new_config = {\n",
" \"PythonAcoustics\": {\n",
" \"LAeq\": {\n",
" \"run\": False\n",
" }\n",
" }\n",
" }\n",
"new_config = {\"PythonAcoustics\": {\"LAeq\": {\"run\": False}}}\n",
"\n",
"analysis.update_config(new_config)\n",
"print(\"Configuration updated\")"
Expand Down Expand Up @@ -2026,7 +2025,9 @@
"start = time.perf_counter()\n",
"\n",
"serial_analysis = AudioAnalysis()\n",
"folder_results = serial_analysis.analyze_folder(wav_folder, calibration_file=levels_file, max_workers=1, resample=48000)\n",
"folder_results = serial_analysis.analyze_folder(\n",
" wav_folder, calibration_file=levels_file, max_workers=1, resample=48000\n",
")\n",
"\n",
"end = time.perf_counter()\n",
"\n",
Expand Down
126 changes: 81 additions & 45 deletions docs/tutorials/HowToAnalyseAndRepresentSoundscapes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"import seaborn as sns\n",
"\n",
"import warnings\n",
"warnings.simplefilter('ignore')"
"\n",
"warnings.simplefilter(\"ignore\")"
]
},
{
Expand Down Expand Up @@ -436,9 +437,14 @@
"source": [
"colors = [\"b\", \"r\"]\n",
"palette = sns.color_palette(colors)\n",
"sspy.plotting.scatter_plot(sample_transform, hue=\"RecordID\", palette=palette, diagonal_lines=True, legend=\"brief\",\n",
" s=100\n",
" )"
"sspy.plotting.scatter_plot(\n",
" sample_transform,\n",
" hue=\"RecordID\",\n",
" palette=palette,\n",
" diagonal_lines=True,\n",
" legend=\"brief\",\n",
" s=100,\n",
")"
]
},
{
Expand Down Expand Up @@ -789,12 +795,17 @@
],
"source": [
"location = \"RegentsParkFields\"\n",
"fig, ax = plt.subplots(1,1, figsize=(7, 7))\n",
"fig, ax = plt.subplots(1, 1, figsize=(7, 7))\n",
"\n",
"sspy.plotting.density_plot(sspy.isd.select_location_ids(ssid, location), hue=\"LocationID\",\n",
" title=\"(b) Median perception contour and scatter plot of individual assessments\\n\\n\",\n",
" palette=\"dark:gray\", ax=ax, legend=True, density_type=\"simple\"\n",
" )\n"
"sspy.plotting.density_plot(\n",
" sspy.isd.select_location_ids(ssid, location),\n",
" hue=\"LocationID\",\n",
" title=\"(b) Median perception contour and scatter plot of individual assessments\\n\\n\",\n",
" palette=\"dark:gray\",\n",
" ax=ax,\n",
" legend=True,\n",
" density_type=\"simple\",\n",
")"
]
},
{
Expand Down Expand Up @@ -847,12 +858,17 @@
}
],
"source": [
"fig, ax = plt.subplots(1,1, figsize=(7,7))\n",
"fig, ax = plt.subplots(1, 1, figsize=(7, 7))\n",
"\n",
"sspy.plotting.density_plot(sspy.isd.select_location_ids(ssid, ['CamdenTown', 'RussellSq', 'PancrasLock']),\n",
" hue=\"LocationID\", title=\"(c) Comparison of the soundscapes of three urban spaces\\n\\n\",\n",
" palette=\"husl\", simple_density=True, ax=ax, legend=True\n",
" )"
"sspy.plotting.density_plot(\n",
" sspy.isd.select_location_ids(ssid, [\"CamdenTown\", \"RussellSq\", \"PancrasLock\"]),\n",
" hue=\"LocationID\",\n",
" title=\"(c) Comparison of the soundscapes of three urban spaces\\n\\n\",\n",
" palette=\"husl\",\n",
" simple_density=True,\n",
" ax=ax,\n",
" legend=True,\n",
")"
]
},
{
Expand Down Expand Up @@ -1178,10 +1194,17 @@
}
],
"source": [
"sspy.plotting.density_plot(ssid, hue=\"dBLevel\", title=\"(d) Soundscape perception as a function of sound level\",\n",
" palette=\"colorblind\", incl_scatter=False, diagonal_lines=False, simple_density=True,\n",
" marginal_kind=\"kde\", legend=True\n",
" )"
"sspy.plotting.density_plot(\n",
" ssid,\n",
" hue=\"dBLevel\",\n",
" title=\"(d) Soundscape perception as a function of sound level\",\n",
" palette=\"colorblind\",\n",
" incl_scatter=False,\n",
" diagonal_lines=False,\n",
" simple_density=True,\n",
" marginal_kind=\"kde\",\n",
" legend=True,\n",
")"
]
},
{
Expand Down Expand Up @@ -1255,19 +1278,21 @@
}
],
"source": [
"\n",
"data_list = [sspy.isd.select_location_ids(ssid, location) for location in ssid.LocationID.unique()]\n",
"data_list = [\n",
" sspy.isd.select_location_ids(ssid, location)\n",
" for location in ssid.LocationID.unique()\n",
"]\n",
"fig = sspy.plotting.create_circumplex_subplots(\n",
" data_list,\n",
" plot_type=\"density\",\n",
" nrows=7,\n",
" ncols=4,\n",
" figsize=(12, 21),\n",
" incl_scatter=True,\n",
" subtitles=ssid.LocationID.unique()\n",
" )\n",
" data_list,\n",
" plot_type=\"density\",\n",
" nrows=7,\n",
" ncols=4,\n",
" figsize=(12, 21),\n",
" incl_scatter=True,\n",
" subtitles=ssid.LocationID.unique(),\n",
")\n",
"\n",
"plt.show()\n"
"plt.show()"
]
},
{
Expand Down Expand Up @@ -1319,10 +1344,16 @@
}
],
"source": [
"sspy.plotting.density_plot(sspy.isd.select_location_ids(ssid, location_ids=\"RegentsParkFields\"), hue=\"SessionID\",\n",
" title=\"Comparison of two days in Regents Park\", fill=False, incl_outline=True,\n",
" incl_scatter=True, simple_density=True, legend=True\n",
" )"
"sspy.plotting.density_plot(\n",
" sspy.isd.select_location_ids(ssid, location_ids=\"RegentsParkFields\"),\n",
" hue=\"SessionID\",\n",
" title=\"Comparison of two days in Regents Park\",\n",
" fill=False,\n",
" incl_outline=True,\n",
" incl_scatter=True,\n",
" simple_density=True,\n",
" legend=True,\n",
")"
]
},
{
Expand Down Expand Up @@ -1367,19 +1398,22 @@
}
],
"source": [
"data_list = [sspy.isd.select_location_ids(ssid, location) for location in ssid[\"LocationID\"].unique()]\n",
"data_list = [\n",
" sspy.isd.select_location_ids(ssid, location)\n",
" for location in ssid[\"LocationID\"].unique()\n",
"]\n",
"\n",
"fig = sspy.plotting.create_circumplex_subplots(\n",
" data_list,\n",
" plot_type=\"simple_density\",\n",
" nrows=7,\n",
" ncols=4,\n",
" figsize=(12, 21),\n",
" incl_scatter=True,\n",
" subtitles=ssid[\"LocationID\"].unique(),\n",
" hue = \"SessionID\",\n",
" fill = False,\n",
" )\n",
" data_list,\n",
" plot_type=\"simple_density\",\n",
" nrows=7,\n",
" ncols=4,\n",
" figsize=(12, 21),\n",
" incl_scatter=True,\n",
" subtitles=ssid[\"LocationID\"].unique(),\n",
" hue=\"SessionID\",\n",
" fill=False,\n",
")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -2238,7 +2272,9 @@
"source": [
"means = sspy.surveys.survey_utils.mean_responses(ssid, group=\"LocationID\")\n",
"means = sspy.surveys.add_iso_coords(means, overwrite=True)\n",
"sspy.plotting.scatter_plot(means, hue=\"LocationID\", xlim=(-0.25, 0.75), ylim=(-0.25, 0.75), s=40, legend=False)\n"
"sspy.plotting.scatter_plot(\n",
" means, hue=\"LocationID\", xlim=(-0.25, 0.75), ylim=(-0.25, 0.75), s=40, legend=False\n",
")"
]
}
],
Expand Down
Loading