Skip to content
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

an issue with extracting westward trajectories #252

Open
HzFWQhvevm4s opened this issue Oct 25, 2024 · 0 comments
Open

an issue with extracting westward trajectories #252

HzFWQhvevm4s opened this issue Oct 25, 2024 · 0 comments

Comments

@HzFWQhvevm4s
Copy link

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant