Changeset 8145
- Timestamp:
- Mar 10, 2011, 9:26:45 PM (14 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/file/netcdf.py
r7859 r8145 23 23 precision = netcdf_float # So if we want to change the precision its done here 24 24 25 ##26 # @brief Clas for a NetCDF data file writer.27 25 class Write_nc: 28 26 """Write an nc file. … … 32 30 """ 33 31 34 ##35 # @brief Instantiate a Write_nc instance.36 # @param quantity_name37 # @param file_name38 # @param time_step_count The number of time steps.39 # @param time_step The time_step size.40 # @param lon41 # @param lat42 32 def __init__(self, 43 33 quantity_name, … … 95 85 #outfile.close() 96 86 97 ##98 # @brief Write a time-step of quantity data.99 # @param quantity_slice The data to be stored for this time-step.100 87 def store_timestep(self, quantity_slice): 101 88 """Write a time slice of quantity info … … 121 108 122 109 123 ##124 # @brief Write an NC elevation file.125 # @param file_out Path to the output file.126 # @param lon ??127 # @param lat ??128 # @param depth_vector The elevation data to write.129 110 def write_elevation_nc(file_out, lon, lat, depth_vector): 130 111 """Write an nc elevation file.""" … … 150 131 outfile.close() 151 132 152 153 ##154 # @brief Write lat/lon headers to a NetCDF file.155 # @param outfile Handle to open file to write to.156 # @param lon An iterable of the longitudes.157 # @param lat An iterable of the latitudes.158 # @note Defines lat/long dimensions and variables. Sets various attributes:159 # .point_spacing and .units160 # and writes lat/lon data.161 133 162 134 def nc_lon_lat_header(outfile, lon, lat): … … 188 160 189 161 190 ##191 # @brief Filter data file, selecting timesteps first:step:last.192 # @param filename1 Data file to filter.193 # @param filename2 File to write filtered timesteps to.194 # @param first First timestep.195 # @param last Last timestep.196 # @param step Timestep stride.197 162 def filter_netcdf(filename1, filename2, first=0, last=None, step=1): 198 163 """Filter data file, selecting timesteps first:step:last. -
trunk/anuga_core/source/anuga/utilities/log_test.py
r6902 r8145 32 32 os.remove(STDOUT_LOG_NAME) 33 33 34 ##35 # @brief Test the logging routines.36 # @note HAVE ONE TEST CASE ONLY! Multiple tests would concatenate37 # multiple test output in one log file.38 34 def test_simple(self): 39 35 '''Check that logging works in simple case.''' -
trunk/anuga_core/source/anuga/utilities/system_tools.py
r8018 r8145 325 325 326 326 327 ##328 # @brief Split a string into 'clean' fields.329 # @param str The string to process.330 # @param delimiter The delimiter string to split 'line' with.331 # @return A list of 'cleaned' field strings.332 # @note Any fields that were initially zero length will be removed.333 # @note If a field contains '\n' it isn't zero length.334 327 def clean_line(str, delimiter): 335 """Split string on given delimiter, remove whitespace from each field.""" 328 """Split a string into 'clean' fields. 329 330 str the string to process 331 delimiter the delimiter string to split 'line' with 332 333 Returns a list of 'cleaned' field strings. 334 335 Any fields that were initially zero length will be removed. 336 If a field contains '\n' it isn't zero length. 337 """ 336 338 337 339 return [x.strip() for x in str.strip().split(delimiter) if x != ''] … … 363 365 ################################################################################ 364 366 365 ##366 # @brief Convert 1-D list of strings to 2-D list of chars.367 # @param l 1-dimensional list of strings.368 # @return A 2-D list of 'characters' (1 char strings).369 # @note No checking that we supply a 1-D list.370 367 def string_to_char(l): 371 368 '''Convert 1-D list of strings to 2-D list of chars.''' … … 385 382 386 383 387 ##388 # @brief Convert 2-D list of chars to 1-D list of strings.389 # @param ll 2-dimensional list of 'characters' (1 char strings).390 # @return A 1-dimensional list of strings.391 # @note Each string has had right-end spaces removed.392 384 def char_to_string(ll): 393 385 '''Convert 2-D list of chars to 1-D list of strings.''' … … 397 389 ################################################################################ 398 390 399 ##400 # @brief Get list of variable names in a python expression string.401 # @param source A string containing a python expression.402 # @return A list of variable name strings.403 # @note Throws SyntaxError exception if not a valid expression.404 391 def get_vars_in_expression(source): 405 392 '''Get list of variable names in a python expression.''' … … 408 395 from compiler.ast import Node 409 396 410 ##411 # @brief Internal recursive function.412 # @param node An AST parse Node.413 # @param var_list Input list of variables.414 # @return An updated list of variables.415 397 def get_vars_body(node, var_list=[]): 416 398 if isinstance(node, Node): … … 430 412 431 413 432 ##433 # @brief Get a file from the web.434 # @param file_url URL of the file to fetch.435 # @param file_name Path to file to create in the filesystem.436 # @param auth Auth tuple (httpproxy, proxyuser, proxypass).437 # @param blocksize Read file in this block size.438 # @return (True, auth) if successful, else (False, auth).439 # @note If 'auth' not supplied, will prompt user.440 # @note Will try using environment variable HTTP_PROXY for proxy server.441 # @note Will try using environment variable PROXY_USERNAME for proxy username.442 # @note Will try using environment variable PROXY_PASSWORD for proxy password.443 414 def get_web_file(file_url, file_name, auth=None, blocksize=1024*1024): 444 415 '''Get a file from the web (HTTP). … … 537 508 538 509 539 ##540 # @brief Tar a file (or directory) into a tarfile.541 # @param files A list of files (or directories) to tar.542 # @param tarfile The created tarfile name.543 # @note 'files' may be a string (single file) or a list of strings.544 # @note We use gzip compression.545 510 def tar_file(files, tarname): 546 511 '''Compress a file or directory into a tar file.''' … … 555 520 556 521 557 ##558 # @brief Untar a file into an optional target directory.559 # @param tarname Name of the file to untar.560 # @param target_dir Directory to untar into.561 522 def untar_file(tarname, target_dir='.'): 562 523 '''Uncompress a tar file.''' … … 569 530 570 531 571 ##572 # @brief Return a hex digest (MD5) of a given file.573 # @param filename Path to the file of interest.574 # @param blocksize Size of data blocks to read.575 # @return A hex digest string (16 bytes).576 # @note Uses MD5 digest if hashlib not available.577 532 def get_file_hexdigest(filename, blocksize=1024*1024*10): 578 533 '''Get a hex digest of a file.''' … … 594 549 595 550 596 ##597 # @brief Create a file containing a hexdigest string of a data file.598 # @param data_file Path to the file to get the hexdigest from.599 # @param digest_file Path to hexdigest file to create.600 # @note Uses MD5 digest.601 551 def make_digest_file(data_file, digest_file): 602 552 '''Create a file containing the hex digest string of a data file.''' … … 608 558 609 559 610 ##611 # @brief Function to return the length of a file.612 # @param in_file Path to file to get length of.613 # @return Number of lines in file.614 # @note Doesn't count '\n' characters.615 # @note Zero byte file, returns 0.616 # @note No \n in file at all, but >0 chars, returns 1.617 560 def file_length(in_file): 618 561 '''Function to return the length of a file.'''
Note: See TracChangeset
for help on using the changeset viewer.