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

Examples should plot without using any Oceananigans functions #1405

Closed
ali-ramadhan opened this issue Feb 26, 2021 · 5 comments
Closed

Examples should plot without using any Oceananigans functions #1405

ali-ramadhan opened this issue Feb 26, 2021 · 5 comments
Labels
documentation 📜 The sacred scrolls

Comments

@ali-ramadhan
Copy link
Member

Take the 1D diffusion example: https://clima.github.io/OceananigansDocumentation/stable/generated/one_dimensional_diffusion/

This is the plotting code:

using JLD2

file = jldopen(simulation.output_writers[:temperature].filepath)

iterations = parse.(Int, keys(file["timeseries/t"]))

anim = @animate for (i, iter) in enumerate(iterations)

    T = file["timeseries/T/$iter"][1, 1, :]
    t = file["timeseries/t/$iter"]

    plot(T, z, linewidth=2, title=@sprintf("t = %.3f", t),
         label="", xlabel="Temperature", ylabel="z", xlims=(0, 1))
end

But where did z come from? From z = znodes(model.tracers.T) some lines above.

But what if I want to plot in a separate script? Or what if I run my simulation on a cluster and want to plot some data on a different machine?

One solution would be to use z = file["grid/zC"]. However, users may be surprised to learn that this output is not sliced and includes halos though (#1194) so many plotting libraries will error because of some dimension mismatch.

So if you don't have access to the grid then you can't plot the coordinates correctly without wrangling with file["grid"] (which requires users to know about halos). And users may want to plot using other programming languages and libraries/programs where you can't get access to an Oceananigans grid.


I guess I'm advocating for plotting without using any Oceananigans functions to make the examples more useful for users.

We can make the plotting code more local which would make it more copy-paste-able for users (more user friendly).

@ali-ramadhan ali-ramadhan added the documentation 📜 The sacred scrolls label Feb 26, 2021
@glwagner
Copy link
Member

glwagner commented Mar 2, 2021

This could conflict with the idea that users "shouldn't have to know about the staggered grid" --- or maybe I am missing something?

We could maybe solve both problems by interpolating output to an output grid. Interpolated data might be more friendly; "native" data is perhaps needed only for more advanced / scientific applications. Certainly as grids get more complicated we will probably make use of interpolated output more and more.

@francispoulin
Copy link
Collaborator

Hmmm, since the data is produced in Oceananigans it seems reasonable to me that one would use part of the library. Having said that, having been a new user not so long ago, I remember thinking it was a bit confusing since I didn't know what the library did. Maybe the idea of plotting things using NetCDF only might be helpful for those who know it already?

@navidcy
Copy link
Collaborator

navidcy commented Mar 2, 2021

Isn't to something like this where a Plot recipe comes handy?

@glwagner
Copy link
Member

glwagner commented Mar 2, 2021

Perhaps, but that only works in julia and would seem to count as an "Oceananigans function"?

@glwagner
Copy link
Member

I'm closing this issue because I'm judging that it's not of current, timely relevance to Oceananigans development. If you would like to make it a higher priority or if you think the issue was closed in error please feel free to re-open.

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

No branches or pull requests

4 participants