Changeset 1046
- Timestamp:
- Mar 9, 2005, 4:37:00 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution/coordinate_transforms
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/coordinate_transforms/geo_reference.py
r1031 r1046 14 14 xllcorner=None, 15 15 yllcorner=None, 16 NetCDFObject = None): 16 NetCDFObject = None, 17 ASCIIFile = None): 17 18 if not xllcorner == None: 18 19 self.xllcorner = xllcorner #Easting of lower left corner … … 24 25 if not NetCDFObject == None: 25 26 self.read_NetCDF(NetCDFObject) 27 28 #FIXME think if this should be here 29 if not ASCIIFile == None: 30 self.read_ASCII(ASCIIFile) 26 31 27 32 def write_NetCDF(self, outfile): … … 46 51 assert (type(self.yllcorner) == types.FloatType) 47 52 assert (type(self.zone) == types.IntType) 53 54 55 def write_ASCII(self, fd): 56 fd.write('# Geo reference' + "\n") 57 fd.write(str(self.zone) + "\n") 58 fd.write(str(self.xllcorner) + "\n") 59 fd.write(str(self.yllcorner) + "\n") 60 61 def read_ASCII(self, fd): 62 fd.readline() # remove the title line 63 self.zone = int(fd.readline()) 64 self.xllcorner = float(fd.readline()) 65 self.yllcorner = float(fd.readline()) 66 67 68 assert (type(self.xllcorner) == types.FloatType) 69 assert (type(self.yllcorner) == types.FloatType) 70 assert (type(self.zone) == types.IntType) 48 71 49 72 #false_easting = infile.false_easting[0] 50 73 #false_northing = infile.false_northing[0] 74 75 def change_geo_ref(self, primary_geo_ref, 76 secondary_geo_ref, secondary_points): 77 #convert into array 78 #add secondary geo ref to points 79 #subtract secondary geo ref from points 80 # return points 81 pass 51 82 52 83 def __repr__(self): -
inundation/ga/storm_surge/pyvolution/coordinate_transforms/test_geo_reference.py
r1030 r1046 32 32 self.failUnless(g == new_g, 'test_read_write_NetCDF failed') 33 33 34 def test_read_write_ASCII(self): 35 from Scientific.IO.NetCDF import NetCDFFile 36 g = Geo_reference(56,1.9,1.9) 37 file_name = tempfile.mktemp(".geo_referenceTest") 38 print "file_name",file_name 39 fd = open(file_name,'w') 40 g.write_ASCII(fd) 41 fd.close() 42 43 fd = open(file_name,'r') 44 new_g = Geo_reference(ASCIIFile=fd) 45 fd.close() 46 os.remove(file_name) 47 48 self.failUnless(g == new_g, 'test_read_write_ASCII failed') 49 34 50 def test___cmp__(self): 35 51 g = Geo_reference(56,1.9,1.9,)
Note: See TracChangeset
for help on using the changeset viewer.