#NEWLINE# def _extend_2d( self , axis , delta , npoints , normal ) : #NEWLINE# #INDENT# ' 2D (index space) extension. ' #NEWLINE# ( imax , jmax ) = self . real_shape #NEWLINE# need_normal = False #NEWLINE# if ( axis == 'i' ) : #NEWLINE# #INDENT# new_shape = ( ( imax + npoints ) , jmax ) #NEWLINE# if ( imax < 2 ) : #NEWLINE# #INDENT# need_normal = True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# new_shape = ( imax , ( jmax + npoints ) ) #NEWLINE# if ( jmax < 2 ) : #NEWLINE# #INDENT# need_normal = True #NEWLINE# #UNINDENT# #UNINDENT# if need_normal : #NEWLINE# #INDENT# extent = self . extent #NEWLINE# dims = ( len ( extent ) / 2 ) #NEWLINE# if ( normal is None ) : #NEWLINE# #INDENT# if ( dims == 2 ) : #NEWLINE# #INDENT# ( min1 , max1 , min2 , max2 ) = extent #NEWLINE# delta1 = ( max1 - min1 ) #NEWLINE# delta2 = ( max2 - min2 ) #NEWLINE# if ( delta1 <= delta2 ) : #NEWLINE# #INDENT# normal = ( 1.0 , 0.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# normal = ( 0.0 , 1.0 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( min1 , max1 , min2 , max2 , min3 , max3 ) = self . extent ( ) #NEWLINE# delta1 = ( max1 - min1 ) #NEWLINE# delta2 = ( max2 - min2 ) #NEWLINE# delta3 = ( max3 - min3 ) #NEWLINE# if ( delta1 <= delta2 ) : #NEWLINE# #INDENT# if ( delta1 <= delta3 ) : #NEWLINE# #INDENT# normal = ( 1.0 , 0.0 , 0.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# normal = ( 0.0 , 0.0 , 1.0 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( delta2 <= delta3 ) : #NEWLINE# #INDENT# normal = ( 0.0 , 1.0 , 0.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# normal = ( 0.0 , 0.0 , 1.0 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( normal ) != dims ) : #NEWLINE# #INDENT# raise ValueError ( ( 'normal needs %d elements' % dims ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# normal = ( 0.0 , 0.0 , 0.0 ) #NEWLINE# #UNINDENT# grid = GridCoordinates ( ) #NEWLINE# if ( self . x is not None ) : #NEWLINE# #INDENT# grid . x = self . _extrap_2d ( axis , delta , npoints , self . x , new_shape , normal [ 0 ] ) #NEWLINE# grid . y = self . _extrap_2d ( axis , delta , npoints , self . y , new_shape , normal [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# grid . r = self . _extrap_2d ( axis , delta , npoints , self . r , new_shape , normal [ 0 ] ) #NEWLINE# grid . t = self . _extrap_2d ( axis , delta , npoints , self . t , new_shape , normal [ 1 ] ) #NEWLINE# #UNINDENT# if ( self . z is not None ) : #NEWLINE# #INDENT# grid . z = self . _extrap_2d ( axis , delta , npoints , self . z , new_shape , normal [ 2 ] ) #NEWLINE# #UNINDENT# grid . ghosts = copy . copy ( self . _ghosts ) #NEWLINE# return grid