source: anuga_work/production/dampier_2006/get_timeseries_and.py @ 4308

Last change on this file since 4308 was 4308, checked in by nick, 18 years ago

update to dampier

File size: 5.7 KB
Line 
1"""
2Generate images of "gauges" for production run
3
4Inputs:
5
6production dirs: dictionary of production directories with a
7                 association to that simulation run, eg high tide,
8                 low tide and MSL.
9                   
10Outputs:
11
12* figures used for report stored in the report_figure directory
13
14"""
15
16from os import sep, getcwd, access, F_OK, mkdir, getenv
17#from anuga.abstract_2d_finite_volumes.util import get_data_from_file
18import os
19from Numeric import zeros, array, allclose
20from os import getcwd, sep, altsep, mkdir, access, F_OK
21import project
22from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, sww2timeseries, get_data_from_file
23
24#makes the csv files from the evolved model
25
26
27home = getenv('INUNDATIONHOME') #Sandpit's parent dir   
28#user = get_user_name()
29data = 'data'
30state = 'western_australia'
31scenario_name = 'dampier.sww'
32scenario = 'dampier_tsunami_scenario_2006'
33#scenario = 'test_dampier'
34an = 'anuga'
35bo = 'boundaries'
36
37run_time = '20070312_030201_run'
38production_dirs = {#run_time: 'URS evolved data'#,
39                   'boundaries': 'URS boundary condition'
40                   }
41
42topo = 'topographies'
43out = 'outputs'
44urs = 'urs'
45gridded = '1_10000'
46
47#gauge_filename = os.path.join(home,data,state,scenario,an,out,scenario_name,'.sww')
48#sww_filename ={}
49#swwfiles = {}
50
51#sww_filename[os.path.join(home,data,state,scenario,an,out,run_time,scenario_name)] = run_time
52
53gauge_boundary_filename = 'gauges_time_series_near_top.csv'
54gauge_evolved_filename = 'gauges_time_series_near_top.csv'
55#gauge_boundary_filename = 'gauges_time_series_middle.csv'
56#gauge_evolved_filename = 'gauges_time_series_middle.csv'
57
58#gauge_boundary_filename = 'gauges_time_series_first.csv'
59#gauge_evolved_filename = 'gauges_time_series_first.csv'
60
61boundary_dir_filename = os.path.join(home,data,state,scenario,an,bo,gauge_boundary_filename)
62print'boundary_dir_filename',boundary_dir_filename
63out_dir=os.path.join(home,data,state,scenario,an,out,run_time)
64out_dir_name= out_dir+sep
65
66evolved_dir_filename= os.path.join(home,data,state,scenario,an,out,run_time,gauge_evolved_filename)
67
68#start_screen_catcher(out_dir_name, print_to_screen=True)
69start_screen_catcher(out_dir_name, extra_info='get_time', print_to_screen=True)
70print'boundary_dir_filename',boundary_dir_filename
71print'evolved_dir_filename',evolved_dir_filename
72
73#file_loc = project.output_dir + label_id + sep
74#swwfile = file_loc + project.scenario_name + '.sww'
75#swwfiles[swwfile] = label_id
76print "hella what the!"
77'''
78#get the timeseries for the evolved sww file
79texname, elev_output = sww2timeseries(sww_filename,
80                                      project.gauges_dir_name_simple,
81                                      production_dirs,
82                                      report = False,
83                                      #reportname = report_name,
84                                      plot_quantity = ['stage', 'momentum'],
85                                      surface = False,
86                                      time_min = None,
87                                      time_max = None,
88                                      title_on = False,
89                                      verbose = True)
90                                     
91'''                                     
92swwfiles = {}
93                                     
94for label_id in production_dirs.keys():
95       
96    if label_id == 'boundaries':
97        print 'boundaries'
98#        file_loc = project.boundaries_in_dir
99#        swwfile = project.boundaries_dir_name3 + '.sww'
100        swwfile = project.boundaries_dir_name6+'.sww'
101    else:
102#        file_loc = project.output_dir + label_id + sep
103        file_loc = out_dir_name
104        swwfile = file_loc + project.scenario_name + '.sww'
105    swwfiles[swwfile] = label_id
106    print"swwfiles",swwfiles
107       
108texname, elev_output = sww2timeseries(swwfiles,
109                                      project.gauges_dir_name_simple,
110                                      production_dirs,
111                                      report = False,
112                                      #reportname = report_name,
113                                      plot_quantity = ['stage', 'xmomentum', 'ymomentum'],
114#                                      plot_quantity = ['stage', 'momentum'],
115                                      surface = False,
116                                      time_min = None,
117                                      time_max = None,
118                                      title_on = False,
119#                                      use_cache = True,
120                                      verbose = True)
121
122#makes the csv files from the evolved model
123
124
125
126e_time, e_stage, e_momentum, e_speed, e_elevation = get_data_from_file(evolved_dir_filename)
127
128print'boundary_dir_filename',boundary_dir_filename
129b_time, b_stage, b_momentum, b_speed, b_elevation = get_data_from_file(boundary_dir_filename)
130
131# compares the 2 models
132j=0
133k=2
134b_sample = []
135e_sample = []
136for i in range(len(b_time)):
137#    if j<(len(e_time)) and b_time[i] == e_time[j]:
138    if j<(len(e_time)) and k<(len(e_time)) and b_time[i] == e_time[j]:
139        b_sample.append(float(b_stage[i]))
140        e_sample.append(float(e_stage[k]))
141        if k <len(e_time): print 'time e equal b:', b_time[i], b_stage[i],i, j, b_sample[j],e_stage[j], e_stage[k],(len(e_time)-1)
142        j = j +1
143        k = k +1
144
145
146e_stage.pop()
147e_stage.pop()
148 
149print len(b_sample), len(e_stage)
150#assert allclose (b_sample, e_sample, 0.5, 0.5)
151
152assert allclose (b_sample, e_stage, 0.5, 0.5) 
153print "test successful" 
154
155
156
157
158                             
159                                         
Note: See TracBrowser for help on using the repository browser.