Changeset 8150
- Timestamp:
- Mar 11, 2011, 7:23:24 PM (14 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/culvert_flows/test_all.py
r7779 r8150 28 28 29 29 30 ##31 # @brief List a string sequence on the screen in columns.32 # @param names Sequence of strings to list.33 # @param func Function to apply to each string in sequence.34 # @param col_width Force columns to this width (default calculated).35 # @param page_width Set displayable page width to this (default 132).36 30 def list_names(names, func=None, col_width=None, page_width=None): 37 31 # set defaults … … 68 62 69 63 70 ##71 # @brief Get 'test_*.py' files and paths to directories.72 # @param path Path to directory to start walk in.73 # @return A tuple (<files>, <dirs>).74 # @note Don't include any files in and below forbidden directories.75 64 def get_test_files(path): 76 65 walk = os.walk(path) … … 175 164 176 165 177 ##178 # @brief Check that the environment is sane.179 # @note Stops here if there is an error.180 166 def check_anuga_import(): 181 167 try: -
trunk/anuga_core/source/anuga/file_conversion/asc2dem.py
r7814 r8150 55 55 56 56 57 ##58 # @brief Convert an ASC file to a DEM file.59 # @param basename_in Stem of input filename.60 # @param basename_out Stem of output filename.61 # @param verbose True if this function is to be verbose.62 57 def _convert_dem_from_ascii2netcdf(name_in, name_out = None, 63 58 verbose = False): -
trunk/anuga_core/source/anuga/file_conversion/dem2pts.py
r7841 r8150 53 53 54 54 55 ##56 # @brief57 # @param basename_in58 # @param basename_out59 # @param verbose60 # @param easting_min61 # @param easting_max62 # @param northing_min63 # @param northing_max64 55 def _dem2pts(name_in, name_out=None, verbose=False, 65 56 easting_min=None, easting_max=None, -
trunk/anuga_core/source/anuga/file_conversion/file_conversion.py
r7866 r8150 86 86 write_obj(FN, xx, yy, zz) 87 87 88 ##89 # @brief Convert time-series text file to TMS file.90 # @param filename91 # @param quantity_names92 # @param time_as_seconds93 88 def timefile2netcdf(file_text, file_out = None, quantity_names=None, \ 94 89 time_as_seconds=False): … … 224 219 225 220 226 ##227 # @brief228 # @param filename229 # @param verbose230 221 def tsh2sww(filename, verbose=False): 231 222 """ … … 266 257 267 258 268 ##269 # @brief Return max&min indexes (for slicing) of area specified.270 # @param latitudes_ref ??271 # @param longitudes_ref ??272 # @param minlat Minimum latitude of specified area.273 # @param maxlat Maximum latitude of specified area.274 # @param minlon Minimum longitude of specified area.275 # @param maxlon Maximum longitude of specified area.276 # @return Tuple (lat_min_index, lat_max_index, lon_min_index, lon_max_index)277 259 def get_min_max_indices(latitudes_ref, longitudes_ref, 278 260 minlat=None, maxlat=None, … … 350 332 351 333 352 ##353 # @brief354 # @param filename355 # @param x356 # @param y357 # @param z358 334 def write_obj(filename, x, y, z): 359 335 """Store x,y,z vectors into filename (obj format). -
trunk/anuga_core/source/anuga/file_conversion/sdf2pts.py
r7814 r8150 3 3 from anuga.geospatial_data.geospatial_data import Geospatial_data 4 4 5 ##6 # @brief Return block of surface lines for each cross section7 # @param lines Iterble of text lines to process.8 # @note BROKEN? UNUSED?9 5 def _read_hecras_cross_sections(lines): 10 6 """Return block of surface lines for each cross section … … 43 39 """Read HEC-RAS Elevation datal from the following ASCII format (.sdf) 44 40 45 # @brief Convert HECRAS (.sdf) file to PTS file. 46 # @param basename_in Sterm of input filename. 47 # @param basename_out Sterm of output filename. 48 # @param verbose True if this function is to be verbose. 41 basename_in Sterm of input filename. 42 basename_out Sterm of output filename. 43 verbose True if this function is to be verbose. 49 44 50 45 Example: -
trunk/anuga_core/source/anuga/file_conversion/urs2nc.py
r7800 r8150 64 64 65 65 66 ##67 # @brief Convert a quantity URS file to a NetCDF file.68 # @param file_in Path to input URS file.69 # @param file_out Path to the output file.70 # @param quantity Name of the quantity to be written to the output file.71 # @return A tuple (lonlatdep, lon, lat, depth).72 66 def _binary_c2nc(file_in, file_out, quantity): 73 67 """Reads in a quantity urs file and writes a quantity nc file. … … 140 134 141 135 142 ##143 # @brief144 # @param long_lat_dep145 # @return A tuple (long, lat, quantity).146 # @note The latitude is the fastest varying dimension - in mux files.147 136 def lon_lat2grid(long_lat_dep): 148 137 """ -
trunk/anuga_core/source/anuga/geometry/polygon.py
r8136 r8150 13 13 from aabb import AABB 14 14 15 ##16 # @brief Determine whether a point is on a line segment.17 # @param point (x, y) of point in question (tuple, list or array).18 # @param line ((x1,y1), (x2,y2)) for line (tuple, list or array).19 # @param rtol Relative error for 'close'.20 # @param atol Absolute error for 'close'.21 # @return True or False.22 15 def point_on_line(point, line, rtol=1.0e-5, atol=1.0e-8): 23 16 """Determine whether a point is on a line segment … … 98 91 } 99 92 100 ##101 # @brief Finds intersection point of two line segments.102 # @param line0 First line ((x1,y1), (x2,y2)).103 # @param line1 Second line ((x1,y1), (x2,y2)).104 # @param rtol Relative error for 'close'.105 # @param atol Absolute error for 'close'.106 # @return (status, value) where:107 # status = 0 - no intersection, value set to None108 # 1 - intersection found, value=(x,y)109 # 2 - lines collienar, overlap, value=overlap segment110 # 3 - lines collinear, no overlap, value is None111 # 4 - lines parallel, value is None112 93 def intersection(line0, line1, rtol=1.0e-5, atol=1.0e-8): 113 94 """Returns intersecting point between two line segments. … … 180 161 return 0, None 181 162 182 ##183 # @brief Finds intersection point of two line segments.184 # @param line0 First line ((x1,y1), (x2,y2)).185 # @param line1 Second line ((x1,y1), (x2,y2)).186 # @return (status, value) where:187 # status = 0 - no intersection, value set to None188 # 1 - intersection found, value=(x,y)189 # 2 - lines collienar, overlap, value=overlap segment190 # 3 - lines collinear, no overlap, value is None191 # 4 - lines parallel, value is None192 # @note Wrapper for C function.193 163 def NEW_C_intersection(line0, line1): 194 164 """Returns intersecting point between two line segments. … … 436 406 raise Exception(msg) 437 407 438 ##439 # @brief Determine which of a set of points are inside a polygon.440 # @param points A set of points (tuple, list or array).441 # @param polygon A set of points defining a polygon (tuple, list or array).442 # @param closed True if points on boundary are considered 'inside' polygon.443 # @param verbose True if this function is to be verbose.444 # @return A list of indices of points inside the polygon.445 408 def inside_polygon(points, polygon, closed=True, verbose=False): 446 409 """Determine points inside a polygon … … 489 452 return indices[:count] 490 453 491 ##492 # @brief Determine if one point is outside a polygon.493 # @param point The point of interest.494 # @param polygon The polygon to test inclusion in.495 # @param closed True if points on boundary are considered 'inside' polygon.496 # @param verbose True if this function is to be verbose.497 # @return True if point is outside the polygon.498 # @note Uses inside_polygon() to do the work.499 454 def is_outside_polygon(point, polygon, closed=True, verbose=False, 500 455 points_geo_ref=None, polygon_geo_ref=None): … … 514 469 raise Exception, msg 515 470 516 ##517 # @brief Determine which of a set of points are outside a polygon.518 # @param points A set of points (tuple, list or array).519 # @param polygon A set of points defining a polygon (tuple, list or array).520 # @param closed True if points on boundary are considered 'inside' polygon.521 # @param verbose True if this function is to be verbose.522 # @return A list of indices of points outside the polygon.523 471 def outside_polygon(points, polygon, closed = True, verbose = False): 524 472 """Determine points outside a polygon … … 562 510 return indices[count:][::-1] #return reversed 563 511 564 ##565 # @brief Separate a list of points into two sets inside+outside a polygon.566 # @param points A set of points (tuple, list or array).567 # @param polygon A set of points defining a polygon (tuple, list or array).568 # @param closed True if points on boundary are considered 'inside' polygon.569 # @param verbose True if this function is to be verbose.570 # @return A tuple (in, out) of point indices for poinst inside amd outside.571 512 def in_and_outside_polygon(points, polygon, closed=True, verbose=False): 572 513 """Determine points inside and outside a polygon … … 1055 996 the extrema in both axes are preserved. 1056 997 1057 ## 1058 # @brief Reduce number of points in polygon by the specified factor.1059 # @param polygon The polygon to reduce.1060 # @param factor The factor to reduce polygon points by (default 10). 1061 # @noteThe extrema of both axes are preserved.998 Reduce number of points in polygon by the specified factor. 999 polygon The polygon to reduce. 1000 factor The factor to reduce polygon points by (default 10). 1001 1002 The extrema of both axes are preserved. 1062 1003 1063 1004 Return reduced polygon -
trunk/anuga_core/source/anuga/geometry/polygon_function.py
r7858 r8150 44 44 45 45 def __init__(self, regions, default=0.0, geo_reference=None): 46 """ 47 # @brief Create instance of a polygon function. 48 # @paramregions A list of (x,y) tuples defining a polygon.49 # @paramdefault Value or function returning value for points outside poly.50 # @paramgeo_reference ??46 """Create instance of a polygon function. 47 48 regions A list of (x,y) tuples defining a polygon. 49 default Value or function returning value for points outside poly. 50 geo_reference ?? 51 51 """ 52 52 … … 90 90 91 91 def __call__(self, pts_x, pts_y): 92 """ 93 # @brief Implement the 'callable' property of Polygon_function. 94 # @paramx List of x coordinates of points ot interest.95 # @paramy List of y coordinates of points ot interest.92 """Implement the 'callable' property of Polygon_function. 93 94 x List of x coordinates of points ot interest. 95 y List of y coordinates of points ot interest. 96 96 """ 97 97 pts_x = num.array(pts_x, num.float) -
trunk/anuga_core/source/anuga/load_mesh/loadASCII.py
r7317 r8150 80 80 81 81 82 ##83 # @brief Read a mesh file (.tsh or .msh) and return a dictionary.84 # @param ofile Path to the file to read.85 # @return A dictionary of data from the input file.86 # @note Throws IOError if can't read file.87 # @note This is used by pmesh.88 82 def import_mesh_file(ofile): 89 83 """Read a mesh file, either .tsh or .msh … … 107 101 108 102 109 ##110 # @brief Write a mesh file from a dictionary.111 # @param ofile The path of the mesh file to write.112 # @param mesh_dict Dictionary containing data to write to output mesh file.113 # @note Raises IOError if file extension is unrecognized.114 103 def export_mesh_file(ofile, mesh_dict): 115 104 """Write a mesh file given a dictionary. … … 148 137 149 138 150 ##151 # @brief Read a mesh file into a dictionary.152 # @param ofile Path of the file to read.153 # @return Points dictionary from the mesh (.tsh) file.154 139 def _read_tsh_file(ofile): 155 140 """Read the text file format for meshes""" … … 165 150 166 151 167 ##168 # @brief Read triangulation data from a file, leave file open.169 # @param fd An open descriptor of the file to read.170 # @return A dictionary ...171 152 def _read_triangulation(fd): 172 153 """Read the generated triangulation, NOT the outline.""" … … 265 246 266 247 267 ##268 # @brief Read a mesh outline file.269 # @param fd An open descriptor of the file to read.270 # @return A Points dictionary.271 # @note If file has no mesh info, an empty dict will be returned.272 248 def _read_outline(fd): 273 249 """Read a mesh file outline. … … 397 373 398 374 399 ##400 # @brief Write an ASCII triangulation file.401 # @param fd An open descriptor to the file to write.402 # @param gen_dict Dictionary containing data to write.403 375 def _write_ASCII_triangulation(fd, gen_dict): 404 376 vertices = gen_dict['vertices'] … … 510 482 511 483 512 ##513 # @brief Write triangulation and outline to a .tsh file.514 # @param ofile Path of the file to write.515 # @mesh_dict Dictionary of data to write.516 484 def _write_tsh_file(ofile, mesh_dict): 517 485 fd = open(ofile, 'w') … … 521 489 522 490 523 ##524 # @brief Write an ASCII outline to a file.525 # @param fd An open descriptor of the file to write.526 # @param dict Dictionary holding data to write.527 491 def _write_ASCII_outline(fd, dict): 528 492 points = dict['points'] … … 597 561 598 562 599 ##600 # @brief Write a .msh file.601 # @param file Path to the file to write.602 # @param mesh Dictionary holding data to write.603 563 def _write_msh_file(file_name, mesh): 604 564 """Write .msh NetCDF file … … 791 751 792 752 793 ##794 # @brief Read a mesh file.795 # @param file_name Path to the file to read.796 # @return A dictionary containing the .msh file data.797 # @note Throws IOError if file not found.798 753 def _read_msh_file(file_name): 799 754 """ Read in an msh file.""" … … 916 871 917 872 918 ##919 # @brief Export a boundary file.920 # @param file_name Path to the file to write.921 # @param points List of point index pairs.922 # @paran title Title string to write into file (first line).923 # @param delimiter Delimiter string to write between points.924 # @note Used by alpha shapes925 873 def export_boundary_file(file_name, points, title, delimiter=','): 926 874 """Export a boundary file. … … 949 897 ################################################################################ 950 898 951 ##952 # @brief953 # @param point_atts954 899 def extent_point_atts(point_atts): 955 900 """Returns 4 points representing the extent … … 963 908 964 909 965 ##966 # @brief Get an extent array for a set of points.967 # @param points A set of points.968 # @return An extent array of form [[min_x, min_y], [max_x, min_y],969 # [max_x, max_y], [min_x, max_y]]970 910 def extent(points): 971 911 points = num.array(points, num.float) … … 995 935 996 936 997 ##998 # @brief Reduce a points file until number of points is less than limit.999 # @param infile Path to input file to thin.1000 # @param outfile Path to output thinned file.1001 # @param max_points Max number of points in output file.1002 # @param verbose True if this function is to be verbose.1003 937 def reduce_pts(infile, outfile, max_points, verbose = False): 1004 938 """Reduce a points file until less than given size. … … 1019 953 1020 954 1021 ##1022 # @brief1023 # @param infile1024 # @param max_points1025 # @param delimiter1026 # @param verbose True if this function is to be verbose.1027 # @return A list of1028 955 def produce_half_point_files(infile, max_points, delimiter, verbose=False): 1029 956 point_atts = _read_pts_file(infile) … … 1046 973 1047 974 1048 ##1049 # @brief1050 # @param point_atts Object with attribute of 'pointlist'.1051 # @return1052 975 def point_atts2array(point_atts): 1053 976 # convert attribute list to array of floats … … 1061 984 1062 985 1063 ##1064 # @brief ??1065 # @param point_atts ??1066 # @return ??1067 986 def half_pts(point_atts): 1068 987 point_atts2array(point_atts) … … 1074 993 return point_atts 1075 994 1076 ##1077 # @brief ??1078 # @param dic ??1079 # @return ??1080 995 def concatinate_attributelist(dic): 1081 996 """ … … 1095 1010 1096 1011 1097 ##1098 # @brief1099 # @param dict1100 # @param indices_to_keep1101 # @return1102 # @note FIXME(dsg), turn this dict plus methods into a class?1103 1012 def take_points(dict, indices_to_keep): 1104 1013 dict = point_atts2array(dict) … … 1112 1021 return dict 1113 1022 1114 ##1115 # @brief ??1116 # @param dict1 ??1117 # @param dict2 ??1118 # @return ??1119 1023 def add_point_dictionaries(dict1, dict2): 1120 1024 """ -
trunk/anuga_core/source/anuga/test_all.py
r8129 r8150 28 28 29 29 30 ##31 # @brief List a string sequence on the screen in columns.32 # @param names Sequence of strings to list.33 # @param func Function to apply to each string in sequence.34 # @param col_width Force columns to this width (default calculated).35 # @param page_width Set displayable page width to this (default 132).36 30 def list_names(names, func=None, col_width=None, page_width=None): 37 31 # set defaults … … 176 170 177 171 178 ##179 # @brief Check that the environment is sane.180 # @note Stops here if there is an error.181 172 def check_anuga_import(): 182 173 try:
Note: See TracChangeset
for help on using the changeset viewer.