Changeset 3953
- Timestamp:
- Nov 9, 2006, 9:42:34 AM (18 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r3944 r3953 1195 1195 return texfile2, elev_output 1196 1196 1197 1198 def gauge_in_sww(swwfile,1199 gauge_filename,1200 verbose = False):1201 1202 """ Determine which gauges fall in sww file.1203 1204 Input variables:1205 1206 swwfiles - sww files1207 1208 gauge_filename - name of file containing gauge data1209 - easting, northing, name , elevation1210 - OR (this is not yet done)1211 - structure which can be converted to a Numeric array,1212 such as a geospatial data object1213 1214 Output:1215 1216 - Modified gauge_filename containing gauges which fall is given sww file.1217 Name = gauges_filename_mod1218 Other important information:1219 1220 """1221 1222 1223 k = _gauge_in_sww(swwfile,1224 gauge_filename,1225 verbose)1226 1227 return k1228 1229 def _gauge_in_sww(swwfile,1230 gauge_filename,1231 verbose = False):1232 1233 try:1234 fid = open(swwfile)1235 except Exception, e:1236 msg = 'File "%s" could not be opened: Error="%s"'\1237 %(swwfile, e)1238 raise msg1239 1240 assert type(gauge_filename) == type(''),\1241 'Gauge filename must be a string'1242 1243 try:1244 fid = open(gauge_filename)1245 except Exception, e:1246 msg = 'File "%s" could not be opened: Error="%s"'\1247 %(gauge_filename, e)1248 raise msg1249 1250 sww_quantity = ['stage', 'elevation', 'xmomentum', 'ymomentum']1251 f = file_function(swwfile,1252 quantities = sww_quantity,1253 #interpolation_points = gauges,1254 verbose = True,1255 use_cache = True)1256 print dir(f)1257 1258 #from bstract_2d_finite_volumes.neighbour_mesh import get_boundary_polygon1259 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh1260 #from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate1261 #from anuga.fit_interpolate.interpolate import Interpolation_function1262 from anuga.fit_interpolate.interpolate import Interpolate1263 1264 test = Mesh(f.vertex_coordinates)1265 print test.mesh.get_boundary_polygon()1266 1267 return check_gauge(gauge_filename,bounding_polygon)1268 1269 def check_gauge(gauge_filename,bounding_polygon):1270 1271 from anuga.utilities.polygon import is_inside_polygon1272 1273 filename_out = gauge_filename + '_mod'1274 fid_out = open(filename_out, 'w')1275 fid_out.write(s)1276 1277 gauges, locations, elev = get_gauges_from_file(gauge_filename)1278 1279 for i, gauge in enumerate(gauges):1280 v = is_inside_polygon(gauge,bounding_polygon,verbose=False)1281 if v == True:1282 s = '%.2f, %.2f, %.2f, %s\n' %(gauges[0], gauges[1], elev[i], locations[i])1283 1284 return fid_out1285 1286 1197 from os.path import basename 1287 1198 -
anuga_core/source/anuga/shallow_water/data_manager.py
r3950 r3953 4020 4020 4021 4021 4022 # FIXME (Ole): Is this doing anything at all?4023 def sww2timeseries(swwfile,4024 gauge_filename,4025 gauge_data_outname,4026 quantity = None,4027 time_min = None,4028 time_max = None,4029 verbose = False):4030 4031 """Read SWW file and extract time series for prescribed quantities at4032 gauge locations.4033 4034 The gauge locations are defined in gauge_filename. This file should be4035 in the form: gaugename, easting, northing, and should be stored in a4036 .csv or .xya file.4037 4038 Time series data at the gauges can be written to file (for example,4039 Benfield requested raw data) with the default being no data written.4040 4041 The parameter quantity must be the name of an existing quantity or4042 an expression involving existing quantities. The default is4043 'depth'.4044 4045 The user can define a list of quantities. The possibilities are4046 the conserved quantitues of the shallow water wave equation and other4047 quantities which can be derived from those, i.e.4048 ['depth', 'xmomentum', 'ymomentum', 'momentum', 'velocity', 'bearing'].4049 4050 Momentum is the absolute momentum, sqrt(xmomentum^2 + ymomentum^2).4051 Note, units of momentum are m^2/s and depth is m.4052 4053 Velocity is absolute momentum divided by depth. (Confirming correct units:4054 vel = abs mom / depth = (m^2/s)/m = m/s.)4055 4056 Bearing returns the angle of the velocity vector from North.4057 4058 If time_min and time_max is given, output plotted in that time range.4059 The default is to plot the entire range of the time evident in sww file.4060 4061 The export graphic format in 'png' and will be stored in the same4062 directory as the input file.4063 """4064 4065 if quantity is None: quantity = 'depth'4066 4067 # extract gauge locations from gauge file4068 4069 # extract all quantities from swwfile (f = file_function)4070 if time_min is None: time_min = min(f.get_time())4071 if time_max is None: time_max = max(f.get_time())4072 4073 # loop through appropriate range of time4074 # plot prescribed quantities and export data if requested4075 4076 #if gauge_data_outname is None:4077 4078 return4079 4022 4080 4023 #### URS 2 SWW ###
Note: See TracChangeset
for help on using the changeset viewer.