Skip to content

Commit 19f969b

Browse files
Species suggestion Backend (#467)
* modify grts_cell to sample_frame_id, the real name * add species range model, management loading command, admin interface * GET species support for recordingId, GRTSCell and Sample_frame_Id for listing * mark geojson file as generated to remove line count * mark geojson file as vendored to remove line count * add category label back to Species results * Update .gitattributes Co-authored-by: Brian Helba <brian.helba@kitware.com> * Update bats_ai/core/management/commands/load_species_geojson.py Co-authored-by: Brian Helba <brian.helba@kitware.com> * swap to tuples to lists for admin * prevent nullable for SpeciesRange.source_feature_id field * update GEOJSON location, add loading to migration * default to CONUS_SAMPLE_FRAME_ID=14 for unknown sample_frame_ids * cleanup species view * pathlib for DEFAULT_GEOJSON * rename species.geojson to species-ranges.geojson * Update bats_ai/core/management/commands/load_species_geojson.py Co-authored-by: Brian Helba <brian.helba@kitware.com> * allow more failing errors in load species range * remove unecessary pk, and default to false if geom exists and overlap is false * in_range output comments, species-range ingestion description --------- Co-authored-by: Brian Helba <brian.helba@kitware.com>
1 parent 5b2a238 commit 19f969b

18 files changed

Lines changed: 463206 additions & 26 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
client/package-lock.json linguist-generated=true
2+
bats_ai/core/data/species-ranges.geojson linguist-vendored=true
23
uv.lock linguist-generated=true
34
assets/example.wav filter=lfs diff=lfs merge=lfs -text
45
assets/model.mobilenet.onnx filter=lfs diff=lfs merge=lfs -text

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,18 @@ on all pipelines for new MRs. The automated checks in GitLab are optional, but
190190
it is highly recommended to perform these checks locally prior to pushing new
191191
commits.
192192

193-
194-
195193
### Spectrogram contours
196194

197-
Spectrogram processing tasks honor `DJANGO_BATAI_SAVE_SPECTROGRAM_CONTOURS` environment variable.
195+
Spectrogram processing tasks honor `DJANGO_BATAI_SAVE_SPECTROGRAM_CONTOURS` environment variable.
198196
Set to `False` by default so workers skip contour extraction (less DB storage space); set to `True` if you need
199197
contours in the UI (UI for contours currently disabled due to performance)
198+
199+
### Species Suggestions by Range
200+
201+
The suggested species for a given location are determined by spatial data stored in `/bats_ai/core/data/species-range.geojson`.
202+
As part of the default migrations this data is ingested into the SpeciesRange database and used for determining suggested
203+
species based on a Recording (internal GRTS_Cell_ID and sample_frame_id).
204+
The if the same species is found multiple times in the geojson the last geometry will be used.
205+
In the future if species-ranges change the managment command of `./manage.py load_species_geojson [optional Geojson Path]`
206+
can be used to reload the default species-range.geojson
207+
if no path is provided or a new one and will update/replace any previous data.

bats_ai/core/admin/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .recording_tag import RecordingTagAdmin
1919
from .sequence_annotations import SequenceAnnotationsAdmin
2020
from .species import SpeciesAdmin
21+
from .species_range import SpeciesRangeAdmin
2122
from .spectrogram import SpectrogramAdmin
2223
from .spectrogram_image import SpectrogramImageAdmin
2324
from .user import UserAdmin
@@ -41,6 +42,7 @@
4142
"RecordingTagAdmin",
4243
"SequenceAnnotationsAdmin",
4344
"SpeciesAdmin",
45+
"SpeciesRangeAdmin",
4446
"SpectrogramAdmin",
4547
"SpectrogramImageAdmin",
4648
"UserAdmin",

bats_ai/core/admin/recording.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RecordingAdmin(admin.ModelAdmin):
3030
"comments",
3131
"recording_location",
3232
"grts_cell_id",
33-
"grts_cell",
33+
"sample_frame_id",
3434
"site_name",
3535
"detector",
3636
"software",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from __future__ import annotations
2+
3+
from django.contrib import admin
4+
from django.contrib.gis.admin import GISModelAdmin
5+
6+
from bats_ai.core.models import SpeciesRange
7+
8+
9+
@admin.register(SpeciesRange)
10+
class SpeciesRangeAdmin(GISModelAdmin):
11+
list_display = [
12+
"id",
13+
"species",
14+
"source_feature_id",
15+
]
16+
list_select_related = ["species"]
17+
search_fields = [
18+
"species__species_code",
19+
"species__common_name",
20+
"source_feature_id",
21+
]
22+
autocomplete_fields = ["species"]
23+
ordering = ["species__species_code"]

0 commit comments

Comments
 (0)