Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for No Surface detected index error #16

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
5 changes: 5 additions & 0 deletions study_lyte/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def get_signal_event(signal_series, threshold=0.001, search_direction='forward',
# if event_idx == 0:
# event_idx = None


return event_idx


Expand Down Expand Up @@ -201,6 +202,10 @@ def get_nir_surface(clean_active, threshold=-1, max_threshold=0.25):
# Detect likely candidate normal ambient conditions
surface = get_signal_event(neutral, search_direction='forward', threshold=threshold,
max_threshold=max_threshold, n_points=n)
# No surface found and all values met criteria
if surface == len(neutral)-1:
surface = 0

return surface


Expand Down
7 changes: 5 additions & 2 deletions study_lyte/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,14 @@ def nir(self):
Retrieve the Active NIR sensor with ambient NIR removed
"""
if self._nir is None:
self._nir = self.raw[["Sensor2","Sensor3", "nir"]]
self._nir = self.raw[["Sensor2", "Sensor3", "nir"]]
self._nir['depth'] = self.depth.values
end = self.stop.index if self.ground.index is None else self.ground.index

self._nir = self._nir.iloc[self.surface.nir.index:end].reset_index()
self._nir = self._nir.drop(columns='index')
self._nir['depth'] = self._nir['depth'] - self._nir['depth'].iloc[0]

return self._nir

@property
Expand Down Expand Up @@ -306,7 +308,8 @@ def surface(self):
if self._surface is None:
# Call to populate nir in raw
idx = get_nir_surface(self.raw['nir'])

if idx == 0:
LOG.warning("Unable to find snow surface, defaulting to first data point")
# Event according the NIR sensors
depth = self.depth.iloc[idx]
nir = Event(name='surface', index=idx, depth=depth, time=self.raw['time'].iloc[idx])
Expand Down
Loading
Loading