Changeset 4485
- Timestamp:
- May 24, 2007, 5:08:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r4480 r4485 528 528 def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='', 529 529 print_to_screen=False, verbose=False): 530 """ 530 """Temporary Interface to new location 531 531 Used to store screen output and errors to file, if run on multiple 532 532 processes eachprocessor will have its own output and error file. … … 536 536 """ 537 537 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 ''' 538 545 dir_name = dir_name 539 546 if access(dir_name,W_OK) == 0: … … 570 577 fid.write(stuff) 571 578 # if print_to_screen: print stuff 572 579 ''' 573 580 def get_revision_number(): 574 581 """Get the version number of the SVN … … 1393 1400 # but any number of files. 1394 1401 def copy_code_files(dir_name, filename1, filename2): 1395 """Copies "filename1" and "filename2" to "dir_name". Very useful for 1402 """ 1403 Temporary Interface to new location 1404 Copies "filename1" and "filename2" to "dir_name". Very useful for 1396 1405 information management 1397 1406 filename1 and filename2 are both absolute pathnames 1398 1407 """ 1399 1408 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 ''' 1400 1414 if access(dir_name,F_OK) == 0: 1401 1415 print 'Make directory %s' %dir_name … … 1405 1419 # copy (__file__, project.output_run_time_dir + basename(__file__)) 1406 1420 print 'Files %s and %s copied' %(filename1, filename2) 1407 1421 ''' 1408 1422 1409 1423 def add_directories(root_directory, directories): … … 1426 1440 def get_data_from_file(filename,separator_value = ','): 1427 1441 """ 1428 Read in data information from file 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 1429 1452 NOTE: wont deal with columns with different lenghts and there must be 1430 1453 no blank lines at the end. 1431 1454 """ 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 ''' 1432 1461 from os import sep, getcwd, access, F_OK, mkdir 1433 1462 from Numeric import array, resize,shape,Float … … 1463 1492 1464 1493 return header_fields, data 1465 1494 ''' 1495 1466 1496 def store_parameters(verbose=False,**kwargs): 1467 1497 """ 1498 Temporary Interface to new location 1468 1499 Must have a file_name keyword arg, this is what is writing to. 1469 1500 might be a better way to do this using CSV module Writer and writeDict … … 1481 1512 the indices 1482 1513 """ 1483 import types 1484 import os 1485 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 ''' 1486 1521 # Check that kwargs is a dictionary 1487 1522 if type(kwargs) != types.DictType: … … 1493 1528 except: 1494 1529 completed=False 1495 1496 # assert that a file_name exists 1497 1498 #get file name and removes from dict 1530 1531 #get file name and removes from dict and assert that a file_name exists 1499 1532 if completed: 1500 1533 try: … … 1508 1541 raise 'kwargs must have output_dir' 1509 1542 1510 1511 # print kwargs1512 1543 #extracts the header info and the new line info 1513 1544 line='' … … 1515 1546 count=0 1516 1547 keys = kwargs.keys() 1517 # print 'keys',keys1518 1548 keys.sort() 1519 # print 'keys',keys1520 1549 1521 1550 # for k in kwargs.keys(): … … 1554 1583 1555 1584 #if header is same or this is a new file 1556 if file_header.strip('\n')== header:1585 if file_header.strip('\n')==str(header): 1557 1586 fid=open(file,"a") 1558 1587 #write new line … … 1567 1596 fid.writelines(line+'\n') 1568 1597 fid.close() 1569 msg = 'file header does not match input info, the input variables have changed, change file name' 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' 1570 1601 raise msg 1571 1602
Note: See TracChangeset
for help on using the changeset viewer.