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

Generate lat/lon variable for wave spectra #135

Open
hevgyrt opened this issue Nov 12, 2024 · 4 comments
Open

Generate lat/lon variable for wave spectra #135

hevgyrt opened this issue Nov 12, 2024 · 4 comments

Comments

@hevgyrt
Copy link

hevgyrt commented Nov 12, 2024

Comparing observed and modeled wave spectra, it would be convenient to have the lat/lon variables on the spectra.

The way I do it now is to find the obs indexes closest to the time_waves_imu values like

obs_ids = []
for i in range(subset.obs_waves_imu.size):
    if np.isfinite(subset.time_waves_imu.values[i]):
        diff = np.abs(subset.time.values-subset.time_waves_imu.values[i])
        obs_ids.append(np.argmin(diff[np.isfinite(diff)]))

Is there a method already taking care of this? Or could you simply add two variables called lon_waves, lat_waves

@jerabaul29
Copy link
Collaborator

You can use this branch if you want, and re-generate the .nc file using the corresponding code:

#104

As we looked together at your data, your current method is fine, but agree that having something more robust and built into trajan would be good :) .

@gauteh this is a quite typical need (@hevgyrt is the third person who takes contact about this regarding the OMB). Given that my branch adds the interpolation function very loosely (it does not "contaminate" much of the codebase), and that it is used in the OMB decoder which is also quite loosely a part of trajan, do you think that #104 could be considered again? :)

@gauteh
Copy link
Member

gauteh commented Nov 12, 2024

Hi, I added an example for how to do this in #136. I am not sure #104 is the way to go yet (sorry), I want to be pretty sure before merging because it is so difficult to walk this back once people start using it.

By the way, I do think that it would be nice to have ready gridobs() to avoid the groupby in in #136. Even though it is pretty short and easy to do in xarray, it is a bit too advanced for a very common operation. Maybe we can do this with:

ds.traj.gridobs('obs_imu_waves')

and if you want to go all the way to 1d gridded you can do:

ds.traj.gridobs('obs_imu_waves').traj.gridtime(obsdim='obs_imu_waves', time='1H')

@jerabaul29
Copy link
Collaborator

No problem @gauteh :) .

I think that #104 and #136 "speak" actually of one part about the technicalities that is similar, but also one part about the "signal processing" choice that is quite different: see the discussion in #104 (comment) .

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

3 participants