Changeset 4487
- Timestamp:
- May 24, 2007, 6:39:01 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r4486 r4487 128 128 #structure 129 129 130 130 f.starttime = starttime 131 131 132 if domain is not None: 132 133 #Update domain.startime if it is *earlier* than starttime from file … … 528 529 def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='', 529 530 print_to_screen=False, verbose=False): 530 """ Temporary Interface to new location531 """ 531 532 Used to store screen output and errors to file, if run on multiple 532 533 processes eachprocessor will have its own output and error file. … … 536 537 """ 537 538 538 print 'start_screen_catcher has moved from util.py. ',539 print 'Please use "from anuga.shallow_water.data_manager import start_screen_catcher"'540 541 return shallow_water.data_manager.start_screen_catcher(dir_name, \542 myid='', numprocs='', extra_info='', \543 print_to_screen=False, verbose=False)544 '''545 539 dir_name = dir_name 546 540 if access(dir_name,W_OK) == 0: … … 577 571 fid.write(stuff) 578 572 # if print_to_screen: print stuff 579 ''' 573 580 574 def get_revision_number(): 581 575 """Get the version number of the SVN … … 713 707 time_min = None, 714 708 time_max = None, 709 time_unit = None, 715 710 title_on = None, 716 711 use_cache = False, … … 810 805 time_min, 811 806 time_max, 807 time_unit, 812 808 title_on, 813 809 use_cache, … … 826 822 time_min = None, 827 823 time_max = None, 824 time_unit = None, 828 825 title_on = None, 829 826 use_cache = False, … … 852 849 if surface is None: 853 850 surface = False 854 851 852 if time_unit is None: 853 time_unit = 'hours' 854 855 855 if title_on is None: 856 856 title_on = True … … 867 867 themaxT = 0.0 868 868 theminT = 0.0 869 869 870 870 for swwfile in swwfiles.keys(): 871 871 … … 880 880 quantities = sww_quantity, 881 881 interpolation_points = gauges, 882 verbose = True,882 verbose = verbose, 883 883 use_cache = use_cache) 884 884 … … 932 932 texfile, elev_output = generate_figures(plot_quantity, file_loc, report, reportname, surface, 933 933 leg_label, f_list, gauges, locations, elev, gauge_index, 934 production_dirs, time_min, time_max, ti tle_on, label_id,935 generate_fig, verbose)934 production_dirs, time_min, time_max, time_unit, 935 title_on, label_id, generate_fig, verbose) 936 936 else: 937 937 texfile = '' … … 1027 1027 def generate_figures(plot_quantity, file_loc, report, reportname, surface, 1028 1028 leg_label, f_list, gauges, locations, elev, gauge_index, 1029 production_dirs, time_min, time_max, ti tle_on, label_id,1030 generate_fig, verbose):1029 production_dirs, time_min, time_max, time_unit, 1030 title_on, label_id, generate_fig, verbose): 1031 1031 """ Generate figures based on required quantities and gauges for each sww file 1032 1032 """ … … 1091 1091 stages_plot3d = zeros((n0,m), Float) 1092 1092 eastings_plot3d = zeros((n0,m),Float) 1093 if time_unit is 'mins': scale = 60.0 1094 if time_unit is 'hours': scale = 3600.0 1093 1095 ##### loop over each swwfile ##### 1094 1096 for j, f in enumerate(f_list): 1097 starttime = f.starttime 1095 1098 if verbose: print 'swwfile %d of %d' %(j, len(f_list)) 1096 1099 comparefile = file_loc[j]+sep+'gauges_maxmins'+'.csv' … … 1112 1115 s = 'Time, Stage, Momentum, Speed, Elevation, xmom, ymom \n' 1113 1116 fid_out.write(s) 1114 1115 1117 #### generate quantities ####### 1116 1118 for i, t in enumerate(f.get_time()): … … 1126 1128 else: 1127 1129 vel = m / (depth + 1.e-6/depth) 1128 #bearing = calc_bearing(uh, vh) 1129 model_time[i,k,j] = t/60.01130 #bearing = calc_bearing(uh, vh) 1131 model_time[i,k,j] = (t + starttime)/scale #t/60.0 1130 1132 stages[i,k,j] = w 1131 1133 elevations[i,k,j] = z … … 1196 1198 elev_output = [] 1197 1199 if generate_fig is True: 1198 depth_axis = axis([time_min/60.0, time_max/60.0, -0.1, max(max_depths)*1.1]) 1199 stage_axis = axis([time_min/60.0, time_max/60.0, min(min_stages), max(max_stages)*1.1]) 1200 #stage_axis = axis([50.0, time_max/60.0, -3.0, 2.0]) 1201 vel_axis = axis([time_min/60.0, time_max/60.0, min(max_speeds), max(max_speeds)*1.1]) 1202 mom_axis = axis([time_min/60.0, time_max/60.0, min(max_momentums), max(max_momentums)*1.1]) 1200 depth_axis = axis([starttime/scale, time_max/scale, -0.1, max(max_depths)*1.1]) 1201 stage_axis = axis([starttime/scale, time_max/scale, min(min_stages), max(max_stages)*1.1]) 1202 vel_axis = axis([starttime/scale, time_max/scale, min(max_speeds), max(max_speeds)*1.1]) 1203 mom_axis = axis([starttime/scale, time_max/scale, min(max_momentums), max(max_momentums)*1.1]) 1203 1204 cstr = ['g', 'r', 'b', 'c', 'm', 'y', 'k'] 1204 1205 nn = len(plot_quantity) … … 1270 1271 legend(('Bearing','West','East')) 1271 1272 1272 xlabel('time (mins)') 1273 if which_quantity == 'stage' and elevations[0:n[j]-1,k,j] > 0: 1274 ylabel('%s (%s)' %('depth', units)) 1275 else: 1276 ylabel('%s (%s)' %(which_quantity, units)) 1273 if time_unit is 'mins': xlabel('time (mins)') 1274 if time_unit is 'hours': xlabel('time (hours)') 1275 #if which_quantity == 'stage' and elevations[0:n[j]-1,k,j] > 0: 1276 # ylabel('%s (%s)' %('depth', units)) 1277 #else: 1278 # ylabel('%s (%s)' %(which_quantity, units)) 1279 #ylabel('%s (%s)' %('wave height', units)) 1280 ylabel('%s (%s)' %(which_quantity, units)) 1277 1281 if len(label_id) > 1: legend((leg_label),loc='upper right') 1278 1282 … … 1400 1404 # but any number of files. 1401 1405 def copy_code_files(dir_name, filename1, filename2): 1402 """ 1403 Temporary Interface to new location 1404 Copies "filename1" and "filename2" to "dir_name". Very useful for 1406 """Copies "filename1" and "filename2" to "dir_name". Very useful for 1405 1407 information management 1406 1408 filename1 and filename2 are both absolute pathnames 1407 1409 """ 1408 1410 1409 print 'copy_code_files has moved from util.py. ',1410 print 'Please use "from anuga.shallow_water.data_manager import copy_code_files"'1411 1412 return shallow_water.data_manager.copy_code_files(dir_name, filename1, filename2)1413 '''1414 1411 if access(dir_name,F_OK) == 0: 1415 1412 print 'Make directory %s' %dir_name … … 1419 1416 # copy (__file__, project.output_run_time_dir + basename(__file__)) 1420 1417 print 'Files %s and %s copied' %(filename1, filename2) 1421 ''' 1418 1422 1419 1423 1420 def add_directories(root_directory, directories): … … 1440 1437 def get_data_from_file(filename,separator_value = ','): 1441 1438 """ 1442 Temporary Interface to new location 1443 Read in data information from file and 1444 1445 Returns: 1446 header_fields, a string? of the first line separated 1447 by the 'separator_value' 1448 1449 data, a array (N data columns X M lines) in the file 1450 excluding the header 1451 1439 Read in data information from file 1452 1440 NOTE: wont deal with columns with different lenghts and there must be 1453 1441 no blank lines at the end. 1454 1442 """ 1455 1456 print 'get_data_from_file has moved from util.py. ',1457 print 'Please use "from anuga.shallow_water.data_manager import get_data_from_file"'1458 1459 return anuga.shallow_water.data_manager.get_data_from_file(filename,separator_value = ',')1460 '''1461 1443 from os import sep, getcwd, access, F_OK, mkdir 1462 1444 from Numeric import array, resize,shape,Float … … 1492 1474 1493 1475 return header_fields, data 1494 ''' 1495 1476 1496 1477 def store_parameters(verbose=False,**kwargs): 1497 1478 """ 1498 Temporary Interface to new location1499 1479 Must have a file_name keyword arg, this is what is writing to. 1500 1480 might be a better way to do this using CSV module Writer and writeDict … … 1512 1492 the indices 1513 1493 """ 1514 1515 print 'store_parameters has moved from util.py. ', 1516 print 'Please use "from anuga.shallow_water.data_manager import store_parameters"' 1517 1518 return shallow_water.data_manager.store_parameters(verbose=False,**kwargs) 1519 1520 ''' 1494 import types 1495 import os 1496 1521 1497 # Check that kwargs is a dictionary 1522 1498 if type(kwargs) != types.DictType: … … 1528 1504 except: 1529 1505 completed=False 1530 1531 #get file name and removes from dict and assert that a file_name exists 1506 1507 # assert that a file_name exists 1508 1509 #get file name and removes from dict 1532 1510 if completed: 1533 1511 try: … … 1541 1519 raise 'kwargs must have output_dir' 1542 1520 1521 1522 # print kwargs 1543 1523 #extracts the header info and the new line info 1544 1524 line='' … … 1546 1526 count=0 1547 1527 keys = kwargs.keys() 1528 # print 'keys',keys 1548 1529 keys.sort() 1530 # print 'keys',keys 1549 1531 1550 1532 # for k in kwargs.keys(): … … 1583 1565 1584 1566 #if header is same or this is a new file 1585 if file_header.strip('\n')== str(header):1567 if file_header.strip('\n')==header: 1586 1568 fid=open(file,"a") 1587 1569 #write new line … … 1596 1578 fid.writelines(line+'\n') 1597 1579 fid.close() 1598 print 'file',file_header.strip('\n') 1599 print 'head',header.strip('\n') 1600 msg = 'file header does not match input info, the input variables have changed, suggest to change file name' 1580 msg = 'file header does not match input info, the input variables have changed, change file name' 1601 1581 raise msg 1602 ''' 1582 1603 1583 1604 1584 def remove_lone_verts(verts, triangles):
Note: See TracChangeset
for help on using the changeset viewer.