Changeset 4485


Ignore:
Timestamp:
May 24, 2007, 5:08:25 PM (17 years ago)
Author:
nick
Message:

moved copy_code_files, get_data_from_file, store_parameters and screen_catcher to shallow_water.data_managger

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r4480 r4485  
    528528def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='',
    529529                         print_to_screen=False, verbose=False):
    530     """
     530    """Temporary Interface to new location
    531531    Used to store screen output and errors to file, if run on multiple
    532532    processes eachprocessor will have its own output and error file.
     
    536536    """
    537537
     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'''
    538545    dir_name = dir_name
    539546    if access(dir_name,W_OK) == 0:
     
    570577        fid.write(stuff)
    571578#        if print_to_screen: print stuff
    572 
     579'''
    573580def get_revision_number():
    574581    """Get the version number of the SVN
     
    13931400# but any number of files.
    13941401def 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
    13961405    information management
    13971406    filename1 and filename2 are both absolute pathnames   
    13981407    """
    13991408
     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'''
    14001414    if access(dir_name,F_OK) == 0:
    14011415        print 'Make directory %s' %dir_name
     
    14051419#    copy (__file__, project.output_run_time_dir + basename(__file__))
    14061420    print 'Files %s and %s copied' %(filename1, filename2)
    1407 
     1421'''
    14081422
    14091423def add_directories(root_directory, directories):
     
    14261440def get_data_from_file(filename,separator_value = ','):
    14271441    """
    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       
    14291452    NOTE: wont deal with columns with different lenghts and there must be
    14301453    no blank lines at the end.
    14311454    """
     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    '''
    14321461    from os import sep, getcwd, access, F_OK, mkdir
    14331462    from Numeric import array, resize,shape,Float
     
    14631492       
    14641493    return header_fields, data
    1465 
     1494    '''
     1495   
    14661496def store_parameters(verbose=False,**kwargs):
    14671497    """
     1498    Temporary Interface to new location
    14681499    Must have a file_name keyword arg, this is what is writing to.
    14691500    might be a better way to do this using CSV module Writer and writeDict
     
    14811512            the indices
    14821513    """
    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    '''
    14861521    # Check that kwargs is a dictionary
    14871522    if type(kwargs) != types.DictType:
     
    14931528    except:
    14941529        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
    14991532    if completed:
    15001533        try:
     
    15081541            raise 'kwargs must have output_dir'
    15091542       
    1510    
    1511 #    print kwargs
    15121543    #extracts the header info and the new line info
    15131544    line=''
     
    15151546    count=0
    15161547    keys = kwargs.keys()
    1517 #    print 'keys',keys
    15181548    keys.sort()
    1519 #    print 'keys',keys
    15201549   
    15211550#    for k in kwargs.keys():
     
    15541583           
    15551584    #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):
    15571586        fid=open(file,"a")
    15581587        #write new line
     
    15671596        fid.writelines(line+'\n')
    15681597        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'
    15701601        raise msg
    15711602
Note: See TracChangeset for help on using the changeset viewer.