Changeset 1674


Ignore:
Timestamp:
Aug 2, 2005, 6:04:27 PM (19 years ago)
Author:
ole
Message:

Introduced file boundary to lwru2.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/validation/LWRU2/lwru2.py

    r1657 r1674  
    88
    99"""
     10
     11def prepare_timeboundary(filename):
     12    """Converting benchmark 2 time series to NetCDF sww file.
     13    """
     14
     15
     16    print 'Preparing time boundary from %s' %filename
     17    from Numeric import array
     18
     19    fid = open(filename)
     20
     21    #Skip first line
     22    line = fid.readline()
     23
     24    lines = fid.readlines()
     25    fid.close()
     26
     27    N = len(lines)
     28
     29    T = zeros(N, Float)       #Time
     30    Q = zeros(N, Float)  #Values
     31
     32    for i, line in enumerate(lines):
     33        fields = line.split()
     34       
     35        T[i] = float(fields[0])
     36        Q[i] = float(fields[1])
     37
     38    #Create sww file
     39    from Scientific.IO.NetCDF import NetCDFFile
     40
     41    fid = NetCDFFile(filename[-4:] + '.sww', 'w')
     42
     43    fid.institution = 'Geoscience Australia'
     44    fid.description = 'Input wave for Benchmark 2'
     45    fid.starttime = 0.0
     46    fid.createDimension('number_of_timesteps', len(T))
     47    fid.createVariable('time', Float, ('number_of_timesteps',))
     48    fid.variables['time'][:] = T
     49           
     50    fid.createVariable('stage', Float, ('number_of_timesteps',))
     51    fid.variables['stage'][:] = Q[:]
     52
     53    fid.createVariable('xmomentum', Float, ('number_of_timesteps',))
     54    fid.variables['xmomentum'][:] = 0.0
     55
     56    fid.createVariable('ymomentum', Float, ('number_of_timesteps',))
     57    fid.variables['ymomentum'][:] = 0.0               
     58
     59
     60
     61    fid.close()
     62
    1063
    1164
     
    2477except:
    2578
     79    #Preparing time boundary
     80    prepare_timeboundary('Benchmark_2_input.txt')
     81   
    2682    #Preparing points
    2783    from pyvolution.data_manager import xya2pts
    28     xya2pts('bathymetry.txt', verbose = True)
     84    xya2pts('Benchmark_2_Bathymetry.txt', verbose = True)
    2985
    3086
     
    75131print 'Boundaries'
    76132Br = Reflective_boundary(domain)
    77 Bf = File_boundary('input_wave.txt', domain)
     133Bf = File_boundary('Benchmark_2_input.sww', domain, verbose=True)
    78134
    79135#Set boundary conditions
Note: See TracChangeset for help on using the changeset viewer.