Esempio n. 1
0
start_time = ydhms2corie(int(syr), int(sday), 0, 15, 0)
end_time = ydhms2corie(int(eyr), int(eday), 0, 0, 0)

hindcast = 1
ndaysDir = 7
if re.match('yyyy-ddd', dir_format):
  hindcast = 0
  ndaysDir = 1

#print "start_time: "+str(start_time)+"\n"

if shape_type == "point":
  pass
elif shape_type == "cross_section":
  cs_dat = meccs_file_util.read_cs_file(shape_file, 1)

  do_cs_norms = 0
  sp = shape_procs()
  for i in range(len(cs_dat)):
    sp.add_shape(cs_dat[i], "cross_sec", 0, "cs"+str(i))
    tmp = cs_dat[i]
    if tmp[0][2]==0 and tmp[0][3]==0:    #assume if the first normal vectors are both 0, then the norms need to be calculated
      do_cs_norms=1

  if do_cs_norms:
    sp.gen_channel_norms(base_dir, start_time, start_time+2, "cross_sec", 16, ndaysDir, hindcast)

  data = sp.gen_cross_section_data(base_dir, start_time, end_time, 16, "base", 1, ndaysDir, hindcast)

  data["start_time"] = start_time
day = int(sys.argv[5])
ndays = int(sys.argv[6])
in_dir = sys.argv[7]
out_base = sys.argv[8]

# set the time (which also dictates output file name)
start_time = ydhms2corie(yr, day, 0, 15, 0)
end_time = start_time + ndays - 0.25 / 24  #puts it right at the end of the day

sp = shape_procs.shape_procs()

# read all the shapes in: assume they are in the shape dir and named "points.txt", "cross_sections.txt", "transects.txt" and "regions.txt"

if os.access(shape_dir + "/cross_sections.txt", os.F_OK):
    (cross_sections, cnames,
     crivers) = meccs_file_util.read_cs_file(shape_dir + "/cross_sections.txt",
                                             0)
    do_cs = 1
else:
    do_cs = 0

for i in arange(start_time, start_time + ndays, 1):
    if (i == start_time):
        rvr = sp.read_cs_data(in_dir + "/river_flow_" + str(int(i)) + "_" +
                              str(int(i + 1)) + ".dat")
    else:
        tmp = sp.read_cs_data(in_dir + "/river_flow_" + str(int(i)) + "_" +
                              str(int(i + 1)) + ".dat")
        rvr['river_flow'] = concatenate((rvr['river_flow'], tmp['river_flow']),
                                        1)
        rvr['end_time'] = tmp['end_time']
shape_dir = sys.argv[2]
yr = int(sys.argv[3])
day = int(sys.argv[4])
ndays = int(sys.argv[5])
in_dir = sys.argv[6]
out_base = sys.argv[7]

# set the time (which also dictates output file name)
start_time = ydhms2corie(yr, day, 0, 15, 0)
end_time = start_time + ndays - 0.25 / 24  #puts it right at the end of the day

sp = shape_procs.shape_procs()

if os.access(shape_dir + "/transects.txt", os.F_OK):
    (transects, tnames,
     trivers) = meccs_file_util.read_cs_file(shape_dir + "/transects.txt", 0)
    do_transects = 1
else:
    do_transects = 0

