| 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('-T','--title',action='store',dest='title',type="string",default=None,help='Give a new title') |
|---|
| 14 | parser.add_option('-K','--marker',action='store',dest='marker',type="string",default=None,help="[1D] Define a new marker") |
|---|
| 15 | parser.add_option('-P','--proj',action='store',dest='proj',type="string",default=None,help='[2D] Define a new map projection') |
|---|
| 16 | parser.add_option('-C','--colorbar',action='store',dest='colorbar',type="string",default=None,help="[2D] Define a new colormap") |
|---|
| 17 | parser.add_option('-E','--explore',action='store_true',dest='explore',default=False,help="[2D] Try many colormaps") |
|---|
| 18 | (opt,args) = parser.parse_args() |
|---|
| 19 | # ----------------------------------------------------------------------- |
|---|
| 20 | clb = ["Greys","Blues","YlOrRd",\ |
|---|
| 21 | "jet","spectral","hot",\ |
|---|
| 22 | "RdBu","RdYlBu","Paired",\ |
|---|
| 23 | "gist_ncar","gist_rainbow","gist_stern"] |
|---|
| 24 | # ----------------------------------------------------------------------- |
|---|
| 25 | |
|---|
| 26 | for files in args: |
|---|
| 27 | |
|---|
| 28 | yeah = pp() |
|---|
| 29 | yeah.quiet = True |
|---|
| 30 | yeah.defineplot(loadfile=files) |
|---|
| 31 | yeah.out = opt.out |
|---|
| 32 | |
|---|
| 33 | if opt.proj is not None: |
|---|
| 34 | for plot in yeah.p: |
|---|
| 35 | plot.proj = opt.proj |
|---|
| 36 | if opt.colorbar is not None: |
|---|
| 37 | yeah.colorbar = opt.colorbar |
|---|
| 38 | for plot in yeah.p: |
|---|
| 39 | plot.colorbar = opt.colorbar |
|---|
| 40 | if opt.marker is not None: |
|---|
| 41 | for plot in yeah.p: |
|---|
| 42 | plot.marker = opt.marker |
|---|
| 43 | if opt.title is not None: |
|---|
| 44 | for plot in yeah.p: |
|---|
| 45 | plot.title = opt.title |
|---|
| 46 | |
|---|
| 47 | if opt.explore: |
|---|
| 48 | for cm in clb: |
|---|
| 49 | for plot in yeah.p: |
|---|
| 50 | plot.colorbar = cm |
|---|
| 51 | plot.title = cm |
|---|
| 52 | yeah.makeplot() |
|---|
| 53 | else: |
|---|
| 54 | yeah.makeplot() |
|---|
| 55 | |
|---|