Changeset 7520
- Timestamp:
- Sep 21, 2009, 7:19:55 PM (14 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r7519 r7520 2487 2487 # change printoptions so that a long string of zeros in not 2488 2488 # summarized as [0.0, 0.0, 0.0, ... 0.0, 0.0, 0.0] 2489 printoptions = num.get_printoptions() 2490 num.set_printoptions(threshold=sys.maxint) 2491 2489 #printoptions = num.get_printoptions() 2490 #num.set_printoptions(threshold=sys.maxint) 2491 2492 format = '%.'+'%g' % number_of_decimal_places +'e' 2492 2493 for i in range(nrows): 2493 2494 if verbose and i % ((nrows+10)/10) == 0: … … 2497 2498 2498 2499 slice = grid_values[base_index:base_index+ncols] 2499 #s = array2string(slice, max_line_width=sys.maxint) 2500 2501 s = num.array2string(slice, max_line_width=sys.maxint, 2502 precision=number_of_decimal_places) 2503 ascid.write(s[1:-1] + '\n') 2504 2505 num.set_printoptions(threshold=printoptions['threshold']) 2500 2501 num.savetxt(ascid, slice.reshape(1,ncols), format, ' ' ) 2502 2506 2503 2507 2504 #Close -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r7519 r7520 2106 2106 def test_sww2dem_larger_zero(self): 2107 2107 """Test that sww information can be converted correctly to asc/prj 2108 format readable by e.g. ArcView. Here: 2109 2110 ncols 11 2111 nrows 11 2108 format readable by e.g. Arcview. This example has rows with a 2109 large number of zeros 2110 2111 ncols 2001 2112 nrows 2 2112 2113 xllcorner 308500 2113 2114 yllcorner 6189000 2114 cellsize 1 0.0000002115 cellsize 1.000000 2115 2116 NODATA_value -9999 2116 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 -200 2117 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 2118 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 2119 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 2120 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 2121 -50 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 2122 -40 -50 -60 -70 -80 -90 -100 -110 -120 -130 -140 2123 -30 -40 -50 -60 -70 -80 -90 -100 -110 -120 -130 2124 -20 -30 -40 -50 -60 -70 -80 -90 -100 -110 -120 2125 -10 -20 -30 -40 -50 -60 -70 -80 -90 -100 -110 2126 0 -10 -20 -30 -40 -50 -60 -70 -80 -90 -100 2127 2117 0.0 .... 2128 2118 """ 2129 2119 … … 2133 2123 #Setup 2134 2124 2135 from mesh_factory import rectangular 2125 from mesh_factory import rectangular_cross 2136 2126 2137 2127 #Create basic mesh (100m x 100m) 2138 points, vertices, boundary = rectangular (2, 2, 100, 100)2128 points, vertices, boundary = rectangular_cross(2000, 1, 2000.0, 1.0) 2139 2129 2140 2130 #Create shallow water domain … … 2170 2160 sww.store_timestep() 2171 2161 2172 # Set theshold for printoptions to somrthing small 2173 # to pickup Rudy's error caused a long sequence of zeros printing 2174 # as [ 0.0, 0.0, 0.0, ... 0.0, 0.0, 0.0] by num.array2string 2175 printoptions = num.get_printoptions() 2176 num.set_printoptions(threshold=9) 2177 2178 cellsize = 10 #10m grid 2162 cellsize = 1.0 #0.1 grid 2179 2163 2180 2164 … … 2207 2191 prjid.close() 2208 2192 2193 2209 2194 L = lines[0].strip().split() 2210 2195 assert L[0].strip().lower() == 'projection' … … 2248 2233 ascid.close() 2249 2234 2235 2236 2250 2237 L = lines[0].strip().split() 2251 2238 assert L[0].strip().lower() == 'ncols' 2252 assert L[1].strip().lower() == ' 11'2239 assert L[1].strip().lower() == '2001' 2253 2240 2254 2241 L = lines[1].strip().split() 2255 2242 assert L[0].strip().lower() == 'nrows' 2256 assert L[1].strip().lower() == ' 11'2243 assert L[1].strip().lower() == '2' 2257 2244 2258 2245 L = lines[2].strip().split() … … 2286 2273 2287 2274 2288 num.set_printoptions(threshold=printoptions['threshold'])2289 2275 #Cleanup 2290 2276 os.remove(prjfile)
Note: See TracChangeset
for help on using the changeset viewer.