for i in arange(start_time, start_time + ndays, 1):

    (yr, day, n) = corie2ydn(i)

    if (i == start_time):
        rvr = sp.read_cs_data(in_dir + "/river_flow_" + str(yr) + "_" +
                              str(day) + "_1.dat")
    else:
        tmp = sp.read_cs_data(in_dir + "/river_flow_" + str(yr) + "_" +
                              str(day) + "_1.dat")
        rvr['river_flow'] = concatenate((rvr['river_flow'], tmp['river_flow']),
Esempio n. 4
0
    sys.exit(
        "usage: python do_class_num_test.py [estuary id] [processed data directory] [start year] [start day] [end year] [end day] [shape type] [shape file]"
    )

estuaryid = sys.argv[1]
base_dir = sys.argv[2]
syr = sys.argv[3]
sday = sys.argv[4]
eyr = sys.argv[5]
eday = sys.argv[6]
ctype = sys.argv[7]
sfile = sys.argv[8]
out_base = sys.argv[9]

if ctype == "intrusion":
    s_dat = meccs_file_util.read_cs_file(sfile, 1)

    mec = meccs.meccs()
    sp = shape_procs.shape_procs()

    intrusion = []
    for i in range(len(s_dat)):
        data = sp.read_cs_data(base_dir + "/" + estuaryid + "_ts" + str(i) +
                               "_" + str(syr) + "_" + str(sday) + "_to_" +
                               str(eyr) + "_" + str(eday) + ".sp")
        intrusion.append(
            mec.get_salinity_intrusion(s_dat[i], data["dmax_salt"], data["dt"],
                                       24.8 * 3600, 2))

    pdb.set_trace()
    dbg = 1
#ahdr = sz_header("/home/workspace/ccalmr37/hyde/coos/2004-01-11/run/1_elev.61")
#ahdr = sz_header("/home/workspace/ccalmr/hindcasts/2004-01-14/run/1_elev.61")
#ahdr.printHeader()
#ahdr.printVgrid()

#mr = mreader("/home/workspace/ccalmr/hindcasts/", bp=pts, start=2923.0104, end=2923+(900./86400.)*3., dvg=1, db=14)
#vel_dat = mr.get_model_data(dtype="hvel.64")
#salt_dat = mr.get_model_data(dtype="salt.63")

#(cs_dat, csnames) = meccs_file_util.read_cs_file("/home/users/hyde/columbia/col_meccs_cs_4.cs", 1)
#cs_dat = meccs_file_util.read_cs_file("/home/users/hyde/columbia/col_meccs_cs_4b.cs", 1)
#pts = meccs_file_util.read_pt_file("/home/users/hyde/columbia/col_meccs_4.pts", 0)

(cs_dat, csnames) = meccs_file_util.read_cs_file(
    "/home/hyde/public_html/ourestuaries/shapes_data/hyde/yaqalsea/cross_sections.txt",
    1)

meccs_file_util.write_cs_file(
    "/home/hyde/public_html/ourestuaries/shapes_data/hyde/yaqalsea/test_cross_sections.txt",
    cs_dat, csnames)

(cs_dbg, dbg_names) = meccs_file_util.read_cs_file(
    "/home/hyde/public_html/ourestuaries/shapes_data/hyde/yaqalsea/test_cross_sections.txt",
    1)

#sp = shape_procs()
#for i in range(len(areas)):
#  sp.add_shape(areas[i], "volume", 0, "vol_"+str(i))
#data = sp.gen_volume_data("/home/workspace/ccalmr/hindcasts/", 2923.0104, 2923+(900./86400.)*2., 16, "base", 1)
Esempio n. 6
0
#data_types = ["salt", "temp", "hvel_u", "hvel_v", "elev"]
data_types = ["salt", "temp", "hvel_u", "hvel_v", "elev", "zcor"]

#for computing significant equality
small = 0.0001

# set the time (which also dictates output file name)
start_time = ydhms2corie(yr, day, 0, 15, 0)
end_time = start_time + ndays - 0.25 / 24  #puts it right at the end of the day

sp = shape_procs.shape_procs()

# read all the shapes in: assume they are in the shape dir and named "points.txt", "cross_sections.txt", "transects.txt" and "regions.txt"
if os.access(shape_dir + "/points.txt", os.F_OK):
    (points, pnames,
     privers) = meccs_file_util.read_cs_file(shape_dir + "/points.txt",
                                             1)  #uses cs file format
    do_points = 1
else:
    do_points = 0
if os.access(shape_dir + "/cross_sections.txt", os.F_OK):
    (cross_sections, cnames,
     crivers) = meccs_file_util.read_cs_file(shape_dir + "/cross_sections.txt",
                                             1)
    do_cs = 1
else:
    do_cs = 0
if os.access(shape_dir + "/transects.txt", os.F_OK):
    #if 0:
    (transects, tnames,
     trivers) = meccs_file_util.read_cs_file(shape_dir + "/transects.txt", 1)
    do_transects = 1
Esempio n. 7
0
import meccs_file_util
#import sys
from pylab import save, load
import os.path
import pdb
import ourestuaries_db

shape_dir = '/home/workspace/ccalmr38/hindcasts/yaqalsea_files/'
model_dir = '/home/workspace/local0/forecasts/yaqalsea/'
year = 2008
sday = 95
ndays = 5
start_time = ydhms2corie(year, sday, 0, 15, 0)
end_time = start_time + ndays-0.25/24  #puts it right at the end of the day

(transects, tnames, trivers) = meccs_file_util.read_cs_file(shape_dir+"/transects.txt", 1)
(points, pnames, privers) = meccs_file_util.read_cs_file(shape_dir+"/points.txt", 1)
(csecs, cnames, crivers) = meccs_file_util.read_cs_file(shape_dir+"/cross_sections.txt", 1)

oe = ourestuaries_db.oe_db()
oe.connect("cdb01.stccmop.org", "ourestuaries", "test_hyde", "poop77")

#(names, pts, norms, rivers) = oe.get_points_by_eid('yaqalsea')
#(names, runids, unames) = oe.get_shape_info_by_eid('yaqalsea', 'cross_section')
#points = 
#for i in range(len(names)):
  
  
#pdb.set_trace()

#sp = shape_procs.shape_procs()
#      meccs_file_util.write_cs_file(shape_dir+"/cross_sections.txt", sp.shapes, cnames, crivers)
#
#
#    for i in range(ndays):
#      curr_time = start_time+i
#
#      data = sp.gen_cross_section_data(base_dir+"/"+estuaryid+"/", curr_time, curr_time+(1-0.25/24), 16, "base", 1, 1, 0)
#      data["start_time"] = curr_time
#      data["end_time"] = curr_time+(1-0.25/24)
#      dname = "%s/%s/%d-%03d/process/" % (base_dir, estuaryid, yr, day+i)
#      sp.save_cs_data(data, dname+"/cross_section_data.dat")

# transect data
if (os.path.exists(shape_dir + "/transects.txt")):
    (transects, tnames,
     trivers) = meccs_file_util.read_cs_file(shape_dir + "/transects.txt", 1)
    if len(transects) > 0:
        for i in range(len(transects)):
            sp = shape_procs.shape_procs()
            sp.add_shape(transects[i], "transect", 50, tnames[i])

            if (meccs_file_util.file_exists(shape_dir + "/" + tnames[i] +
                                            "_transects.ob")
                    and int(do_refresh) == 0):
                sp.ob_file = shape_dir + "/" + tnames[i] + "_transects.ob"
            else:
                agr = Gr()
                [year, day, ts] = model_util.corie2ydn(start_time)
                dname = "%s/%d-%03d/run/" % (base_dir + "/" + estuaryid + "/",
                                             yr, day)
                agr.readHGrid(dname + "hgrid.gr3")