Changeset 1820
 Timestamp:
 Sep 12, 2005, 6:05:53 PM (18 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

inundation/pyvolution/least_squares.py
r1819 r1820 961 961 962 962 #Use keys if no names are specified 963 if quantity_names is not None: 964 self.quantity_names = quantity_names 965 else: 966 self.quantity_names = quantities.keys() 963 if quantity_names is None: 964 quantity_names = quantities.keys() 967 965 968 966 … … 977 975 self.spatial = True 978 976 977 979 978 980 # 979 #Save for use with statistics 980 self.quantity_names = quantity_names 981 self.quantities = quantities 982 self.vertex_coordinates = vertex_coordinates 981 983 self.interpolation_points = interpolation_points 982 984 self.T = time[:] #Time assumed to be relative to starttime … … 993 995 994 996 try: 995 interpolation_points = ensure_numeric(interpolation_points) 997 self.interpolation_points =\ 998 ensure_numeric(self.interpolation_points) 996 999 except: 997 1000 msg = 'Interpolation points must be an N x 2 Numeric array '+\ 998 1001 'or a list of points\n' 999 msg += 'I got: %s.' %( str( interpolation_points)[:60] + '...')1002 msg += 'I got: %s.' %( str(self.interpolation_points)[:60] + '...') 1000 1003 raise msg 1001 1004 … … 1004 1007 self.precomputed_values[name] =\ 1005 1008 zeros((len(self.T), 1006 len( interpolation_points)),1009 len(self.interpolation_points)), 1007 1010 Float) 1008 1011 … … 1010 1013 interpol = Interpolation(vertex_coordinates, 1011 1014 triangles, 1012 point_coordinates = interpolation_points,1015 point_coordinates = self.interpolation_points, 1013 1016 alpha = 0, 1014 1017 precrop = False, … … 1025 1028 #Report 1026 1029 if verbose: 1027 #FIXME: Move to e.g. __repr__ 1028 x = vertex_coordinates[:,0] 1029 y = vertex_coordinates[:,1] 1030 1031 print '' 1032 print 'Interpolation_function statistics:' 1033 print ' Extent:' 1034 print ' x in [%f, %f], len(x) == %d'\ 1035 %(min(x), max(x), len(x)) 1036 print ' y in [%f, %f], len(y) == %d'\ 1037 %(min(y), max(y), len(y)) 1038 print ' t in [%f, %f], len(t) == %d'\ 1039 %(min(self.T), max(self.T), len(self.T)) 1040 print ' Quantities:' 1041 for name in quantity_names: 1042 q = quantities[name][:].flat 1043 print ' %s in [%f, %f]' %(name, min(q), max(q)) 1044 print ' Interpolation points (xi, eta):'\ 1045 ' number of points == %d ' %interpolation_points.shape[0] 1046 print ' xi in [%f, %f]' %(min(interpolation_points[:,0]), 1047 max(interpolation_points[:,0])) 1048 print ' eta in [%f, %f]' %(min(interpolation_points[:,1]), 1049 max(interpolation_points[:,1])) 1050 print ' Interpolated quantities (over all timesteps):' 1051 1052 for name in quantity_names: 1053 q = self.precomputed_values[name][:].flat 1054 print ' %s at interpolation points in [%f, %f]'\ 1055 %(name, min(q), max(q)) 1056 print '' 1030 print self.statistics() 1031 #self.print_statistics() 1057 1032 1058 1033 else: … … 1077 1052 1078 1053 def __repr__(self): 1079 return 'Interpolation function (spationtemporal)' 1054 #return 'Interpolation function (spationtemporal)' 1055 return self.statistics() 1056 1080 1057 1081 1058 def __call__(self, t, point_id = None, x = None, y = None): … … 1199 1176 1200 1177 1178 def statistics(self): 1179 """Output statistics about interpolation_function 1180 """ 1181 1182 vertex_coordinates = self.vertex_coordinates 1183 interpolation_points = self.interpolation_points 1184 quantity_names = self.quantity_names 1185 quantities = self.quantities 1186 precomputed_values = self.precomputed_values 1187 1188 x = vertex_coordinates[:,0] 1189 y = vertex_coordinates[:,1] 1190 1191 str = '\n' 1192 str += 'Interpolation_function (spationtemporal) statistics:\n' 1193 str += ' Extent:\n' 1194 str += ' x in [%f, %f], len(x) == %d\n'\ 1195 %(min(x), max(x), len(x)) 1196 str += ' y in [%f, %f], len(y) == %d\n'\ 1197 %(min(y), max(y), len(y)) 1198 str += ' t in [%f, %f], len(t) == %d\n'\ 1199 %(min(self.T), max(self.T), len(self.T)) 1200 str += ' Quantities:\n' 1201 for name in quantity_names: 1202 q = quantities[name][:].flat 1203 str += ' %s in [%f, %f]\n' %(name, min(q), max(q)) 1204 str += ' Interpolation points (xi, eta):'\ 1205 ' number of points == %d\n' %interpolation_points.shape[0] 1206 str += ' xi in [%f, %f]\n' %(min(interpolation_points[:,0]), 1207 max(interpolation_points[:,0])) 1208 str += ' eta in [%f, %f]\n' %(min(interpolation_points[:,1]), 1209 max(interpolation_points[:,1])) 1210 str += ' Interpolated quantities (over all timesteps):\n' 1211 1212 for name in quantity_names: 1213 q = precomputed_values[name][:].flat 1214 str += ' %s at interpolation points in [%f, %f]\n'\ 1215 %(name, min(q), max(q)) 1216 str += '\n' 1217 1218 return str 1219 1220 #FIXME: Delete 1221 #print '' 1222 #print 'Interpolation_function statistics:' 1223 #print ' Extent:' 1224 #print ' x in [%f, %f], len(x) == %d'\ 1225 # %(min(x), max(x), len(x)) 1226 #print ' y in [%f, %f], len(y) == %d'\ 1227 # %(min(y), max(y), len(y)) 1228 #print ' t in [%f, %f], len(t) == %d'\ 1229 # %(min(self.T), max(self.T), len(self.T)) 1230 #print ' Quantities:' 1231 #for name in quantity_names: 1232 # q = quantities[name][:].flat 1233 # print ' %s in [%f, %f]' %(name, min(q), max(q)) 1234 #print ' Interpolation points (xi, eta):'\ 1235 # ' number of points == %d ' %interpolation_points.shape[0] 1236 #print ' xi in [%f, %f]' %(min(interpolation_points[:,0]), 1237 # max(interpolation_points[:,0])) 1238 #print ' eta in [%f, %f]' %(min(interpolation_points[:,1]), 1239 # max(interpolation_points[:,1])) 1240 #print ' Interpolated quantities (over all timesteps):' 1241 # 1242 #for name in quantity_names: 1243 # q = precomputed_values[name][:].flat 1244 # print ' %s at interpolation points in [%f, %f]'\ 1245 # %(name, min(q), max(q)) 1246 #print '' 1201 1247 1202 1248
Note: See TracChangeset
for help on using the changeset viewer.