Skip to content

Commit

Permalink
indent issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgitonga authored Sep 17, 2023
1 parent 8c200e6 commit 423d896
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions ecoscope/io/earthranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,56 +676,56 @@ def get_patrol_observations(self, patrols_df, patrol_type=None, include_patrol_d
relocations : ecoscope.base.Relocations
"""

observations = []
for _, patrol in patrols_df.iterrows():
for patrol_segment in patrol["patrol_segments"]:
subject_id = (patrol_segment.get("leader") or {}).get("id")
patrol_start_time = (patrol_segment.get("time_range") or {}).get("start_time")
patrol_end_time = (patrol_segment.get("time_range") or {}).get("end_time")
observations = []
for _, patrol in patrols_df.iterrows():
for patrol_segment in patrol["patrol_segments"]:
subject_id = (patrol_segment.get("leader") or {}).get("id")
patrol_start_time = (patrol_segment.get("time_range") or {}).get("start_time")
patrol_end_time = (patrol_segment.get("time_range") or {}).get("end_time")

if None in {subject_id, patrol_start_time}:
continue
if None in {subject_id, patrol_start_time}:
continue

try:
observation = self.get_subject_observations(
subject_ids=[subject_id],
since=patrol_start_time,
until=patrol_end_time
)
if include_patrol_details:
observation["patrol_id"] = patrol["id"]
observation["patrol_serial_number"] = patrol["serial_number"]
observation["patrol_start_time"] = patrol_start_time
observation["patrol_end_time"] = patrol_end_time
observation["patrol_type"] = patrol_type
observation = (
observation.reset_index()
.merge(
pd.DataFrame(self.get_patrol_types()).add_prefix("patrol_type__"),
left_on="patrol_type",
right_on="id"
)
.drop(
columns=[
"patrol_type__ordernum",
"patrol_type__icon_id",
"patrol_type__default_priority",
"patrol_type__is_active"
]
try:
observation = self.get_subject_observations(
subject_ids=[subject_id],
since=patrol_start_time,
until=patrol_end_time
)
if include_patrol_details:
observation["patrol_id"] = patrol["id"]
observation["patrol_serial_number"] = patrol["serial_number"]
observation["patrol_start_time"] = patrol_start_time
observation["patrol_end_time"] = patrol_end_time
observation["patrol_type"] = patrol_type
observation = (
observation.reset_index()
.merge(
pd.DataFrame(self.get_patrol_types()).add_prefix("patrol_type__"),
left_on="patrol_type",
right_on="id"
)
.drop(
columns=[
"patrol_type__ordernum",
"patrol_type__icon_id",
"patrol_type__default_priority",
"patrol_type__is_active"
]
)
)
)
observations.append(observation)
observations.append(observation)

except Exception as e:
print(
f"Getting observations for subject_id={subject_id} start_time={patrol_start_time}"
f"end_time={patrol_end_time} failed for: {e}"
)
except Exception as e:
print(
f"Getting observations for subject_id={subject_id} start_time={patrol_start_time}"
f"end_time={patrol_end_time} failed for: {e}"
)

df = ecoscope.base.Relocations(pd.concat(observations))
if include_patrol_details:
return df.set_index("id")
return df
df = ecoscope.base.Relocations(pd.concat(observations))
if include_patrol_details:
return df.set_index("id")
return df

def get_patrol_segment_events(
self,
Expand Down

0 comments on commit 423d896

Please sign in to comment.