source: trunk/UTIL/PYTHON/planetoplot_v2/examples/meso_profile.py @ 910

Last change on this file since 910 was 910, checked in by aslmd, 12 years ago

PLANETOPLOT v2


  1. Spiga LMD/UPMC 24/03/2013

Contents


core


  • ppclass.py --> main class with pp() objects (need ppplot and ppcompute)
  • ppplot.py --> plot class (can be used independently, need ppcompute)
  • ppcompute.py --> computation class (can be used independently)

scripts


  • pp.py --> command line utility to use ppclass
  • pp_reload.py --> command line utility to load saved plot objects *.ppobj
  • example/* --> example scripts using ppclass

settings files


  • set_area.txt --> setting file: predefined areas for plotting (can be omitted)
  • set_back.txt --> setting file: predefined backgrounds for plotting (can be omitted)
  • set_multiplot.txt --> setting file: predefined coefficients for multiplots (can be omitted)
  • set_ppclass.txt --> setting file: predefined variables for x,y,z,t (can be omitted)
  • set_var.txt --> setting file: predefined colorbars, format, labels, etc... for variables (can be omitted)

documentation


  • README.TXT --> this README file

data


  • demo_data/* --> plot objects for a demonstration tour and customizing tests

Requirements


python + numpy + matplotlib + netCDF4

  • for mapping --> Basemap
  • for scientific computations --> scipy

[recommended: Enthought Python Distribution (free for academics)]

Installation


  • install required softwares and librairies in requirements
  • add planetoplot_v2 in your PYTHONPATH environment variable (and in your PATH to use pp.py)

Take a demo tour


pp_reload.py demo_data/*

Improvements compared to v1


  • code readability and structuration for future improvements
  • modularity (class formulation) + easy definition/addition of attributes
  • separation between data retrieval and plotting
  • versatility + command line (pp.py)

--> for quick inspection

+ interactive session (ipython)

--> for testing and exploring

+ scripts

--> for powerful and fully customized results

  • performance (overall and on large files) + memory consumption (only retrieve what is needed)
  • saving/loading plot objects in/from *.ppobj
  • plot aesthetics and customizing (see header in ppplot)
  • multiplot flexibility with .plotin attribute
  • easy definition of presets with set_*.txt files
  • function: one field vs. another one
  • emulation of + - / * operations on fields (between two fields or between a field and a int/float)
  • computations of min/max in addition to mean
  • simple inspection of dimensions+variables in a file (pp.py -f file)
  • verbose / non verbose mode

Acknowledgements


Thanks to A. Colaitis, T. Navarro, J. Leconte
for feedbacks and contributions on version 1

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#! /usr/bin/env python
2from ppclass import pp
3
4# define object, file, var
5m = pp()
6m.file = "/home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00:00:00"
7m.var = "W"
8
9# define dimensions
10m.x = "136.,139." # computing over x interval
11m.y = -5. # setting a fixed y value
12m.z = None # leaving z as a free dimension
13m.t = [6.,12.,18.,24.] # setting 4 fixed t values
14
15# define settings
16m.superpose = True # superpose 1D plots
17#m.verbose = True # making the programe verbose
18#m.out = "pdf" # output format
19
20# get data and make plot with default settings
21m.getplot()
22
23# get potential temperature at same point.
24# don't plot it. do an operation on it.
25tpot = pp()
26tpot << m
27tpot.var = "T"
28tpot.get()
29tpot = tpot + 220.
30
31# get geopotential at same point.
32# don't plot it. do an operation on it (to get height).
33geop = pp()
34geop << m
35geop.var = "PHTOT"
36geop.get()
37z = geop/3.72/1000.
38
39# define potential temperature as a function of height
40S = tpot.f(z)
41
42# change a few plot settings
43for curve in S.p: 
44    curve.lstyle = "--"
45    curve.marker = ""
46S.p[0].swaplab = False
47S.p[0].ylabel="Geopotential height (km)"
48S.p[0].xlabel="Potential temperature (K)"
49
50# make the plot
51S.makeplot()
Note: See TracBrowser for help on using the repository browser.