#fname = 'ThawData_Yr10_All.csv' #with open(fname, 'wb') as csvFile: # writer = csv.writer(csvFile, delimiter=',') for i in range(len(runPrefixList)): y = np.nan * np.ones([nruns, len(trange)], 'd') for j in range(nruns): directory = runPrefixList[i] + '_' + runDate + '.' + str(j + 1) isDir = os.path.isdir(os.getcwd() + '/' + directory) if not isDir: continue keys, times, dat = parse_ats.readATS(directory, "visdump_data.h5", timeunits='yr') col_dat = transect_data.transect_data(['saturation_ice'], keys=np.s_[trange], directory=directory) times_subset = times[trange] #col_dat structure: #col 1 = variable #col 2 = time #col 3 = x position #col 4 = z position z_surf = col_dat[1, 0, :, -1] + ( col_dat[1, 0, :, -1] - col_dat[1, 0, :, -2] ) / 2. # average of the uppermost and second-to-uppermost rows, shifted up to the top row z_bott = col_dat[1, 0, :, 0] - ( col_dat[1, 0, :, 1] - col_dat[1, 0, :, 0] ) / 2. # average of the bottom and second-to-bottom rows, shifted up to the bottom row for k in range(len(trange)): where_unsat = np.where(col_dat[2, k, xPos, :] == 1)[0]
## Testing the datetime functionality dt = datetime.fromordinal(733828) dt dt.strftime('%Y%m%d') directory = "./hillslope-test-allMinColumn/" keys, times, dat = parse_ats.readATS(directory, "visdump_data.h5", timeunits='yr') ## SELECT TIME INTERVAL TO PULL AND PLOT: # Visdumps are spit out every 30 days. Index 0 is January of year 1; 12 is January year 2; etc... ind_start = 0 ind_end = -1 # if you want it to run to the end of the list, type '-1' for the last item on the list. ind_int = 90 # there is one checkpoint file every 30 days col_dat = transect_data.transect_data(['saturation_gas','saturation_ice'], keys=np.s_[ind_start:ind_end:ind_int], directory=directory) times_subset = times[ind_start:ind_end:ind_int] print times_subset nvar, nt, nx, nz = col_dat.shape print nt n = 12 # length of a year in python indeces m = (nt)/(n) # determine how many years we're viewing, adding 1 because python indexes at 0 print m,n # z_surf and z_bott is extrapolated based on dz, and is not necessarily exact if # dz varies in the top (respectively bottom) two cells z_surf = col_dat[1,0,:,-1] + (col_dat[1,0,:,-1] - col_dat[1,0,:,-2])/2. # average of the uppermost and second-to-uppermost rows, shifted up to the top row z_bott = col_dat[1,0,:,0] - (col_dat[1,0,:,1] - col_dat[1,0,:,0])/2. # average of the bottom and second-to-bottom rows, shifted up to the bottom row
def water_table2D(dirname, datum=None, location='center', v86=False, patm=101325.): prefix = "" if v86 else "surface-" # get the ponded depth keys,times,dats = parse_ats.readATS(dirname, "visdump_surface_data.h5") pd = parse_ats.get2DSurfaceData(keys, dats, prefix+"ponded_depth") if location == 'center': center = len(dats[prefix+"elevation.cell.0"][keys[0]]) elif location == 'trough': center = 1 print ('Location: ', location, center) elev_cell = dats[prefix+"elevation.cell.0"][keys[0]][center-1] dats.close() print ('Datum (surface elevation)', elev_cell) if datum is None: datum = elev_cell datum_offset = elev_cell - datum # get the columnar pressure water_table = np.zeros((len(keys),),'d') thaw_depth = np.zeros((len(keys),),'d') col_dat = transect_data.transect_data(['pressure', 'temperature'], directory=dirname) vars = 2 nvar, cycles, xnum, znum = col_dat.shape #print xnum xnum = center #print xnum for k in range(col_dat.shape[1]): if pd[k, xnum-1] > 0: water_table[k] = pd[k, xnum-1] + datum_offset #wt_surf[k] = pd[k, xnum-1] + datum_offset #print 'surface:: ',k, pd[k, xnum-1] else: #print 'subsurface: ', k, pd[k, xnum-1] wt_index = np.where(col_dat[vars ,k,xnum-1, :] >= patm)[0] #var 1 temp_index = np.where(col_dat[vars+1 ,k,xnum-1, :] >= 273.25)[0] ## temp_data = col_dat[vars + 1,k,xnum-1, :] #var 2 if len(wt_index) is 0: wt_index = 0 else: wt_index = wt_index[-1] if (len(temp_index) is 0): temp_index =0 else: temp_index = temp_index[0] if (temp_data[wt_index] > 273.25): water_table[k] = col_dat[1,k,xnum-1, wt_index] - datum temp_index = np.where(col_dat[vars+1 ,k,xnum-1, :] >= 273.2)[0] ## #print col_dat[vars+1 ,k,xnum-1, :], round(times[k]*365.25,2), k if len(temp_index) > 0: #print 'ALT: ', len(temp_index), temp_index[0], col_dat[vars+1 ,k,xnum-1, temp_index[0]] thaw_depth[k] = col_dat[1,k,xnum-1, temp_index[0]] - datum return times, water_table, thaw_depth, elev_cell
def water_table(dirname, datum=None, v86=False, patm=101325.): prefix = "" if v86 else "surface-" # get the ponded depth keys,times,dats = parse_ats.readATS(dirname, "visdump_surface_data.h5") pd = parse_ats.get2DSurfaceData(keys, dats, prefix+"ponded_depth") center = len(dats[prefix+"elevation.cell.0"][keys[0]]) print ('Center location: ', center) elev_surf = dats[prefix+"elevation.cell.0"][keys[0]][center-1] dats.close() print ('Datum (surface elevation)', elev_surf) if datum is None: datum = elev_surf datum_offset = elev_surf - datum # get the columnar pressure wt = np.zeros((len(keys),),'d') wt_ss = np.zeros((len(keys),),'d') wt_surf = np.zeros((len(keys),),'d') thaw_depth = np.zeros((len(keys),),'d') wt_bottom = np.zeros((len(keys),),'d') col_dat = transect_data.transect_data(['pressure', 'temperature'], directory=dirname) vars = 2 nvar, cycles, xnum, znum = col_dat.shape for k in range(col_dat.shape[1]): if pd[k, xnum-1] > 0: wt[k] = pd[k, xnum-1] + datum_offset wt_surf[k] = pd[k, xnum-1] + datum_offset else: wt_index = np.where(col_dat[vars ,k,xnum-1, :] >= patm)[0] #var 1 temp_index = np.where(col_dat[vars+1 ,k,xnum-1, :] >= 273.25)[0] ## temp_data = col_dat[vars + 1,k,xnum-1, :] #var 2 wt_index0 = wt_index if len(wt_index) is 0: wt_index = 0 wt_index0 = 0 else: wt_index = wt_index[-1] if (len(wt_index0) > 2): wt_index0 = wt_index0[-2] if (len(temp_index) is 0): temp_index =0 else: temp_index = temp_index[0] if (temp_data[wt_index] > 273.25): wt[k] = col_dat[1,k,xnum-1, wt_index] - datum else: wt_ss[k] = col_dat[1,k,xnum-1, temp_index] - datum temp_index = np.where(col_dat[vars+1 ,k,xnum-1, :] >= 273.25)[0] ## if len(temp_index) > 0: thaw_depth[k] = col_dat[1,k,xnum-1, temp_index[0]] - datum return times, wt, wt_ss, wt_bottom, thaw_depth
fig, axes = plt.subplots(4,2,sharex=True) #fname = 'ThawData_Yr10_All.csv' #with open(fname, 'wb') as csvFile: # writer = csv.writer(csvFile, delimiter=',') for i in range(len(runPrefixList)): y = np.nan*np.ones([nruns,len(trange)],'d') for j in range(nruns): directory = runPrefixList[i] + '_' + runDate + '.' + str(j+1) isDir = os.path.isdir(os.getcwd() + '/' + directory) if not isDir: continue keys, times, dat = parse_ats.readATS(directory, "visdump_data.h5", timeunits='yr') col_dat = transect_data.transect_data(['saturation_gas','porosity','cell_volume',], keys=np.s_[trange], directory=directory) times_subset = times[trange] #col_dat structure: #col 1 = variable #col 2 = time #col 3 = x position #col 4 = z position z_surf = col_dat[1,0,:,-1] + (col_dat[1,0,:,-1] - col_dat[1,0,:,-2])/2. # average of the uppermost and second-to-uppermost rows, shifted up to the top row z_bott = col_dat[1,0,:,0] - (col_dat[1,0,:,1] - col_dat[1,0,:,0])/2. # average of the bottom and second-to-bottom rows, shifted up to the bottom row yTemp = col_dat[2,:,:,:]*col_dat[3,:,:,:]*col_dat[4,:,:,:] # calculate the empty pore volume of each celll (gas saturation*porosity*cell volume at all locations) zSum = np.sum(yTemp,2) # sum the 2nd dimension of the yTemp matrix to get the total empty pore volume in EACH COLUMN with depth xSum = np.sum(zSum,1) # sum the 1st dimension of the zSum matrix to get the total empty pore volume in EACH DOMAIN at every point in time y[j,:] = xSum if(j<8): cVal = 'k' elif(j<16):