Skip to content

Commit

Permalink
Merge pull request #93 from slacgismo/hotfix
Browse files Browse the repository at this point in the history
remove infinite while loop!
  • Loading branch information
bmeyers authored May 1, 2023
2 parents 3a10a93 + 2eb6d02 commit 49ebf22
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions solardatatools/time_axis_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from datetime import timedelta
import numpy as np
import pandas as pd
from scipy.stats import mode
from collections import Counter

TZ_LOOKUP = {
"America/Anchorage": 9,
Expand Down Expand Up @@ -196,18 +196,9 @@ def standardize_time_axis(
np.int64
) # Round to the nearest 10 seconds
# Find *all* common sampling frequencies
done = False
deltas = []
fltr = np.ones_like(diff, dtype=bool)
while not done:
for d in deltas:
fltr = np.logical_and(fltr, diff != d)
delta, count = mode(diff[fltr])
if count / len(diff) < 0.01 or len(delta) == 0:
done = True
else:
deltas.append(delta[0])
freq = deltas[0] # the number of seconds between each measurement
freq_counts = Counter(diff)
freq = freq_counts.most_common()[0][0]
deltas = [c[0] for c in freq_counts.most_common()]
if len(deltas) > 1:
if verbose:
print("CAUTION: Multiple scan rates detected!")
Expand Down

0 comments on commit 49ebf22

Please sign in to comment.