1 | import numpy as npy
|
---|
2 |
|
---|
3 | def checkplotoptions(md,options):
|
---|
4 | '''
|
---|
5 | CHECKPLOTOPTIONS - build a structure that holds all plot options
|
---|
6 |
|
---|
7 | Usage:
|
---|
8 | options=checkplotoptions(md,options)
|
---|
9 |
|
---|
10 | See also: PLOTMODEL
|
---|
11 |
|
---|
12 | NOTE: not fully implemented yet
|
---|
13 | '''
|
---|
14 |
|
---|
15 |
|
---|
16 | #units
|
---|
17 | if options.exist('unit'):
|
---|
18 | if 'km' in options.getfieldvalue('unit','km'):
|
---|
19 | options.changefieldvalue('unit',10**-3)
|
---|
20 | if '100km' in options.getfieldvalue('unit','100km'):
|
---|
21 | options.changefieldvalue('unit',10**-5)
|
---|
22 |
|
---|
23 | #density
|
---|
24 | if options.exist('density'):
|
---|
25 | density=options.getfieldvalue('density')
|
---|
26 | options.changefieldvalue('density',abs(ceil(density)))
|
---|
27 |
|
---|
28 | #show section
|
---|
29 | if options.exist('showsection'):
|
---|
30 | if 'on' in options.getfieldvalue('showsection','on'):
|
---|
31 | options.changefieldvalue('showsection',4)
|
---|
32 |
|
---|
33 | #smooth values
|
---|
34 | if options.exist('smooth'):
|
---|
35 | if 'on' in options.getfieldvalue('smooth','on'):
|
---|
36 | options.changefieldvalue('smooth',0)
|
---|
37 |
|
---|
38 | #contouronly values
|
---|
39 | if options.exist('contouronly'):
|
---|
40 | if 'on' in options.getfieldvalue('contouronly','on'):
|
---|
41 | options.changefieldvalue('contouronly',1)
|
---|
42 |
|
---|
43 | #colorbar
|
---|
44 | if options.exist('colorbar'):
|
---|
45 | if 'on' in options.getfieldvalue('colorbar','on'):
|
---|
46 | options.changefieldvalue('colorbar',1)
|
---|
47 | elif 'off' in options.getfieldvalue('colorbar','off'):
|
---|
48 | options.changefieldvalue('colorbar',0)
|
---|
49 |
|
---|
50 | #text
|
---|
51 | if options.exist('text'):
|
---|
52 | #1: textvalue
|
---|
53 | textvalues=options.getfieldvalue('text')
|
---|
54 | numtext=len(textvalues)
|
---|
55 |
|
---|
56 | #2: textweight
|
---|
57 | if options.exist('textweight'):
|
---|
58 | textweightvalues=options.getfieldvalue('textweight')
|
---|
59 | else:
|
---|
60 | textweightvalues='n'
|
---|
61 | textweightvalues=npy.tile(textweightvalues,numtext)
|
---|
62 |
|
---|
63 | #3 textsize
|
---|
64 | if options.exist('textsize'):
|
---|
65 | textsizevalues=options.getfieldvalue('textsize')
|
---|
66 | else:
|
---|
67 | textsizevalues=14
|
---|
68 | textsizevalues=npy.tile(textsizevalues,numtext)
|
---|
69 |
|
---|
70 | #4 textcolor
|
---|
71 | if options.exist('textcolor'):
|
---|
72 | textcolorvalues=options.getfieldvalue('textcolor')
|
---|
73 | else:
|
---|
74 | textcolorvalues='k'
|
---|
75 | textcolorvalues=npy.tile(textsizevalues,numtext)
|
---|
76 |
|
---|
77 | #5 textposition
|
---|
78 | if options.exist('textposition'):
|
---|
79 | options.getfieldvalue('textposition')
|
---|
80 | else:
|
---|
81 | raise Exception("plotmodel error message: 'textposition' option is missing")
|
---|
82 |
|
---|
83 | #6 textrotation
|
---|
84 | if options.exist('textrotation'):
|
---|
85 | textrotationvalues=options.getfieldvalue('textrotation')
|
---|
86 | else:
|
---|
87 | textrotationvalues=0
|
---|
88 | textrotationvalues=npy.tile(textrotationvalues,numtext)
|
---|
89 |
|
---|
90 | options.changfieldvalue('text',textvalues)
|
---|
91 | options.changfieldvalue('textsize',textsizevalues)
|
---|
92 | options.changfieldvalue('textweight',textweightvalues)
|
---|
93 | options.changfieldvalue('textcolor',textcolorvalues)
|
---|
94 | options.changfieldvalue('textposition',textpositionvalues)
|
---|
95 | options.changfieldvalue('textrotation',textrotationvalues)
|
---|
96 |
|
---|
97 | #expdisp
|
---|
98 | expdispvaluesarray=[0,0]
|
---|
99 | expstylevaluesarray=[0,0]
|
---|
100 | expstylevalues=[0,0]
|
---|
101 | if options.exist('expstyle'):
|
---|
102 | expstylevalues=options.getfieldvalue('expstyle')
|
---|
103 | if options.exist('expdisp'):
|
---|
104 | expdispvalues=options.getfieldvalue('expdisp')
|
---|
105 | for i in npy.arange(len(expdispvalues)):
|
---|
106 | expdispvaluesarray.append(expdispvalues[i])
|
---|
107 | if len(expstylevalues)>i+1:
|
---|
108 | expstylevaluesarray.append(expstylevalues[i])
|
---|
109 | else:
|
---|
110 | expstylevaluesarray.append('-k')
|
---|
111 |
|
---|
112 | options.changefieldvalue('expstyle',expstylevaluesarray)
|
---|
113 | options.changefieldvalue('expdisp',expdispvaluesarray)
|
---|
114 |
|
---|
115 | #latlonnumbering
|
---|
116 | if options.exist('latlonclick'):
|
---|
117 | if 'on' in options.getfieldvalue('latlonclick','on'):
|
---|
118 | options.changefieldvalue('latlonclick',1)
|
---|
119 |
|
---|
120 | #northarrow
|
---|
121 | if options.exist('northarrow'):
|
---|
122 | if 'on' in options.getfieldvalue('northarrow','on'):
|
---|
123 | #default values
|
---|
124 | Lx=max(md.mesh.x)-min(md.mesh.x)
|
---|
125 | Ly=max(md.mesh.y)-min(md.mesh.y)
|
---|
126 | options.changefieldvalue('northarrow',[min(md.mesh.x)+1./6.*Lx, min(md.mesh.y)+5./6.*Ly, 1./15.*Ly, 0.25, 1./250.*Ly])
|
---|
127 |
|
---|
128 | #scale ruler
|
---|
129 | if options.exist('scaleruler'):
|
---|
130 | if 'on' in options.exist('scaleruler','on'):
|
---|
131 | Lx=max(md.mesh.x)-min(md.mesh.x)
|
---|
132 | Ly=max(md.mesh.y)-min(md.mesh.y)
|
---|
133 | options.changefieldvalue('scaleruler',[min(md.mesh.x)+6./8.*Lx, min(md.mesh.y)+1./10.*Ly, 10**(ceil(log10(Lx)))/5, floor(Lx/100), 5])
|
---|
134 |
|
---|
135 | #log scale
|
---|
136 | if options.exist('log'):
|
---|
137 | if options.exist('caxis'):
|
---|
138 | options.changefieldvalue('caxis',log(options.getfieldvalue('caxis'))/log(options.getfieldvalue('log')))
|
---|
139 | options.changefieldvalue('cutoff',log(options.getfieldvalue('cutoff',1.5))/log(options.getfieldvalue('log')))
|
---|
140 |
|
---|
141 | return options
|
---|