Changeset 2955


Ignore:
Timestamp:
May 24, 2006, 11:39:56 AM (18 years ago)
Author:
nick
Message:

update pt hedland
geospatial_data object updated
updated polygon.py to allow numeric arrays

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • inundation/geospatial_data/geospatial_data.py

    r2942 r2955  
    333333                raise IOError, msg
    334334            except IOError, e:
    335                 fd.close()   
     335                fd.close() 
    336336                # Catch this to add an error message
    337337                msg = 'Could not open file or incorrect file format %s:%s' %(file_name, e)
  • inundation/geospatial_data/test_geospatial_data.py

    r2942 r2955  
    5145140.0 1.0 0.0 10.0\n\
    5155151.0 0.0 10.4 40.0\n\
    516 #geo\n\
     516#geocrap\n\
    51751756\n\
    518 1.1\n\
    519 1.0\n")
    520 
     51856.6\n\
     5193\n"
     520)
    521521        file.close()
    522522        try:
  • inundation/utilities/polygon.py

    r2912 r2955  
    401401    return abs(poly_area/2)
    402402
    403 def plot_polygons(polygons,
    404                   figname,
    405                   verbose = False):
     403def plot_polygons(polygons, figname, verbose=False):
    406404   
    407405    """ Take list of polygons and plot.
     
    422420
    423421    assert type(polygons) == list,\
    424                'polygon must be a list'
    425 
     422               'input must be a list of polygons'
     423               
    426424    ion()
    427425    hold(True)
     
    431429    miny = 1e10
    432430    maxy = 0.0
    433     for i in range(len(polygons)):
    434         x, y = poly_xy(polygons[i]) 
     431   
     432    for polygon in polygons:
     433        x, y = poly_xy(polygon) 
    435434        if min(x) < minx: minx = min(x)
    436435        if max(x) > maxx: maxx = max(x)
     
    449448    return vec
    450449
    451 def poly_xy(poly):
     450def poly_xy(polygon, verbose=False):
    452451    """ this is used within plot_polygons so need to duplicate
    453452        the first point so can have closed polygon in plot
    454453    """
    455454
    456     assert type(poly[0]) == list,\
    457                'polygon must be a list of points'
    458    
    459     x = []
    460     y = []
    461     n = len(poly)
    462     firstpt = poly[0]
    463     for i in range(n):
    464         thispt = poly[i]
    465         x.append(thispt[0])
    466         y.append(thispt[1])
    467 
    468     x.append(firstpt[0])
    469     y.append(firstpt[1])
     455    if verbose: print 'Checking input to poly_xy'
     456
     457    try:
     458        polygon = ensure_numeric(polygon, Float)
     459    except NameError, e:
     460        raise NameError, e
     461    except:
     462        msg = 'Polygon %s could not be converted to Numeric array' %(str(polygon))
     463        raise msg
     464
     465    x = polygon[:,0]
     466    y = polygon[:,1]
     467    x = concatenate((x, [polygon[0,0]]), axis = 0)
     468    y = concatenate((y, [polygon[0,1]]), axis = 0)
    470469   
    471470    return x, y
     471   
     472#    x = []
     473#    y = []
     474#    n = len(poly)
     475#    firstpt = poly[0]
     476#    for i in range(n):
     477#        thispt = poly[i]
     478#        x.append(thispt[0])
     479#        y.append(thispt[1])
     480
     481#    x.append(firstpt[0])
     482#    y.append(firstpt[1])
     483   
     484#    return x, y
    472485
    473486class Polygon_function:
  • production/onslow_2006/export_results.py

    r2902 r2955  
    77from os import sep
    88
    9 time_dir = "20060426_004517"
     9time_dir = "20060426_004129"
    1010directory = project.outputdir
    1111name = directory + time_dir +sep + "source"
  • production/pt_hedland_2006/project.py

    r2954 r2955  
    130130d3 = [552686.0, 7871580.0]
    131131#d4 = [604415.81, 7733013.56]
    132 d4 = [630000.0, 7733013.56]
     132d4 = [638000.0, 7733013.56]
    133133#d5 = [656561.15, 7732615.11]
    134 d5 = [657000.0, 7732615.11]
     134d5 = [662000.0, 7732615.11]
    135135#d6 = [708940.32, 7750510.33]
    136 d6 = [682000.0, 7740510.33]
     136d6 = [690000.0, 7740510.33]
    137137
    138138polyAll = [d0, d1, d2, d3, d4, d5, d6]
     
    149149#Are there other significant features?
    150150j0 = [670000, 7760000]
    151 j1 = [630000, 7745000]
     151j1 = [633000, 7745000]
    152152j2 = [665000, 7743000]
    153153j3 = [690000, 7755000]
     
    155155poly_region = [j0, j1, j2, j3]
    156156
    157 coast_buffer_file = datadir+'buff_poly_pts_test.xya'
     157coast_buffer_file = datadir+'pts2ascii_test.xya'
    158158G = Geospatial_data(file_name=coast_buffer_file,delimiter=' ')
    159 poly_coast = G.get_data_points()
     159poly_coast = list(G.get_data_points())
    160160#print 'get_data_points()',G.get_data_points()
     161#print 'get_',poly_region
    161162
    162163
     164
  • production/pt_hedland_2006/run_pt_hedland.py

    r2954 r2955  
    7474
    7575#used to catch screen output to file
    76 sys.stdout = Screen_Catcher(screen_output_name)
    77 sys.stderr = Screen_Catcher(screen_error_name)
     76#sys.stdout = Screen_Catcher(screen_output_name)
     77#sys.stderr = Screen_Catcher(screen_error_name)
    7878
    7979
     
    122122interior_regions = [[project.poly_pt_hedland, pt_hedland_res],
    123123                    [project.poly_coast, coast_res]]
     124#                    [project.poly_region, region_res]]
    124125
    125126print 'number of interior regions', len(interior_regions)
     
    137138        count += 1
    138139
    139 #figname = 'pt_hedland_polys'
    140 #plot_polygons([project.polyAll,project.poly_pt_hedland,project.poly_region],
    141 #              figname,
    142 #              verbose = True)
     140figname = 'pt_hedland_polys'
     141print'pt_hedland_polys'
     142#plot_polygons([project.polyAll, project.poly_pt_hedland, project.poly_region],
     143plot_polygons([project.poly_coast],
     144              figname,
     145              verbose = True)
    143146
    144147if count == 0:
     
    148151    print 'check %s in production directory' %figname
    149152    import sys; sys.exit()
    150    
     153
    151154print 'start create mesh from regions'
    152155from caching import cache
Note: See TracChangeset for help on using the changeset viewer.