-
Notifications
You must be signed in to change notification settings - Fork 127
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
Julia example #1240
Julia example #1240
Conversation
please merge the latest |
Great contribution, this will make Julia support more visible!
I think you can use the json library to write the provenance, since json is a subset of yaml. |
Regarding the code style, it would be nice if you could use more functions, even if it's just creating a |
Thanks for the suggestion @bouweandela , indeed I considered it at the beginning but then I chose another approach. I now changed to code to use JSON.jl and indeed it works fine. |
Ok, I added a "compute_diagnostic" function which is called by the main script. For now the main script is still that, a script. Still, please notice that it is enclosed in |
Sorry for the slow reply. I have preference for a |
Hi @bouweandela , sorry I was even slower in reacting to this. The diagnostic is now using a main() function as requested. Please let me know what you think. Cheers. |
Hi Jost, looks great to me. Maybe it would be nice if you could add some example code that reads the netcdf file and creates a plot, just to get people started and make them aware of the preferred libraries to use for this. If you don't have time for this now, we can also merge as is. Also a mention of the example script in the documentation would be nice, e.g. in doc/sphinx/source/esmvaldiag/new_diagnostic.rst? |
Sure @bouweandela I will try and add these things asap |
Hi @bouweandela , the example is now much more sophisticated, as it reads a netcdf file, computes a temporal average, writes this as output file and produces a nice plot. The only thing which is not working as expected is provenance: my |
PS: since plotting a map is a general issue, I added a function for this in diag_scripts/shared/external.jl or would it be better for it to have its own file like diag_scripts/shared/plotmap.jl ? |
I added a reference to the julia example in doc/sphinx/source/esmvaldiag/new_diagnostic.rst |
Hi @bouweandela please see my latest changes above, what do you think (in particular for the documentation changes)? After merging the latest version2_development now this branch also passes al tests. Cheers |
Hi @jhardenberg Thank you for all the updates, I think this now provides a much nicer example to get started.
Thanks, this is great.
Yes, that would be good.
It seems to work ok-ish: the provenance does get embedded in the .png file. It might be nicer to make a separate provenance record for the plot file (re: our earlier discussion about the plot_file attribute and whether or not this is a good design, should support multiple plots etc.), since I do not expect to have much time to improve this in the foreseeable future and that way the .xml files will also get generated.
Both is fine, when we have more plotting functions at some point it might make sense to put them together in a separate file. |
Are there no native Julia libraries for plotting a map? |
This PR implements an example diagnostic in pure Julia which was missing and which can serve as a base for further Julia diagnostics. Provenance logging is included (since no library provides this I had to write a small YAML writer in
diag_scripts/shared/external.jl
). Resolves #1238