Changeset 5691 for anuga_validation/Hinwood_2008/calc_norm.py
 Timestamp:
 Aug 27, 2008, 8:52:21 AM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

anuga_validation/Hinwood_2008/calc_norm.py
r5689 r5691 1 1 """ 2 This is getting really messy.3 2 4 3 All err results are going into the same dir, and it can't really be changed. … … 12 11 # Standard modules 13 12 import os 14 from os import sep, path15 13 from csv import writer 16 14 from time import localtime, strftime 17 15 18 16 # Related major packages 19 from Numeric import arange, array, zeros, Float, where, greater, less, \ 20 compress, argmin, choose, searchsorted, sqrt, sum 21 22 import project 23 from os import sep 17 from Numeric import zeros, Float, where, greater, less, compress, sqrt, sum 18 24 19 from anuga.shallow_water.data_manager import csv2dict 25 20 from anuga.utilities.numerical_tools import ensure_numeric, err, norm 26 27 21 from anuga.utilities.interp import interp 28 22 … … 33 27 assert min > SMALL_MIN 34 28 no_maxs = where(less(vector,max), vector, SMALL_MIN) 35 #print "no_maxs", no_maxs36 29 band_condition = greater(no_maxs, min) 37 30 return band_condition … … 41 34 y_location_tag=':0.0'): 42 35 """ 43 Given a bunchof scenarios that have CSV guage files, calc the36 Given a list of scenarios that have CSV guage files, calc the 44 37 err, Number_of_samples and rmsd for all gauges in each scenario. 45 38 Write this info to a file for each scenario. … … 67 60 time_sim = ensure_numeric(time_sim) 68 61 time_exp = ensure_numeric(time_exp) 69 #print "min(time_exp)", min(time_exp)70 #print "max(time_exp)", max(time_exp)71 62 72 63 condition = get_max_min_condition_array(run_data['wave_times'][0], 73 64 run_data['wave_times'][1], 74 65 time_exp) 75 time_exp_cut = compress(condition, time_exp) #, axis=axis) 76 #print "min(time_exp_cut)", min(time_exp_cut) 77 #print "max(time_exp_cut)", max(time_exp_cut) 78 79 #assert min(time_sim) < min(time_exp) 66 time_exp_cut = compress(condition, time_exp) 80 67 81 68 print "Writing to ", file_err … … 100 87 err_list.append(norm) 101 88 points.append(len(quantity_sim_interp)) 102 rmsd_list.append(norm/sqrt(len(quantity_sim_interp))) 103 #print "norm", norm 104 #for i in range(len(quantity_sim_interp)): 105 106 #print "quantity_sim_interp", quantity_sim_interp[i] 107 #print "quantity_exp_cut", quantity_exp_cut[i] 89 rmsd_list.append(norm/sqrt(len(quantity_sim_interp))) 108 90 assert len(location_exps) == len(err_list) 109 91 … … 124 106 the first colum explains the rows. 125 107 """ 126 #slope, _ = csv2dict(file_sim)127 108 128 109 # Read the depth file … … 137 118 depths = zeros(n_time, Float) # 138 119 sensors = zeros((n_time,n_sensors), Float) 139 quantity_locations = title.split(',') #(',')120 quantity_locations = title.split(',') 140 121 quantity_locations.pop(0) # remove 'time' 141 122 … … 144 125 145 126 for i, line in enumerate(lines): 146 fields = line.split(',') #(',')127 fields = line.split(',') 147 128 fields = [float(j) for j in fields] 148 129 times[i] = fields[0] 149 130 sensors[i] = fields[1:] # 1: to remove time 150 131 151 #print "times",times152 #print "locations", locations153 #print "sensors", sensors154 132 return times, locations, sensors 155 133 … … 161 139 def err_files(scenarios, outputdir_tag, quantity='stage'): 162 140 """ 163 The err files, for a list of scenarios141 Create a list of err files, for a list of scenarios. 164 142 """ 165 143 file_errs = [] … … 173 151 174 152 def compare_different_settings(outputdir_tag, scenarios, quantity='stage'): 175 153 """ 154 Calculate the RMSD for all the tests in a scenario 155 """ 176 156 files = err_files(scenarios, outputdir_tag, quantity=quantity) 177 157 err = 0.0 … … 195 175 def err_addition(err_list, number_of_samples_list): 196 176 """ 197 err1 is the err value (sqrt(sum_over_x&y((xi  yi)^2))) for a set of values 198 number_of_samples1 is the number of values associated with the err. 177 This function 'sums' a list of errs and sums a list of samples 178 179 err is the err value (sqrt(sum_over_x&y((xi  yi)^2))) for a set of values. 180 number_of_samples is the number of values associated with the err. 199 181 200 182 If this function gets used alot, maybe pull this out and make it an object … … 212 194 from scenarios import scenarios 213 195 214 215 scenarios = [scenarios[0]] # !!!!!!!!!!!!!!!!!!!!!! 216 #scenarios = scenarios[4:] # !!!!!!!!!!!!!!!!!!!!!! 217 218 219 outputdir_tag = "_nolmts_wdth_0.1_z_0.0_ys_0.5_mta_0.01" 196 #scenarios = [scenarios[0]] # !!!!!!!!!!!!!!!!!!!!!! 197 198 outputdir_tag = "_nolmts_wdth_0.1_z_0.0_ys_0.01_mta_0.01" 220 199 calc_norms = True 221 200 #calc_norms = False
Note: See TracChangeset
for help on using the changeset viewer.