-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Hello,
I have a data frame (df
) for in-situ profiles with date, lon, lat, and other information.
My current objective is to add columns to this data frame, on the basis of a set of eddy tracks.
- Is the float within an eddy contour? YES/NO
- Lon, Lat for the eddy center,
- Radius and Age (lifetime) of this eddy.
I'm not entirely sure how to address that.
My first approach was to loop on days, subset both the in situ data frame and the eddies collection, and then use the inside
function. With the following code, I can determine if a given profile is within any eddy identified for that day.
ta1 = TrackEddiesObservations.load_file("../out_"+set1+"/Tracks_Overlap/Anticyclonic.nc")
dmin=ta1.time.min()
dmax=ta1.time.max()
for d in range(dmin,dmax):
a1=ta1.extract_with_period((d,d))
dfsub = df[df["time"]==d]
for dl in dfsub.iterrows():
isin = a1.inside(x=np.array([dl[1].longitude], dtype=np.float64), y=np.array([dl[1].latitude], dtype=np.float64))
if isin:
....
However I have difficulties to get the index of the eddy for wich the condition is true, and then access the relevant info.
Should I loop over all eddies in ´a1´ ?
How can this be done?
I guess I just need a few general guidance, in particular regarding indexing through the TrackEddiesObservations objects.
PS: I guess looping on days isn't strictly necessary here, but it was also done for visualization reasons.
Thanks !