if (akey != 'dt' and akey != 'name' and akey != 'end_time' and akey != 'start_time'): csdata[akey] = concatenate((csdata[akey], tmp[akey]), 1) csdata['end_time'] = tmp['end_time'] interval = 24.8 * 3600 tidal_period = 12.4 * 3600 dt = 900 mc = meccs.meccs() ocean_salt = 33.5 ocean_den = 1024.0 salt_intr = 2.0 #mean_river_flux mean_flux = mc.get_time_avg_data(rvr['river_flow'][0, :], dt, interval) meccs_file_util.write_raw_data(out_base, "mean_river_flux_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ mean_flux, ["mean river flux"], "day:\t"+str(day)+"\tyear\t"+str(yr), interval, "seconds", "m^3/s") #cross_section calculations cs_HnR = [] cs_froude = [] cs_flux = [] cs_area = [] cs_salt = [] cs_s_salt = [] cs_b_salt = [] cs_ac_surf_vel = [] cs_temp = [] cs_b_temp = [] cs_s_temp = [] cs_rho = []
tstep_int = ceil(interval / dt) #keeping it simple and slightly innacurate tmp = zeros((tdata[i]['bott_den'][0::tran_space_interval, :].shape[0], int(tdata[i]['bott_den'].shape[1] / tstep_int)), float) dpth = tdata[i]['depth'][0::tran_space_interval, :] for j in range(tdata[i]['bott_den'][0::tran_space_interval, :].shape[0]): tmp[j, :] = mc.get_time_avg_data( da_mag[i][j, :] / sqrt(9.8 * (bott_den[i][j, :] - surf_den[i][j, :]) / 1024 * dpth[j, :]), dt, interval) tr_froude.append(tmp) # output transect data: for i in range(len(transects)): meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_salt_intrusion_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ salt_intrusion[i].T, ["salinity intrusion"], "day:\t"+str(day)+"\tyear\t"+str(yr), interval, "seconds", "meters") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_output_xy_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ out_xy[i], ["x", "y"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "N/A", "meters") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_surf_vel_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ surf_vel[i].T, ["surface velocity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "m/s") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_ac_davg_vel_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ da_vel[i].T, ["along channel depth averaged velocity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "m/s") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_mag_depth_avg_vel_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ da_mag[i].T, ["magnitude of depth averaged velocity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "m/s") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_surface_salt_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ surf_salt[i].T, ["surface salinity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "psu") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_bottom_salt_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ bott_salt[i].T, ["bottom salinity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "psu") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_davg_salt_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ davg_salt[i].T, ["depth averaged salinity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "psu") meccs_file_util.write_raw_data(out_base, "transect_"+tnames[i]+"_surface_rho_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \
if len(sys.argv) < 5: sys.exit("usage: python get_net_flux.py [processed flux file] [out dir] [name base] [time avg period (seconds)] [river index]...") flux_file = sys.argv[1] out_dir = sys.argv[2] name_base = sys.argv[3] interval = int(sys.argv[4]) rivers = [] for i in range(5,len(sys.argv)): rivers.append(int(sys.argv[i])) fin = flux_file # set the time (which also dictates output file name) sp = shape_procs.shape_procs() rvr = sp.read_cs_data(fin) mc = meccs.meccs() #mean_river_flux for i in rivers: if i==rivers[0]: mean_flux = mc.get_time_avg_data(rvr['river_flow'][:,i], 900, interval) else: mean_flux = mean_flux+mc.get_time_avg_data(rvr['river_flow'][:,i], 900, interval) meccs_file_util.write_raw_data(out_dir, name_base+"_river_flux.dat", \ mean_flux, ["mean river flux"], " ", interval, "seconds", "m^3/s")
from numpy import * from gr import * from ob import * import shape_procs from model_util import * import pdb from model_reader import mreader import meccs_file_util import sys from pylab import save, load import meccs import os estuaryid = "yaqalsea" fin = "/home/hyde/models/yaqalsea/river_flow_4443_4495.dat" out_base = "/home/hyde/models/yaqalsea/" # set the time (which also dictates output file name) sp = shape_procs.shape_procs() rvr = sp.read_cs_data(fin) mc = meccs.meccs() #mean_river_flux mean_flux = mc.get_time_avg_data(rvr['river_flow'][:, 0], 900, 86400) meccs_file_util.write_raw_data(out_base, "river_flux_"+str(4443)+"_"+str(53)+"_1.dat", \ mean_flux, ["mean river flux"], "day:\t"+str(4443)+"\t"+str(53), 86400, "seconds", "m^3/s")
dt) #keeping it simple and slightly innacurate tmp = zeros((tdata[i]['bott_den'][0::tran_space_interval, :].shape[0], int(tdata[i]['bott_den'].shape[1] / tstep_int)), float) dpth = tdata[i]['depth'][0::tran_space_interval, :] for j in range( tdata[i]['bott_den'][0::tran_space_interval, :].shape[0]): tmp[j, :] = mc.get_time_avg_data( da_mag[i][j, :] / sqrt(9.8 * (bott_den[i][j, :] - surf_den[i][j, :]) / 1024 * dpth[j, :]), dt, interval) tr_froude.append(tmp) # output transect data: for i in range(len(transects)): meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_salt_intrusion_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ salt_intrusion[i].T, ["salinity intrusion"], "day:\t"+str(day)+"\tyear\t"+str(yr), interval, "seconds", "meters") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_output_xy_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ out_xy[i], ["x", "y"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "N/A", "meters") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_surf_vel_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ surf_vel[i].T, ["surface velocity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "m/s") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_ac_davg_vel_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ da_vel[i].T, ["along channel depth averaged velocity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "m/s") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_mag_depth_avg_vel_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ da_mag[i].T, ["magnitude of depth averaged velocity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "m/s") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_surface_salt_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ surf_salt[i].T, ["surface salinity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "psu") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_bottom_salt_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ bott_salt[i].T, ["bottom salinity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "psu") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_davg_salt_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ davg_salt[i].T, ["depth averaged salinity"], "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "psu") meccs_file_util.write_raw_data(out_dir, "transect_"+tnames[i]+"_surface_rho_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \
(salt, eta, dry, z) = mr_pt.get_model_data("salt.63", curr_time, curr_time + (1 - 0.25 / 24)) (temp, eta, dry, z) = mr_pt.get_model_data("temp.63", curr_time, curr_time + (1 - 0.25 / 24)) (hvel, eta, dry, z) = mr_pt.get_model_data("hvel.64", curr_time, curr_time + (1 - 0.25 / 24)) (zcor, eta, dry, z) = mr_pt.get_model_data("zcor.63", curr_time, curr_time + (1 - 0.25 / 24)) for j in range(len(pnames)): meccs_file_util.write_raw_data(dname, pnames[j] + "_salt.dat", salt[j, :, 0, :], [pnames[j]], curr_time, 900, "seconds", "psu") meccs_file_util.write_raw_data(dname, pnames[j] + "_temp.dat", temp[j, :, 0, :], [pnames[j]], curr_time, 900, "seconds", "C") meccs_file_util.write_raw_data(dname, pnames[j] + "_hvel_u.dat", hvel[j, :, 0, :], [pnames[j]], curr_time, 900, "seconds", "m/s") meccs_file_util.write_raw_data(dname, pnames[j] + "_hvel_v.dat", hvel[j, :, 1, :], [pnames[j]], curr_time, 900, "seconds", "m/s") meccs_file_util.write_raw_data(dname, pnames[j] + "_elev.dat",
cs_s_salt.append(csdata['cs_surf_salt'][i, :]) cs_b_salt.append(csdata['cs_bott_salt'][i, :]) cs_ac_surf_vel.append(csdata['cs_surf_hvel_dir'][i, :]) cs_temp.append(csdata['davg_temp'][i, :]) cs_s_temp.append(csdata['cs_surf_temp'][i, :]) cs_b_temp.append(csdata['cs_bott_temp'][i, :]) cs_rho.append(csdata['davg_den'][i, :]) cs_s_rho.append(csdata['cs_surf_den'][i, :]) cs_b_rho.append(csdata['cs_bott_den'][i, :]) tmp = zeros((cs_HnR[0].shape[1], len(cnames) * 2), float) tmpnames = [] for i in range(len(cnames)): tmp[:, i * 2:i * 2 + 2] = cs_HnR[i].T tmpnames.append("[" + cnames[i] + ": x, y]") meccs_file_util.write_raw_data(out_dir, "csection_Hansen_n_Rattray_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ tmp, tmpnames, "day:\t"+str(day)+"\tyear\t"+str(yr), interval, "seconds", "dimensionless") tmp = zeros((cs_froude[0].shape[0], len(cnames)), float) for i in range(len(cnames)): tmp[:, i] = cs_froude[i] meccs_file_util.write_raw_data(out_dir, "csection_froude_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ tmp, cnames, "day:\t"+str(day)+"\tyear\t"+str(yr), interval, "seconds", "dimensionless") tmp = zeros((cs_flux[0].shape[0], len(cnames)), float) for i in range(len(cnames)): tmp[:, i] = cs_flux[i] meccs_file_util.write_raw_data(out_dir, "csection_flux_"+str(yr)+"_"+str(day)+"_"+str(ndays)+".dat", \ tmp, cnames, "day:\t"+str(day)+"\tyear\t"+str(yr), dt, "seconds", "m^3/s") tmp = zeros((cs_area[0].shape[0], len(cnames)), float) for i in range(len(cnames)):