def plot_worker(jobq,mask,pid,lineshape,range): ''' args[0] = array file name args[1] = output figure name if mask, where masked==0 is masked ''' if lineshape: lines = shapefile.load_shape_list(lineshape) else: lines = None while True: #--get some args from the queue args = jobq.get() #--check if this is a sentenial if args == None: break #--load if args[2]: arr = np.fromfile(args[0],dtype=np.float32) arr.resize(bro.nrow,bro.ncol) else: arr = np.loadtxt(args[0]) if mask != None: arr = np.ma.masked_where(mask==0,arr) #print args[0],arr.min(),arr.max(),arr.mean() #--generic plotting fig = pylab.figure() ax = pylab.subplot(1,1,1,aspect='equal') if range: vmax = range[1] vmin = range[0] else: vmax = arr.max() vmin = arr.min() #p = ax.imshow(arr,interpolation='none') p = ax.pcolor(bro.X,bro.Y,np.flipud(arr),vmax=vmax,vmin=vmin) pylab.colorbar(p) if lines: for line in lines: ax.plot(line[0,:],line[1,:],'k-',lw=1.0) #break ax.set_xticklabels([]) ax.set_yticklabels([]) ax.set_xlim(bro.plt_x) ax.set_ylim(bro.plt_y) ax.set_title(args[0]) fmt = args[1].split('.')[-1] pylab.savefig(args[1],dpi=300,format=fmt) pylab.close(fig) #--mark this task as done jobq.task_done() print 'plot worker',pid,' finished',args[0] #--mark the sentenial as done jobq.task_done() return
def plot_worker(jobq, mask, pid, lineshape, range): ''' args[0] = array file name args[1] = output figure name if mask, where masked==0 is masked ''' if lineshape: lines = shapefile.load_shape_list(lineshape) else: lines = None while True: #--get some args from the queue args = jobq.get() #--check if this is a sentenial if args == None: break #--load if args[2]: arr = np.fromfile(args[0], dtype=np.float32) arr.resize(bro.nrow, bro.ncol) else: arr = np.loadtxt(args[0]) if mask != None: arr = np.ma.masked_where(mask == 0, arr) #print args[0],arr.min(),arr.max(),arr.mean() #--generic plotting fig = pylab.figure() ax = pylab.subplot(1, 1, 1, aspect='equal') if range: vmax = range[1] vmin = range[0] else: vmax = arr.max() vmin = arr.min() #p = ax.imshow(arr,interpolation='none') p = ax.pcolor(bro.X, bro.Y, np.flipud(arr), vmax=vmax, vmin=vmin) pylab.colorbar(p) if lines: for line in lines: ax.plot(line[0, :], line[1, :], 'k-', lw=1.0) #break ax.set_xticklabels([]) ax.set_yticklabels([]) ax.set_xlim(bro.plt_x) ax.set_ylim(bro.plt_y) ax.set_title(args[0]) fmt = args[1].split('.')[-1] pylab.savefig(args[1], dpi=300, format=fmt) pylab.close(fig) #--mark this task as done jobq.task_done() print 'plot worker', pid, ' finished', args[0] #--mark the sentenial as done jobq.task_done() return
def plot_worker(jobq,mask,pid,offset,delta,lineshape,range): ''' args[0] = array file name args[1] = output figure name if mask, where masked==0 is masked ''' if lineshape: lines = shapefile.load_shape_list(lineshape) else: lines = None while True: #--get some args from the queue args = jobq.get() #--check if this is a sentenial if args == None: break #--load arr = np.loadtxt(args[0]) nrow,ncol = arr.shape x = np.arange(0,ncol*delta,delta) + offset[0] y = np.arange(0,nrow*delta,delta) + offset[1] X,Y = np.meshgrid(x,y) print x.shape,y.shape if mask != None: arr = np.ma.masked_where(mask==0,arr) #print args[0],arr.min(),arr.max(),arr.mean() #--generic plotting fig = pylab.figure() ax = pylab.subplot(111) #p = ax.pcolor(arr) if range: #p = ax.pcolor(X,Y,arr,vmax=range[1],vmin=range[0]) if lines: for line in lines: ax.plot(line[:,0],line[:,1],'k-',lw=1.0) else: p = ax.imshow(arr,interpolation='none') #pylab.colorbar(p) fmt = args[1].split('.')[-1] pylab.savefig(args[1],dpi=300,format=fmt) pylab.close(fig) #--mark this task as done jobq.task_done() print 'plot worker',pid,' finished',args[0] #--mark the sentenial as done jobq.task_done() return
#--make sure output directories exist OutputDir = os.path.join( ResultsDir, 'Figures', 'Zeta' ) umdutils.TestDirExist([os.path.join( ResultsDir,'Figures','dir.tst' ),os.path.join( OutputDir, 'dir.tst' )]) #--default data if command line argument not defined for variable head_file = os.path.join( ResultsDir, 'UMD.hds' ) zeta_file = os.path.join( ResultsDir, 'UMD.zta' ) #--get available times in the head file #--zeta surface to extract zta_text = ' ZETAPLANE 2' zetaObj = mfb.MODFLOW_CBB(nlay,nrow,ncol,zeta_file) times = zetaObj.get_time_list(zta_text) ntimes = times.shape[0] #--make a map #--read shapefile to use as base map on figures shape_name = os.path.join('D:/','Data','Users','jdhughes','GIS','Project Data','2080DBF00','Spatial','FigureData','BaseMap') hydrography = sf.load_shape_list(shape_name) salinity_struct_shape_name = os.path.join('D:/','Data','Users','jdhughes','GIS','Project Data','2080DBF00','Spatial','FigureData','SalinityControlStructures') salinity_struc = sf.load_shape_list(salinity_struct_shape_name) df_struct_shape_name = os.path.join('D:/','Data','Users','jdhughes','GIS','Project Data','2080DBF00','Spatial','FigureData','DrainageFloodControlStructures') df_struc = sf.load_shape_list(df_struct_shape_name) pws_struct_shape_name = os.path.join('D:/','Data','Users','jdhughes','GIS','Project Data','2080DBF00','Spatial','Water Use','pumpwells_lb') pws = sf.load_shape_list(pws_struct_shape_name) #--coordinate information x0, y0 = 539750.0, 2785750.0 dx,dy = 500., 500. xcell = np.arange(x0+dx/2.,x0+(ncol*dx)+dx/2.0,dx) ycell = np.arange(y0+dy/2.,y0+(nrow*dy)+dy/2.0,dy) Xcell,Ycell = np.meshgrid(xcell,ycell) xedge = np.arange(x0,x0+float(ncol)*dx+0.001,dx) yedge = np.arange(y0,y0+float(nrow)*dy+0.001,dy) Xedge,Yedge = np.meshgrid(xedge,yedge)
def main(): #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #shp = sf.reader(well_shapename) #print sf.get_fieldnames(well_shapename) records = sf.load_as_dict(well_shapename, loadShapes=False) well_names = records['DPEP_NAME'] well_zbots = records['zbot'] float_zbots = [] for i, wb in enumerate(well_zbots): float_zbots.append(float(wb)) well_zbots = np.array(float_zbots) well_rows, well_cols = records['row'], records['column'] pump = pandas.read_csv( '..\\..\\_pumpage\\dataframes\\pws_filled_zeros.csv', index_col=0, parse_dates=True) #--load lines and active dates line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = sf.load_shape_list(line_shapename) shp = sf.Reader(line_shapename) fnames = sf.get_fieldnames(line_shapename, ignorecase=True) #for i,fn in enumerate(fnames): # print i,fn a_idx = fnames.index('ACTIVE_ST') line_active = [] for i in range(shp.numRecords): rec = shp.record(i) year = int(rec[a_idx]) if year < flow.start.year: year = flow.start.year dt = datetime(year=year, month=1, day=1) line_active.append(dt) #--head stuff #--use bot of Q5 to check for dry cells hds_elev = np.loadtxt(flow.ref_dir + 'Q5_bot.ref') hds_layer_idx = 0 head_file = flow.root + '.hds' headObj = mfb.MODFLOW_Head(flow.nlay, flow.nrow, flow.ncol, head_file) htimes = headObj.get_time_list() #--zeta stuff zta_layer_idx = 0 zta_elev = np.loadtxt(flow.ref_dir + 'Q1_bot.ref') zeta_file = flow.root + '.zta' zetaObj = mfb.MODFLOW_CBB(flow.nlay, flow.nrow, flow.ncol, zeta_file) zta_text = ' ZETAPLANE 1' z1times = zetaObj.get_time_list(zta_text) #zeta_file = None #-- stress period step sp_step = 1 plt_dir = 'png\\results\\' #--for ffmpeg - sequentially numbered plt_num = 1 istart = 0 q_args = [] for i, dt in enumerate(flow.sp_start): if i >= istart and i % sp_step == 0: print 'building args list for ', dt try: h_seekpoint = long(htimes[i, 3]) except: break if zeta_file: z_seekpoint = long(z1times[i, 3]) else: z_seekpoint = None act_lines = [] for ldt, line in zip(line_active, lines): if ldt <= dt: act_lines.append(line) act_wells = [] if i == 0: plt_start = dt else: plt_start = flow.sp_start[i - sp_step] plt_end = flow.sp_end[i] pump_plt = pump[plt_start:plt_end] pump_plt_sum = pump_plt.sum() for wname, wpoint, wrow, wcol, wzbot in zip( well_names, well_points, well_rows, well_cols, well_zbots): if wname in pump_plt.keys() and pump_plt_sum[wname] != 0: act_wells.append(wpoint) fig_name = plt_dir + 'sp{0:03.0f}.png'.format(plt_num) #fig_title = 'stress period '+str(i+1)+' start date '+dt.strftime('%d/%m/%Y') fig_title = str(dt.year) args = [ fig_name, h_seekpoint, z_seekpoint, act_lines, act_wells, hds_layer_idx, zta_layer_idx, fig_title ] q_args.append(args) plt_num += 1 jobq = mp.JoinableQueue() #--for testing #jobq.put_nowait(q_args[0]) #jobq.put_nowait(None) #plot_worker(jobq,0,head_file,None,hds_elev,zta_elev) #return procs = [] num_procs = 6 for i in range(num_procs): #--pass the woker function jobq and a PID p = mp.Process(target=plot_worker, args=(jobq, i, head_file, zeta_file, hds_elev, zta_elev)) p.daemon = True print 'starting process', p.name p.start() procs.append(p) for q in q_args: jobq.put(q) for p in procs: jobq.put(None) #--block until all finish for p in procs: p.join() print p.name, 'Finished' cmd_line = 'ffmpeg.exe -i results\sp%03d.png -r 24 demo.avi -y' os.system(cmd_line) return
mpl.rcParams['font.serif'] = 'Times' mpl.rcParams['font.cursive'] = 'Zapf Chancery' mpl.rcParams['font.fantasy'] = 'Comic Sans MS' mpl.rcParams['font.monospace'] = 'Courier New' mpl.rcParams['pdf.compression'] = 0 mpl.rcParams['pdf.fonttype'] = 42 ticksize = 6 mpl.rcParams['legend.fontsize'] = 6 mpl.rcParams['axes.labelsize'] = 8 mpl.rcParams['xtick.labelsize'] = ticksize mpl.rcParams['ytick.labelsize'] = ticksize #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #shp = sf.reader(well_shapename) #print sf.get_fieldnames(well_shapename) records = sf.load_as_dict(well_shapename, loadShapes=False) well_names = records['DPEP_NAME'] well_zbots = records['zbot'] float_zbots = [] for i, wb in enumerate(well_zbots): float_zbots.append(float(wb)) well_zbots = np.array(float_zbots) well_rows, well_cols = records['row'], records['column'] pump = pandas.read_csv('..\\..\\_pumpage\\pws_filled_zeros.csv', index_col=0, parse_dates=True) #--load lines and active dates
init_conc = np.zeros_like(botm) #--process each active cell for i in range(flow.nrow): for j in range(flow.ncol): if ibound[i, j] != 0: b = botm[:, i, j] z_elev = z1[i, j] ic = in_layers(z_elev, b) init_conc[:, i, j] = ic for k, lname in enumerate(seawat.layer_botm_names): aname = seawat.ref_dir + lname + '_srconc.ref' np.savetxt(aname, init_conc[k, :, :], fmt='%13.5E') #--plot imshow_extent = [flow.x[0], flow.x[-1], flow.y[0], flow.y[-1]] line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = shapefile.load_shape_list(line_shapename) for k in range(seawat.nlay): fig = pylab.figure() ax = pylab.subplot(111) init_lay = init_conc[k, :, :] init_lay = np.ma.masked_where(init_lay == 0, init_lay) ax.imshow(init_lay, extent=imshow_extent) for line in lines: ax.plot(line[0, :], line[1, :], 'k-', lw=0.25) l_name = seawat.layer_botm_names[k] ax.set_title(l_name) fig_name = 'png\\input\\init_conc_' + l_name + '.png' pylab.savefig(fig_name, format='png', dpi=500)
def main(): # --load well locations and pandas dataframe well_shapename = "..\\..\\_gis\\shapes\\pws_combine" well_points = sf.load_shape_list(well_shapename) # --load lines and active dates line_shapename = "..\\..\\_gis\shapes\sw_reaches" lines = sf.load_shape_list(line_shapename) # --head stuff # --use bot of Q5 to check for dry cells hds_elev = np.loadtxt(flow.ref_dir + "Q5_bot.ref") hds_layer_idx = 0 head_file = flow.root + ".hds" headObj = mfb.MODFLOW_Head(flow.nlay, flow.nrow, flow.ncol, head_file) htimes = headObj.get_time_list() # --zeta stuff zta_layer_idx = 0 zta_elev = np.loadtxt(flow.ref_dir + "Q1_bot.ref") zeta_file = flow.root + ".zta" zetaObj = mfb.MODFLOW_CBB(flow.nlay, flow.nrow, flow.ncol, zeta_file) zta_text = " ZETAPLANE 1" z1times = zetaObj.get_time_list(zta_text) # zeta_file = None # -- stress period step sp_step = 1 plt_dir = "png\\results\\" # --for ffmpeg - sequentially numbered plt_num = 1 istart = 0 q_args = [] for i, dt in enumerate(flow.sp_start): if i >= istart and i % sp_step == 0: print "building args list for ", dt try: h_seekpoint = long(htimes[i, 3]) except: break if zeta_file: z_seekpoint = long(z1times[i, 3]) else: z_seekpoint = None fig_name = plt_dir + "sp{0:03.0f}.png".format(plt_num) # fig_title = 'stress period '+str(i+1)+' start date '+dt.strftime('%d/%m/%Y') fig_title = str(dt.year) args = [fig_name, h_seekpoint, z_seekpoint, lines, well_points, hds_layer_idx, zta_layer_idx, fig_title] q_args.append(args) plt_num += 1 jobq = mp.JoinableQueue() # --for testing # jobq.put_nowait(q_args[0]) # jobq.put_nowait(None) # plot_worker(jobq,0,head_file,None,hds_elev,zta_elev) # return procs = [] num_procs = 3 for i in range(num_procs): # --pass the woker function jobq and a PID p = mp.Process(target=plot_worker, args=(jobq, i, head_file, zeta_file, hds_elev, zta_elev)) p.daemon = True print "starting process", p.name p.start() procs.append(p) for q in q_args: jobq.put(q) for p in procs: jobq.put(None) # --block until all finish for p in procs: p.join() print p.name, "Finished" cmd_line = "ffmpeg.exe -i results\sp%03d.png -r 24 demo.avi -y" os.system(cmd_line) return
nlay,nrow,ncol = 3,189,101 #--read ibound ib_ref = os.path.join( '..', 'REF', 'UMD_IBOUND.ref' ) ib = au.loadArrayFromFile(nrow,ncol,ib_ref) #--read initial zetas ref = os.path.join( '..', 'REF', 'UMD_IHEAD_NAVD.ref' ) ihead = au.loadArrayFromFile(nrow,ncol,ref) #--read the top of the model lse_ref = os.path.join( '..', 'REF', 'UMD_URBAN_EDEN_TOPO.ref' ) model_lse = au.loadArrayFromFile(nrow,ncol,lse_ref) #--make a map iweek = 0 #--read shapefile to use as base map on figures shape_name = os.path.join( 'D:/','Data','Users','jdhughes','GIS','Project Data','2080DBF00','Spatial','FigureData','BaseMap' ) print shape_name hydrography = sf.load_shape_list(shape_name) #--coordinate information x0, y0 = 539750.0, 2785750.0 dx,dy = 500., 500. xcell = np.arange(x0+dx/2.,x0+(ncol*dx)+dx/2.0,dx) ycell = np.arange(y0+dy/2.,y0+(nrow*dy)+dy/2.0,dy) Xcell,Ycell = np.meshgrid(xcell,ycell) xedge = np.arange(x0,x0+float(ncol)*dx+0.001,dx) yedge = np.arange(y0,y0+float(nrow)*dy+0.001,dy) Xedge,Yedge = np.meshgrid(xedge,yedge) xmin,xmax = x0,x0+float(ncol)*dx ymin,ymax = y0,y0+float(nrow)*dy #--common data for each figure hdcontour = np.arange(-1.5,2.5,0.5) dtwcontour = np.arange(-5.,5.,1.) #--create figures for each output time
def main(num_plots): #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #shp = sf.reader(well_shapename) #print sf.get_fieldnames(well_shapename) records = sf.load_as_dict(well_shapename,loadShapes=False) well_names = records['DPEP_NAME'] well_zbots = records['zbot'] float_zbots = [] for i,wb in enumerate(well_zbots): float_zbots.append(float(wb)) well_zbots = np.array(float_zbots) well_rows, well_cols = records['row'],records['column'] pump = pandas.read_csv('..\\..\\_pumpage\\dataframes\\pws_filled_zeros.csv',index_col=0,parse_dates=True) #--load lines and active dates line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = sf.load_shape_list(line_shapename) shp = sf.Reader(line_shapename) fnames = sf.get_fieldnames(line_shapename,ignorecase=True) #for i,fn in enumerate(fnames): # print i,fn a_idx = fnames.index('ACTIVE_ST') line_active = [] for i in range(shp.numRecords): rec = shp.record(i) year = int(rec[a_idx]) if year < flow.start.year: year = flow.start.year dt = datetime(year=year,month=1,day=1) line_active.append(dt) #--head stuff #--use bot of Q5 to check for dry cells #hds_elev = np.loadtxt(flow.ref_dir+'Q5_bot.ref') #hds_layer_idx = 0 #head_file = flow.root+'.hds' #headObj = mfb.MODFLOW_Head(flow.nlay,flow.nrow,flow.ncol,head_file) #htimes = headObj.get_time_list() #--conc stuff conc_lay_idxs = [0,5,9,11] conc_file = 'MT3D001.UCN' concObj = mfb.MT3D_Concentration(seawat.nlay,seawat.nrow,seawat.ncol,conc_file) ctimes = concObj.get_time_list() #--zeta stuff #zta_layer_idx = 0 #zta_elev = np.loadtxt(flow.ref_dir+'Q1_bot.ref') #zeta_file = flow.root+'.zta' #zetaObj = mfb.MODFLOW_CBB(flow.nlay,flow.nrow,flow.ncol,zeta_file) #zta_text = ' ZETAPLANE 1' #z1times = zetaObj.get_time_list(zta_text) #zeta_file = None #-- stress period step sp_step = 1 plt_dir = 'png\\results\\seawat\\' #--for ffmpeg - sequentially numbered plt_num = 1 istart = 0 q_args = [] for i,[start,end] in enumerate(zip(seawat.sp_start,seawat.sp_end)): if i >= istart and i%sp_step == 0: print 'building args list for stress period ending on ',end #--find the conc output nearest the end of the stress period try: kper_seekpoints = ctimes[np.where(ctimes[:,2]==i+1),-1] c_seekpoint = long(kper_seekpoints[0][-1]) except: break act_lines = [] for ldt,line in zip(line_active,lines): if ldt <= start: act_lines.append(line) act_wells = [] if i == 0: plt_start = start else: plt_start = seawat.sp_start[i-sp_step] plt_end = seawat.sp_end[i] pump_plt = pump[plt_start:plt_end] pump_plt_sum = pump_plt.sum() for wname,wpoint,wrow,wcol,wzbot in zip(well_names,well_points,well_rows,well_cols,well_zbots): if wname in pump_plt.keys() and pump_plt_sum[wname] != 0: act_wells.append(wpoint) fig_name = plt_dir+'sp{0:03.0f}_conc.png'.format(plt_num) fig_title = 'stress period '+str(i+1)+' start date '+start.strftime('%d/%m/%Y') args = [fig_name,c_seekpoint,conc_lay_idxs,act_lines,act_wells,fig_title] q_args.append(args) plt_num += 1 if num_plots != None and i > num_plots: break jobq = mp.JoinableQueue() #--for testing if num_plots != None: jobq.put_nowait(q_args[0]) jobq.put_nowait(None) plot_worker(jobq,1,conc_file) return procs = [] num_procs = 3 for i in range(num_procs): #--pass the woker function jobq and a PID p = mp.Process(target=plot_worker,args=(jobq,i,conc_file)) p.daemon = True print 'starting process',p.name p.start() procs.append(p) for q in q_args: jobq.put(q) for p in procs: jobq.put(None) #--block until all finish for p in procs: p.join() print p.name,'Finished' anim_name = 'png\\demo_conc.avi' if os.path.exists(anim_name): os.remove(anim_name) cmd_line = 'ffmpeg.exe -i png\\results\\seawat\\sp%03d_conc.png -r 24 '+anim_name+' -y' os.system(cmd_line) return
z.append(zt) #--coordinate information x0, y0 = 539750.0, 2785750.0 dx, dy = 500., 500. xcell, ycell = mfd.cell_coordinates(nrow, ncol, dx, dy) xcell += x0 ycell += y0 xedge, yedge = mfd.edge_coordinates(nrow, ncol, dx, dy) xedge += x0 yedge += y0 xmin, xmax = xedge.min(), xedge.max() ymin, ymax = yedge.min(), yedge.max() #--read shapefile with cross-section data shape_name = os.path.join('..', 'GIS', 'UMDCrossSections') print shape_name xsect_list = sf.load_shape_list(shape_name) shapes, records = sf.load_as_dict(shape_name) nxsect = len(shapes) xsect_name = [] xsect_label = [] for idx in xrange(0, nxsect): xsect_name.append(records['XSECT'][idx].replace(' ', '')) xsect_label.append(records['Label'][idx]) #--create crossection figures dxsect = 5. ifigure = 0 lay_width = [0.5, 0.5, 0.5, 0.5] lay_color = ['k', 'k', 'k', 'k'] # fresh brackish saltwater #surf_color = ['#40d3f7','#4E8975','#F76541'] surf_color = ['#40d3f7', '#40d3f7', '#F76541']
def main(num_plots): #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #shp = sf.reader(well_shapename) #print sf.get_fieldnames(well_shapename) records = sf.load_as_dict(well_shapename, loadShapes=False) well_names = records['DPEP_NAME'] well_zbots = records['zbot'] float_zbots = [] for i, wb in enumerate(well_zbots): float_zbots.append(float(wb)) well_zbots = np.array(float_zbots) well_rows, well_cols = records['row'], records['column'] pump = pandas.read_csv( '..\\..\\_pumpage\\dataframes\\pws_filled_zeros.csv', index_col=0, parse_dates=True) #--load lines and active dates line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = sf.load_shape_list(line_shapename) shp = sf.Reader(line_shapename) fnames = sf.get_fieldnames(line_shapename, ignorecase=True) #for i,fn in enumerate(fnames): # print i,fn a_idx = fnames.index('ACTIVE_ST') line_active = [] for i in range(shp.numRecords): rec = shp.record(i) year = int(rec[a_idx]) if year < flow.start.year: year = flow.start.year dt = datetime(year=year, month=1, day=1) line_active.append(dt) #--head stuff #--use bot of Q5 to check for dry cells #hds_elev = np.loadtxt(flow.ref_dir+'Q5_bot.ref') #hds_layer_idx = 0 #head_file = flow.root+'.hds' #headObj = mfb.MODFLOW_Head(flow.nlay,flow.nrow,flow.ncol,head_file) #htimes = headObj.get_time_list() #--conc stuff conc_lay_idxs = [0, 5, 9, 11] conc_file = 'MT3D001.UCN' concObj = mfb.MT3D_Concentration(seawat.nlay, seawat.nrow, seawat.ncol, conc_file) ctimes = concObj.get_time_list() #--zeta stuff #zta_layer_idx = 0 #zta_elev = np.loadtxt(flow.ref_dir+'Q1_bot.ref') #zeta_file = flow.root+'.zta' #zetaObj = mfb.MODFLOW_CBB(flow.nlay,flow.nrow,flow.ncol,zeta_file) #zta_text = ' ZETAPLANE 1' #z1times = zetaObj.get_time_list(zta_text) #zeta_file = None #-- stress period step sp_step = 1 plt_dir = 'png\\results\\seawat\\' #--for ffmpeg - sequentially numbered plt_num = 1 istart = 0 q_args = [] for i, [start, end] in enumerate(zip(seawat.sp_start, seawat.sp_end)): if i >= istart and i % sp_step == 0: print 'building args list for stress period ending on ', end #--find the conc output nearest the end of the stress period try: kper_seekpoints = ctimes[np.where(ctimes[:, 2] == i + 1), -1] c_seekpoint = long(kper_seekpoints[0][-1]) except: break act_lines = [] for ldt, line in zip(line_active, lines): if ldt <= start: act_lines.append(line) act_wells = [] if i == 0: plt_start = start else: plt_start = seawat.sp_start[i - sp_step] plt_end = seawat.sp_end[i] pump_plt = pump[plt_start:plt_end] pump_plt_sum = pump_plt.sum() for wname, wpoint, wrow, wcol, wzbot in zip( well_names, well_points, well_rows, well_cols, well_zbots): if wname in pump_plt.keys() and pump_plt_sum[wname] != 0: act_wells.append(wpoint) fig_name = plt_dir + 'sp{0:03.0f}_conc.png'.format(plt_num) fig_title = 'stress period ' + str( i + 1) + ' start date ' + start.strftime('%d/%m/%Y') args = [ fig_name, c_seekpoint, conc_lay_idxs, act_lines, act_wells, fig_title ] q_args.append(args) plt_num += 1 if num_plots != None and i > num_plots: break jobq = mp.JoinableQueue() #--for testing if num_plots != None: jobq.put_nowait(q_args[0]) jobq.put_nowait(None) plot_worker(jobq, 1, conc_file) return procs = [] num_procs = 3 for i in range(num_procs): #--pass the woker function jobq and a PID p = mp.Process(target=plot_worker, args=(jobq, i, conc_file)) p.daemon = True print 'starting process', p.name p.start() procs.append(p) for q in q_args: jobq.put(q) for p in procs: jobq.put(None) #--block until all finish for p in procs: p.join() print p.name, 'Finished' anim_name = 'png\\demo_conc.avi' if os.path.exists(anim_name): os.remove(anim_name) cmd_line = 'ffmpeg.exe -i png\\results\\seawat\\sp%03d_conc.png -r 24 ' + anim_name + ' -y' os.system(cmd_line) return
import pylab import shapefile shape_name = 'polylines_active' lines = shapefile.load_shape_list(shape_name) fig = pylab.figure() ax = pylab.subplot(111) for line in lines: ax.plot(line[0,:],line[1,:],'k--') pylab.show()
#--process each active cell for i in range(flow.nrow): for j in range(flow.ncol): if ibound[i,j] != 0: b = botm[:,i,j] z_elev = z1[i,j] ic = in_layers(z_elev,b) init_conc[:,i,j] = ic for k,lname in enumerate(seawat.layer_botm_names): aname = seawat.ref_dir+lname+'_srconc.ref' np.savetxt(aname,init_conc[k,:,:],fmt='%13.5E') #--plot imshow_extent = [flow.x[0],flow.x[-1],flow.y[0],flow.y[-1]] line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = shapefile.load_shape_list(line_shapename) for k in range(seawat.nlay): fig = pylab.figure() ax = pylab.subplot(111) init_lay = init_conc[k,:,:] init_lay = np.ma.masked_where(init_lay==0,init_lay) ax.imshow(init_lay,extent=imshow_extent) for line in lines: ax.plot(line[0,:],line[1,:],'k-',lw=0.25) l_name = seawat.layer_botm_names[k] ax.set_title(l_name) fig_name = 'png\\input\\init_conc_'+l_name+'.png' pylab.savefig(fig_name,format='png',dpi=500)
def main(num_plots): #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #shp = sf.reader(well_shapename) #print sf.get_fieldnames(well_shapename) records = sf.load_as_dict(well_shapename, loadShapes=False) well_names = records['DPEP_NAME'] well_aban = records['ABAN_YEAR'] act_wells = [] for pt, ab in zip(well_points, well_aban): if ab == '': act_wells.append(pt) #--load lines and active dates line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = sf.load_shape_list(line_shapename) #--head stuff #--use bot of Q5 to check for dry cells #hds_elev = np.loadtxt(flow.ref_dir+'Q5_bot.ref') #hds_layer_idx = 0 #head_file = flow.root+'.hds' #headObj = mfb.MODFLOW_Head(flow.nlay,flow.nrow,flow.ncol,head_file) #htimes = headObj.get_time_list() #--conc stuff conc_lay_idxs = [0, 2, 3, 4, 5] conc_file = 'MT3D001.UCN' concObj = mfb.MT3D_Concentration(seawat.nlay, seawat.nrow, seawat.ncol, conc_file) ctimes = concObj.get_time_list() #-- stress period step sp_step = 1 plt_dir = 'png\\results\\seawat\\' #--for ffmpeg - sequentially numbered plt_num = 1 istart = 0 q_args = [] for i, [start, end] in enumerate(zip(seawat.sp_start, seawat.sp_end)): if i >= istart and i % sp_step == 0: print 'building args list for stress period ending on ', end #--find the conc output nearest the end of the stress period try: kper_seekpoints = ctimes[np.where(ctimes[:, 2] == i + 1), -1] c_seekpoint = long(kper_seekpoints[0][-1]) except: break fig_name = plt_dir + 'sp{0:03.0f}_conc.png'.format(plt_num) fig_title = 'stress period ' + str( i + 1) + ' start date ' + start.strftime('%d/%m/%Y') args = [ fig_name, c_seekpoint, conc_lay_idxs, lines, act_wells, fig_title ] q_args.append(args) plt_num += 1 if num_plots != None and i > num_plots: break jobq = mp.JoinableQueue() #--for testing #if num_plots != None: # jobq.put_nowait(q_args[0]) # jobq.put_nowait(None) # plot_worker(jobq,1,conc_file) # return procs = [] num_procs = 4 for i in range(num_procs): #--pass the woker function jobq and a PID p = mp.Process(target=plot_worker, args=(jobq, i, conc_file)) p.daemon = True print 'starting process', p.name p.start() procs.append(p) for q in q_args: jobq.put(q) for p in procs: jobq.put(None) #--block until all finish for p in procs: p.join() print p.name, 'Finished' anim_name = 'png\\demo_conc.avi' if os.path.exists(anim_name): os.remove(anim_name) cmd_line = 'ffmpeg.exe -i png\\results\\seawat\\sp%03d_conc.png -r 24 ' + anim_name + ' -y' os.system(cmd_line) return
def main(): #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #shp = sf.reader(well_shapename) #print sf.get_fieldnames(well_shapename) records = sf.load_as_dict(well_shapename,loadShapes=False) well_names = records['DPEP_NAME'] well_zbots = records['zbot'] float_zbots = [] for i,wb in enumerate(well_zbots): float_zbots.append(float(wb)) well_zbots = np.array(float_zbots) well_rows, well_cols = records['row'],records['column'] pump = pandas.read_csv('..\\..\\_pumpage\\dataframes\\pws_filled_zeros.csv',index_col=0,parse_dates=True) #--load lines and active dates line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = sf.load_shape_list(line_shapename) shp = sf.Reader(line_shapename) fnames = sf.get_fieldnames(line_shapename,ignorecase=True) #for i,fn in enumerate(fnames): # print i,fn a_idx = fnames.index('ACTIVE_ST') line_active = [] for i in range(shp.numRecords): rec = shp.record(i) year = int(rec[a_idx]) if year < flow.start.year: year = flow.start.year dt = datetime(year=year,month=1,day=1) line_active.append(dt) #--head stuff #--use bot of Q5 to check for dry cells hds_elev = np.loadtxt(flow.ref_dir+'Q5_bot.ref') hds_layer_idx = 0 head_file = flow.root+'.hds' headObj = mfb.MODFLOW_Head(flow.nlay,flow.nrow,flow.ncol,head_file) htimes = headObj.get_time_list() #--zeta stuff zta_layer_idx = 0 zta_elev = np.loadtxt(flow.ref_dir+'Q1_bot.ref') zeta_file = flow.root+'.zta' zetaObj = mfb.MODFLOW_CBB(flow.nlay,flow.nrow,flow.ncol,zeta_file) zta_text = ' ZETAPLANE 1' z1times = zetaObj.get_time_list(zta_text) #zeta_file = None #-- stress period step sp_step = 1 plt_dir = 'png\\results\\' #--for ffmpeg - sequentially numbered plt_num = 1 istart = 0 q_args = [] for i,dt in enumerate(flow.sp_start): if i >= istart and i%sp_step == 0: print 'building args list for ',dt try: h_seekpoint = long(htimes[i,3]) except: break if zeta_file: z_seekpoint = long(z1times[i,3]) else: z_seekpoint = None act_lines = [] for ldt,line in zip(line_active,lines): if ldt <= dt: act_lines.append(line) act_wells = [] if i == 0: plt_start = dt else: plt_start = flow.sp_start[i-sp_step] plt_end = flow.sp_end[i] pump_plt = pump[plt_start:plt_end] pump_plt_sum = pump_plt.sum() for wname,wpoint,wrow,wcol,wzbot in zip(well_names,well_points,well_rows,well_cols,well_zbots): if wname in pump_plt.keys() and pump_plt_sum[wname] != 0: act_wells.append(wpoint) fig_name = plt_dir+'sp{0:03.0f}.png'.format(plt_num) #fig_title = 'stress period '+str(i+1)+' start date '+dt.strftime('%d/%m/%Y') fig_title = str(dt.year) args = [fig_name,h_seekpoint,z_seekpoint,act_lines,act_wells,hds_layer_idx,zta_layer_idx,fig_title] q_args.append(args) plt_num += 1 jobq = mp.JoinableQueue() #--for testing #jobq.put_nowait(q_args[0]) #jobq.put_nowait(None) #plot_worker(jobq,0,head_file,None,hds_elev,zta_elev) #return procs = [] num_procs = 6 for i in range(num_procs): #--pass the woker function jobq and a PID p = mp.Process(target=plot_worker,args=(jobq,i,head_file,zeta_file,hds_elev,zta_elev)) p.daemon = True print 'starting process',p.name p.start() procs.append(p) for q in q_args: jobq.put(q) for p in procs: jobq.put(None) #--block until all finish for p in procs: p.join() print p.name,'Finished' cmd_line = 'ffmpeg.exe -i results\sp%03d.png -r 24 demo.avi -y' os.system(cmd_line) return
z.append( zt ) #--coordinate information x0, y0 = 539750.0, 2785750.0 dx,dy = 500., 500. xcell, ycell = mfd.cell_coordinates(nrow,ncol,dx,dy) xcell += x0 ycell += y0 xedge, yedge = mfd.edge_coordinates(nrow,ncol,dx,dy) xedge += x0 yedge += y0 xmin,xmax = xedge.min(),xedge.max() ymin,ymax = yedge.min(),yedge.max() #--read shapefile with cross-section data shape_name = os.path.join( '..','GIS','UMDCrossSections' ) print shape_name xsect_list = sf.load_shape_list(shape_name) shapes,records = sf.load_as_dict(shape_name) nxsect = len(shapes) xsect_name = [] xsect_label = [] for idx in xrange( 0, nxsect ): xsect_name.append( records['XSECT'][idx].replace(' ','') ) xsect_label.append( records['Label'][idx] ) #--create crossection figures dxsect = 5. ifigure = 0 lay_width = [0.5,0.5,0.5,0.5] lay_color = ['k','k','k','k'] # fresh brackish saltwater #surf_color = ['#40d3f7','#4E8975','#F76541'] surf_color = ['#40d3f7','#40d3f7','#F76541']
text = ' ET SEGMENTS' sys.stdout.write('Building time list for...{0}\n'.format(text)) ets_time_list = metObj.get_time_list(text) text = ' NEXRAD RAINFALL' sys.stdout.write('Building time list for...{0}\n'.format(text)) rch_time_list = metObj.get_time_list(text) text = ' SEPTIC RETURN' sys.stdout.write('Building time list for...{0}\n'.format(text)) sep_time_list = metObj.get_time_list(text) ntimes = sep_time_list.shape[0] #--make a map #--read shapefile to use as base map on figures shape_name = os.path.join('D:/', 'Data', 'Users', 'jdhughes', 'GIS', 'Project Data', '2080DBF00', 'Spatial', 'FigureData', 'BaseMap') hydrography = sf.load_shape_list(shape_name) salinity_struct_shape_name = os.path.join('D:/', 'Data', 'Users', 'jdhughes', 'GIS', 'Project Data', '2080DBF00', 'Spatial', 'FigureData', 'SalinityControlStructures') salinity_struc = sf.load_shape_list(salinity_struct_shape_name) df_struct_shape_name = os.path.join('D:/', 'Data', 'Users', 'jdhughes', 'GIS', 'Project Data', '2080DBF00', 'Spatial', 'FigureData', 'DrainageFloodControlStructures') df_struc = sf.load_shape_list(df_struct_shape_name) pws_struct_shape_name = os.path.join('D:/', 'Data', 'Users', 'jdhughes', 'GIS', 'Project Data', '2080DBF00', 'Spatial', 'Water Use', 'pumpwells_lb') pws = sf.load_shape_list(pws_struct_shape_name) #--coordinate information
def plot_worker(jobq,resultq,mask,pid,lineshape,plot): ''' args[0] = figure name args[1] = sp length args[2] = rch array name args[3] = ets array name if mask, where masked==0 is masked ''' imshow_extent = [flow.x[0],flow.x[-1],flow.y[0],flow.y[-1]] lines = shapefile.load_shape_list(lineshape) while True: #--get some args from the queue args = jobq.get() #--check if this is a sentenial if args == None: break #--load rch rcharr = np.fromfile(args[2],dtype=np.float32) rcharr.resize(flow.nrow,flow.ncol) #rcharr *= flow.rch_mult rcharr = np.ma.masked_where(mask==0,rcharr) #--load ets etsarr = np.fromfile(args[3],dtype=np.float32) etsarr.resize(flow.nrow,flow.ncol) etsarr /= 25.4 etsarr = np.ma.masked_where(mask==0,etsarr) ratemax = max(rcharr.max(),etsarr.max()) ratemin = min(rcharr.min(),etsarr.min()) rchdepth = rcharr * args[1] etsdepth = etsarr * args[1] results = [args[-1],np.mean(rchdepth),np.max(rchdepth),np.min(rchdepth),np.mean(etsdepth),np.max(etsdepth),np.min(etsdepth)] resultq.put(results) depthmax = max(rchdepth.max(),etsdepth.max()) depthmin = min(rchdepth.min(),etsdepth.min()) #--plot if plot: fig = pylab.figure(figsize=(8,8)) ax1 = pylab.axes((0.05,0.525,0.45,0.45)) ax2 = pylab.axes((0.05,0.055,0.45,0.45)) ax3 = pylab.axes((0.525,0.525,0.45,0.45)) ax4 = pylab.axes((0.525,0.055,0.45,0.45)) cax1 = pylab.axes((0.05,0.53,0.45,0.015)) cax2 = pylab.axes((0.05,0.05,0.45,0.015)) cax3 = pylab.axes((0.525,0.53,0.45,0.015)) cax4 = pylab.axes((0.525,0.05,0.45,0.015)) fig.text(0.5,0.965,args[0].split('.')[0]) p1 = ax1.imshow(rcharr,extent=imshow_extent,interpolation='none')#,vmax=ratemax,vmin=ratemin) p2 = ax2.imshow(etsarr,extent=imshow_extent,interpolation='none')#,vmax=ratemax,vmin=ratemin) p3 = ax3.imshow(rchdepth,extent=imshow_extent,interpolation='none')#,vmax=volmax,vmin=volmin) p4 = ax4.imshow(rchdepth-etsdepth,extent=imshow_extent,interpolation='none')#,vmax=volmax,vmin=volmin) cb1 = pylab.colorbar(p1,cax=cax1,orientation='horizontal') cb2 = pylab.colorbar(p2,cax=cax2,orientation='horizontal') cb3 = pylab.colorbar(p3,cax=cax3,orientation='horizontal') cb4 = pylab.colorbar(p4,cax=cax4,orientation='horizontal') cb1.set_label('recharge rate $in/day$') cb2.set_label('reference ET rate $in/day$') cb3.set_label('recharge depth $inches$') cb4.set_label('recharge depth minus ref ET depth $inches$') ax1.set_ylim(flow.plt_y) ax1.set_xlim(flow.plt_x) ax2.set_ylim(flow.plt_y) ax2.set_xlim(flow.plt_x) ax3.set_ylim(flow.plt_y) ax3.set_xlim(flow.plt_x) ax4.set_ylim(flow.plt_y) ax4.set_xlim(flow.plt_x) ax1.set_xticklabels([]) ax3.set_xticklabels([]) ax3.set_yticklabels([]) ax4.set_yticklabels([]) fmt = args[0].split('.')[-1] pylab.savefig(args[0],dpi=300,format=fmt) pylab.close(fig) #--mark this task as done jobq.task_done() print 'plot worker',pid,' finished',args[0] #--mark the sentenial as done jobq.task_done() resultq.put(None) return
mpl.rcParams['font.cursive'] = 'Zapf Chancery' mpl.rcParams['font.fantasy'] = 'Comic Sans MS' mpl.rcParams['font.monospace'] = 'Courier New' mpl.rcParams['pdf.compression'] = 0 mpl.rcParams['pdf.fonttype'] = 42 ticksize = 6 mpl.rcParams['legend.fontsize'] = 6 mpl.rcParams['axes.labelsize'] = 8 mpl.rcParams['xtick.labelsize'] = ticksize mpl.rcParams['ytick.labelsize'] = ticksize #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #shp = sf.reader(well_shapename) #print sf.get_fieldnames(well_shapename) records = sf.load_as_dict(well_shapename,loadShapes=False) well_names = records['DPEP_NAME'] well_zbots = records['zbot'] float_zbots = [] for i,wb in enumerate(well_zbots): float_zbots.append(float(wb)) well_zbots = np.array(float_zbots) well_rows, well_cols = records['row'],records['column'] pump = pandas.read_csv('..\\..\\_pumpage\\pws_filled_zeros.csv',index_col=0,parse_dates=True) #--load lines and active dates line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = sf.load_shape_list(line_shapename)
def main(): #--load well locations and pandas dataframe well_shapename = '..\\..\\_gis\\shapes\\pws_combine' well_points = sf.load_shape_list(well_shapename) #--load lines and active dates line_shapename = '..\\..\\_gis\shapes\sw_reaches' lines = sf.load_shape_list(line_shapename) #--head stuff #--use bot of Q5 to check for dry cells hds_elev = np.loadtxt(flow.ref_dir + 'Q5_bot.ref') hds_layer_idx = 0 head_file = flow.root + '.hds' headObj = mfb.MODFLOW_Head(flow.nlay, flow.nrow, flow.ncol, head_file) htimes = headObj.get_time_list() #--zeta stuff zta_layer_idx = 0 zta_elev = np.loadtxt(flow.ref_dir + 'Q1_bot.ref') zeta_file = flow.root + '.zta' zetaObj = mfb.MODFLOW_CBB(flow.nlay, flow.nrow, flow.ncol, zeta_file) zta_text = ' ZETAPLANE 1' z1times = zetaObj.get_time_list(zta_text) #zeta_file = None #-- stress period step sp_step = 1 plt_dir = 'png\\results\\' #--for ffmpeg - sequentially numbered plt_num = 1 istart = 0 q_args = [] for i, dt in enumerate(flow.sp_start): if i >= istart and i % sp_step == 0: print 'building args list for ', dt try: h_seekpoint = long(htimes[i, 3]) except: break if zeta_file: z_seekpoint = long(z1times[i, 3]) else: z_seekpoint = None fig_name = plt_dir + 'sp{0:03.0f}.png'.format(plt_num) #fig_title = 'stress period '+str(i+1)+' start date '+dt.strftime('%d/%m/%Y') fig_title = str(dt.year) args = [ fig_name, h_seekpoint, z_seekpoint, lines, well_points, hds_layer_idx, zta_layer_idx, fig_title ] q_args.append(args) plt_num += 1 jobq = mp.JoinableQueue() #--for testing #jobq.put_nowait(q_args[0]) #jobq.put_nowait(None) #plot_worker(jobq,0,head_file,None,hds_elev,zta_elev) #return procs = [] num_procs = 3 for i in range(num_procs): #--pass the woker function jobq and a PID p = mp.Process(target=plot_worker, args=(jobq, i, head_file, zeta_file, hds_elev, zta_elev)) p.daemon = True print 'starting process', p.name p.start() procs.append(p) for q in q_args: jobq.put(q) for p in procs: jobq.put(None) #--block until all finish for p in procs: p.join() print p.name, 'Finished' cmd_line = 'ffmpeg.exe -i results\sp%03d.png -r 24 demo.avi -y' os.system(cmd_line) return
tgf.write( cval ) else: cval = '% 9i %9i %9i %9.5f %9.3g %s\n' % ( ilay, irow+1, icol+1, te, cond, ctag) tdf.write( cval ) return True #--main script cpath2mod = '..\\..\\UMD.01\\' KeepAllPng = False MakeImages = False MakeMFFiles = False maxdays = 0 shape_name = 'D:\\Data\\Users\\jdhughes\\GIS\\Project Data\\2080DBF00\\Spatial\\FigureData\\BaseMap' hydrography = sf.load_shape_list(shape_name) figuresize = [4.4,6] #--get command line arguments narg = len(sys.argv) iarg = 0 if narg > 1: while iarg < narg-1: iarg += 1 basearg = sys.argv[iarg].lower() if basearg == '-maxdays': try: iarg += 1 maxdays = int( sys.argv[iarg] ) print 'command line arg: maxdays = ', maxdays
def plot_worker(jobq, resultq, mask, pid, lineshape, plot): ''' args[0] = figure name args[1] = sp length args[2] = rch array name args[3] = ets array name if mask, where masked==0 is masked ''' imshow_extent = [flow.x[0], flow.x[-1], flow.y[0], flow.y[-1]] lines = shapefile.load_shape_list(lineshape) while True: #--get some args from the queue args = jobq.get() #--check if this is a sentenial if args == None: break #--load rch rcharr = np.fromfile(args[2], dtype=np.float32) rcharr.resize(flow.nrow, flow.ncol) #rcharr *= flow.rch_mult rcharr = np.ma.masked_where(mask == 0, rcharr) #--load ets etsarr = np.fromfile(args[3], dtype=np.float32) etsarr.resize(flow.nrow, flow.ncol) etsarr /= 25.4 etsarr = np.ma.masked_where(mask == 0, etsarr) ratemax = max(rcharr.max(), etsarr.max()) ratemin = min(rcharr.min(), etsarr.min()) rchdepth = rcharr * args[1] etsdepth = etsarr * args[1] results = [ args[-1], np.mean(rchdepth), np.max(rchdepth), np.min(rchdepth), np.mean(etsdepth), np.max(etsdepth), np.min(etsdepth) ] resultq.put(results) depthmax = max(rchdepth.max(), etsdepth.max()) depthmin = min(rchdepth.min(), etsdepth.min()) #--plot if plot: fig = pylab.figure(figsize=(8, 8)) ax1 = pylab.axes((0.05, 0.525, 0.45, 0.45)) ax2 = pylab.axes((0.05, 0.055, 0.45, 0.45)) ax3 = pylab.axes((0.525, 0.525, 0.45, 0.45)) ax4 = pylab.axes((0.525, 0.055, 0.45, 0.45)) cax1 = pylab.axes((0.05, 0.53, 0.45, 0.015)) cax2 = pylab.axes((0.05, 0.05, 0.45, 0.015)) cax3 = pylab.axes((0.525, 0.53, 0.45, 0.015)) cax4 = pylab.axes((0.525, 0.05, 0.45, 0.015)) fig.text(0.5, 0.965, args[0].split('.')[0]) p1 = ax1.imshow(rcharr, extent=imshow_extent, interpolation='none') #,vmax=ratemax,vmin=ratemin) p2 = ax2.imshow(etsarr, extent=imshow_extent, interpolation='none') #,vmax=ratemax,vmin=ratemin) p3 = ax3.imshow(rchdepth, extent=imshow_extent, interpolation='none') #,vmax=volmax,vmin=volmin) p4 = ax4.imshow(rchdepth - etsdepth, extent=imshow_extent, interpolation='none') #,vmax=volmax,vmin=volmin) cb1 = pylab.colorbar(p1, cax=cax1, orientation='horizontal') cb2 = pylab.colorbar(p2, cax=cax2, orientation='horizontal') cb3 = pylab.colorbar(p3, cax=cax3, orientation='horizontal') cb4 = pylab.colorbar(p4, cax=cax4, orientation='horizontal') cb1.set_label('recharge rate $in/day$') cb2.set_label('reference ET rate $in/day$') cb3.set_label('recharge depth $inches$') cb4.set_label('recharge depth minus ref ET depth $inches$') ax1.set_ylim(flow.plt_y) ax1.set_xlim(flow.plt_x) ax2.set_ylim(flow.plt_y) ax2.set_xlim(flow.plt_x) ax3.set_ylim(flow.plt_y) ax3.set_xlim(flow.plt_x) ax4.set_ylim(flow.plt_y) ax4.set_xlim(flow.plt_x) ax1.set_xticklabels([]) ax3.set_xticklabels([]) ax3.set_yticklabels([]) ax4.set_yticklabels([]) fmt = args[0].split('.')[-1] pylab.savefig(args[0], dpi=300, format=fmt) pylab.close(fig) #--mark this task as done jobq.task_done() print 'plot worker', pid, ' finished', args[0] #--mark the sentenial as done jobq.task_done() resultq.put(None) return