-
Notifications
You must be signed in to change notification settings - Fork 41
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
New method to fetch data along a given trajectory #169
Comments
@gmaze This would be a great feature and is actually the reason why issue #168 came up: I was querying the index file too often because I was looking for near-by floats along a specific float's trajectory by using: argo = ArgoDataFetcher().profile(WMO,profnumber).to_xarray()
d = {'profile_number': argo.CYCLE_NUMBER,
'PSAL': argo.PSAL,
'TEMP': argo.TEMP,
'PRES': argo.PRES,
'time': argo.TIME,
'lon': argo.LONGITUDE,
'lat': argo.LATITUDE,
}
df = pd.DataFrame(data=d)
argo = argo_loader.region([df.lon[0]-.5, df.lon[0]+.5, df.lat[0]-.5, df.lat[0]+.5, 1500, 2100, '2020-01-01', '2022-01-01']).to_xarray()
d = {'profile_number': argo.CYCLE_NUMBER,
'PSAL': argo.PSAL,
'TEMP': argo.TEMP,
'PRES': argo.PRES,
'time': argo.TIME,
'lon': argo.LONGITUDE,
'lat': argo.LATITUDE,
'WMO': argo.PLATFORM_NUMBER
}
sbe = pd.DataFrame(data=d) where df.lon[0] is the longitude of the float of interest at a specific profile. The additional variables are also a great touch, I currently add the absolute distance from the reference profile using sbe['dist'] = hs.haversine((df.lat[0],df.lon[0]),(sbe.lat[ii],sbe.lon[ii])) CaveatsSome thoughts should be put into avoiding duplicates, otherwise the array could unnecessarily grow. sbe.drop(sbe[sbe['WMO'] == int(WMO)].index, inplace = True) |
Great ! Avoiding duplicates may indeed be included 👍 |
I tried the following code to fetch data in a 2 years, 1x1 degree box around each profiles. WMO = [6903075]
profnumber = np.arange(2,10)
fetcher = ArgoDataFetcher(cache=True).profile(WMO, profnumber)
argo_ds = fetcher.to_xarray()
argo_ds = argo_ds.argo.point2profile()
fig, ax = plt.subplots(nrows=1, ncols=1)
ax.plot(argo_ds['LONGITUDE'], argo_ds['LATITUDE'], 'r+-', markersize=12)
for i_prof in argo_ds['N_PROF']:
this_prof = argo_ds.sel(N_PROF=i_prof)
lon = this_prof['LONGITUDE'].values[np.newaxis][0]
lat = this_prof['LATITUDE'].values[np.newaxis][0]
tim = this_prof['TIME'].values[np.newaxis][0]
bbox = list(np.add([lon, lon, lat, lat, 1500, 2000, tim, tim],
[-.5, .5, -.5, .5, 0, 0, -np.timedelta64(12*30, 'D'), np.timedelta64(12*30, 'D')]))
bbox[-1] = pd.to_datetime(str(bbox[-1])).strftime('%Y%m%d%H%M')
bbox[-2] = pd.to_datetime(str(bbox[-2])).strftime('%Y%m%d%H%M')
try:
fetcher = ArgoDataFetcher(cache=True, ds='phy').region(bbox)
local_ds = fetcher.load().data
local_ds = local_ds.argo.point2profile()
except Exception:
print(fetcher.uri)
pass
ax.plot(local_ds['LONGITUDE'], local_ds['LATITUDE'], 'k.')
ax.hlines(bbox[2:4], bbox[0], bbox[1], color='black', linewidth=0.5)
ax.vlines(bbox[0:2], bbox[2], bbox[3], color='black', linewidth=0.5)
ax.text(lon, lat+0.01, '%i' % this_prof['CYCLE_NUMBER'], horizontalalignment='center')
ax.grid()
ax.set_title(WMO) Clearly, the overlapping boxes is something we should avoid |
|
Something like that is in the works for ERDDAP and should be in the next version. However, that won't help much here b/c we don't know when the argo ERDDAP server would be updated and argopy supports multiple sources of data that are non-ERDDAP. Anyway, just wanted to mention that at least this may be easier in the future. |
A polygon selection would be useful for some application I reckon. For the problem here (i.e., fetching data along a float's trajectory), I thought that filtering out duplicates would suffice. It would solve the issue of overlapping boxes, wouldn't it? The only problem it adds is how to reference the profiles to one another (as in, one profile could be in 2 boxes). I tried to draw it as an example to be clearer: Float 1 is easy - no problem there Does that make sense? |
Indeed, but at the expense of generating more data transfer than necessary, since all the post-processing/filtering would be done on the client side, I would try to avoid this Not sure this would be much of a problem if the time range is reasonable though |
Nice draw !! 😸
This issue would be solved by the distance metric I guess |
This issue was marked as staled automatically because it has not seen any activity in 90 days |
This issue was marked as staled automatically because it has not seen any activity in 90 days |
This issue was closed automatically because it has not seen any activity in 365 days |
This issue was marked as staled automatically because it has not seen any activity in 90 days |
Motivation
For some Argo data analysis it could be useful to be able to fetch data
around
some specific locations, eg:compare some float data with neighbor floats (any QC would do this, but also sensor dev. see eg from @matdever Discrepancy between argopy.status() and status page #168 )
co-localise Argo float profiles with some Huricane path (eg here from Kim Wood )
it could be useful to have an access point that directly fetch this.
API for new access point
It could look like this:
This new access point, could in fact take a path or trajectory as input:
Further
Note this API could easily be plugged into the
argo
access point:The text was updated successfully, but these errors were encountered: