Skip to content

Conversation

gauteh
Copy link
Member

@gauteh gauteh commented Nov 12, 2024

For plotting elevation energy spectra.

  • This may have to be a dataset accessor because otherwise we do not have access to the time coordinate.
  • In the future this may go into a separate package. But as long as we use the same accessor name the API should be the same for users.
    csv_in = test_data / 'csv/omb3.csv'
    ds = read_omb_csv(csv_in)
    print(ds)
    print(ds.elevation_energy_spectrum)
    print(ds.frequencies_waves_imu)

    plt.figure()
    ds.isel(trajectory=0).elevation_energy_spectrum.wave.plot(
        ds.isel(trajectory=0).time_waves_imu.squeeze())

    if plot:
        plt.show()

    plt.close('all')

Solves #134

@jerabaul29
Copy link
Collaborator

@gauteh I am not used too much to pushing commits on someone else's branch; if I should do this another way, just let me know :) .

@gauteh
Copy link
Member Author

gauteh commented Nov 12, 2024

This is the way to do it!

@jerabaul29
Copy link
Collaborator

note:

  • this is probably soon ok to merge as a "feature addition"; for example, this should already more or less fix the need of @hevgyrt :) . I can add a few more tweaks so this looks a bit more like the original spectrum plots.

  • @gauteh I guess that you would like https://github.com/OpenDrift/trajan/blob/main/trajan/plot/spectra.py to be removed, right? Otherwise, there is duplicated functionality between the "accessor" based and the "free function" way of doing this plot? :)

@gauteh
Copy link
Member Author

gauteh commented Nov 12, 2024

Yep, you remove the old one. I think it is ready to merge. In the future we may have to move it up to dataset level, alternatively use to_1d after selecting trajectory and then plotting (then the times variable won't be necessary).

@jerabaul29
Copy link
Collaborator

(a couple more commits landing soon :) )

@jerabaul29
Copy link
Collaborator

jerabaul29 commented Nov 28, 2024

@gauteh this seems to work now, except for the docs building.

About the doc building: it looks like the error is due to:

plot.spectra.plot_trajan_spectra

which is true has disappeared as I cleaned up old code.

The strange thing is that it looks like / I would have thought that this file should be re-generated and updated automatically by the CI/CD, right? I.e. I can edit this file by hand if you want, but this is probably not the intended behavior, maybe something that has a problem with how the doc building is run? Is this fixed on main and maybe a lingering bug from this branch, that will disappear at merge? Or a bug on main too that needs to be fixed (here or separately)? If so, should we merge? :)

@jerabaul29
Copy link
Collaborator

But I think that otherwise this should be more or less ready to merge? :)

@jerabaul29
Copy link
Collaborator

@knutfrode I edited the doc api.rst by hand as we discussed, the CICD is green again :) .

@knutfrode
Copy link
Contributor

Good, then I merge now.

@knutfrode knutfrode merged commit fcedbb8 into OpenDrift:main Nov 28, 2024
12 checks passed
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

Successfully merging this pull request may close these issues.

3 participants