Changeset 4381


Ignore:
Timestamp:
Apr 16, 2007, 3:28:39 PM (18 years ago)
Author:
duncan
Message:

removing dead code

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4380 r4381  
    671671        fid.sync()
    672672        fid.close()
    673 
    674 
    675 
    676 
    677 
    678 #Function for storing xya output
    679 #FIXME Not done yet for this version
    680 #This is obsolete.  Use geo_spatial_data instead
    681 class Data_format_xya(Data_format):
    682     """Generic interface to data formats
    683     """
    684 
    685 
    686     def __init__(self, domain, mode = 'w'):
    687         from Scientific.IO.NetCDF import NetCDFFile
    688         from Numeric import Int, Float, Float32
    689 
    690         self.precision = Float32 #Use single precision
    691 
    692         Data_format.__init__(self, domain, 'xya', mode)
    693 
    694 
    695 
    696     #FIXME -This is the old xya format
    697     def store_all(self):
    698         """Specialisation of store all for xya format
    699 
    700         Writes x,y,z coordinates of triangles constituting
    701         the bed elevation.
    702         """
    703 
    704         from Numeric import concatenate
    705 
    706         domain = self.domain
    707 
    708         fd = open(self.filename, 'w')
    709 
    710 
    711         if domain.smooth is True:
    712             number_of_points =  len(domain.vertexlist)
    713         else:
    714             number_of_points = 3*self.number_of_volumes
    715 
    716         numVertAttrib = 3 #Three attributes is what is assumed by the xya format
    717 
    718         fd.write(str(number_of_points) + " " + str(numVertAttrib) +\
    719                  " # <vertex #> <x> <y> [attributes]" + "\n")
    720 
    721 
    722         # Get X, Y, bed elevation and friction (index=0,1)
    723         X,Y,A,V = domain.get_vertex_values(xy=True, value_array='field_values',
    724                                            indices = (0,1), precision = self.precision)
    725 
    726         bed_eles = A[:,0]
    727         fricts = A[:,1]
    728 
    729         # Get stage (index=0)
    730         B,V = domain.get_vertex_values(xy=False, value_array='conserved_quantities',
    731                                        indices = (0,), precision = self.precision)
    732 
    733         stages = B[:,0]
    734 
    735         #<vertex #> <x> <y> [attributes]
    736         for x, y, bed_ele, stage, frict in map(None, X, Y, bed_eles,
    737                                                stages, fricts):
    738 
    739             s = '%.6f %.6f %.6f %.6f %.6f\n' %(x, y, bed_ele, stage, frict)
    740             fd.write(s)
    741 
    742         #close
    743         fd.close()
    744 
    745 
    746     def store_timestep(self, t, V0, V1, V2):
    747         """Store time, water heights (and momentums) to file
    748         """
    749         pass
    750673
    751674
     
    12291152    return cls(domain, mode)
    12301153
    1231 #FIXME move into geospatial.  There should only be one method that
    1232 # reads xya, and writes pts.
    1233 def xya2pts(basename_in, basename_out=None, verbose=False,
    1234             #easting_min=None, easting_max=None,
    1235             #northing_min=None, northing_max=None,
    1236             stride = 1,
    1237             attribute_name = 'elevation',
    1238             z_func = None):
    1239     """Read points data from ascii (.xya)
    1240 
    1241     Example:
    1242 
    1243               x(m)        y(m)        z(m)
    1244          0.00000e+00  0.00000e+00  1.3535000e-01
    1245          0.00000e+00  1.40000e-02  1.3535000e-01
    1246 
    1247 
    1248 
    1249     Convert to NetCDF pts format which is
    1250 
    1251     points:  (Nx2) Float array
    1252     elevation: N Float array
    1253 
    1254     Only lines that contain three numeric values are processed
    1255 
    1256     If z_func is specified, it will be applied to the third field
    1257     """
    1258 
    1259     import os
    1260     #from Scientific.IO.NetCDF import NetCDFFile
    1261     from Numeric import Float, arrayrange, concatenate
    1262 
    1263     root, ext = os.path.splitext(basename_in)
    1264 
    1265     if ext == '': ext = '.xya'
    1266 
    1267     #Get NetCDF
    1268     infile = open(root + ext, 'r')  #Open existing xya file for read
    1269 
    1270     if verbose: print 'Reading xya points from %s' %(root + ext)
    1271 
    1272     points = []
    1273     attribute = []
    1274     for i, line in enumerate(infile.readlines()):
    1275 
    1276         if i % stride != 0: continue
    1277 
    1278         fields = line.split()
    1279 
    1280         try:
    1281             assert len(fields) == 3
    1282         except:
    1283             print 'WARNING: Line %d doesn\'t have 3 elements: %s' %(i, line)
    1284 
    1285         try:
    1286             x = float( fields[0] )
    1287             y = float( fields[1] )
    1288             z = float( fields[2] )
    1289         except:
    1290             continue
    1291 
    1292         points.append( [x, y] )
    1293 
    1294         if callable(z_func):
    1295             attribute.append(z_func(z))
    1296         else:
    1297             attribute.append(z)
    1298 
    1299 
    1300     #Get output file
    1301     if basename_out == None:
    1302         ptsname = root + '.pts'
    1303     else:
    1304         ptsname = basename_out + '.pts'
    1305 
    1306     if verbose: print 'Store to NetCDF file %s' %ptsname
    1307     write_ptsfile(ptsname, points, attribute, attribute_name)
    1308 
    1309 
    1310 
    1311 ######Obsoleted by export_points in load_mesh
    1312 def write_ptsfile(ptsname, points, attribute, attribute_name = None,
    1313                   zone=None, xllcorner=None, yllcorner=None):
    1314     """Write points and associated attribute to pts (NetCDF) format
    1315     """
    1316 
    1317     print 'WARNING: write_ptsfile is obsolete. Use export_points from load_mesh.loadASCII instead.'
    1318 
    1319     from Numeric import Float
    1320 
    1321     if attribute_name is None:
    1322         attribute_name = 'attribute'
    1323 
    1324 
    1325     from Scientific.IO.NetCDF import NetCDFFile
    1326 
    1327     # NetCDF file definition
    1328     outfile = NetCDFFile(ptsname, 'w')
    1329 
    1330 
    1331     #Create new file
    1332     outfile.institution = 'Geoscience Australia'
    1333     outfile.description = 'NetCDF pts format for compact and '\
    1334                           'portable storage of spatial point data'
    1335 
    1336 
    1337     #Georeferencing
    1338     from anuga.coordinate_transforms.geo_reference import Geo_reference
    1339     if zone is None:
    1340         assert xllcorner is None, 'xllcorner must be None'
    1341         assert yllcorner is None, 'yllcorner must be None'
    1342         Geo_reference().write_NetCDF(outfile)
    1343     else:
    1344         Geo_reference(zone, xllcorner, yllcorner).write_NetCDF(outfile)
    1345 
    1346 
    1347 
    1348     outfile.createDimension('number_of_points', len(points))
    1349     outfile.createDimension('number_of_dimensions', 2) #This is 2d data
    1350 
    1351     # variable definitions
    1352     outfile.createVariable('points', Float, ('number_of_points',
    1353                                              'number_of_dimensions'))
    1354     outfile.createVariable(attribute_name, Float, ('number_of_points',))
    1355 
    1356     # Get handles to the variables
    1357     nc_points = outfile.variables['points']
    1358     nc_attribute = outfile.variables[attribute_name]
    1359 
    1360     #Store data
    1361     nc_points[:, :] = points
    1362     nc_attribute[:] = attribute
    1363 
    1364     outfile.close()
     1154
    13651155
    13661156
     
    20471837
    20481838    #Interpolate
    2049     #from least_squares import Interpolation
    20501839    from anuga.fit_interpolate.interpolate import Interpolate
    20511840
     
    44924281
    44934282    """
    4494     #FIXME cache this function!
    44954283   
    44964284    from sets import ImmutableSet
     
    45334321    sqrt_2_rounded_up = 1.415
    45344322    buffer = sqrt_2_rounded_up * grid_spacing
    4535    
    4536     #
    45374323   
    45384324    max_lat = max(seg_lat_long[0][0], seg_lat_long[1][0]) + buffer
     
    46934479    # This mesh has a problem.  Triangles are streched over ungridded areas.
    46944480    #  If these areas could be described as holes in pmesh, that would be great
    4695    
     4481
     4482    # I can't just get the user to selection a point in the middle.
     4483    # A boundary is needed around these points.
     4484    # But if the zone of points is obvious enough auto-segment should do
     4485    # a good boundary.
    46964486    mesh = Mesh()
    46974487    mesh.add_vertices(points_utm)
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4378 r4381  
    572572        os.remove(sww.filename)
    573573
    574 
    575     #def test_write_pts(self):
    576     #    #Obsolete
    577     #
    578     #    #Get (enough) datapoints
    579     #
    580     #    from Numeric import array
    581     #    points = array([[ 0.66666667, 0.66666667],
    582     #                    [ 1.33333333, 1.33333333],
    583     #                    [ 2.66666667, 0.66666667],
    584     #                    [ 0.66666667, 2.66666667],
    585     #                    [ 0.0, 1.0],
    586     #                    [ 0.0, 3.0],
    587     #                    [ 1.0, 0.0],
    588     #                    [ 1.0, 1.0],
    589     #                    [ 1.0, 2.0],
    590     #                    [ 1.0, 3.0],
    591     #                    [ 2.0, 1.0],
    592     #                    [ 3.0, 0.0],
    593     #                    [ 3.0, 1.0]])
    594     #
    595     #    z = points[:,0] + 2*points[:,1]
    596     #
    597     #    ptsfile = 'testptsfile.pts'
    598     #    write_ptsfile(ptsfile, points, z,
    599     #                  attribute_name = 'linear_combination')
    600     #
    601     #    #Check contents
    602     #    #Get NetCDF
    603     #    from Scientific.IO.NetCDF import NetCDFFile
    604     #    fid = NetCDFFile(ptsfile, 'r')
    605     #
    606     #    # Get the variables
    607     #    #print fid.variables.keys()
    608     #    points1 = fid.variables['points']
    609     #    z1 = fid.variables['linear_combination']
    610     #
    611     #    #Check values#
    612     #
    613     #    #print points[:]
    614     #    #print ref_points
    615     #    assert allclose(points, points1)
    616     #
    617     #    #print attributes[:]
    618     #    #print ref_elevation
    619     #    assert allclose(z, z1)
    620     #
    621     #    #Cleanup
    622     #    fid.close()
    623     #
    624     #    import os
    625     #    os.remove(ptsfile)
    626574
    627575
     
    55445492        fid.close()
    55455493        self.delete_mux(files)
    5546         #os.remove(sww_file)
     5494        os.remove(sww_file)
    55475495 
    55485496    def test_urs_ungridded2swwIII (self):
Note: See TracChangeset for help on using the changeset viewer.