1 | #! /usr/bin/env python |
---|
2 | # ----------------------------------------------------------------------- |
---|
3 | # A very simple script to reload a previously saved plot array in ppclass |
---|
4 | # ... for a demo, try "pp_reload.py demo_data/*" |
---|
5 | # Author: A. Spiga 03/2013 |
---|
6 | # ----------------------------------------------------------------------- |
---|
7 | from optparse import OptionParser ### TBR by argparse |
---|
8 | from ppclass import pp |
---|
9 | from ppplot import rainbow |
---|
10 | # ----------------------------------------------------------------------- |
---|
11 | parser = OptionParser() |
---|
12 | parser.add_option('-O','--out',action='store',dest='out',type="string",default="gui",help='Specify a new output format') |
---|
13 | parser.add_option('-R','--res',action='store',dest='res',type="string",default=150.,help='Picture resolution') |
---|
14 | parser.add_option('-T','--title',action='store',dest='title',type="string",default=None,help='Give a new title') |
---|
15 | parser.add_option('-K','--marker',action='store',dest='marker',type="string",default=None,help="[1D] Define a new marker") |
---|
16 | parser.add_option('-P','--proj',action='store',dest='proj',type="string",default=None,help='[2D] Define a new map projection') |
---|
17 | parser.add_option('-C','--colorbar',action='store',dest='colorbar',type="string",default=None,help="[2D] Define a new colormap") |
---|
18 | parser.add_option('-E','--explore',action='store_true',dest='explore',default=False,help="[2D] Try many colormaps") |
---|
19 | (opt,args) = parser.parse_args() |
---|
20 | # ----------------------------------------------------------------------- |
---|
21 | clb = ["Greys","Blues","YlOrRd",\ |
---|
22 | "jet","spectral","hot",\ |
---|
23 | "RdBu","RdYlBu","Paired",\ |
---|
24 | "gist_ncar","gist_rainbow","gist_stern"] |
---|
25 | # ----------------------------------------------------------------------- |
---|
26 | |
---|
27 | for files in args: |
---|
28 | |
---|
29 | yeah = pp() |
---|
30 | yeah.quiet = True |
---|
31 | yeah.defineplot(loadfile=files) |
---|
32 | yeah.out = opt.out |
---|
33 | yeah.res = opt.res |
---|
34 | |
---|
35 | if opt.proj is not None: |
---|
36 | for plot in yeah.p: |
---|
37 | plot.proj = opt.proj |
---|
38 | if opt.colorbar is not None: |
---|
39 | yeah.colorbar = opt.colorbar |
---|
40 | for plot in yeah.p: |
---|
41 | plot.colorbar = opt.colorbar |
---|
42 | if opt.marker is not None: |
---|
43 | for plot in yeah.p: |
---|
44 | plot.marker = opt.marker |
---|
45 | if opt.title is not None: |
---|
46 | for plot in yeah.p: |
---|
47 | plot.title = opt.title |
---|
48 | |
---|
49 | if opt.explore: |
---|
50 | for cm in clb: |
---|
51 | for plot in yeah.p: |
---|
52 | plot.colorbar = cm |
---|
53 | plot.title = cm |
---|
54 | yeah.makeplot() |
---|
55 | else: |
---|
56 | yeah.makeplot() |
---|
57 | |
---|