Changeset 2624


Ignore:
Timestamp:
Mar 29, 2006, 8:42:34 AM (18 years ago)
Author:
nick
Message:

fixed geospatial_data to not use point_dict in export and updated onslow run to use new geospatial_data methods

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inundation/geospatial_data/geospatial_data.py

    r2594 r2624  
    2020                 geo_reference = None,
    2121                 default_attribute_name = None,
    22                  file_name = None):
    23          
     22                 file_name = None,
     23                 absolute = True):
    2424
    2525        """Create instance from data points and associated attributes
     
    4747        file_name: Name of input file.....
    4848       
     49        absolute: is the data point absolute or relative to a xll and yll
     50        in a zone
     51       
    4952        """
    5053
     
    5659            self.set_geo_reference(geo_reference)
    5760            self.set_default_attribute_name(default_attribute_name)
     61            self.set_absolute(absolute)
    5862           
    5963       
     
    152156                self.file_name = file_name
    153157                print 'file name from set', self.file_name
    154 
     158   
     159    def set_absolute(self, absolute = True):
     160        if absolute is False:
     161            self.absolute = False
     162        else:
     163            self.absolute = True
     164   
     165    '''
    155166    def set_self_from_file(self, file_name = None):
    156167        # check if file_name is a string and also that the file exists
     
    162173            self = self.import_points_file(file_name)
    163174        return self
    164            
     175        '''   
    165176
    166177    def get_geo_reference(self):
     
    202213        return self.attributes[attribute_name]
    203214
     215    def get_all_attributes(self):
     216        """
     217        Return values for all attributes.
     218        """
     219
     220        return self.attributes
    204221
    205222    def __add__(self, other):
    206         """
     223        '''
    207224        returns the addition of 2 geospatical objects,
    208225        objects are concatencated to the end of each other
     
    210227        NOTE: doesn't add if objects contain different
    211228        attributes 
    212         """
     229       
     230        Always return relative points!
     231        '''
    213232
    214233
     
    237256
    238257        xll = yll = 0.
    239         relative_points1 = self.get_data_points(absolute=False)
    240         relative_points2 = other.get_data_points(absolute=False)
    241            
    242         #print 'R1', relative_points1
    243         #print 'R2', relative_points2       
     258       
     259        relative_points1 = self.get_data_points(absolute = False)
     260        relative_points2 = other.get_data_points(absolute = False)
    244261
    245262       
    246263        new_relative_points1 = new_geo_ref.change_points_geo_ref(relative_points1, geo_ref1)
    247264        new_relative_points2 = new_geo_ref.change_points_geo_ref(relative_points2, geo_ref2)
    248 
    249         #print 'NR1', new_relative_points1
    250         #print 'NR2', new_relative_points2       
    251265       
    252266        #Now both point sets are relative to new_geo_ref and zones have been reconciled
     
    256270        new_points = concatenate((new_relative_points1,
    257271                                  new_relative_points2),
    258                                  axis = 0)
     272                                  axis = 0)
     273 #       print 'new points:', new_points
    259274
    260275     
     
    277292        return Geospatial_data(new_points,
    278293                               new_attributes,
    279                                new_geo_ref)
    280 
    281 
    282 
     294                               new_geo_ref,
     295                               absolute = False)
     296
     297
     298    '''
    283299    def xxx__add__(self, other):
    284300        """
     
    339355            raise msg
    340356
    341      
    342    
    343 ###
    344 #  IMPORT/EXPORT POINTS FILES
    345 ###
     357    '''   
     358   
     359    ###
     360    #  IMPORT/EXPORT POINTS FILES
     361    ###
     362    def new_import_points_file(self, ofile, delimiter = None, verbose = False):
     363        """ load an .xya or .pts file
     364        Note: will throw an IOError if it can't load the file.
     365        Catch these!
     366        """
     367       
     368        all_data = {}
     369        if ofile[-4:]== ".xya":
     370            try:
     371                if delimiter == None:
     372                    try:
     373                        fd = open(ofile)
     374                        all_data = _read_xya_file(fd, ',')
     375                    except SyntaxError:
     376                        fd.close()
     377                        fd = open(ofile)
     378                        all_data = _read_xya_file(fd, ' ')
     379                else:
     380                    fd = open(ofile)
     381                    all_data = _read_xya_file(fd, delimiter)
     382                fd.close()
     383            except (IndexError,ValueError,SyntaxError):
     384                fd.close()   
     385                msg = 'Could not open file %s ' %ofile
     386                raise IOError, msg
     387            except IOError, e:
     388                # Catch this to add an error message
     389                msg = 'Could not open file or incorrect file format %s:%s' %(ofile, e)
     390                raise IOError, msg
     391               
     392        elif ofile[-4:]== ".pts":
     393            try:
     394    #            print 'hi from import_points_file'
     395                all_data = _read_pts_file(ofile, verbose)
     396    #            print 'hi1 from import_points_file', all_data
     397            except IOError, e:   
     398                msg = 'Could not open file %s ' %ofile
     399                raise IOError, msg       
     400        else:     
     401            msg = 'Extension %s is unknown' %ofile[-4:]
     402            raise IOError, msg
     403   
     404        return all_data
     405   
     406    def new_export_points_file(self, ofile):
     407        """
     408        write a points file, ofile, as a text (.xya) or binary (.pts) file
     409   
     410        ofile is the file name, including the extension
     411   
     412        The point_dict is defined at the top of this file.
     413        """
     414        #this was done for all keys in the mesh file.
     415        #if not mesh_dict.has_key('points'):
     416        #    mesh_dict['points'] = []
     417        if (ofile[-4:] == ".xya"):
     418            _new_write_xya_file(ofile, self.get_data_points(self.absolute),
     419                                   self.get_all_attributes(),
     420                                   self.get_geo_reference())
     421        elif (ofile[-4:] == ".pts"):
     422            _new_write_pts_file(ofile, self.get_data_points(self.absolute),
     423                                   self.get_all_attributes(),
     424                                   self.get_geo_reference())
     425        else:
     426            msg = 'Unknown file type %s ' %ofile
     427            raise IOError, msg
     428   
    346429
    347430def import_points_file( ofile, delimiter = None, verbose = False):
     
    388471
    389472    return all_data
    390 
     473'''
    391474def export_points_file(ofile, point_dict):
    392475    """
     
    407490        msg = 'Unknown file type %s ' %ofile
    408491        raise IOError, msg
    409 
     492'''
    410493def _read_pts_file(file_name, verbose = False):
    411494    """Read .pts NetCDF file
     
    520603
    521604
    522 
     605def _new_write_pts_file(file_name, write_data_points,
     606                                   write_attributes,
     607                                   write_geo_reference = None):
     608    """Write .pts NetCDF file   
     609
     610    WARNING: This function mangles the point_atts data structure
     611    """
     612    #FIXME: (DSG)This format has issues.
     613    # There can't be an attribute called points
     614    # consider format change
     615    # method changed by NB not sure if above statement is correct
     616
     617    ''' should create new test for this
     618    legal_keys = ['pointlist', 'attributelist', 'geo_reference']
     619    for key in point_atts.keys():
     620        msg = 'Key %s is illegal. Valid keys are %s' %(key, legal_keys)
     621        assert key in legal_keys, msg
     622    '''   
     623    from Scientific.IO.NetCDF import NetCDFFile
     624    # NetCDF file definition
     625    outfile = NetCDFFile(file_name, 'w')
     626   
     627    #Create new file
     628    outfile.institution = 'Geoscience Australia'
     629    outfile.description = 'NetCDF format for compact and portable storage ' +\
     630                      'of spatial point data'
     631   
     632    # dimension definitions
     633    shape = write_data_points.shape[0]
     634    outfile.createDimension('number_of_points', shape) 
     635    outfile.createDimension('number_of_dimensions', 2) #This is 2d data
     636   
     637    # variable definition
     638    outfile.createVariable('points', Float, ('number_of_points',
     639                                             'number_of_dimensions'))
     640
     641    #create variables 
     642    outfile.variables['points'][:] = write_data_points #.astype(Float32)
     643
     644    for key in write_attributes.keys():
     645        outfile.createVariable(key, Float, ('number_of_points',))
     646        outfile.variables[key][:] = write_attributes[key] #.astype(Float32)
     647       
     648    if write_geo_reference is not None:
     649        write_geo_reference.write_NetCDF(outfile)
     650       
     651    outfile.close()
     652 
     653
     654
     655def _new_write_xya_file( file_name, write_data_points,
     656                                    write_attributes,
     657                                    write_geo_reference = None,
     658                                    delimiter = ','):
     659    """
     660    export a file, ofile, with the xya format
     661   
     662    """
     663    points = write_data_points
     664    pointattributes = write_attributes
     665   
     666    fd = open(file_name,'w')
     667    titlelist = ""
     668    for title in pointattributes.keys():
     669        titlelist = titlelist + title + delimiter
     670    titlelist = titlelist[0:-len(delimiter)] # remove the last delimiter
     671    fd.write(titlelist+"\n")
     672    #<vertex #> <x> <y> [attributes]
     673    for i,vert in enumerate( points):
     674       
     675        attlist = ","
     676        for att in pointattributes.keys():
     677            attlist = attlist + str(pointattributes[att][i])+ delimiter
     678        attlist = attlist[0:-len(delimiter)] # remove the last delimiter
     679        attlist.strip()
     680        fd.write( str(vert[0]) + delimiter
     681                  + str(vert[1])
     682                  + attlist + "\n")
     683    '''   
     684    # geo_reference info
     685    if xya_dict.has_key('geo_reference') and \
     686           not xya_dict['geo_reference'] is None:
     687        xya_dict['geo_reference'].write_ASCII(fd)
     688    '''
     689    if  write_geo_reference is not None:
     690        write_geo_reference.write_ASCII(fd)
     691    fd.close()
     692'''
    523693def _write_pts_file(file_name, point_atts):
    524694    """Write .pts NetCDF file   
     
    600770        xya_dict['geo_reference'].write_ASCII(fd)
    601771    fd.close()
    602    
     772    '''
    603773def _point_atts2array(point_atts):
    604774    point_atts['pointlist'] = array(point_atts['pointlist']).astype(Float)
     
    682852   
    683853    #FIXME remove dependance on points to dict in export only!
    684     G_points_dict = geospatial_data2points_dictionary(G)
    685     export_points_file(results_file, G_points_dict)
     854#    G_points_dict = geospatial_data2points_dictionary(G)
     855#    export_points_file(results_file, G_points_dict)
     856
     857#    G_points_dict = geospatial_data2points_dictionary(G)
     858
     859    G.new_export_points_file(results_file)
    686860   
    687861   
  • inundation/geospatial_data/test_geospatial_data.py

    r2594 r2624  
    301301        points = [[1.0, 2.1], [3.0, 5.3], [5.0, 6.1], [6.0, 3.3]]
    302302        attributes = [2, 4, 5, 76]
    303 
     303        '''
    304304        # Use old pointsdict format
    305305        pointsdict = {'pointlist': points,
    306306                      'attributelist': {'att1': attributes,
    307307                                        'att2': array(attributes) + 1}}
    308      
     308        '''
     309        att_dict = {'att1': attributes,
     310                    'att2': array(attributes) +1}
     311                   
    309312        # Create points as an xya file
    310313        FN = 'test_points.xya'
    311         export_points_file(FN, pointsdict)
    312 
     314        G1 = Geospatial_data(points, att_dict)
     315        G1.new_export_points_file(FN)
     316#        G1.new_export_points_file(ofile)
    313317
    314318        #Create object from file
     
    397401                        'imaginary file did not raise error!')
    398402 
    399     def Xtest_read_write_points_file_bad(self):
    400         #not used yet as i'm uncertain if "tri_dict" is nesscessary to geospatial_data
    401         dict = self.tri_dict.copy()
    402         fileName = tempfile.mktemp(".xxx")
    403         try:
    404             export_points_file(fileName,dict)
    405         except IOError:
    406             pass
    407         else:
    408             self.failUnless(0 ==1,
    409                         'bad points file extension did not raise error!')
    410 
    411403    def test_read_write_points_file_bad2(self):
    412         dict = {}
     404#        dict = {}
    413405        att_dict = {}
    414         dict['pointlist'] = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     406        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    415407        att_dict['elevation'] = array([10.0, 0.0, 10.4])
    416408        att_dict['brightness'] = array([10.0, 0.0, 10.4])
    417         dict['attributelist'] = att_dict
    418         dict['geo_reference'] = Geo_reference(56,1.9,1.9)
    419         try:
    420             export_points_file("_???/yeah.xya",dict)
     409#        dict['attributelist'] = att_dict
     410        geo_reference = Geo_reference(56,1.9,1.9)
     411       
     412        G = Geospatial_data(pointlist, att_dict, geo_reference)
     413       
     414        try:
     415#            export_points_file("_???/yeah.xya",dict)
     416            G.new_export_points_file("_???/yeah.xya")
     417           
    421418        except IOError:
    422419            pass
    423420        else:
    424             self.failUnless(0 ==1,
     421            self.failUnless(0 == 1,
    425422                        'bad points file extension did not raise error!')
    426423                   
     
    573570       
    574571    def test_export_xya_file(self):
    575         dict = {}
     572#        dict = {}
    576573        att_dict = {}
    577         dict['pointlist'] = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     574        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    578575        att_dict['elevation'] = array([10.0, 0.0, 10.4])
    579576        att_dict['brightness'] = array([10.0, 0.0, 10.4])
    580         dict['attributelist'] = att_dict
    581         dict['geo_reference'] = Geo_reference(56,1.9,1.9)
    582        
    583        
    584         fileName = tempfile.mktemp(".xya")
    585         export_points_file(fileName, dict)
     577#        dict['attributelist'] = att_dict
     578        geo_reference = Geo_reference(56,1.9,1.9)
     579       
     580       
     581        fileName = tempfile.mktemp(".xya")
     582        G = Geospatial_data( pointlist, att_dict, geo_reference, absolute = False)
     583        G.new_export_points_file(fileName)
    586584        dict2 = import_points_file(fileName)
    587585        #print "fileName",fileName
     
    594592        assert allclose(dict2['attributelist']['brightness'], answer)
    595593        #print "dict2['geo_reference']",dict2['geo_reference']
    596         self.failUnless(dict['geo_reference'] == dict2['geo_reference'],
     594        self.failUnless(geo_reference == dict2['geo_reference'],
    597595                         'test_writepts failed. Test geo_reference')
    598596
    599597    def test_export_xya_file2(self):
    600         dict = {}
     598#        dict = {}
    601599        att_dict = {}
    602         dict['pointlist'] = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     600        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    603601        att_dict['elevation'] = array([10.0, 0.0, 10.4])
    604602        att_dict['brightness'] = array([10.0, 0.0, 10.4])
    605         dict['attributelist'] = att_dict
    606        
    607        
    608         fileName = tempfile.mktemp(".xya")
    609         export_points_file(fileName, dict)
     603#        dict['attributelist'] = att_dict
     604       
     605        fileName = tempfile.mktemp(".xya")
     606        G = Geospatial_data(pointlist, att_dict)
     607        G.new_export_points_file(fileName)
    610608        dict2 = import_points_file(fileName)
    611609        #print "fileName",fileName
     
    616614        assert allclose(dict2['attributelist']['elevation'], [10.0, 0.0, 10.4])
    617615        answer = [10.0, 0.0, 10.4]
     616        assert allclose(dict2['attributelist']['brightness'], answer)
     617
     618    def test_new_export_xya_file2(self):
     619        dict = {}
     620        att_dict = {}
     621        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     622        att_dict['elevation'] = array([10.1, 0.0, 10.4])
     623        att_dict['brightness'] = array([10.0, 1.0, 10.4])
     624       
     625        fileName = tempfile.mktemp(".xya")
     626       
     627        G = Geospatial_data(pointlist, att_dict)
     628       
     629        G.new_export_points_file(fileName)
     630
     631        dict2 = import_points_file(fileName)
     632
     633        os.remove(fileName)
     634       
     635        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     636        assert allclose(dict2['attributelist']['elevation'], [10.1, 0.0, 10.4])
     637        answer = [10.0, 1.0, 10.4]
     638        assert allclose(dict2['attributelist']['brightness'], answer)
     639
     640    def test_new_export_pts_file(self):
     641        att_dict = {}
     642        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     643        att_dict['elevation'] = array([10.1, 0.0, 10.4])
     644        att_dict['brightness'] = array([10.0, 1.0, 10.4])
     645       
     646        fileName = tempfile.mktemp(".pts")
     647       
     648        G = Geospatial_data(pointlist, att_dict)
     649       
     650        G.new_export_points_file(fileName)
     651
     652        dict2 = import_points_file(fileName)
     653
     654        os.remove(fileName)
     655       
     656        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     657        assert allclose(dict2['attributelist']['elevation'], [10.1, 0.0, 10.4])
     658        answer = [10.0, 1.0, 10.4]
    618659        assert allclose(dict2['attributelist']['brightness'], answer)
    619660
     
    658699       
    659700    def test_writepts(self):
    660         dict = {}
     701#        dict = {}
    661702        att_dict = {}
    662         dict['pointlist'] = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     703        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    663704        att_dict['elevation'] = array([10.0, 0.0, 10.4])
    664705        att_dict['brightness'] = array([10.0, 0.0, 10.4])
    665         dict['attributelist'] = att_dict
    666         dict['geo_reference'] = Geo_reference(56,1.9,1.9)
    667        
     706#        dict['attributelist'] = att_dict
     707        geo_reference = Geo_reference(56,1.9,1.9)
    668708       
    669709        fileName = tempfile.mktemp(".pts")
    670         export_points_file(fileName, dict)
     710       
     711        G = Geospatial_data(pointlist, att_dict, geo_reference, absolute = False)
     712       
     713        G.new_export_points_file(fileName)
     714       
    671715        dict2 = import_points_file(fileName)
    672         #print "fileName",fileName
    673         os.remove(fileName)
    674         #print "dict2",dict2
    675        
     716
     717        os.remove(fileName)
     718
    676719        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    677720        assert allclose(dict2['attributelist']['elevation'], [10.0, 0.0, 10.4])
     
    682725        #print "dict2['geo_reference']",dict2['geo_reference']
    683726       
    684         self.failUnless(dict['geo_reference'] == dict2['geo_reference'],
     727        self.failUnless(geo_reference == dict2['geo_reference'],
    685728                         'test_writepts failed. Test geo_reference')
    686729       
     
    705748       
    706749        from Scientific.IO.NetCDF import NetCDFFile
    707 
    708750
    709751#        fileName = tempfile.mktemp(".pts")
     
    738780        assert allclose(G.get_geo_reference().get_xllcorner(), 0.0)
    739781        assert allclose(G.get_geo_reference().get_yllcorner(), 0.0)
    740        
    741782
    742783        assert allclose(G.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     
    749790       
    750791        from Scientific.IO.NetCDF import NetCDFFile
    751 
    752792
    753793        FN = 'test_points.pts'
     
    761801        geo_reference.write_NetCDF(outfile)
    762802
    763        
    764803        # dimension definitions
    765804        outfile.createDimension('number_of_points', 3)   
     
    775814        elevation = outfile.variables['elevation']
    776815
    777  
    778816        points[0, :] = [1.0,0.0]
    779817        elevation[0] = 10.0
     
    787825        G = Geospatial_data(file_name = FN)
    788826
    789 
    790 
    791827        assert allclose(G.get_geo_reference().get_xllcorner(), xll)
    792828        assert allclose(G.get_geo_reference().get_yllcorner(), yll)
    793        
    794829
    795830        assert allclose(G.get_data_points(), [[1.0+xll, 0.0+yll],
     
    801836
    802837       
    803     def xtest_add_points_files(self):
     838    def test_add_points_files(self):
    804839        '''adds an xya and pts files and checks resulting file is correct
    805840        '''
     
    808843       
    809844        # create files
    810         dict1 = {}
     845#        dict1 = {}
    811846        att_dict1 = {}
    812         dict1['pointlist'] = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     847        pointlist1 = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    813848        att_dict1['elevation'] = array([-10.0, 0.0, 10.4])
    814849        att_dict1['brightness'] = array([10.0, 0.0, 10.4])
    815         dict1['attributelist'] = att_dict1
    816         dict1['geo_reference'] = Geo_reference(56, 1.9, 1.9)
    817        
    818         dict2 = {}
     850#        dict1['attributelist'] = att_dict1
     851        geo_reference1 = Geo_reference(56, 2.0, 1.0)
     852       
     853#        dict2 = {}
    819854        att_dict2 = {}
    820         dict2['pointlist'] = array([[2.0, 1.0],[1.0, 2.0],[2.0, 1.0]])
     855        pointlist2 = array([[2.0, 1.0],[1.0, 2.0],[2.0, 1.0]])
    821856        att_dict2['elevation'] = array([1.0, 15.0, 1.4])
    822857        att_dict2['brightness'] = array([14.0, 1.0, -12.4])
    823         dict2['attributelist'] = att_dict2
    824         dict2['geo_reference'] = Geo_reference(56, 1.0, 1.0) #FIXME (Ole): I changed this, why does it still pass
     858#        dict2['attributelist'] = att_dict2
     859        geo_reference2 = Geo_reference(56, 1.0, 2.0) #FIXME (Ole): I changed this, why does it still pass
    825860        #OK - it fails now, after the fix revealed by test_create_from_pts_file_with_geo')
     861
     862        G1 = Geospatial_data(pointlist1, att_dict1, geo_reference1)
     863        G2 = Geospatial_data(pointlist2, att_dict2, geo_reference2)
    826864       
    827865        fileName1 = tempfile.mktemp(".xya")
    828866        fileName2 = tempfile.mktemp(".pts")
    829867
    830         export_points_file(fileName1, dict1)
    831         export_points_file(fileName2, dict2)
     868#        G1.new_export_points_file(fileName1)
     869#        G2.new_export_points_file(fileName2)
    832870       
    833871        results_file = 'resulting_points.pts'
    834872       
    835873        # add files
    836         add_points_files(fileName1, fileName2, results_file )
     874       
     875        G = G1 + G2
     876       
     877        G.new_export_points_file(results_file)
     878#        add_points_files(fileName1, fileName2, results_file )
    837879       
    838880        #read results
    839881        results_dict = import_points_file(results_file)
     882#        print 'results points:', results_dict['pointlist']
     883#        print 'results geo_ref:', results_dict['geo_reference']
    840884       
    841885        assert allclose(results_dict['pointlist'],
    842                         [[1.0, 0.0],[0.0, 1.0],
    843                          [1.0, 0.0],[2.0, 1.0],
    844                          [1.0, 2.0],[2.0, 1.0]])
     886                        [[2.0, 0.0],[1.0, 1.0],
     887                         [2.0, 0.0],[2.0, 2.0],
     888                         [1.0, 3.0],[2.0, 2.0]])
    845889        assert allclose(results_dict['attributelist']['elevation'],
    846890                        [-10.0, 0.0, 10.4, 1.0, 15.0, 1.4])
     
    849893        assert allclose(results_dict['attributelist']['brightness'], answer)
    850894       
    851         self.failUnless(results_dict['geo_reference'] == dict2['geo_reference'],
     895        self.failUnless(results_dict['geo_reference'] == geo_reference1,
    852896                         'test_writepts failed. Test geo_reference')
    853897                         
    854         os.remove(fileName1)
    855         os.remove(fileName2)
     898#        os.remove(fileName1)
     899#        os.remove(fileName2)
    856900        os.remove(results_file)
    857901
  • production/onslow_2006/project.py

    r2616 r2624  
    4747polygondir = home+sep+scenario_dir_name+sep+'polygons'+sep
    4848boundarydir = home+sep+scenario_dir_name+sep+'boundaries'+sep
     49print'bound', boundarydir
     50
     51# boundary source data
     52MOST_dir = 'f:'+sep+'3'+sep+'ehn'+sep+'users'+sep+'davidb'+sep+'tsunami'+sep+'WA_project'+sep+'SU-AU_90'+sep+'most_2'+sep+'detailed'+sep
    4953
    5054codedir = getcwd()+sep
  • production/onslow_2006/run_onslow.py

    r2616 r2624  
    5555source_dir = project.boundarydir
    5656
    57 # creates copy of code in output dir
     57# creates copy of code in output dir if dir doesn't exist
    5858if access(project.outputdir,F_OK) == 0 :
    5959    mkdir (project.outputdir)
    6060copy (project.codedirname, project.outputdir + project.codename)
    6161copy (project.codedir + 'run_onslow.py', project.outputdir + 'run_onslow.py')
    62 
     62print'hello'
     63print' most file', project.MOST_dir + project.boundary_basename+'_ha.nc'
     64if access(project.MOST_dir + project.boundary_basename+'_ha.nc',F_OK) == 1 :
     65    print' most file', project.MOST_dir + project.boundary_basename
    6366
    6467'''
     
    7982
    8083        '''
     84'''
    8185print'create G1'
    8286G1 = Geospatial_data(file_name = project.offshore_dem_name + '.xya')
     
    9195G.new_export_points_file(project.combined_dem_name + '.pts')
    9296
    93 '''
    94 add_points_files(
    95                   project.offshore_dem_name + '.xya',
    96                   project.onshore_dem_name + '.pts',
    97                   project.combined_dem_name + '.pts')
    9897'''
    9998#-------------------------------------------------------------------------------                                 
     
    106105
    107106# original
    108 interior_res = 5000
     107interior_res = 50000
    109108interior_regions = [[project.poly_onslow, interior_res],
    110109                    [project.poly_thevenard, interior_res],
     
    119118                             'left': [2], 'bottom': [3],
    120119                             'bottomright': [4], 'topright': [5]},
    121            'maximum_triangle_area': 100000,
     120           'maximum_triangle_area': 1000000,
    122121           'filename': meshname,           
    123122           'interior_regions': interior_regions},
     
    167166domain.set_quantity('friction', 0.0)
    168167print 'hi and file',project.combined_dem_name + '.pts'
     168
    169169domain.set_quantity('elevation',
    170170#                    0.
     
    176176                    alpha = 0.1
    177177                    )
     178
    178179print 'hi1'
    179180
     
    190191
    191192cache(ferret2sww,
    192       (source_dir + project.boundary_basename,
     193#      (source_dir + project.boundary_basename,
     194#       source_dir + project.boundary_basename),
     195      (project.MOST_dir + project.boundary_basename,
    193196       source_dir + project.boundary_basename),
    194197      {'verbose': True,
Note: See TracChangeset for help on using the changeset viewer.