User Tools

Site Tools


other:python:jyp_steps

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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:36]
jypeter [Matplotlib]
Line 175: Line 175:
  
 <note important>​ <note important>​
-The full content of this //​matplotlib//​ section has been moved to\\ [[other:​python:​matplotlib_by_jyp|Working with matplotlib (JYP version)]]\\ after becoming too big to manage here</​note>​+The full content of this //​matplotlib//​ section has been moved to\\ [[other:​python:​matplotlib_by_jyp|Working with matplotlib (JYP version)]]\\ after becoming too big to manage here 
 + 
 +\\ Note: [[other:​python:​maps_by_jyp|Plotting maps with matplotlib+cartopy]] (examples provided by JYP) 
 +</​note>​
  
 Summary: there are lots of python libraries that you can use for plotting, but Matplotlib has become a //de facto// standard Summary: there are lots of python libraries that you can use for plotting, but Matplotlib has become a //de facto// standard
Line 228: Line 231:
  
 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 262:
 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 ====
  
other/python/jyp_steps.txt · Last modified: 2024/03/07 10:15 by jypeter