@@ -131,7 +131,7 @@ def process_src(nm, code):
131131class Gv (object ):
132132
133133 """
134- Class: Gv # Vector
134+ Class: Gv # Vector
135135
136136 Description of Gv Class:
137137 The vector graphics method displays a vector plot of a 2D vector field. Vectors
@@ -145,76 +145,76 @@ class Gv(object):
145145 entry.
146146
147147 Other Useful Functions:
148- a=vcs.init() # Constructor
149- a.show('vector') # Show predefined vector graphics methods
150- a.show('line') # Show predefined VCS line objects
151- a.setcolormap("AMIP") # Change the VCS color Map
152- a.vector(s1, s2, v,'default') # Plot data 's1', and 's2' with vector 'v'
148+ a=vcs.init() # Constructor
149+ a.show('vector') # Show predefined vector graphics methods
150+ a.show('line') # Show predefined VCS line objects
151+ a.setcolormap("AMIP") # Change the VCS color Map
152+ a.vector(s1, s2, v,'default') # Plot data 's1', and 's2' with vector 'v'
153153 and 'default' template
154- a.update() # Updates the VCS Canvas at user's request
155- a.mode=1, or 0 # If 1, then automatic update, else if
154+ a.update() # Updates the VCS Canvas at user's request
155+ a.mode=1, or 0 # If 1, then automatic update, else if
156156 0, then use update function to
157157 update the VCS Canvas.
158158
159159 Example of Use:
160160 a=vcs.init()
161161 To Create a new instance of vector use:
162- vc=a.createvector('new','quick') # Copies content of 'quick' to 'new'
163- vc=a.createvector('new') # Copies content of 'default' to 'new'
162+ vc=a.createvector('new','quick') # Copies content of 'quick' to 'new'
163+ vc=a.createvector('new') # Copies content of 'default' to 'new'
164164
165165 To Modify an existing vector use:
166166 vc=a.getvector('AMIP_psl')
167167
168- vc.list() # Will list all the vector attribute values
169- vc.projection='linear' # Can only be 'linear'
168+ vc.list() # Will list all the vector attribute values
169+ vc.projection='linear' # Can only be 'linear'
170170 lon30={-180:'180W',-150:'150W',0:'Eq'}
171171 vc.xticlabels1=lon30
172172 vc.xticlabels2=lon30
173- vc.xticlabels(lon30, lon30) # Will set them both
173+ vc.xticlabels(lon30, lon30) # Will set them both
174174 vc.xmtics1=''
175175 vc.xmtics2=''
176- vc.xmtics(lon30, lon30) # Will set them both
176+ vc.xmtics(lon30, lon30) # Will set them both
177177 vc.yticlabels1=lat10
178178 vc.yticlabels2=lat10
179- vc.yticlabels(lat10, lat10) # Will set them both
179+ vc.yticlabels(lat10, lat10) # Will set them both
180180 vc.ymtics1=''
181181 vc.ymtics2=''
182- vc.ymtics(lat10, lat10) # Will set them both
182+ vc.ymtics(lat10, lat10) # Will set them both
183183 vc.datawc_y1=-90.0
184184 vc.datawc_y2=90.0
185185 vc.datawc_x1=-180.0
186186 vc.datawc_x2=180.0
187- vc.datawc(-90, 90, -180, 180) # Will set them all
187+ vc.datawc(-90, 90, -180, 180) # Will set them all
188188 xaxisconvert='linear'
189189 yaxisconvert='linear'
190- vc.xyscale('linear', 'area_wt') # Will set them both
190+ vc.xyscale('linear', 'area_wt') # Will set them both
191191
192192 Specify the line style:
193- vc.line=0 # Same as vc.line='solid'
194- vc.line=1 # Same as vc.line='dash'
195- vc.line=2 # Same as vc.line='dot'
196- vc.line=3 # Same as vc.line='dash-dot'
197- vc.line=4 # Same as vc.line='long-dot'
193+ vc.line=0 # Same as vc.line='solid'
194+ vc.line=1 # Same as vc.line='dash'
195+ vc.line=2 # Same as vc.line='dot'
196+ vc.line=3 # Same as vc.line='dash-dot'
197+ vc.line=4 # Same as vc.line='long-dot'
198198
199199 Specify the line color of the vectors:
200- vc.linecolor=16 # Color range: 16 to 230, default line color is black
201- vc.linewidth=1 # Width range: 1 to 100, default size is 1
200+ vc.linecolor=16 # Color range: 16 to 230, default line color is black
201+ vc.linewidth=1 # Width range: 1 to 100, default size is 1
202202
203203 Specify the vector scale factor:
204- vc.scale=2.0 # Can be an integer or float
204+ vc.scale=2.0 # Can be an integer or float
205205
206206 Specify the vector alignment:
207- vc.alignment=0 # Same as vc.alignment='head'
208- vc.alignment=1 # Same as vc.alignment='center'
209- vc.alignment=2 # Same as vc.alignment='tail'
207+ vc.alignment=0 # Same as vc.alignment='head'
208+ vc.alignment=1 # Same as vc.alignment='center'
209+ vc.alignment=2 # Same as vc.alignment='tail'
210210
211211 Specify the vector type:
212- vc.type=0 # Same as vc.type='arrow head'
213- vc.type=1 # Same as vc.type='wind barbs'
214- vc.type=2 # Same as vc.type='solid arrow head'
212+ vc.type=0 # Same as vc.type='arrow head'
213+ vc.type=1 # Same as vc.type='wind barbs'
214+ vc.type=2 # Same as vc.type='solid arrow head'
215215
216216 Specify the vector reference:
217- vc.reference=4 # Can be an integer or float
217+ vc.reference=4 # Can be an integer or float
218218"""
219219 __slots__ = [
220220 'name' ,
@@ -244,6 +244,9 @@ class Gv(object):
244244 'type' ,
245245 'reference' ,
246246 'colormap' ,
247+ 'scaleoptions' ,
248+ 'scaletype' ,
249+ 'scalerange' ,
247250 '_name' ,
248251 '_xaxisconvert' ,
249252 '_yaxisconvert' ,
@@ -270,9 +273,13 @@ class Gv(object):
270273 '_type' ,
271274 '_reference' ,
272275 '_colormap' ,
276+ '_scaleoptions' ,
277+ '_scaletype' ,
278+ '_scalerange' ,
273279 ]
274280
275281 colormap = VCS_validation_functions .colormap
282+ scaleoptions = ('off' , 'constant' , 'normalize' , 'linear' , 'constantNNormalize' , 'constantNLinear' )
276283
277284 def _getname (self ):
278285 return self ._name
@@ -528,6 +535,30 @@ def _setalignment(self, value):
528535 self ._alignment = value
529536 alignment = property (_getalignment , _setalignment )
530537
538+ def _getscaletype (self ):
539+ return self ._scaletype
540+
541+ def _setscaletype (self , value ):
542+ value = VCS_validation_functions .checkInStringList (self ,
543+ 'scaletype' ,
544+ value ,
545+ self .scaleoptions )
546+ self ._scaletype = value
547+ scaletype = property (_getscaletype , _setscaletype )
548+
549+ def _getscalerange (self ):
550+ return self ._scalerange
551+
552+ def _setscalerange (self , value ):
553+ value = VCS_validation_functions .checkListOfNumbers (self ,
554+ 'scalerange' ,
555+ value ,
556+ minvalue = 0.0 ,
557+ minelements = 2 ,
558+ maxelements = 2 )
559+ self ._scalerange = value
560+ scalerange = property (_getscalerange , _setscalerange )
561+
531562 def __init__ (self , Gv_name , Gv_name_src = 'default' ):
532563 # #
533564 ###########################################################
@@ -568,6 +599,8 @@ def __init__(self, Gv_name, Gv_name_src='default'):
568599 self ._datawc_timeunits = "days since 2000"
569600 self ._datawc_calendar = 135441
570601 self ._colormap = None
602+ self ._scaletype = self .scaleoptions [4 ]
603+ self ._scalerange = [0.1 , 1.0 ]
571604 else :
572605 if isinstance (Gv_name_src , Gv ):
573606 Gv_name_src = Gv_name_src .name
@@ -583,7 +616,9 @@ def __init__(self, Gv_name, Gv_name_src='default'):
583616 'datawc_x2' , 'xaxisconvert' , 'yaxisconvert' ,
584617 'line' , 'linecolor' , 'linewidth' ,
585618 'datawc_timeunits' , 'datawc_calendar' , 'colormap' ,
586- 'scale' , 'alignment' , 'type' , 'reference' ]:
619+ 'scale' , 'alignment' , 'type' , 'reference' , 'scaletype' ,
620+ 'scalerange' ]:
621+
587622 setattr (self , att , getattr (src , att ))
588623 # Ok now we need to stick in the elements
589624 vcs .elements ["vector" ][Gv_name ] = self
@@ -660,6 +695,8 @@ def list(self):
660695 print "alignment = " , self .alignment
661696 print "type = " , self .type
662697 print "reference = " , self .reference
698+ print "scaletype = " , self .scaletype
699+ print "scalerange = " , self .scalerange
663700
664701 ##########################################################################
665702 # #
@@ -798,6 +835,9 @@ def script(self, script_filename=None, mode=None):
798835 fp .write ("%s.linecolor = %s\n " % (unique_name , self .linecolor ))
799836 fp .write ("%s.linewidth = %s\n " % (unique_name , self .linewidth ))
800837 fp .write ("%s.scale = %s\n " % (unique_name , self .scale ))
838+ fp .write ("%s.scaletype = %s\n " % (unique_name , self .scaletype ))
839+ fp .write ("%s.scalerange = %s\n " % (unique_name , self .scalerange ))
840+ fp .write ("%s.scaleoptions = %s\n " % (unique_name , self .scaleoptions ))
801841 fp .write ("%s.alignment = '%s'\n " % (unique_name , self .alignment ))
802842 fp .write ("%s.type = '%s'\n " % (unique_name , self .type ))
803843 fp .write ("%s.reference = %s\n \n " % (unique_name , self .reference ))
@@ -814,5 +854,5 @@ def script(self, script_filename=None, mode=None):
814854
815855
816856###############################################################################
817- # END OF FILE #
857+ # END OF FILE #
818858###############################################################################
0 commit comments