Changeset 4487


Ignore:
Timestamp:
May 24, 2007, 6:39:01 PM (18 years ago)
Author:
sexton
Message:

minor update to sww2timeseries

File:
1 edited

Legend:

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

    r4486 r4487  
    128128    #structure
    129129
    130 
     130    f.starttime = starttime
     131   
    131132    if domain is not None:
    132133        #Update domain.startime if it is *earlier* than starttime from file
     
    528529def start_screen_catcher(dir_name, myid='', numprocs='', extra_info='',
    529530                         print_to_screen=False, verbose=False):
    530     """Temporary Interface to new location
     531    """
    531532    Used to store screen output and errors to file, if run on multiple
    532533    processes eachprocessor will have its own output and error file.
     
    536537    """
    537538
    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 '''
    545539    dir_name = dir_name
    546540    if access(dir_name,W_OK) == 0:
     
    577571        fid.write(stuff)
    578572#        if print_to_screen: print stuff
    579 '''
     573
    580574def get_revision_number():
    581575    """Get the version number of the SVN
     
    713707                   time_min = None,
    714708                   time_max = None,
     709                   time_unit = None,
    715710                   title_on = None,
    716711                   use_cache = False,
     
    810805                        time_min,
    811806                        time_max,
     807                        time_unit,
    812808                        title_on,
    813809                        use_cache,
     
    826822                    time_min = None,
    827823                    time_max = None,
     824                    time_unit = None,
    828825                    title_on = None,
    829826                    use_cache = False,
     
    852849    if surface is None:
    853850        surface = False
    854        
     851
     852    if time_unit is None:
     853        time_unit = 'hours'
     854   
    855855    if title_on is None:
    856856        title_on = True
     
    867867    themaxT = 0.0
    868868    theminT = 0.0
    869    
     869
    870870    for swwfile in swwfiles.keys():
    871871
     
    880880                          quantities = sww_quantity,
    881881                          interpolation_points = gauges,
    882                           verbose = True,
     882                          verbose = verbose,
    883883                          use_cache = use_cache)
    884884
     
    932932        texfile, elev_output = generate_figures(plot_quantity, file_loc, report, reportname, surface,
    933933                                                leg_label, f_list, gauges, locations, elev, gauge_index,
    934                                                 production_dirs, time_min, time_max, title_on, label_id,
    935                                                 generate_fig, verbose)
     934                                                production_dirs, time_min, time_max, time_unit,
     935                                                title_on, label_id, generate_fig, verbose)
    936936    else:
    937937        texfile = ''
     
    10271027def generate_figures(plot_quantity, file_loc, report, reportname, surface,
    10281028                     leg_label, f_list, gauges, locations, elev, gauge_index,
    1029                      production_dirs, time_min, time_max, title_on, label_id,
    1030                      generate_fig, verbose):
     1029                     production_dirs, time_min, time_max, time_unit,
     1030                     title_on, label_id, generate_fig, verbose):
    10311031    """ Generate figures based on required quantities and gauges for each sww file
    10321032    """
     
    10911091    stages_plot3d = zeros((n0,m), Float)
    10921092    eastings_plot3d = zeros((n0,m),Float)
     1093    if time_unit is 'mins': scale = 60.0
     1094    if time_unit is 'hours': scale = 3600.0
    10931095    ##### loop over each swwfile #####
    10941096    for j, f in enumerate(f_list):
     1097        starttime = f.starttime
    10951098        if verbose: print 'swwfile %d of %d' %(j, len(f_list))
    10961099        comparefile = file_loc[j]+sep+'gauges_maxmins'+'.csv'
     
    11121115            s = 'Time, Stage, Momentum, Speed, Elevation, xmom, ymom \n'
    11131116            fid_out.write(s)
    1114            
    11151117            #### generate quantities #######
    11161118            for i, t in enumerate(f.get_time()):
     
    11261128                    else:
    11271129                        vel = m / (depth + 1.e-6/depth)
    1128                     #bearing = calc_bearing(uh, vh)
    1129                     model_time[i,k,j] = t/60.0
     1130                    #bearing = calc_bearing(uh, vh)                   
     1131                    model_time[i,k,j] = (t + starttime)/scale #t/60.0
    11301132                    stages[i,k,j] = w
    11311133                    elevations[i,k,j] = z
     
    11961198    elev_output = []
    11971199    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])
    12031204        cstr = ['g', 'r', 'b', 'c', 'm', 'y', 'k']
    12041205        nn = len(plot_quantity)
     
    12701271                        legend(('Bearing','West','East'))
    12711272
    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))
    12771281                    if len(label_id) > 1: legend((leg_label),loc='upper right')
    12781282
     
    14001404# but any number of files.
    14011405def 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
    14051407    information management
    14061408    filename1 and filename2 are both absolute pathnames   
    14071409    """
    14081410
    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     '''
    14141411    if access(dir_name,F_OK) == 0:
    14151412        print 'Make directory %s' %dir_name
     
    14191416#    copy (__file__, project.output_run_time_dir + basename(__file__))
    14201417    print 'Files %s and %s copied' %(filename1, filename2)
    1421     '''
     1418
    14221419
    14231420def add_directories(root_directory, directories):
     
    14401437def get_data_from_file(filename,separator_value = ','):
    14411438    """
    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
    14521440    NOTE: wont deal with columns with different lenghts and there must be
    14531441    no blank lines at the end.
    14541442    """
    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     '''
    14611443    from os import sep, getcwd, access, F_OK, mkdir
    14621444    from Numeric import array, resize,shape,Float
     
    14921474       
    14931475    return header_fields, data
    1494     '''
    1495    
     1476
    14961477def store_parameters(verbose=False,**kwargs):
    14971478    """
    1498       Temporary Interface to new location
    14991479    Must have a file_name keyword arg, this is what is writing to.
    15001480    might be a better way to do this using CSV module Writer and writeDict
     
    15121492            the indices
    15131493    """
    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
    15211497    # Check that kwargs is a dictionary
    15221498    if type(kwargs) != types.DictType:
     
    15281504    except:
    15291505        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
    15321510    if completed:
    15331511        try:
     
    15411519            raise 'kwargs must have output_dir'
    15421520       
     1521   
     1522#    print kwargs
    15431523    #extracts the header info and the new line info
    15441524    line=''
     
    15461526    count=0
    15471527    keys = kwargs.keys()
     1528#    print 'keys',keys
    15481529    keys.sort()
     1530#    print 'keys',keys
    15491531   
    15501532#    for k in kwargs.keys():
     
    15831565           
    15841566    #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:
    15861568        fid=open(file,"a")
    15871569        #write new line
     
    15961578        fid.writelines(line+'\n')
    15971579        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'
    16011581        raise msg
    1602     '''
     1582
    16031583
    16041584def remove_lone_verts(verts, triangles):
Note: See TracChangeset for help on using the changeset viewer.