Changeset 5350


Ignore:
Timestamp:
May 21, 2008, 11:02:27 AM (16 years ago)
Author:
duncan
Message:

Checking in Hinwood work

Location:
anuga_work/development/Hinwood_2008
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/Hinwood_2008/boundary.csv

    r5092 r5350  
    1 time sec,stage m,X velocity m/s,Y velocity m/s
    2 0,0.4,0,0.01
    3 0.1,0.401996668,0.005990005,0.01
    4 0.2,0.403973387,0.01192016,0.01
    5 0.3,0.405910404,0.017731212,0.01
    6 0.4,0.407788367,0.023365101,0.01
    7 0.5,0.409588511,0.028765532,0.01
    8 0.6,0.411292849,0.033878548,0.01
    9 0.7,0.412884354,0.038653061,0.01
    10 0.8,0.414347122,0.043041365,0.01
    11 0.9,0.415666538,0.046999615,0.01
    12 1,0.41682942,0.050488259,0.01
    13 1.1,0.417824147,0.053472442,0.01
    14 1.2,0.418640782,0.055922345,0.01
    15 1.3,0.419271164,0.057813491,0.01
    16 1.4,0.419708995,0.059126984,0.01
    17 1.5,0.4199499,0.059849699,0.01
    18 1.6,0.419991472,0.059974416,0.01
    19 1.7,0.419833296,0.059499889,0.01
    20 1.8,0.419476953,0.058430858,0.01
    21 1.9,0.418926002,0.056778005,0.01
    22 2,0.418185949,0.054557846,0.01
    23 2.1,0.417264187,0.051792562,0.01
    24 2.2,0.416169928,0.048509784,0.01
    25 2.3,0.414914104,0.044742313,0.01
    26 2.4,0.413509264,0.040527791,0.01
    27 2.5,0.411969443,0.035908329,0.01
    28 2.6,0.410310027,0.030930082,0.01
    29 2.7,0.408547598,0.025642793,0.01
    30 2.8,0.406699763,0.020099289,0.01
    31 2.9,0.404784987,0.01435496,0.01
    32 3,0.4028224,0.0084672,0.01
    33 3.1,0.400831613,0.00249484,0.01
    34 3.2,0.398832517,-0.003502449,0.01
    35 3.3,0.396845086,-0.009464742,0.01
    36 3.4,0.394889178,-0.015332466,0.01
    37 3.5,0.392984335,-0.021046994,0.01
    38 3.6,0.391149591,-0.026551227,0.01
    39 3.7,0.389403277,-0.031790168,0.01
    40 3.8,0.387762842,-0.036711473,0.01
    41 3.9,0.386244677,-0.04126597,0.01
    42 4,0.38486395,-0.04540815,0.01
    43 4.1,0.383634458,-0.049096627,0.01
    44 4.2,0.382568485,-0.052294546,0.01
    45 4.3,0.381676681,-0.054969956,0.01
    46 4.4,0.380967959,-0.057096124,0.01
    47 4.5,0.380449398,-0.058651807,0.01
    48 4.6,0.38012618,-0.05962146,0.01
    49 4.7,0.380001535,-0.059995395,0.01
    50 4.8,0.380076708,-0.059769877,0.01
    51 4.9,0.380350948,-0.058947157,0.01
    52 5,0.380821515,-0.057535456,0.01
    53 5.1,0.381483706,-0.055548881,0.01
    54 5.2,0.382330907,-0.053007279,0.01
    55 5.3,0.383354651,-0.049936047,0.01
    56 5.4,0.38454471,-0.046365869,0.01
    57 5.5,0.385889193,-0.04233242,0.01
    58 5.6,0.387374667,-0.037875998,0.01
    59 5.7,0.388986289,-0.033041133,0.01
    60 5.8,0.390707956,-0.027876131,0.01
    61 5.9,0.392522467,-0.0224326,0.01
    62 6,0.39441169,-0.01676493,0.01
    63 6.1,0.39635675,-0.01092975,0.01
    64 6.2,0.398338212,-0.004985364,0.01
    65 6.3,0.400336278,0.001008834,0.01
    66 6.4,0.402330984,0.006992952,0.01
    67 6.5,0.4043024,0.012907199,0.01
    68 6.6,0.406230827,0.018692482,0.01
    69 6.7,0.408096998,0.024290995,0.01
    70 6.8,0.409882267,0.029646801,0.01
    71 6.9,0.411568795,0.034706386,0.01
    72 7,0.413139732,0.039419196,0.01
    73 7.1,0.414579381,0.043738142,0.01
    74 7.2,0.415873357,0.047620072,0.01
    75 7.3,0.417008732,0.051026197,0.01
    76 7.4,0.417974162,0.053922486,0.01
    77 7.5,0.41876,0.056279999,0.01
    78 7.6,0.419358393,0.05807518,0.01
    79 7.7,0.419763365,0.059290094,0.01
    80 7.8,0.419970867,0.059912601,0.01
    81 7.9,0.419978827,0.059936481,0.01
    82 8,0.419787165,0.059361495,0.01
    83 8.1,0.419397796,0.058193389,0.01
    84 8.2,0.418814611,0.056443833,0.01
    85 8.3,0.418043437,0.05413031,0.01
    86 8.4,0.417091978,0.051275934,0.01
    87 8.5,0.415969742,0.047909227,0.01
    88 8.6,0.414687942,0.044063826,0.01
    89 8.7,0.413259385,0.039778154,0.01
    90 8.8,0.411698344,0.035095032,0.01
    91 8.9,0.410020417,0.030061251,0.01
    92 9,0.40824237,0.024727109,0.01
    93 9.1,0.406381967,0.019145902,0.01
    94 9.2,0.404457798,0.013373395,0.01
    95 9.3,0.402489088,0.007467265,0.01
    96 9.4,0.400495509,0.001486526,0.01
    97 9.5,0.398496978,-0.004509067,0.01
    98 9.6,0.396513464,-0.010459607,0.01
    99 9.7,0.394564787,-0.016305638,0.01
    100 9.8,0.392670417,-0.021988748,0.01
    101 9.9,0.390849282,-0.027452154,0.01
    102 10,0.389119578,-0.032641267,0.01
    103 10.1,0.387498587,-0.037504239,0.01
    104 10.2,0.386002506,-0.041992481,0.01
    105 10.3,0.384646284,-0.046061149,0.01
    106 10.4,0.383443471,-0.049669588,0.01
    107 10.5,0.382406085,-0.052781746,0.01
    108 10.6,0.381544492,-0.055366525,0.01
    109 10.7,0.3808673,-0.057398101,0.01
    110 10.8,0.380381275,-0.058856174,0.01
    111 10.9,0.380091275,-0.059726175,0.01
    112 11,0.380000196,-0.059999412,0.01
    113 11.1,0.380108948,-0.059673155,0.01
    114 11.2,0.380416445,-0.058750664,0.01
    115 11.3,0.380919615,-0.057241155,0.01
    116 11.4,0.381613429,-0.055159712,0.01
    117 11.5,0.382490957,-0.05252713,0.01
    118 11.6,0.383543428,-0.049369716,0.01
    119 11.7,0.384760328,-0.045719015,0.01
    120 11.8,0.386129498,-0.041611505,0.01
    121 11.9,0.387637258,-0.037088227,0.01
    122 12,0.389268542,-0.032194375,0.01
    123 12.1,0.391007051,-0.026978848,0.01
    124 12.2,0.392835414,-0.021493757,0.01
    125 12.3,0.394735364,-0.015793907,0.01
    126 12.4,0.396687916,-0.009936251,0.01
    127 12.5,0.398673562,-0.003979314,0.01
    128 12.6,0.400672461,0.002017383,0.01
    129 12.7,0.402664641,0.007993922,0.01
    130 12.8,0.404630197,0.01389059,0.01
    131 12.9,0.406549489,0.019648466,0.01
    132 13,0.408403341,0.025210022,0.01
    133 13.1,0.410173229,0.030519688,0.01
    134 13.2,0.41184147,0.035524411,0.01
    135 13.3,0.413391395,0.040174186,0.01
    136 13.4,0.414807518,0.044422553,0.01
    137 13.5,0.416075689,0.048227066,0.01
    138 13.6,0.417183236,0.051549709,0.01
    139 13.7,0.418119095,0.054357285,0.01
    140 13.8,0.418873913,0.05662174,0.01
    141 13.9,0.41944015,0.05832045,0.01
    142 14,0.419812147,0.059436441,0.01
    143 14.1,0.419986188,0.059958563,0.01
    144 14.2,0.419960533,0.059881599,0.01
    145 14.3,0.419735439,0.059206318,0.01
    146 14.4,0.419313156,0.057939467,0.01
    147 14.5,0.418697901,0.056093703,0.01
    148 14.6,0.417895823,0.05368747,0.01
    149 14.7,0.416914937,0.05074481,0.01
    150 14.8,0.415765041,0.047295124,0.01
    151 14.9,0.414457627,0.043372881,0.01
    152 15,0.413005757,0.03901727,0.01
     1time sec,stage m,X velocity m/s
     20,0.4,0
     30.1,0.401996668,0.005990005
     40.2,0.403973387,0.01192016
     50.3,0.405910404,0.017731212
     60.4,0.407788367,0.023365101
     70.5,0.409588511,0.028765532
     80.6,0.411292849,0.033878548
     90.7,0.412884354,0.038653061
     100.8,0.414347122,0.043041365
     110.9,0.415666538,0.046999615
     121,0.41682942,0.050488259
     131.1,0.417824147,0.053472442
     141.2,0.418640782,0.055922345
     151.3,0.419271164,0.057813491
     161.4,0.419708995,0.059126984
     171.5,0.4199499,0.059849699
     181.6,0.419991472,0.059974416
     191.7,0.419833296,0.059499889
     201.8,0.419476953,0.058430858
     211.9,0.418926002,0.056778005
     222,0.418185949,0.054557846
     232.1,0.417264187,0.051792562
     242.2,0.416169928,0.048509784
     252.3,0.414914104,0.044742313
     262.4,0.413509264,0.040527791
     272.5,0.411969443,0.035908329
     282.6,0.410310027,0.030930082
     292.7,0.408547598,0.025642793
     302.8,0.406699763,0.020099289
     312.9,0.404784987,0.01435496
     323,0.4028224,0.0084672
     333.1,0.400831613,0.00249484
     343.2,0.398832517,-0.003502449
     353.3,0.396845086,-0.009464742
     363.4,0.394889178,-0.015332466
     373.5,0.392984335,-0.021046994
     383.6,0.391149591,-0.026551227
     393.7,0.389403277,-0.031790168
     403.8,0.387762842,-0.036711473
     413.9,0.386244677,-0.04126597
     424,0.38486395,-0.04540815
     434.1,0.383634458,-0.049096627
     444.2,0.382568485,-0.052294546
     454.3,0.381676681,-0.054969956
     464.4,0.380967959,-0.057096124
     474.5,0.380449398,-0.058651807
     484.6,0.38012618,-0.05962146
     494.7,0.380001535,-0.059995395
     504.8,0.380076708,-0.059769877
     514.9,0.380350948,-0.058947157
     525,0.380821515,-0.057535456
     535.1,0.381483706,-0.055548881
     545.2,0.382330907,-0.053007279
     555.3,0.383354651,-0.049936047
     565.4,0.38454471,-0.046365869
     575.5,0.385889193,-0.04233242
     585.6,0.387374667,-0.037875998
     595.7,0.388986289,-0.033041133
     605.8,0.390707956,-0.027876131
     615.9,0.392522467,-0.0224326
     626,0.39441169,-0.01676493
     636.1,0.39635675,-0.01092975
     646.2,0.398338212,-0.004985364
     656.3,0.400336278,0.001008834
     666.4,0.402330984,0.006992952
     676.5,0.4043024,0.012907199
     686.6,0.406230827,0.018692482
     696.7,0.408096998,0.024290995
     706.8,0.409882267,0.029646801
     716.9,0.411568795,0.034706386
     727,0.413139732,0.039419196
     737.1,0.414579381,0.043738142
     747.2,0.415873357,0.047620072
     757.3,0.417008732,0.051026197
     767.4,0.417974162,0.053922486
     777.5,0.41876,0.056279999
     787.6,0.419358393,0.05807518
     797.7,0.419763365,0.059290094
     807.8,0.419970867,0.059912601
     817.9,0.419978827,0.059936481
     828,0.419787165,0.059361495
     838.1,0.419397796,0.058193389
     848.2,0.418814611,0.056443833
     858.3,0.418043437,0.05413031
     868.4,0.417091978,0.051275934
     878.5,0.415969742,0.047909227
     888.6,0.414687942,0.044063826
     898.7,0.413259385,0.039778154
     908.8,0.411698344,0.035095032
     918.9,0.410020417,0.030061251
     929,0.40824237,0.024727109
     939.1,0.406381967,0.019145902
     949.2,0.404457798,0.013373395
     959.3,0.402489088,0.007467265
     969.4,0.400495509,0.001486526
     979.5,0.398496978,-0.004509067
     989.6,0.396513464,-0.010459607
     999.7,0.394564787,-0.016305638
     1009.8,0.392670417,-0.021988748
     1019.9,0.390849282,-0.027452154
     10210,0.389119578,-0.032641267
     10310.1,0.387498587,-0.037504239
     10410.2,0.386002506,-0.041992481
     10510.3,0.384646284,-0.046061149
     10610.4,0.383443471,-0.049669588
     10710.5,0.382406085,-0.052781746
     10810.6,0.381544492,-0.055366525
     10910.7,0.3808673,-0.057398101
     11010.8,0.380381275,-0.058856174
     11110.9,0.380091275,-0.059726175
     11211,0.380000196,-0.059999412
     11311.1,0.380108948,-0.059673155
     11411.2,0.380416445,-0.058750664
     11511.3,0.380919615,-0.057241155
     11611.4,0.381613429,-0.055159712
     11711.5,0.382490957,-0.05252713
     11811.6,0.383543428,-0.049369716
     11911.7,0.384760328,-0.045719015
     12011.8,0.386129498,-0.041611505
     12111.9,0.387637258,-0.037088227
     12212,0.389268542,-0.032194375
     12312.1,0.391007051,-0.026978848
     12412.2,0.392835414,-0.021493757
     12512.3,0.394735364,-0.015793907
     12612.4,0.396687916,-0.009936251
     12712.5,0.398673562,-0.003979314
     12812.6,0.400672461,0.002017383
     12912.7,0.402664641,0.007993922
     13012.8,0.404630197,0.01389059
     13112.9,0.406549489,0.019648466
     13213,0.408403341,0.025210022
     13313.1,0.410173229,0.030519688
     13413.2,0.41184147,0.035524411
     13513.3,0.413391395,0.040174186
     13613.4,0.414807518,0.044422553
     13713.5,0.416075689,0.048227066
     13813.6,0.417183236,0.051549709
     13913.7,0.418119095,0.054357285
     14013.8,0.418873913,0.05662174
     14113.9,0.41944015,0.05832045
     14214,0.419812147,0.059436441
     14314.1,0.419986188,0.059958563
     14414.2,0.419960533,0.059881599
     14514.3,0.419735439,0.059206318
     14614.4,0.419313156,0.057939467
     14714.5,0.418697901,0.056093703
     14814.6,0.417895823,0.05368747
     14914.7,0.416914937,0.05074481
     15014.8,0.415765041,0.047295124
     15114.9,0.414457627,0.043372881
     15215,0.413005757,0.03901727
  • anuga_work/development/Hinwood_2008/prepare_time_boundary.py

    r5076 r5350  
    1818from Scientific.IO.NetCDF import NetCDFFile
    1919from Numeric import array, zeros, Float
     20 
     21from anuga.utilities.numerical_tools import ensure_numeric
    2022
    21 from project import boundary_file
     23from interp import interp
    2224
    23 def prepare_timeboundary(filename):
     25def prepare_time_boundary(filename):
    2426    """Convert benchmark 2 time series to NetCDF tms file.
    2527    This is a 'throw-away' code taylor made for files like
     
    5456        Q[i] = depth = float(fields[1])
    5557        X[i] = float(fields[2]) * depth
    56         Y[i] = float(fields[3]) * depth
     58        try:
     59            Y[i] = float(fields[3]) * depth
     60        except:
     61            pass
    5762
    5863
     
    7883    fid.close()
    7984
    80 #-------------------------------------------------------------
     85
     86def combine_velocity_depth(velocity_file, depth_file, out_file):
     87    """
     88   
     89    Convert the rawish velocity and depth values, which have values at
     90    different times to a csv file, with values at the same time, with
     91    SI units.
     92
     93    The format for the velocity file is;
     94    [time, sec], [x-velocity +ve is towards the wave generator, m/sec],
     95    [y-velocity], [z-velocity]
     96
     97    The format for the pressure file is
     98    [time, sec], [mm above SWL for sensor A], many other sensors...
     99    """
     100
     101    # Read velocity file
     102    vfid = open(velocity_file)
     103    lines = vfid.readlines()
     104    vfid.close()
     105
     106   
     107    n_velocity = len(lines)
     108    vtimes = zeros(n_velocity, Float)  #Time
     109    velocities = zeros(n_velocity, Float)  #
     110
     111    for i, line in enumerate(lines):
     112        fields = line.split(',')
     113
     114        vtimes[i] = float(fields[0])
     115        velocities[i] = float(fields[1])
     116
     117    # Read the depth file
     118    dfid = open(depth_file)
     119    lines = dfid.readlines()
     120    dfid.close()
     121
     122
     123    n_depth = len(lines)
     124    dtimes = zeros(n_depth, Float)  #Time
     125    depths = zeros(n_depth, Float)  #
     126   
     127    for i, line in enumerate(lines):
     128        fields = line.split(',')
     129
     130        dtimes[i] = float(fields[0])
     131        depths[i] = float(fields[1])
     132
     133    depths_at_vtimes = interp(dtimes, depths, vtimes, missing=1e+20)
     134    depths_at_vtimes = ensure_numeric(depths_at_vtimes)
     135    depths_at_vtimes = depths_at_vtimes/1000.00 # convert from mm to m
     136    velocities = ensure_numeric(velocities)
     137    velocities = velocities * -1.0 # Swap axis around
     138   
     139    fid = open(out_file,'w')
     140
     141    assert len(depths_at_vtimes) == len(vtimes)
     142   
     143    #for vtime, depth_at_vtime, velocity in map(vtimes, depths_at_vtimes,
     144    #                                           velocities):
     145    for i in xrange(len(vtimes)):
     146        fid.write(str(vtimes[i]) + ',' + str(depths_at_vtimes[i]) \
     147                  + ',' + str(velocities[i])+'\n')
     148
     149    fid.close()
     150   
     151   
     152#-------------------------------------------------------------------
    81153if __name__ == "__main__":
    82     prepare_timeboundary(boundary_file)
     154    combine_velocity_depth('T2R7velfilt.csv','T2R7pressfilt.csv', 'cyeah.csv')
     155
  • anuga_work/development/Hinwood_2008/project.py

    r5076 r5350  
    1212from anuga.utilities.system_tools import get_user_name
    1313
    14 boundary_file = 'boundary.tsm'
    1514
    1615class Project:   
     
    2221        self.user = get_user_name()
    2322        if home is None:
    24             home = getenv('INUNDATIONHOME') #Sandpit's parent dir   
     23            try:
     24                home = getenv('INUNDATIONHOME') #Sandpit's parent dir
     25            except:
     26                home = '.'
    2527        self.home = home
    2628        # Create the structure of where the output directories will go
     
    3032        if outputdir_name is None:
    3133            #gets time for dir
    32             outputdir_name = strftime('%Y%m%d_%H%M%S',localtime())
     34            outputdir_name = strftime('%Y%m%d_%H%M%S',localtime())
     35       
    3336        general_outputdir = scenariodir+sep+'output'+sep
    3437        self.outputdir = general_outputdir+outputdir_name+sep
    3538        self.meshdir = scenariodir+sep+'meshes'+sep
     39        self.scenariodir = scenariodir+sep
     40        self.boundary_file = self.scenariodir + 'boundary.tsm'
    3641
    3742        # creates copy of output dir structure, if it doesn't exist
  • anuga_work/development/Hinwood_2008/run_dam.py

    r5236 r5350  
    3939import project                 # Definition of file names and polygons
    4040import create_mesh
     41from prepare_time_boundary import prepare_time_boundary
     42
     43
    4144
    4245def elevation_function(x,y):
     
    5558
    5659def main(friction=0.01, outputdir_name=None, is_trial_run=False):
     60
     61   
    5762    basename = 'zz' + str(friction)
    5863    if is_trial_run is True:
     
    6974       
    7075    pro_instance = project.Project(['data','flumes','Hinwood_2008'],
    71                                    outputdir_name=outputdir_name,
    72                                    home='.')
     76                                   outputdir_name=outputdir_name)
    7377    print "The output dir is", pro_instance.outputdir
    7478    copy_code_files(pro_instance.outputdir,__file__,
     
    7983    copy (pro_instance.codedir + 'create_mesh.py',
    8084          pro_instance.outputdir + 'create_mesh.py')
     85
     86   
     87    # Convert the boundary file, .csv to .tsm
     88    try:
     89        temp = open(pro_instance.boundary_file)
     90        temp.close()
     91    except IOError:
     92        prepare_time_boundary(pro_instance.boundary_file)
    8193   
    8294    mesh_filename = pro_instance.meshdir + basename + '.msh'
     
    135147    #function = file_function(project.boundary_file, domain, verbose=True)
    136148    #Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function)
    137 
    138     function = file_function(project.boundary_file, domain, verbose=True)
     149    try:
     150        function = file_function(pro_instance.boundary_file, domain,
     151                                 verbose=True)
     152    except IOError:
     153        msg = 'Run prepare_time_boundary.py. File "%s" could not be opened.'\
     154                  %(pro_instance.boundary_file)
     155        raise msg
     156       
    139157    Br = Reflective_boundary(domain)
    140158    #Bd = Dirichlet_boundary([0.3,0,0])
Note: See TracChangeset for help on using the changeset viewer.