Skip to content

Commit

Permalink
remove remaining collar voltage code from core library (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgitonga authored Dec 13, 2023
1 parent 26cdc44 commit f32b721
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 280 deletions.
23 changes: 0 additions & 23 deletions ecoscope/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,6 @@ def pack_columns(dataframe: pd.DataFrame, columns: typing.List):
return dataframe


def extract_voltage(s: typing.Dict):
"""
Extracts voltage from different source-provider in EarthRanger
Parameters
----------
s: typing.Dict
Returns
-------
typing.Any
"""
additional = s["extra__observation_details"] or {}
voltage = additional.get("battery", None) # savannah tracking
if not voltage:
voltage = additional.get("mainVoltage", None) # vectronics
if not voltage:
voltage = additional.get("batt", None) # AWT
if not voltage:
voltage = additional.get("power", None) # Followit
return voltage


def download_file(url, path, overwrite_existing=False, chunk_size=1024, **request_kwargs):
r = requests.get(url, stream=True, **request_kwargs)

Expand Down
2 changes: 0 additions & 2 deletions ecoscope/plotting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from ecoscope.plotting.plot import (
EcoPlotData,
add_seasons,
collar_event_timeline,
ecoplot,
mcp,
nsd,
Expand All @@ -12,7 +11,6 @@
__all__ = [
"EcoPlotData",
"add_seasons",
"collar_event_timeline",
"ecoplot",
"mcp",
"nsd",
Expand Down
44 changes: 0 additions & 44 deletions ecoscope/plotting/plot.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import logging
import os
import uuid

import numpy as np
import pandas as pd
import plotly.graph_objs as go
import shapely
from plotly.subplots import make_subplots
from sklearn.neighbors import KernelDensity

from ecoscope.io.utils import extract_voltage

logger = logging.getLogger(__name__)


class EcoPlotData:
def __init__(self, grouped, x_col="x", y_col="y", groupby_style=None, **style):
Expand Down Expand Up @@ -158,42 +150,6 @@ def add_seasons(fig, season_df):
return fig


def collar_event_timeline(relocations, collar_events):
fig = go.FigureWidget()

ys = [0]
if not collar_events.empty:
times = collar_events["time"].to_list()
times.append(relocations["fixtime"][-1])
xs = [[times[i]] * 3 + [times[i + 1]] for i in range(len(collar_events))]
ys = [[0, i + 1, 0, 0] for i in range(len(collar_events))]
colors = collar_events["colors"]

for x, y, color in zip(xs, ys, colors):
fig.add_trace(go.Scatter(x=x, y=y, line_color=color))
fig.update_layout(
annotations=[
go.layout.Annotation(x=row.time, y=i, text=f"{row.event_type}<br>{row.time.date()}")
for i, (_, row) in enumerate(collar_events.iterrows(), 1)
]
)

x = relocations.fixtime
y = np.full(len(x), np.max(ys) / 10)
fig.add_trace(go.Scatter(x=x, y=y, line_color="rgb(0,0,255)", mode="markers", marker_size=1))

fig.update_layout(
margin_l=0,
margin_r=0,
margin_t=0,
margin_b=15,
yaxis_visible=False,
showlegend=False,
)

return fig


def mcp(relocations):
relocations = relocations.to_crs(relocations.estimate_utm_crs())

Expand Down
10 changes: 3 additions & 7 deletions notebooks/01. IO/EarthRanger_IO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"tags": []
},
Expand Down Expand Up @@ -644,9 +644,7 @@
"metadata": {},
"outputs": [],
"source": [
"spatial_feature = er_io.get_spatial_feature(\n",
" spatial_feature_id=\"8868718f-0154-45bf-a74d-a66706ef958f\"\n",
" )\n",
"spatial_feature = er_io.get_spatial_feature(spatial_feature_id=\"8868718f-0154-45bf-a74d-a66706ef958f\")\n",
"spatial_feature"
]
},
Expand All @@ -663,9 +661,7 @@
"metadata": {},
"outputs": [],
"source": [
"spatial_features = er_io.get_spatial_features_group(\n",
" spatial_features_group_id=\"15698426-7e0f-41df-9bc3-495d87e2e097\"\n",
" )\n",
"spatial_features = er_io.get_spatial_features_group(spatial_features_group_id=\"15698426-7e0f-41df-9bc3-495d87e2e097\")\n",
"spatial_features"
]
},
Expand Down
204 changes: 0 additions & 204 deletions notebooks/06. Data Management/Collar Voltage.ipynb

This file was deleted.

0 comments on commit f32b721

Please sign in to comment.