def plot(): hds_file = grid.modelname + '.hds' hds_obj = mfb.MODFLOW_Head(grid.nlay, grid.nrow, grid.ncol, hds_file) htimes = hds_obj.get_time_list() q_args = [] plot_dir = 'png\\' for htime in htimes[20:]: htime = htime[-1] totim, kper, kstp, arr, success = hds_obj.get_array(htime) for k in range(grid.nlay): ibnd = np.loadtxt(grid.ibound_names[k]) arr_lay = arr[k, :, :] arr_lay = np.ma.masked_where(ibnd == 0, arr_lay) print k, arr_lay.min(), arr_lay.max() pname = plot_dir + 'head_' + str(k + 1) + '.png' plot_array(pname, arr_lay) break
delc = 1.0 delz = z_len / nlay try: plt = [sys.argv[1]] except: plt = ['h', 'c'] xsec_row = 0 cmap_heads = pylab.get_cmap('Spectral_r') cmap_conc = cmap_heads figsize = (4.67, 2.57) axes = [] if 'h' in plt: hds_obj = mfb.MODFLOW_Head(nlay, nrow, ncol, 'henry_coarse.hds') while True: totim, kstp, kper, hd, success = hds_obj.next() print 'head', totim if success == False: break fig = pylab.figure() ax = pylab.subplot(111, aspect='equal') p = ax.pcolor(np.flipud(hd[:, xsec_row, :]), cmap=cmap_heads, vmin=hd.min(), vmax=hd.max()) ax.set_yticklabels([]) ax.set_xticklabels([]) cax = pylab.colorbar(p, orientation='horizontal') cax.ax.set_title('heads ' + str(totim))
def plot_worker(jobq, pid, hds_name, zta_name, dry_elev, zta_elev): if hds_name is not None: headObj = mfb.MODFLOW_Head(flow.nlay, flow.nrow, flow.ncol, hds_name) htimes = headObj.get_time_list() ntimes = htimes.shape[0] if zta_name is not None: 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) while True: args = jobq.get() if args == None: break '''args[0] = plot name args[1] = hds seekpoint args[2] = zeta seekpoint args[3] = active reaches args[4] = active wells args[5] = head layer index args[6] = zta layer index args[7] = fig_title ''' fig_name = args[0] hds_seekpoint = args[1] zta_seekpoint = args[2] lines = args[3] wells = args[4] h_layer_idx = args[5] z_layer_idx = args[6] fig_title = args[7] #--load and mask head if hds_name is not None: totim, kstp, kper, h, success = headObj.get_array(hds_seekpoint) hd = np.copy(h[h_layer_idx, :, :]) dtw = np.copy(h[h_layer_idx, :, :]) dtw = flow.top - dtw mask_flood = np.ones_like(dtw) mask_flood = np.ma.masked_where(dtw >= 0, mask_flood) mask_flood = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), mask_flood) mask_dry = np.ones_like(dtw) mask_dry = np.ma.masked_where(hd > dry_elev, mask_dry) mask_dry = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), mask_dry) hd = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), hd) dtw = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), dtw) #--load and mask zeta surface 1 if zta_name is not None: z, totim, success = zetaObj.get_array(zta_seekpoint) z1 = z[z_layer_idx, :, :] z1m = np.ma.masked_where(z1 < zta_elev, z1) z1m = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), z1m) dz1 = flow.top - z1m 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)) cax1 = pylab.axes((0.05, 0.53, 0.45, 0.015)) cax2 = pylab.axes((0.05, 0.05, 0.45, 0.015)) p1 = ax1.imshow(hd, extent=imshow_extent, cmap=cmap, interpolation='none', vmax=hd_levels[-1], vmin=hd_levels[0]) #p2 = ax2.imshow(dtw,extent=imshow_extent,cmap=cmap,interpolation='none',vmax=dtw_levels[-1],vmin=dtw_levels[0]) p2 = ax2.imshow(z1m, extent=imshow_extent, interpolation='none', vmax=0.0, vmin=-135.0) #ax1.imshow(mask_flood,alpha=0.5,extent=imshow_extent,cmap=cmap_flood,interpolation='nearest',vmin=0,vmax=1) #ax2.imshow(mask_flood,alpha=0.5,extent=imshow_extent,cmap=cmap_flood,interpolation='nearest',vmin=0,vmax=1) ax1.imshow(mask_dry, extent=imshow_extent, cmap=cmap_dry, interpolation='nearest', vmin=0, vmax=1) ax2.imshow(mask_dry, extent=imshow_extent, cmap=cmap_dry, interpolation='nearest', vmin=0, vmax=1) cb1 = pylab.colorbar(p1, cax=cax1, orientation='horizontal') cb2 = pylab.colorbar(p2, cax=cax2, orientation='horizontal') cb1.set_label('water table elevation $ft NGVD$') cb2.set_label('elevation of interface $ft NGVD$') ax1.set_ylim(flow.plt_y) ax1.set_xlim(flow.plt_x) ax2.set_ylim(flow.plt_y) ax2.set_xlim(flow.plt_x) ax1.set_xticklabels([]) #-- plot active reaches for line in lines: ax1.plot(line[0, :], line[1, :], 'k-', lw=0.25) ax2.plot(line[0, :], line[1, :], 'k-', lw=0.25) #-- plot active wells #for wpoint in wells: # color=salt_well_color # if hds_name: # ax1.plot(wpoint[0],wpoint[1],'.',mfc=color,mec='none',ms=4) # ax2.plot(wpoint[0],wpoint[1],'.',mfc=color,mec='none',ms=4) # if zta_name: # ax3.plot(wpoint[0],wpoint[1],'.',mfc=color,mec='none',ms=4) # ax4.plot(wpoint[0],wpoint[1],'.',mfc=color,mec='none',ms=4) for wpoint in wells: color = 'k' ax1.plot(wpoint[0], wpoint[1], '.', mfc=color, mec='none', ms=4) ax2.plot(wpoint[0], wpoint[1], '.', mfc=color, mec='none', ms=4) fig.text(0.25, 0.965, fig_title, ha='center') pylab.savefig(fig_name, dpi=300, format='png', bbox_inches='tight') pylab.close('all') print pid, '-- done--', fig_title jobq.task_done() jobq.task_done() 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
import numpy as np import MFBinaryClass as mfb from bro_pred import seawat '''get initial conditions for seawat model predictive run - heads and zetas ''' hds_file = '..\\..\\_model\\bro.02\\seawat.hds' conc_file = '..\\..\\_model\\bro.02\\MT3D001.UCN' hds_obj = mfb.MODFLOW_Head(seawat.nlay, seawat.nrow, seawat.ncol, hds_file) conc_obj = mfb.MT3D_Concentration(seawat.nlay, seawat.nrow, seawat.ncol, conc_file) htimes = hds_obj.get_time_list() ctimes = conc_obj.get_time_list() hseekpoint = long(htimes[-1, 3]) cseekpoint = long(ctimes[-1, 3]) hds_save = seawat.ref_dir + 'strt_' conc_save = seawat.ref_dir + 'sconc_1_' htotim, kstp, kper, h, hsuccess = hds_obj.get_array(hseekpoint) ctotim, ckstp, ckper, c, csuccess = conc_obj.get_array(cseekpoint) if not hsuccess: raise Exception('could not extract heads') if not csuccess: raise Exception('could not extract zetas')
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 < bro.start.year: year = bro.start.year dt = datetime(year=year, month=1, day=1) line_active.append(dt) #--head stuff #--use bot of layer 1 to check for dry cells l1_bot = np.loadtxt('ref\\Q5_bot.ref') hds_layer_idx = 0 head_file = bro.modelname + '.hds' headObj = mfb.MODFLOW_Head(bro.nlay, bro.nrow, bro.ncol, head_file) htimes = headObj.get_time_list() ntimes = htimes.shape[0] #--swi stuff #zta_layer_idx_1 = 3 #zta_layer_idx_2 = 4 #zta_layer_bot_1 = np.loadtxt('ref\\Q2_bot.ref') #zta_layer_bot_2 = np.loadtxt('ref\\Q1_bot.ref') #zeta_file = bro.modelname+'.zta' #zetaObj = mfb.MODFLOW_CBB(bro.nlay,bro.nrow,bro.ncol,zeta_file) #zta_text = ' ZETAPLANE 1' #z1times = zetaObj.get_time_list(zta_text) #zta_text = ' ZETAPLANE 2' #z2times = zetaObj.get_time_list(zta_text)
import pylab import numpy as np import MFBinaryClass as mfb nrow, ncol, nlay = 383, 262, 3 hds_obj = mfb.MODFLOW_Head(nlay, nrow, ncol, 'tsala.hds') totim, kstp, kper, hd, success = hds_obj.get_record() for l in range(nlay): np.savetxt('ref\\init_heads_' + str(l + 1) + '.ref', hd[l, :, :], fmt='%15.6e')
shape_dir = 'shapes\\' #sys.exit() #--heads ibound = np.loadtxt('ref\ibound.ref') #--loop over each month, using the last day in the month tot_days = 0 for m in range(1,13): days = calendar.mdays[m] tot_days += days hds_handle = mfb.MODFLOW_Head(nlay,nrow,ncol,results+'bro_6lay.hds') totim,kstp,kper,h,success = hds_handle.get_record(tot_days) print 'day',tot_days,' processing for month ',m for l in range(nlay): this_head = h[l,:,:] this_head[np.where(ibound==0)] = -9999.0 au.ref2grd('shapes\\head_layer'+str(l+1)+'_month'+str(m)+'.txt',\ h[l,:,:],nrow,ncol,offset,500.0)
#--read ibound ib_ref = os.path.join('..', 'REF', 'UMD_IBOUND.ref') ib = au.loadArrayFromFile(nrow, ncol, ib_ref) #--read the bottom of the model bot_ref = os.path.join('..', 'REF', 'UMD_BOTM_L1.ref') model_bot1 = au.loadArrayFromFile(nrow, ncol, bot_ref) bot_ref = os.path.join('..', 'REF', 'UMD_BOTM_L2.ref') model_bot2 = au.loadArrayFromFile(nrow, ncol, bot_ref) bot_ref = os.path.join('..', 'REF', 'UMD_BOTM_L3.ref') model_bot3 = au.loadArrayFromFile(nrow, ncol, bot_ref) #--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 #--get available times in the head file headObj = mfb.MODFLOW_Head(nlay, nrow, ncol, head_file) head_time_list = headObj.get_time_list() #--zeta surface to extract zetaObj = mfb.MODFLOW_CBB(nlay, nrow, ncol, zeta_file) zta_text = ' ZETAPLANE 1' z1_time_list = zetaObj.get_time_list(zta_text) zta_text = ' ZETAPLANE 2' z2_time_list = zetaObj.get_time_list(zta_text) #--get last head and last zeta #--read head data - final zeta surface iposition = long(head_time_list[-1, 3]) totim, kstp, kper, h, success = headObj.get_array(iposition) #--read zeta data - final zeta surface iposition = long(z1_time_list[-1, 3]) z1, totim, success = zetaObj.get_array(iposition) iposition = long(z2_time_list[-1, 3])
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
ResultsDir = sys.argv[iarg] #--replace path in HeadFile with the value passed from the command line HeadFile = os.path.join(ResultsDir, HeadBaseName) print 'command line arg: -resultsdir = ', ResultsDir except: print 'cannot parse command line arg: -resultsdir' print 'processing head data from...{0}\nFor the period from {1} to {2}'.format( HeadFile, start_date, end_date) print ' for {0} head stations'.format(num_sites) #--read discretization data offset, nlay, nrow, ncol, delr, delc = mfd.load_dis_file(DIS_file) xedge, yedge = mfd.edge_coordinates(nrow, ncol, delr, delc) #--open head file headObj = mfb.MODFLOW_Head(nlay, nrow, ncol, HeadFile) times = headObj.get_time_list() #--read ibound ib = au.loadArrayFromFile(nrow, ncol, IBOUND_file) #--read the top of layer 1 top_file = os.path.join('..', 'REF', 'UMD_URBAN_EDEN_TOPO.ref') temp = au.loadArrayFromFile(nrow, ncol, top_file) #--read layer bottoms bot = np.zeros((nlay + 1, nrow, ncol), np.float) bot[0, :, :] = np.copy(temp) for k in xrange(0, nlay): bot_file = os.path.join('..', 'REF', 'UMD_BOTM_L{0}.ref'.format(k + 1)) temp = au.loadArrayFromFile(nrow, ncol, bot_file) bot[k + 1, :, :] = np.copy(temp) #--make sure output directories exist
#--use the iswrbnd to mask the inactive reaches iswrbnd = np.loadtxt('swr_full\\swr_ds6.dat') #--first make a backup copy for l in range(bi.nlay): shutil.copy('ref\\init_heads_'+str(l+1)+'.ref','ref\\init_heads_'+str(l+1)+'_bak.ref') shutil.copy('swr_full\\swr_ds14a.dat','swr_full\\swr_ds_14a_bak.dat') #--heads top = np.loadtxt('ref\\top_filter_20_edge.ref') hds_handle = mfb.MODFLOW_Head(bi.nlay,bi.nrow,bi.ncol,results+'bro_6lay.hds') try: totim,kstp,kper,h,success = hds_handle.get_record(float(sys.argv[1])) print 'heads from totim ',sys.argv[1],' read' except: totim,kstp,kper,h,success = hds_handle.get_record() for l in range(bi.nlay): np.savetxt('ref\\init_heads_'+str(l+1)+'.ref',h[l,:,:],fmt='%15.6e') h = ma.masked_where(h < -900.0,h) h = ma.masked_where(h > top,h) au.plotArray(h[0,:,:],bi.delr,bi.delc,offset=bi.offset,output=None,title='head') #--get stages for init stage swr_obj = mfb.SWR_Record(0,results+'bro_6lay.stg') try: totim,dt,kper,kstp,swrstp,success,r = swr_obj.get_record(float(sys.argv[1]))
def plot_worker(jobq, pid, dry_elev, zta_elev, hds1, hds2, zta1, zta2): headObj1 = mfb.MODFLOW_Head(flow.nlay, flow.nrow, flow.ncol, hds1) headObj2 = mfb.MODFLOW_Head(flow.nlay, flow.nrow, flow.ncol, hds2) zetaObj1 = mfb.MODFLOW_CBB(flow.nlay, flow.nrow, flow.ncol, zta1) zetaObj2 = mfb.MODFLOW_CBB(flow.nlay, flow.nrow, flow.ncol, zta2) while True: args = jobq.get() if args == None: break '''args[0] = plot name args[1] = hds1 seekpoint args[2] = zeta1 seekpoint args[3] = hds2 seekpoint args[4] = zeta2 seekpoint args[5] = active reaches args[6] = active wells args[7] = head layer index args[8] = zta layer index args[9] = fig_title ''' fig_name = args[0] hds1_seekpoint = args[1] zta1_seekpoint = args[2] hds2_seekpoint = args[3] zta2_seekpoint = args[4] lines = args[5] wells = args[6] h_layer_idx = args[7] z_layer_idx = args[8] fig_title = args[9] #--load and mask head totim, kstp, kper, h1, success = headObj1.get_array(hds1_seekpoint) hd1 = h1[h_layer_idx, :, :] hd1 = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), hd1) totim, kstp, kper, h2, success = headObj2.get_array(hds2_seekpoint) hd2 = h2[h_layer_idx, :, :] hd2 = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), hd2) hd_diff = hd1 - hd2 hd_diff = np.ma.masked_where(np.abs(hd_diff) < 0.01, hd_diff) #hd1 = np.ma.masked_where(np.abs(hd_diff)<0.01,hd1) hd2 = np.ma.masked_where(np.abs(hd_diff) < 0.01, hd2) z1, totim, success = zetaObj1.get_array(zta1_seekpoint) z1 = z1[z_layer_idx, :, :] z1m = np.ma.masked_where(z1 < zta_elev, z1) z1m = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), z1m) z2, totim, success = zetaObj2.get_array(zta2_seekpoint) z2 = z2[z_layer_idx, :, :] z2m = np.ma.masked_where(z2 < zta_elev, z2) z2m = np.ma.masked_where( np.logical_and(flow.ibound != 1, flow.ibound != 2), z2m) zt_diff = z1 - z2 zt_diff = np.ma.masked_where(np.abs(zt_diff) < 0.1, zt_diff) 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)) cax1 = pylab.axes((0.05, 0.53, 0.45, 0.015)) cax2 = pylab.axes((0.05, 0.05, 0.45, 0.015)) #vmax = max(np.max(hd1),np.max(hd2)) #vmin = min(np.min(hd1),np.min(hd2)) vmax, vmin = 10, -5.0 p1 = ax1.imshow(hd1, extent=imshow_extent, cmap=cmap, interpolation='none', vmax=vmax, vmin=vmin) p2 = ax2.imshow(hd_diff, extent=imshow_extent, cmap=cmap, interpolation='none') #,vmax=vmax,vmin=vmin) cb1 = pylab.colorbar(p1, cax=cax1, orientation='horizontal') cb2 = pylab.colorbar(p2, cax=cax2, orientation='horizontal') cb1.set_label('elevation $ft NGVD$') cb2.set_label('elevation $ft NGVD$') ax1.set_ylim(flow.plt_y) ax1.set_xlim(flow.plt_x) ax2.set_ylim(flow.plt_y) ax2.set_xlim(flow.plt_x) ax1.set_xticklabels([]) ax3 = pylab.axes((0.525, 0.525, 0.45, 0.45)) ax4 = pylab.axes((0.525, 0.055, 0.45, 0.45)) cax3 = pylab.axes((0.525, 0.53, 0.45, 0.015)) cax4 = pylab.axes((0.525, 0.05, 0.45, 0.015)) p3 = ax3.imshow(z1m, extent=imshow_extent, interpolation='none') p4 = ax4.imshow(zt_diff, extent=imshow_extent, interpolation='none') cb3 = pylab.colorbar(p3, cax=cax3, orientation='horizontal') cb4 = pylab.colorbar(p4, cax=cax4, orientation='horizontal') cb3.set_label('interface elevation $ft NGVD$') cb4.set_label('interface elevation $ft NGVD$') ax3.set_ylim(flow.plt_y) ax3.set_xlim(flow.plt_x) ax4.set_ylim(flow.plt_y) ax4.set_xlim(flow.plt_x) ax3.set_xticklabels([]) ax3.set_yticklabels([]) ax4.set_yticklabels([]) #-- plot active reaches for line in lines: ax1.plot(line[0, :], line[1, :], 'k-', lw=0.25) ax2.plot(line[0, :], line[1, :], 'k-', lw=0.25) ax3.plot(line[0, :], line[1, :], 'k-', lw=0.25) ax4.plot(line[0, :], line[1, :], 'k-', lw=0.25) for wpoint in wells: color = 'k' ax1.plot(wpoint[0], wpoint[1], '.', mfc=color, mec='none', ms=4) ax2.plot(wpoint[0], wpoint[1], '.', mfc=color, mec='none', ms=4) ax3.plot(wpoint[0], wpoint[1], '.', mfc=color, mec='none', ms=4) ax4.plot(wpoint[0], wpoint[1], '.', mfc=color, mec='none', ms=4) fig.text(0.5, 0.965, fig_title, ha='center') pylab.savefig(fig_name, dpi=300, format='png', bbox_inches='tight') pylab.close('all') print pid, '-- done--', fig_title jobq.task_done() jobq.task_done() return
import numpy as np import MFBinaryClass as mfb from bro_pred import flow '''get initial conditions for flow model predictive run - heads and zetas ''' hds_file = '..\\..\\_model\\bro.03\\flow.hds' zta_file = '..\\..\\_model\\bro.03\\flow.zta' zta_text = ' ZETAPLANE 1' hds_obj = mfb.MODFLOW_Head(flow.nlay,flow.nrow,flow.ncol,hds_file) zta_obj = mfb.MODFLOW_CBB(flow.nlay,flow.nrow,flow.ncol,zta_file) htimes = hds_obj.get_time_list() ztimes = zta_obj.get_time_list(zta_text) hseekpoint = long(htimes[-1,3]) zseekpoint = long(ztimes[-1,3]) hds_save = flow.ref_dir+'strt_1.ref' zta_save = flow.ref_dir+'IZETA_1_L1.ref' htotim,kstp,kper,h,hsuccess = hds_obj.get_array(hseekpoint) z,ztotim,zsuccess = zta_obj.get_array(zseekpoint) if not hsuccess: raise Exception('could not extract heads') if not zsuccess: raise Exception('could not extract zetas')
import sys import numpy as np import pylab import arrayUtil as au import MFBinaryClass as mfb reload(mfb) nlay, nrow, ncol = 9, 301, 501 delr, delc = 500, 500 offset = [668350., 288415.] hds_file = 'Results\\bro.hds' hdsObj = mfb.MODFLOW_Head(nlay, nrow, ncol, hds_file) success = True while success == True: totim, kstp, kper, heads, success = hdsObj.next() print totim #for ilay in range(0,nlay): # au.writeArrayToFile(heads[ilay,:,:],'layer_'+str(ilay+1)+'.ref') au.plotArray(heads[0, ::2, ::2], delr, delc, bln='bro_hydro.bln', title=str(1) + ' ' + str(totim), offset=offset, output='save', max=10.0)
for a in range(0,len(compele)): thisCompele = reach_key[np.where(reach_key[:,1]==a+1)].astype(int) #print a+1,thisCompele[0,2],thisCompele[0,3] for r in thisCompele: #print r array[r[2]-1,r[3]-1] = compele[a,i] m_array[r[2]-1,r[3]-1] = 1 array = ma.masked_where(m_array==-999.0,array) this_ax = au.plotArray(array,delr,delc,offset=offset,\ output=None,title=repr(i)+' '+ce_items[i]) #--heads top = np.loadtxt('ref\\top_filter_35_edge.ref') hds_handle = mfb.MODFLOW_Head(1,nrow,ncol,results+'bro_1lay.hds') totim,kstp,kper,h,success = hds_handle.get_record() np.savetxt('init_heads.ref',h[0,:,:],fmt='%15.6e') h = ma.masked_where(h < -900.0,h) h = ma.masked_where(h > top,h) au.plotArray(h[0,:,:],delr,delc,offset=offset,output=None,title='head') #--get stages for init stage swr_obj = mfb.SWR_Record(0,results+'bro_1lay.stg') totim,dt,kper,kstp,swrstp,success,r = swr_obj.get_record() #print reach_key[:,0],r #np.savetxt('stage_out.dat',np.array([reach_key[:,0],r])) save_stage(reach_key[:,0],reach_key[:,1],r)