This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
other:python:jyp_steps [2019/11/18 11:04] jypeter Replaced files links with sharebox links |
other:python:jyp_steps [2020/02/04 08:33] jypeter [Cartopy + Iris] |
||
---|---|---|---|
Line 228: | Line 228: | ||
Examples: | Examples: | ||
+ | * [[other:python:maps_by_jyp|Examples provided by JYP]] | ||
* [[http://scitools.org.uk/cartopy/docs/latest/gallery.html|Gallery on the Cartopy web site]] | * [[http://scitools.org.uk/cartopy/docs/latest/gallery.html|Gallery on the Cartopy web site]] | ||
* [[http://scitools.org.uk/iris/docs/latest/gallery.html|Gallery on the Iris web site]] | * [[http://scitools.org.uk/iris/docs/latest/gallery.html|Gallery on the Iris web site]] | ||
Line 258: | Line 259: | ||
We list here some resources about non-NetCDF data formats that can be useful | We list here some resources about non-NetCDF data formats that can be useful | ||
+ | ==== The shelve package ==== | ||
+ | |||
+ | The [[https://docs.python.org/3/library/shelve.html|built-in shelve package]], can be easily used for storing data (python objects like lists, dictionaries, numpy arrays that are not too big, ...) on disk and retrieving them later | ||
+ | |||
+ | Use case: | ||
+ | - Use a script do to the heavy data pre-processing and store the (intermediate) results in a file using ''shelve'', or update the results | ||
+ | - Use another script for plotting the results stored with ''shelve''. This way you don't have to wait for the pre-processing step to finish each time you want to improve your plot(s) | ||
+ | |||
+ | Warning: | ||
+ | * read the [[https://docs.python.org/3/library/shelve.html|documentation]] and the example carefully (it's quite small) | ||
+ | * if you get the impression that the data is not saved correctly, re-read the parts about updating correctly the content of the shelve file | ||
+ | * you should be able to store most python objects in a shelve file, but it is safer to make tests | ||
+ | * do not forget to close the output file | ||
+ | * if you are dealing with big arrays and want to avoid performance issues, you should use netCDF files for storing the intermediate results | ||
==== json files ==== | ==== json files ==== | ||