-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Description
Hello, I've been trying to extract westward eddy trajectories with a longitude span over 10 degrees, but it ends up extracting those with a span between -10.0 and 0.0(-10.0 ≤ delta_lon ≤ 0.0), so I took a look at the source code and noticed that there might be something causing the issue:
py-eddy-tracker/src/py_eddy_tracker/observations/tracking.py
Lines 366 to 385 in 3a54bbb
| def extract_toward_direction(self, west=True, delta_lon=None): | |
| """ | |
| Get trajectories going in the same direction | |
| :param bool west: Only eastward eddies if True return westward | |
| :param None,float delta_lon: Only eddies with more than delta_lon span in longitude | |
| :return: Only eastern eddy | |
| :rtype: __class__ | |
| .. minigallery:: py_eddy_tracker.TrackEddiesObservations.extract_toward_direction | |
| """ | |
| lon = self.longitude | |
| i0, nb = self.index_from_track, self.nb_obs_by_track | |
| i1 = i0 - 1 + nb | |
| d_lon = lon[i1] - lon[i0] | |
| m = d_lon < 0 if west else d_lon > 0 | |
| if delta_lon is not None: | |
| m *= delta_lon < d_lon | |
| m = m.repeat(nb) | |
| return self.extract_with_mask(m) |
my settings:
c.extract_toward_direction(west=True, delta_lon= -10.0)# let lon[i1] = -40.0, lon[i0] = -20.0
d_lon = lon[i1] - lon[i0]
# d_lon = -20.0
m = d_lon < 0 if west else d_lon > 0
# west = True, d_lon < 0 = True, m = True
if delta_lon is not None:
# True
m *= delta_lon < d_lon
# delta_lon < dlon = False, m= 0
m = m.repeat(nb)
# nb of points masked
return self.extract_with_mask(m) an alternative approach might be:
if delta_lon is not None:
m *= abs(delta_lon) < abs(d_lon)Best wishes,
lolcat
Metadata
Metadata
Assignees
Labels
No labels