Changeset 2469


Ignore:
Timestamp:
Mar 3, 2006, 9:52:00 AM (18 years ago)
Author:
sexton
Message:

Updating time series to write output to file (filename reflecting gauge name/location)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • production/sydney_2006/get_timeseries.py

    r2406 r2469  
    99from matplotlib.ticker import MultipleLocator, FormatStrFormatter
    1010
    11 swwfile = project.outputname2 + '.sww'
     11swwfile = project.outputname + '.sww'
     12
     13
    1214
    1315#Time interval to plot
     
    3840gauges, lines, locations = get_gauges_from_file(project.gauge_filename)
    3941
     42print 'number of gauges for Benfield:   ', len(gauges)
     43
    4044#Read model output
    4145quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum']
     
    6367    ymom = []
    6468    bearings = []
     69    depths = []
    6570
    6671    max_depth = 0
     
    7984        uh = f(t, point_id = k)[2]
    8085        vh = f(t, point_id = k)[3]
    81         #myloc = locations[k]
     86        myloc = locations[k]
     87        depth = w-z
    8288
    8389        m = sqrt(uh*uh + vh*vh)   #Absolute momentum
    8490        vel = sqrt(uh*uh + vh*vh) / (w-z + 1.e-30) #Absolute velocity
    8591        angle = degrees(atan(vh/(uh+1.e-15)))
    86         print 'angle', angle
    8792        if (0 < angle < 90.0):
    8893            if vh > 0:
     
    106111        ymom.append(vh)
    107112        bearings.append(bearing)
     113        depths.append(depth)
    108114
    109115        if w-z > max_depth:
     
    113119        if vel > max_velocity:
    114120            max_velocity = vel
    115             print 'max speed', max_velocity
    116121
    117122    #Plot only those gauges that have been inundated by more than a threshold
     
    128133        plot(model_time, stages, '-b',
    129134             model_time, elevations, '-k')
    130     name = 'Gauge_%d: (%.1f, %.1f)' %(k, g[0], g[1])
    131     #name = 'Gauge_%d: (%.1f, %.1f) Location: %s' %(k, g[0], g[1], myloc)
     135    #name = 'Gauge_%d: (%.1f, %.1f)' %(k, g[0], g[1])
     136    name = 'Gauge_%d: (%.1f, %.1f) Location: %s' %(k, g[0], g[1], myloc)
    132137    title(name)
    133138
     
    138143           shadow=True,
    139144           loc='upper right')
    140     savefig('Gauge_%d_stage' %k) # savefig('Gauge_%s_stage' %myloc)
    141 
    142     raw_input('Next')
    143 
    144     #X Momentum plot
    145     ion()
    146     hold(False)
    147     plot(model_time, xmom, '-r')
    148     title(name)
    149 
    150     title('%s (x momentum)' %name)
    151     xlabel('time [s]')
    152     ylabel('uh [m^2/s]')   
    153     savefig('Gauge_%d_xmomentum' %k)
    154     #savefig('Gauge_%s_momentum' %myloc)
    155    
    156     raw_input('Next')
    157 
    158     #y Momentum plot
    159     ion()
    160     hold(False)
    161     plot(model_time, ymom, '-r')
    162     title(name)
    163 
    164     title('%s (y momentum)' %name)
    165     xlabel('time [s]')
    166     ylabel('vh [m^2/s]')   
    167     savefig('Gauge_%d_ymomentum' %k)
    168     #savefig('Gauge_%s_momentum' %myloc)
    169    
    170     raw_input('Next')
     145    #savefig('Gauge_%d_stage' %k)
     146    savefig('Gauge_%s_stage' %myloc)
     147
     148    # raw_input('Next')
    171149   
    172150    #Momentum plot
     
    179157    xlabel('time [s]')
    180158    ylabel('sqrt( uh^2 + vh^2 ) [m^2/s]')   
    181     savefig('Gauge_%d_momentum' %k)
    182     #savefig('Gauge_%s_momentum' %myloc)
    183    
    184     raw_input('Next')
     159    #savefig('Gauge_%d_momentum' %k)
     160    savefig('Gauge_%s_momentum' %myloc)
     161   
     162    # raw_input('Next')
    185163
    186164    #Bearing plot
     
    193171    text(maxT+tstep, 90, 'East')
    194172    text(maxT+tstep, 270, 'West')
    195     majorLocator = MultipleLocator(45)
     173    #majorLocator = MultipleLocator(3600)
    196174    #print 'major', majorLocator[1]
    197     #ax.yaxis.set_major_locator(majorLocator) #'yticklabels', range(30,390,30))
     175    #ax.xaxis.set_major_locator(majorLocator) #'yticklabels', range(30,390,30))
    198176    # set(labels,color='g',rotation=45)
    199177
     
    201179    xlabel('time [s]')
    202180    ylabel(' atan(vh/uh) [degrees from North]')   
    203     savefig('Gauge_%d_bearing' %k)
    204     #savefig('Gauge_%s_bearing' %myloc)
    205    
    206     raw_input('Next')
     181    #savefig('Gauge_%d_bearing' %k)
     182    savefig('Gauge_%s_bearing' %myloc)
     183   
     184    # raw_input('Next')
    207185
    208186    #Speed plot
     
    215193    xlabel('time [s]')
    216194    ylabel('sqrt( uh^2 + vh^2 ) / depth [m/s]')   
    217     savefig('Gauge_%d_speed' %k)
    218     #savefig('Gauge_%s_speed' %myloc)
    219    
    220     raw_input('Next')
    221    
    222 
     195    #savefig('Gauge_%d_speed' %k)
     196    savefig('Gauge_%s_speed' %myloc)
     197   
     198    # raw_input('Next')
     199
     200    whichone = '_%s' %myloc
     201    thisfile = project.gaugetimeseries+whichone+'.csv'
     202    fid = open(thisfile, 'w')
     203    s = 'Time, Depth, Momentum, Velocity \n'
     204    fid.write(s)
     205    for i_t, i_d, i_m, i_vel in zip(model_time, depths, momenta, velocity):
     206        s = '%.2f, %.2f, %.2f, %.2f\n' %(i_t, i_d, i_m, i_vel)
     207        fid.write(s)
     208       
    223209show()
    224210
     211
Note: See TracChangeset for help on using the changeset viewer.