Changeset 4304
- Timestamp:
- Mar 15, 2007, 4:48:11 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r4278 r4304 504 504 ##################### end of obsolete stuff ? ############ 505 505 506 def start_screen_catcher(dir_name, myid=0, numprocs=1, print_to_screen=False, 507 verbose=False): 508 """Used to store screen output and errors to file, if run on multiple 506 def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='', 507 print_to_screen=False, verbose=False): 508 """ 509 Used to store screen output and errors to file, if run on multiple 509 510 processes eachprocessor will have its own output and error file. 511 512 extra_info - is used as a string that can identify outputs with another 513 string eg. '_other' 510 514 """ 511 515 … … 515 519 if verbose: print "myid", myid 516 520 mkdir (dir_name,0777) 517 screen_output_name = dir_name + "screen_output_%d_%d.txt" %(myid,numprocs) 518 screen_error_name = dir_name + "screen_error_%d_%d.txt" %(myid,numprocs) 521 if myid <>'': 522 myid = '_'+str(myid) 523 if numprocs <>'': 524 numprocs = '_'+str(numprocs) 525 if extra_info <>'': 526 extra_info = '_'+str(extra_info) 527 screen_output_name = dir_name + "screen_output%s%s%s.txt" %(myid,numprocs,extra_info) 528 screen_error_name = dir_name + "screen_error%s%s%s.txt" %(myid,numprocs,extra_info) 519 529 print screen_output_name 520 530 #used to catch screen output to file … … 667 677 time_max = None, 668 678 title_on = None, 679 use_cache = False, 669 680 verbose = False): 670 681 … … 689 700 such as a geospatial data object 690 701 702 production_dirs - A list of list, example {20061101_121212: '1 in 10000', 703 'boundaries': 'urs boundary'} 704 this will use the second part as the label and the first part 705 as the ? 706 691 707 report - if True, then write figures to report_figures directory in 692 708 relevant production directory … … 744 760 ['stage', 'elevation', 'xmomentum', 'ymomentum'] 745 761 If this has not occurred then sww2timeseries will not work. 746 747 762 """ 748 763 … … 759 774 time_max, 760 775 title_on, 776 use_cache, 761 777 verbose) 762 778 … … 774 790 time_max = None, 775 791 title_on = None, 792 use_cache = False, 776 793 verbose = False): 777 794 … … 827 844 interpolation_points = gauges, 828 845 verbose = True, 829 use_cache = True)846 use_cache = use_cache) 830 847 831 848 # determine which gauges are contained in sww file … … 1054 1071 thisfile = file_loc[j]+sep+'gauges_time_series'+'_'+gaugeloc+'.csv' 1055 1072 fid_out = open(thisfile, 'w') 1056 s = 'Time, Stage, Momentum, Speed, Elevation \n'1073 s = 'Time, Stage, Momentum, Speed, Elevation, xmom, ymom \n' 1057 1074 fid_out.write(s) 1058 1075 … … 1082 1099 thisgauge = gauges[k] 1083 1100 eastings[i,k,j] = thisgauge[0] 1084 s = '%.2f, %.2f, %.2f, %.2f, %.2f \n' %(t, w, m, vel, z)1101 s = '%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f\n' %(t, w, m, vel, z, uh, vh) 1085 1102 fid_out.write(s) 1086 1103 if t/60.0 <= 13920: tindex = i … … 1368 1385 return dir 1369 1386 1370 1371 1387 def get_data_from_file(filename): 1388 """ Read in data information from file 1389 WARNING THERE IS NO UNIT TEST FOR THIS! 1390 or the get_gauges_from_file() 1391 """ 1392 from os import sep, getcwd, access, F_OK, mkdir 1393 fid = open(filename) 1394 lines = fid.readlines() 1395 fid.close() 1396 1397 # seperated_value = ',' 1398 1399 time = [] 1400 speed = [] 1401 stage = [] 1402 momentum = [] 1403 elevation = [] 1404 line1 = lines[0] 1405 line11 = line1.split(',') 1406 # east_index = len(line11)+1 1407 # north_index = len(line11)+1 1408 # name_index = len(line11)+1 1409 # elev_index = len(line11)+1 1410 # Time Stage Momentum Speed Elevation 1411 1412 #read header to find the position (index) of each column of data 1413 for i in range(len(line11)): 1414 if line11[i].strip('\n').strip(' ').lower() == 'time': 1415 time_index = i 1416 print'time index', time_index 1417 if line11[i].strip('\n').strip(' ').lower() == 'stage': stage_index = i 1418 if line11[i].strip('\n').strip(' ').lower() == 'momentum': momentum_index = i 1419 if line11[i].strip('\n').strip(' ').lower() == 'speed': speed_index = i 1420 if line11[i].strip('\n').strip(' ').lower() == 'elevation': elevation_index = i 1421 print'i',i 1422 print'time',time_index,'stage',stage_index,'elevation',elevation_index 1423 1424 1425 for line in lines[1:]: 1426 fields = line.split(',') 1427 if elevation_index < len(line11): elevation.append(float(fields[elevation_index])) 1428 if time_index < len(line11): time.append(float(fields[time_index])) 1429 if momentum_index < len(line11): momentum.append(float(fields[momentum_index])) 1430 if speed_index < len(line11): speed.append(float(fields[speed_index])) 1431 if stage_index < len(line11): stage.append(float(fields[stage_index])) 1432 1433 1434 ''' 1435 if east_index < len(line11) and north_index < len(line11): 1436 gauges.append([float(fields[east_index]), float(fields[north_index])]) 1437 else: 1438 msg = 'WARNING: %s does not contain location information' %(filename) 1439 raise Exception, msg 1440 if elev_index < len(line11): elev.append(float(fields[elev_index])) 1441 if name_index < len(line11): 1442 loc = fields[name_index] 1443 gaugelocation.append(loc.strip('\n')) 1444 ''' 1445 return time, stage, momentum, speed, elevation 1446 1447 1448
Note: See TracChangeset
for help on using the changeset viewer.