import sys import os import math import shapefile import numpy as np import swr #--the fields to put in the shapefile ds_13a_in = [8, 10] ds_13b_in = [0, 4, 5, 6, 7] #--load the swr structure records ds_13a = swr.ds_13a( '..\\500_grid_setup\\swr_full\\swr_ds13a_working_strval.dat') ds_13a.load_structures() #for s in ds_13a.structures: # print s['a_com'] #sys.exit() #--load the structure shapefile file = 'she_structures_culverts_1.shp' shp = shapefile.Reader(shapefile=file) nrec = shp.numRecords records = shp.records() shapes = shp.shapes() dbf_header = shp.dbfHeader() #--the dbf attribute index of the reach identifier bname_idx = 0 sname_idx = 1 stype_idx = 2
uc.append(i) sdata = np.loadtxt(filename,delimiter=',',skiprows=1,usecols=uc) cfd_2_cfs = 1.0/86400.0 #--scale str flow to cfs sdata[:,11] *= cfd_2_cfs * 1.0 #--over write invert with up/dw diff sdata[:,9] = sdata[:,7] - sdata[:,8] header[9] = 'DIFF' header.append('') #--get a list of unique structure reaches us = np.unique(sdata[:,idx_reach]) #print us #--load structure info ds_13a = swr.ds_13a('swr_full\\swr_ds13a_working_strval.dat') ds_13a.load_structures() #sys.exit() #--load the entire active reach stage record #--better to do it once than over and over reach_key = np.loadtxt('swr_full\\swr_ds4a.dat',skiprows=2,usecols=[0,2,4,5]) swr_obj = mfb.SWR_Record(0,'results\\bro_6lay.stg') totim,dt,kper,kstp,swrstp,success,r = swr_obj.next() stage = r.copy() stage_totim = [totim] while True: totim,dt,kper,kstp,swrstp,success,r = swr_obj.next() if success is False: break stage = np.hstack((stage,r))
import swr ds_13a = swr.ds_13a('swr_ds13a.dat') ds_13a.load_structures() ds_13a.add_wcd3_2_weirs() ds_13a.write_structures('swr_ds_13a_meters_ngvd.dat',byreach=True) #ds_13a.op_2_weir() m_2_ft = 3.281 ngvd_2_navd = -1.5 mps_2_ftpd = 3.281 * 60.0 * 60.0 * 24.0 cms_2_cfd = (3.281**3) * 60.0 * 60.0 * 24.0 cms2_2_cfd2 = (3.281**3) * 60.0**2 * 60.0**2 * 24.0**2 lin_istrtype = [5,6,7,8,9] flux_istrtype = [3] #ds_13a.filt(5) ds_13a.scale_offset('strinv',m_2_ft,ngvd_2_navd) ds_13a.scale_offset('strinv2',m_2_ft,ngvd_2_navd) ds_13a.scale_offset('strlen',m_2_ft,0.0) ds_13a.scale_offset('strval',m_2_ft,ngvd_2_navd,istrtype=lin_istrtype) ds_13a.scale_offset('strval',cms_2_cfd,0.0,istrtype=flux_istrtype) ds_13a.scale_offset('strwid',m_2_ft,0.0) ds_13a.scale_offset('strwid2',m_2_ft,0.0) ds_13a.scale_offset('cstrcrit',m_2_ft,ngvd_2_navd) ds_13a.scale_offset('strcritc',m_2_ft,0.0)
import swr ds_13a = swr.ds_13a('swr_ds13a_working_strval.dat') ds_13a.load_structures() for s in ds_13a.structures: if s['istrtype'] == 6 and s['strinv'] < -2.0: s['strinv'] = -1.5 print s['strinv'],s['a_com'] ds_13a.write_structures('swr_ds13a_working_strval_1.dat',byreach=True) ds_13a.write_ds12('swr_ds12.dat')
import sys import os import math import shapefile import numpy as np import swr #--the fields to put in the shapefile ds_13a_in = [8,10] ds_13b_in = [0,4,5,6,7] #--load the swr structure records ds_13a = swr.ds_13a('..\\500_grid_setup\\swr_full\\swr_ds13a_working_strval.dat') ds_13a.load_structures() #for s in ds_13a.structures: # print s['a_com'] #sys.exit() #--load the structure shapefile file = 'she_structures_culverts_1.shp' shp = shapefile.Reader(shapefile=file) nrec = shp.numRecords records = shp.records() shapes = shp.shapes() dbf_header = shp.dbfHeader() #--the dbf attribute index of the reach identifier bname_idx = 0 sname_idx = 1 stype_idx = 2 chain_idx = 3
import sys import os import math import shapefile import numpy as np import swr #--load the swr structure records ds_13a = swr.ds_13a('older\\swr_full\\swr_ds13a_working_strval.dat') ds_13a.load_structures() #--load the structure shapefile file = '..\\_gis\\shapes\\sw_structures' shp = shapefile.Reader(shapefile=file) nrec = shp.numRecords records = shp.records() shapes = shp.shapes() dbf_header = shp.dbfHeader() #--the dbf attribute index of the reach identifier bname_idx = 0 sname_idx = 1 chain_idx = 3 #--set the writer instance wr = shapefile.Writer() field_names = [] for item in dbf_header: wr.field(item[0], fieldType=item[1], size=item[2], decimal=item[3]) field_names.append(item[0])
'swr_full\\swr_ds4a.dat', skiprows=2, usecols=[0, 2, 4, 5]) reach_array = np.zeros((nrow, ncol)) - 999. swribnd = np.loadtxt('swr_full\\swr_ds6.dat', usecols=[0, 1]) wr = shapefile.Writer() wr.field('istrrch', fieldType='N', size=10, decimal=0) wr.field('istrnum', fieldType='N', size=10, decimal=0) wr.field('istrconn', fieldType='N', size=10, decimal=0) wr.field('istrrch_rg', fieldType='N', size=10, decimal=0) wr.field('istrcon_rg', fieldType='N', size=10, decimal=0) #--load the structures ds_13a = swr.ds_13a('swr_full\\swr_ds13a_w.dat') ds_13a.load_structures() s_count = 0 for s in ds_13a.structures: #--loop over each polyline istrrch = s['istrrch'] istrconn = s['istrconn'] istrnum = s['istrnum'] ibnd_istrrch = swribnd[np.where(swribnd[:, 0] == istrrch), 1] ibnd_istrconn = swribnd[np.where(swribnd[:, 0] == istrconn), 1] if ibnd_istrrch != 0 and ibnd_istrconn != 0: #if True: #--get the points for the polylines of istrrch and istrconn istrrch_points = None istrconn_points = None istrrch_rg = None