-
Notifications
You must be signed in to change notification settings - Fork 0
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
Interpolate and group ais #8
base: master
Are you sure you want to change the base?
Conversation
# then apply an interpolation function for each timepoint. The | ||
# interpolation function will take a dataframe and a timepoint, | ||
# and will determine, based on the nearest records before/after | ||
# the timepoint, which interpolation rule to apply. | ||
# | ||
# While this function sounds like it takes a long time, its ok at | ||
# the outset to accomplish this somewhat inefficiently. | ||
mmsi_set = ais_df.groupby["mmsi"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groupby is a function, needs parentheses (e.g. groupby("mmsi")
)
Also, be careful naming things *_set
when they're not a set object. Try mmsi_gb
since this is a groupby object.
MWM: "near" = entries before and after the given time, | ||
"very near" = one entry within a neighborhood of the given time | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the point of this is. These aren't definitions, despite the equals sign. These are cases when each term is used.
time: when to interpolate the ship positions. | ||
delta: the "very near" threshold | ||
""" | ||
time_col = mmsi["BaseDateTime"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try something like this, but faster:
for target_time in times:
last_before = max(obs_time - target_time for obs_time in time_col if obs_time < target_time)
first_after = min(obs_time - target_time for obs_time in time_col if obs_time > target_time)
if (
last_before
and target_time - last_before < near
and first_after
and first_after - target_time < near
):
# C1
elif last_before and target_time - last_before < very_near:
# C2
elif first_after and first_after - target_time < very_near:
# C2
time: when to interpolate the ship positions. | ||
delta: the "very near" threshold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to do this for a list of times, so either _interpolate_and_group_ais()
needs to apply this to each time, or _ais_interpolator_dispatcher()
needs to take a list of times.
Also, you need deltas for the "near" and "very near" thresholds.
from tehom import downloads, _persistence | ||
|
||
|
||
def test_download_ais_to_temp(declare_stateful): | ||
year = 2014 | ||
month = 1 | ||
zone = 1 | ||
downloads._download_ais_to_temp(year, month, zone) | ||
path = _persistence.AIS_TEMP_DIR / f"{year}_{month}_{zone}.zip" | ||
assert path.exists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong branch
c4a4ca6
to
d66326a
Compare
No description provided.