Skip to content

Commit

Permalink
Do not consider incomplete guider measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Aug 13, 2023
1 parent a2142be commit 3c838ed
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/gort/devices/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,22 @@ async def _monitor_task(self, timeout: float = 30):
# Sort by frameno.
df = df.sort_values("frameno")

if "fwhm" not in df or "separation" not in df:
# Remove NaN rows.
df = df.dropna()

now = datetime.datetime.utcnow()
time_range = now - pandas.Timedelta(f"{timeout} seconds")
time_data = df.loc[df.time > time_range, :]

if (
len(time_data) == 0
or "fwhm" not in time_data
or "separation" not in time_data
):
continue

# Calculate and report last.
last = df.tail(1)
last = time_data.tail(1)
sep_last = round(last.separation.values[0], 3)
fwhm_last = round(last.fwhm.values[0], 2)
mode_last = last["mode"].values[0]
Expand All @@ -302,13 +313,7 @@ async def _monitor_task(self, timeout: float = 30):
"info",
)

# Remove NaN rows.
df = df.dropna()

# Calculate and report averages.
now = datetime.datetime.utcnow()
time_range = now - pandas.Timedelta(f"{timeout} seconds")
time_data = df.loc[df.time > time_range, :]
sep_avg = round(time_data.separation.mean(), 3)
fwhm_avg = round(time_data.fwhm.mean(), 2)
self.write_to_log(
Expand Down

0 comments on commit 3c838ed

Please sign in to comment.