#NEWLINE# def _plot_array_helper( plotarray , model = None , sr = None , axes = None , names = None , filenames = None , fignum = None , mflay = None , **kwargs ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import matplotlib.pyplot as plt #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# s = ( 'Could not import matplotlib.  Must install matplotlib ' + ' in order to plot LayerFile data.' ) #NEWLINE# raise Exception ( s ) #NEWLINE# #UNINDENT# import flopy.plot.map as map #NEWLINE# if ( len ( plotarray . shape ) == 2 ) : #NEWLINE# #INDENT# plotarray = plotarray . reshape ( ( 1 , plotarray . shape [ 0 ] , plotarray . shape [ 1 ] ) ) #NEWLINE# #UNINDENT# if ( 'figsize' in kwargs ) : #NEWLINE# #INDENT# figsize = kwargs . pop ( 'figsize' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# figsize = None #NEWLINE# #UNINDENT# if ( 'masked_values' in kwargs ) : #NEWLINE# #INDENT# masked_values = kwargs . pop ( 'masked_values' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# masked_values = None #NEWLINE# #UNINDENT# if ( 'pcolor' in kwargs ) : #NEWLINE# #INDENT# pcolor = kwargs . pop ( 'pcolor' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pcolor = True #NEWLINE# #UNINDENT# if ( 'inactive' in kwargs ) : #NEWLINE# #INDENT# inactive = kwargs . pop ( 'inactive' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# inactive = True #NEWLINE# #UNINDENT# if ( 'contour' in kwargs ) : #NEWLINE# #INDENT# contourdata = kwargs . pop ( 'contour' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# contourdata = False #NEWLINE# #UNINDENT# if ( 'clabel' in kwargs ) : #NEWLINE# #INDENT# clabel = kwargs . pop ( 'clabel' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# clabel = False #NEWLINE# #UNINDENT# if ( 'colorbar' in kwargs ) : #NEWLINE# #INDENT# cb = kwargs . pop ( 'colorbar' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cb = False #NEWLINE# #UNINDENT# if ( 'grid' in kwargs ) : #NEWLINE# #INDENT# grid = kwargs . pop ( 'grid' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# grid = False #NEWLINE# #UNINDENT# if ( 'levels' in kwargs ) : #NEWLINE# #INDENT# levels = kwargs . pop ( 'levels' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# levels = None #NEWLINE# #UNINDENT# if ( 'colors' in kwargs ) : #NEWLINE# #INDENT# colors = kwargs . pop ( 'colors' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# colors = 'black' #NEWLINE# #UNINDENT# if ( 'dpi' in kwargs ) : #NEWLINE# #INDENT# dpi = kwargs . pop ( 'dpi' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dpi = None #NEWLINE# #UNINDENT# if ( 'fmt' in kwargs ) : #NEWLINE# #INDENT# fmt = kwargs . pop ( 'fmt' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fmt = '%1.3f' #NEWLINE# #UNINDENT# if ( mflay is not None ) : #NEWLINE# #INDENT# i0 = int ( mflay ) #NEWLINE# if ( ( i0 + 1 ) >= plotarray . shape [ 0 ] ) : #NEWLINE# #INDENT# i0 = ( plotarray . shape [ 0 ] - 1 ) #NEWLINE# #UNINDENT# i1 = ( i0 + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# i0 = 0 #NEWLINE# i1 = plotarray . shape [ 0 ] #NEWLINE# #UNINDENT# if ( names is not None ) : #NEWLINE# #INDENT# if ( not isinstance ( names , list ) ) : #NEWLINE# #INDENT# names = [ names ] #NEWLINE# #UNINDENT# assert ( len ( names ) == plotarray . shape [ 0 ] ) #NEWLINE# #UNINDENT# if ( filenames is not None ) : #NEWLINE# #INDENT# if ( not isinstance ( filenames , list ) ) : #NEWLINE# #INDENT# filenames = [ filenames ] #NEWLINE# #UNINDENT# assert ( len ( filenames ) == plotarray . shape [ 0 ] ) #NEWLINE# #UNINDENT# if ( fignum is not None ) : #NEWLINE# #INDENT# if ( not isinstance ( fignum , list ) ) : #NEWLINE# #INDENT# fignum = [ fignum ] #NEWLINE# #UNINDENT# assert ( len ( fignum ) == plotarray . shape [ 0 ] ) #NEWLINE# f0 = fignum [ 0 ] #NEWLINE# for i in plt . get_fignums ( ) : #NEWLINE# #INDENT# if ( i >= f0 ) : #NEWLINE# #INDENT# f0 = ( i + 1 ) #NEWLINE# #UNINDENT# #UNINDENT# finc = ( f0 - fignum [ 0 ] ) #NEWLINE# for idx in range ( len ( fignum ) ) : #NEWLINE# #INDENT# fignum [ idx ] += finc #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# f0 = 0 #NEWLINE# for i in plt . get_fignums ( ) : #NEWLINE# #INDENT# if ( i >= f0 ) : #NEWLINE# #INDENT# f0 += 1 #NEWLINE# #UNINDENT# #UNINDENT# f1 = ( f0 + ( i1 - i0 ) ) #NEWLINE# fignum = np . arange ( f0 , f1 ) #NEWLINE# #UNINDENT# if ( grid is not None ) : #NEWLINE# #INDENT# if ( not isinstance ( axes , list ) ) : #NEWLINE# #INDENT# axes = [ axes ] #NEWLINE# #UNINDENT# assert ( len ( axes ) == plotarray . shape [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# axes = [ ] #NEWLINE# for ( idx , k ) in enumerate ( range ( i0 , i1 ) ) : #NEWLINE# #INDENT# fig = plt . figure ( figsize = figsize , num = fignum [ idx ] ) #NEWLINE# ax = plt . subplot ( 1 , 1 , 1 , aspect = 'equal' ) #NEWLINE# if ( names is not None ) : #NEWLINE# #INDENT# title = names [ k ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# klay = k #NEWLINE# if ( mflay is not None ) : #NEWLINE# #INDENT# klay = int ( mflay ) #NEWLINE# #UNINDENT# title = '{} Layer {}' . format ( 'data' , ( klay + 1 ) ) #NEWLINE# #UNINDENT# ax . set_title ( title ) #NEWLINE# axes . append ( ax ) #NEWLINE# #UNINDENT# #UNINDENT# for ( idx , k ) in enumerate ( range ( i0 , i1 ) ) : #NEWLINE# #INDENT# fig = plt . figure ( num = fignum [ idx ] ) #NEWLINE# mm = map . ModelMap ( ax = axes [ idx ] , model = model , sr = sr , layer = k ) #NEWLINE# if pcolor : #NEWLINE# #INDENT# cm = mm . plot_array ( plotarray [ k ] , masked_values = masked_values , ax = axes [ idx ] , ** kwargs ) #NEWLINE# if cb : #NEWLINE# #INDENT# label = '' #NEWLINE# if ( not isinstance ( cb , bool ) ) : #NEWLINE# #INDENT# label = str ( cb ) #NEWLINE# #UNINDENT# plt . colorbar ( cm , ax = axes [ idx ] , shrink = 0.5 , label = label ) #NEWLINE# #UNINDENT# #UNINDENT# if contourdata : #NEWLINE# #INDENT# cl = mm . contour_array ( plotarray [ k ] , masked_values = masked_values , ax = axes [ idx ] , colors = colors , levels = levels , ** kwargs ) #NEWLINE# if clabel : #NEWLINE# #INDENT# axes [ idx ] . clabel ( cl , fmt = fmt , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# if grid : #NEWLINE# #INDENT# mm . plot_grid ( ax = axes [ idx ] ) #NEWLINE# #UNINDENT# if inactive : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ib = model . bas6 . ibound . array #NEWLINE# mm . plot_inactive ( ibound = ib , ax = axes [ idx ] ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( len ( axes ) == 1 ) : #NEWLINE# #INDENT# axes = axes [ 0 ] #NEWLINE# #UNINDENT# if ( filenames is not None ) : #NEWLINE# #INDENT# for ( idx , k ) in enumerate ( range ( i0 , i1 ) ) : #NEWLINE# #INDENT# fig = plt . figure ( num = fignum [ idx ] ) #NEWLINE# fig . savefig ( filenames [ idx ] , dpi = dpi ) #NEWLINE# print ( '    created...{}' . format ( os . path . basename ( filenames [ idx ] ) ) ) #NEWLINE# #UNINDENT# axes = None #NEWLINE# plt . close ( 'all' ) #NEWLINE# #UNINDENT# return axes