source: anuga_work/development/Hinwood_2008/slope.py @ 7818

Last change on this file since 7818 was 5710, checked in by duncan, 16 years ago

comments

File size: 26.5 KB
Line 
1
2"""
3Plot up files from the Hinwood project.
4"""
5from os import sep
6import project
7from copy import deepcopy
8#from scipy import arange
9from csv import writer
10
11from Numeric import arange, array, zeros, Float, where, greater, less, \
12     compress, argmin, choose, searchsorted
13
14from anuga.fit_interpolate.interpolate import interpolate_sww2csv
15from anuga.shallow_water.data_manager import csv2dict
16from anuga.utilities.numerical_tools import ensure_numeric
17
18
19SLOPE_STR = 'stage_slopes'
20TIME_STR = 'times'
21
22TIME_BORDER = 5
23LOCATION_BORDER = .5
24
25def load_sensors(quantity_file):
26    """
27    Load a csv file, where the first row is the column header and
28    the first colum explains the rows.
29
30    returns the data as two vectors and an array.
31    """
32    #slope, _ = csv2dict(file_sim)
33   
34    # Read the depth file
35    dfid = open(quantity_file)
36    lines = dfid.readlines()
37    dfid.close()
38
39    title = lines.pop(0)
40    n_time = len(lines)
41    n_sensors = len(lines[0].split(','))-1  # -1 to remove time
42    times = zeros(n_time, Float)  #Time
43    depths = zeros(n_time, Float)  #
44    sensors = zeros((n_time,n_sensors), Float)
45    quantity_locations = title.split(',') #(',')
46    quantity_locations.pop(0) # remove 'time'
47
48    # Doing j.split(':')[0] drops the y location
49    locations = [float(j.split(':')[0]) for j in quantity_locations]
50   
51    for i, line in enumerate(lines):
52        fields = line.split(',') #(',')
53        fields = [float(j) for j in fields]
54        times[i] = fields[0]
55        sensors[i] = fields[1:] # 1: to remove time
56
57    #print "times",times
58    #print "locations", locations
59    #print "sensors", sensors
60    return times, locations, sensors
61   
62def load_slopes(stage_file):
63    """
64    Finds the slope, wrt distance of a distance, time, quantity csv file.
65
66    returns the times and slope_locations vectors and the slopes array.
67    """
68    times, locations, sensors = load_sensors(stage_file)
69    n_slope_locations = len(locations)-1
70    n_time = len(times)
71    slope_locations = zeros(n_slope_locations, Float)  #
72    slopes = zeros((n_time,n_slope_locations), Float)
73
74    # An array of the sensor spacing values
75    delta_locations = zeros(n_slope_locations, Float)
76   
77    for i in arange(n_slope_locations):
78        delta_locations[i] = (locations[i+1] - locations[i])
79        slope_locations[i] = locations[i] + 0.5*delta_locations[i]
80   
81    for j in arange(n_time):
82        for i in arange(n_slope_locations):
83            slopes[j,i] = (sensors[j,i+1] - sensors[j,i])/delta_locations[i]
84
85    return times, slope_locations, slopes
86
87
88def graph_contours(times, x_data, z_data,
89                 y_label='Time, seconds',
90                 plot_title="slope",
91                 x_label='x location, m',
92                 save_as=None,
93                 is_interactive=False,
94                 break_xs=None,
95                 break_times=None):
96    """
97    Currently used to generate stage slope contour graphs.
98
99    Has been generalised a bit.
100    """
101    # Do not move these imports.  Tornado doesn't have pylab
102    from pylab import meshgrid, cm, contourf, contour, ion, plot, xlabel, \
103         ylabel, close, legend, savefig, title, figure ,colorbar, show , axis
104
105    origin = 'lower'
106
107    if is_interactive:
108        ion()
109       
110    # Can't seem to reshape this info once it is in the function
111    CS = contourf(x_data, times, z_data, 10,
112                  cmap=cm.bone,
113                  origin=origin)
114   
115    #CS2 = contour(x_data, times, z_data, CS.levels[::1],
116     #             colors = 'r',
117      #            origin=origin,
118       #           hold='on')
119   
120    title(plot_title)
121    xlabel(x_label)
122    ylabel(y_label)
123
124    if break_times is not None and break_xs is not None:
125        plot(break_xs, break_times, 'ro')
126   
127   
128    # Make a colorbar for the ContourSet returned by the contourf call.
129    cbar = colorbar(CS)
130
131    # Add the contour line levels to the colorbar
132    cbar.ax.set_ylabel('stage slope')
133    #cbar.add_lines(CS2)
134         
135    if is_interactive:       
136        raw_input() # Wait for enter pressed
137       
138    if save_as is not None:
139        savefig(save_as)
140    close()  #Need to close this plot
141
142def graph_froude(times, x_data, z_data,
143                 y_label='Time, seconds',
144                 plot_title="Froude Number",
145                 x_label='x location, m',
146                 save_as=None,
147                 is_interactive=False,
148                 break_xs=None,
149                 break_times=None):
150    """
151    Used to generate a froude Number contour graph.
152
153    """
154    # Do not move these imports.  Tornado doesn't have pylab
155    from pylab import meshgrid, cm, contourf, contour, ion, plot, xlabel, \
156         ylabel, close, legend, savefig, title, figure ,colorbar, show , axis
157
158    origin = 'lower'
159
160    if is_interactive:
161        ion()
162       
163    # Can't seem to reshape this info once it is in the function
164    #CS = contourf(x_data, times, z_data, [-1,0.6,0.8,1,2,4],
165     #             colors = ('black', 'r', 'g', 'b','r'),
166      #            #cmap=cm.bone,
167       #           origin=origin)
168    CS = contourf(x_data, times, z_data, 10,
169                  #colors = ('black', 'r', 'g', 'b','r'),
170                  cmap=cm.bone,
171                  origin=origin)
172   
173    #CS2 = contour(x_data, times, z_data, CS.levels[::1],
174     #             colors = 'r',
175      #            origin=origin,
176       #           hold='on')
177   
178    title(plot_title)
179    xlabel(x_label)
180    ylabel(y_label)
181
182    if break_times is not None and break_xs is not None:
183        plot(break_xs, break_times, 'yo')
184   
185   
186    # Make a colorbar for the ContourSet returned by the contourf call.
187    cbar = colorbar(CS)
188
189    # Add the contour line levels to the colorbar
190    cbar.ax.set_ylabel('Froude Number')
191    #cbar.add_lines(CS2)
192         
193    if is_interactive:       
194        raw_input() # Wait for enter pressed
195       
196    if save_as is not None:
197        savefig(save_as)
198    close()  #Need to close this plot
199   
200def auto_graph_slopes(outputdir_tag, scenarios, is_interactive=False):
201    """
202    Used to generate all the stage slope contour graphs of a scenario list
203    """
204    plot_type = ".pdf"
205    for run_data in scenarios:
206        id = run_data['scenario_id']
207        outputdir_name = id + outputdir_tag
208        pro_instance = project.Project(['data','flumes','Hinwood_2008'],
209                                       outputdir_name=outputdir_name)
210        end = id + ".csv"
211        anuga_break_times = []
212        for break_time in run_data['break_times']:
213            anuga_break_times.append( \
214                break_time -  run_data['ANUGA_start_time'])
215        stage_file = pro_instance.outputdir + "fslope_stage_" + end
216        plot_title = "Stage slope " + id + "\n file:" + \
217                     outputdir_name + "_slope_stage" + plot_type
218        print "Creating ", stage_file
219        save_as = pro_instance.plots_dir + sep + \
220                            outputdir_name + "_slope_stage" + plot_type
221        times, locations, slopes = load_slopes(stage_file)
222        #times, slopes = get_band(anuga_break_times[0]-TIME_BORDER,
223         #                          100, times, slopes, 0)
224        #locations, slopes = get_band(
225         #   min(run_data['break_xs'])- 2*LOCATION_BORDER,
226          #  100, locations, slopes, -1)
227        graph_contours(times, locations, slopes,
228                       plot_title=plot_title,
229                       break_xs=run_data['break_xs'],
230                       break_times=anuga_break_times,
231                       save_as=save_as,
232                       is_interactive=is_interactive)
233
234def auto_graph_froudes(outputdir_tag, scenarios, is_interactive=False):
235    """
236    Used to generate all the Froude number contour graphs of a scenario list
237    """
238   
239    plot_type = ".pdf"
240   
241    for run_data in scenarios:
242        id = run_data['scenario_id']
243        outputdir_name = id + outputdir_tag
244        pro_instance = project.Project(['data','flumes','Hinwood_2008'],
245                                       outputdir_name=outputdir_name)
246        end = id + ".csv"
247        anuga_break_times = []
248        for break_time in run_data['break_times']:
249            anuga_break_times.append( \
250                break_time -  run_data['ANUGA_start_time'])
251        plot_title = "Froude Number" + id + "\n file:" + \
252                     outputdir_name + "_froude" + plot_type
253        froude_file = pro_instance.outputdir + "fslope_froude_" + end
254        print "Creating ", froude_file
255        save_as = pro_instance.plots_dir + sep + \
256                            outputdir_name + "_froude" + plot_type
257        dtimes, locations, sensors = load_sensors(froude_file)
258        dtimes, sensors = get_band(anuga_break_times[0]-TIME_BORDER,
259                                   100, dtimes, sensors, 0)
260        locations, sensors = get_band(
261            min(run_data['break_xs'])-LOCATION_BORDER,
262            100, locations, sensors, -1)
263        #print "dtimes", dtimes
264        #print "sensors", sensors
265        #times, slope_locations, slopes = load_slopes(stage_file)
266        graph_froude(dtimes, locations, sensors,
267                     plot_title=plot_title,
268                     break_xs=run_data['break_xs'],
269                     break_times=anuga_break_times,
270                     save_as=save_as,
271                     is_interactive=is_interactive)
272       
273def find_froude(times_froude, locations_froude, froudes_array,
274                times, locations):
275    """
276    interpolate across location to find froude number values
277    """
278   
279    if len(times) == 0:
280        return []
281    time_indexes = searchsorted(times_froude, times)
282    location_indexes = searchsorted(locations_froude, locations)
283
284   
285    assert len(time_indexes) == len(location_indexes)
286
287    froudes = []
288    for time_i, loc_i, time, location in map(None, time_indexes,
289                                             location_indexes,
290                                             times, locations):
291        # the time values should be the same
292        assert times_froude[time_i] == time
293
294        # The distance value should be half way between the froude locations
295        midpoint = locations_froude[loc_i-1] + \
296                   (locations_froude[loc_i]-locations_froude[loc_i-1])*0.5
297        #print "location", location
298        #print "midpoint", midpoint
299        assert location == midpoint
300        froude = froudes_array[time_i, loc_i-1] + \
301                   (froudes_array[time_i, loc_i]- \
302                    froudes_array[time_i, loc_i-1])*0.5
303        froudes.append(froude)
304               
305    return froudes
306   
307def auto_find_min_slopes(slope_tag, outputdir_tag, scenarios):
308    """
309    Given stage and froude wrt time and location csv files,
310    find the waves and get the froude number and stage slope
311    at the wave face.
312
313    For each wave write a csv file giving the location, stage slope, time and
314    froude number.
315    """
316   
317    for run_data in scenarios:
318        id = run_data['scenario_id']
319        outputdir_name = id + outputdir_tag
320        pro_instance = project.Project(['data','flumes','Hinwood_2008'],
321                                       outputdir_name=outputdir_name)
322        end = id + ".csv"
323        anuga_break_times = []
324        for break_time in run_data['break_times']:
325            anuga_break_times.append( \
326                break_time -  run_data['ANUGA_start_time'])
327           
328        stage_file = pro_instance.outputdir + slope_tag + "slope_stage_" + end
329        froude_file = pro_instance.outputdir + slope_tag + "slope_froude_" + \
330                      end
331       
332        times, slope_locations, slopes = load_slopes(stage_file)
333        #print "slope_locations", slope_locations
334        times_froude, locations_froude, froudes_a = load_sensors(froude_file)
335        #print "locations_froude", locations_froude
336        waves = find_min_slopes(times, slope_locations, slopes,
337                                anuga_break_times,
338                                run_data['band_offset'])
339       
340        # write the wave info here
341        # and find the froude values
342        for i, wave in enumerate(waves):
343           
344            id = "wave_" + str(i)
345            wave_file = stage_file[:-4] + '_'+ id + ".csv"
346            print "wave_file", wave_file
347            froudes = find_froude(times_froude, locations_froude,
348                             froudes_a, wave[TIME_STR],
349                                  slope_locations)
350            wave_writer = writer(file(wave_file, "wb"))
351            wave_writer.writerow(["x location", "min slope", "Time", "Froude"])
352            wave_writer.writerows(map(None,
353                                      slope_locations,
354                                      wave[SLOPE_STR],
355                                      wave[TIME_STR],
356                                      froudes))
357
358def calc_wave_file_min_slope_max_froude(slope_tag, outputdir_tag, scenarios):
359    """
360    Calc the min slope and max froude number in the wave files
361    Used so all graphs have the same axis.
362    """
363    min_slope = 0
364    max_froude = 0
365   
366    for run_data in scenarios:
367        for wave_file, save_as, wave_number in Get_file_name(
368        run_data, outputdir_tag, slope_tag):
369            simulation, _ = csv2dict(wave_file)
370            slope = [float(x) for x in simulation['min slope']]
371            froude = [float(x) for x in simulation['Froude']]
372           
373            min_slope = min(min(slope), min_slope)
374           
375            max_froude = max(max(froude), max_froude)
376           
377   
378    return min_slope, max_froude
379
380class Get_file_name:
381    """
382    Used to make the file names, and workout the wave number.
383    """
384   
385    def __init__(self, run_data, outputdir_tag, slope_tag):
386       
387        self.plot_type = ".pdf"
388        # The scenario data
389        id = run_data['scenario_id']
390       
391        self.outputdir_name = id + outputdir_tag
392        self.pro_instance = project.Project(['data','flumes','Hinwood_2008'],
393                                            outputdir_name=self.outputdir_name)
394        self.wave_number = -1
395        self.max_waves = len(run_data['break_type'])
396        self.slope_tag = slope_tag
397        self.end = id + ".csv"
398
399    def next(self):
400        self.wave_number += 1
401        if self.wave_number >= self.max_waves: raise StopIteration
402        wave_tag = "wave_" + str(self.wave_number)
403        stage_file = self.pro_instance.outputdir + self.slope_tag + \
404                     "slope_stage_" + self.end
405        wave_file = stage_file[:-4] + '_'+ wave_tag + ".csv"
406        save_as = self.pro_instance.plots_dir + sep + \
407                  self.outputdir_name + "_" + wave_tag + self.plot_type
408        return wave_file, save_as, self.wave_number
409
410    def __iter__(self):
411        return self
412       
413
414
415
416def auto_plot_froude_slopes(slope_tag, outputdir_tag, scenarios):
417    """
418    Used to generate all the Froude number, stage slope, time graphs
419    of a scenario list
420    """
421
422    slope_min, froude_max = calc_wave_file_min_slope_max_froude(
423        slope_tag, outputdir_tag, scenarios)
424   
425   
426    for run_data in scenarios:
427        assert len(run_data['break_times']) == len(run_data['break_xs'])
428        assert len(run_data['break_times']) == len(run_data['break_type'])
429       
430        anuga_break_times = []
431        for break_time in run_data['break_times']:
432            anuga_break_times.append( \
433                break_time -  run_data['ANUGA_start_time'])
434           
435        for wave_file, save_as, wave_number in Get_file_name(
436        run_data, outputdir_tag, slope_tag):
437            print "wave_file", wave_file
438            break_type = run_data['break_type'][wave_number]
439            plot_title = run_data['scenario_id'] + \
440                         ' Wave: ' + str(wave_number) + \
441                         ' Break Type: ' + break_type + '\n' + \
442                         'File: ' + wave_file[34:] # not good!
443            plot_foude_slope_stage(wave_file,
444                                   anuga_break_times[wave_number],
445                                   run_data['break_xs'][wave_number],
446                                   plot_title=plot_title,
447                                   break_type=break_type,
448                                   save_as=save_as,
449                                   is_interactive=False,
450                                   froude_min=0,
451                                   froude_max=froude_max,
452                                   slope_min=slope_min,
453                                   slope_max=0)
454       
455       
456   
457def gauges_for_slope(slope_tag, outputdir_tag, scenarios):
458    """
459    This is used to create a stage file, using gauges relivent to
460    finding a slope.
461
462    It also create's a frounde file.
463    """
464    dx = 0.005
465    for run_data in scenarios:
466        point_x = arange(run_data['start_slope_x'],
467                        run_data['finish_slope_x'],
468                        dx).tolist()
469        flume_y_middle = 0.0
470        points = []
471        for gauge_x in point_x:
472            points.append([gauge_x, flume_y_middle])
473        id = run_data['scenario_id']
474   
475        basename = 'zz_' + run_data['scenario_id']
476        outputdir_name = id + outputdir_tag
477        pro_instance = project.Project(['data','flumes','Hinwood_2008'],
478                                       outputdir_name=outputdir_name)
479        end = id + ".csv"
480        interpolate_sww2csv( \
481            pro_instance.outputdir + basename +".sww",
482            points,
483            pro_instance.outputdir + slope_tag + "slope_depth_" + end,
484            pro_instance.outputdir + slope_tag + "slope_velocity_x_" + end,
485            pro_instance.outputdir + slope_tag + "slope_velocity_y_" + end,
486            pro_instance.outputdir + slope_tag + "slope_stage_" + end,
487            pro_instance.outputdir + slope_tag + "slope_froude_" + end,
488            time_thinning=1)
489
490def find_min_slopes(times, slope_locations, slopes,
491                    anuga_break_times, band_offset):
492    """
493   
494    """
495    bands = break_times2bands(anuga_break_times, band_offset)
496
497    waves = []
498    for i,_ in enumerate(bands[0:-1]):
499        max_q, max_q_times = get_min_in_band(bands[i], bands[i+1],
500                                             times, slopes)
501        waves.append({SLOPE_STR:max_q, TIME_STR:max_q_times})
502    return waves
503
504   
505def get_band(min, max, vector, quantity_array, axis):
506    """
507    Return a band of vector and quantity, within (not including) the
508    min, max.
509
510    For a time band, set the axis to 0.
511    For a location band, set the axis to -1.
512   
513    """
514
515    SMALL_MIN = -1e10  # Not that small, but small enough
516    vector = ensure_numeric(vector)
517    quantity_array = ensure_numeric(quantity_array)
518
519    assert min > SMALL_MIN
520    no_maxs = where(less(vector,max), vector, SMALL_MIN)
521    #print "no_maxs", no_maxs
522    band_condition = greater(no_maxs, min)
523    band_vector = compress(band_condition, vector, axis=axis)
524    #print "band_time", band_time
525    #print "quantity_array", quantity_array.shape
526    band_quantity = compress(band_condition, quantity_array, axis=axis)
527    return band_vector, band_quantity
528
529def get_min_in_band(min_time, max_time, time_vector, quantity_array):
530    """
531    given a quantity array, with the 2nd axis being
532    time, represented by the time_vector, find the minimum within
533    the time band.
534
535    Assumes times are positive
536    """
537   
538    time_vector = ensure_numeric(time_vector)
539    quantity_array = ensure_numeric(quantity_array)
540
541    band_time, band_quantity  = get_band(min_time, max_time,
542                                         time_vector, quantity_array, 0)
543    #print "band_quantity",band_quantity
544    try:
545        max_quantity_indices = argmin(band_quantity, axis=0)
546    except:
547        #print "time_vector", time_vector
548        print "min_time",min_time
549        print "max_time", max_time
550        return [],[]
551       
552    #print "max_quantity_indices", max_quantity_indices
553    max_quantity_times = choose(max_quantity_indices, band_time)
554    #print "max_quantity_times", max_quantity_times
555    max_quantities = choose(max_quantity_indices, band_quantity)
556    #print "max_quantities", max_quantities
557
558    return max_quantities, max_quantity_times
559
560def break_times2bands(break_times, band_offset):
561    """
562    Break_times is a list of times, ascending.
563    bands is a list of times, being the midpoints of break_times, with a min
564    and max band added.
565    """
566    assert len(break_times)>2
567   
568    bands = [] #deepcopy(break_times)
569    bands.append(break_times[0]-0.5*(break_times[1]-break_times[0]))
570
571
572    for i,break_x in enumerate(break_times[0:-1]):
573        bands.append(break_times[i]+0.5*(break_times[i+1]-break_times[i]))
574       
575    bands.append(break_times[-1]+0.5*(break_times[-1]-break_times[-2]))
576    bands = ensure_numeric(bands)
577    bands += band_offset
578    return bands
579
580def plot_foude_slope_stage(wave_file,
581                           break_time,
582                           break_x,
583                           save_as=None,
584                           plot_title="",
585                           is_interactive=False,
586                           break_type="",
587                           froude_min=None,
588                           froude_max=None,
589                           slope_min=None,
590                           slope_max=None):
591    """
592    """
593    from pylab import ion, plot, xlabel, ylabel, close, legend, \
594         savefig, title, axis, setp, subplot, grid, axvspan
595    from anuga.shallow_water.data_manager import csv2dict
596
597
598
599    # Load in the csv files and convert info from strings to floats
600    simulation, _ = csv2dict(wave_file)
601    location = [float(x) for x in simulation['x location']]
602    slope = [float(x) for x in simulation['min slope']]
603    time = [float(x) for x in simulation['Time']]
604    froude = [float(x) for x in simulation['Froude']]
605
606    min_location = min(location)
607    max_location = max(location)
608   
609    if is_interactive:
610        ion()
611    # The upper subplot
612    subplot(311)
613    l_froude = plot(location, froude)
614    #setp(l_froude, color='r')
615
616    # Add axis stuff
617    title(plot_title)
618    y_label = "Froude Number"
619    ylabel(y_label)
620    grid(True)
621    axvspan(break_x-0.001,break_x+0.001, facecolor='g')
622    if froude_min is not None and froude_max is not None:
623        axis(ymin=froude_min, ymax=froude_max)
624   
625    # The slope subplot
626    subplot(312)
627    l_slope = plot(location, slope)
628    setp(l_slope, color='r')
629
630    # Add axis stuff and legend
631    x_label = "X location, m"
632    y_label = "Stage slope"
633    #xlabel(x_label)
634    ylabel(y_label)
635    grid(True)
636    axvspan(break_x-0.001,break_x+0.001, facecolor='g')
637    if slope_min is not None and slope_max is not None:
638        axis(ymin=slope_min, ymax=slope_max )
639
640    # The time, x location subplot
641    subplot(313)
642    l_time = plot(location, time)
643    setp(l_time, color='g')
644    #print "break_x", break_x
645    #print "break_time", break_time
646    plot([break_x], [break_time], 'yo')
647    #plot([break_x-1], [], 'yo')
648
649    # Add axis stuff and legend
650    x_label = "X location, m"
651    y_label = "time, sec"
652    xlabel(x_label)
653    ylabel(y_label)
654    grid(True)
655
656   
657    # The order defines the label
658    #legend((legend_exp, legend_sim),'upper left')
659    #legend(('Wave front'),'upper left')
660   
661    if is_interactive:
662        # Wait for enter pressed
663        raw_input()
664
665    if save_as is not None:
666        savefig(save_as)
667   
668    #Need to close this plot
669    close()
670   
671def plot_foude_elements_stage(wave_file,
672                           break_time,
673                           break_x,
674                           save_as=None,
675                           plot_title="",
676                           is_interactive=False,
677                           break_type="",
678                           froude_min=None,
679                           froude_max=None,
680                           slope_min=None,
681                           slope_max=None):
682    """
683    """
684    from pylab import ion, plot, xlabel, ylabel, close, legend, \
685         savefig, title, axis, setp, subplot, grid, axvspan
686    from anuga.shallow_water.data_manager import csv2dict
687
688
689
690    # Load in the csv files and convert info from strings to floats
691    simulation, _ = csv2dict(wave_file)
692    location = [float(x) for x in simulation['x location']]
693    slope = [float(x) for x in simulation['min slope']]
694    time = [float(x) for x in simulation['Time']]
695    froude = [float(x) for x in simulation['Froude']]
696
697    min_location = min(location)
698    max_location = max(location)
699   
700    if is_interactive:
701        ion()
702    # The upper subplot
703    subplot(311)
704    l_froude = plot(location, froude)
705    #setp(l_froude, color='r')
706
707    # Add axis stuff
708    title(plot_title)
709    y_label = "Froude Number"
710    ylabel(y_label)
711    grid(True)
712    axvspan(break_x-0.001,break_x+0.001, facecolor='g')
713    if froude_min is not None and froude_max is not None:
714        axis(ymin=froude_min, ymax=froude_max)
715   
716    # The slope subplot
717    subplot(312)
718    l_slope = plot(location, slope)
719    setp(l_slope, color='r')
720
721    # Add axis stuff and legend
722    x_label = "X location, m"
723    y_label = "Stage slope"
724    #xlabel(x_label)
725    ylabel(y_label)
726    grid(True)
727    axvspan(break_x-0.001,break_x+0.001, facecolor='g')
728    if slope_min is not None and slope_max is not None:
729        axis(ymin=slope_min, ymax=slope_max )
730
731    # The time, x location subplot
732    subplot(313)
733    l_time = plot(location, time)
734    setp(l_time, color='g')
735    #print "break_x", break_x
736    #print "break_time", break_time
737    plot([break_x], [break_time], 'yo')
738    #plot([break_x-1], [], 'yo')
739
740    # Add axis stuff and legend
741    x_label = "X location, m"
742    y_label = "time, sec"
743    xlabel(x_label)
744    ylabel(y_label)
745    grid(True)
746
747   
748    # The order defines the label
749    #legend((legend_exp, legend_sim),'upper left')
750    #legend(('Wave front'),'upper left')
751   
752    if is_interactive:
753        # Wait for enter pressed
754        raw_input()
755
756    if save_as is not None:
757        savefig(save_as)
758   
759    #Need to close this plot
760    close()
761   
762#-------------------------------------------------------------
763if __name__ == "__main__":
764    """
765    """
766    from scenarios import scenarios
767    #scenarios = [scenarios[0]]
768    outputdir_tag = "_good_tri_area_0.01_limiterD"
769    outputdir_tag = "_nolmts_wdth_0.1_z_0.012_ys_0.05_mta_1e-05_G"
770    slope_tag = ""
771    #outputdir_tag = "_test_limiterC"
772    #scenarios = [scenarios[4]] # !!!!!!!!!!!!!!!!!!!!!!
773    #scenarios = scenarios[4:] # !!!!!!!!!!!!!!!!!!!!!!
774   
775    gauges_for_slope(slope_tag, outputdir_tag, scenarios)
776    #auto_graph_slopes(outputdir_tag, scenarios) #, is_interactive=True)
777    #auto_find_min_slopes(slope_tag, outputdir_tag, scenarios)
778    #auto_graph_froudes(outputdir_tag, scenarios)
779    #auto_plot_froude_slopes(slope_tag, outputdir_tag, scenarios)
780    #g = Get_file_name(scenarios[0], outputdir_tag, slope_tag)
781    #for wave_file, save_as, wave_number in Get_file_name(
782     #   scenarios[0], outputdir_tag, slope_tag):
783      #  print "**************"
Note: See TracBrowser for help on using the repository browser.