import sys from loadValidation import loadValidation from valTable import valTable import pandas as pd path = 'val_struct.pkl' # create validation struct, and make .csv files from it loadValidation() valTable(path) # load in .csv file as command line arg and print it out csv_file = 'valTables/{}_val.csv'.format(sys.argv[1]) table = pd.DataFrame.from_csv(csv_file) print table
''' This code will take in a set of filenames for FVCOM, ADCP, and TG data, and create a validation struct from them. It will then append ''' # set up paths to FVCOM files, ADCP files, and TideGauge files to create struct fvFiles = ['/EcoII/EcoEII_server_data_tree/workspace/simulated/FVCOM/dngrid/july_2012_3D/output/'] adcpFiles = ['/EcoII/EcoEII_server_data_tree/code/jonCode/ADCP_Processing/GP-120726-BPd_avg_10min.mat'] tideFiles = ['/EcoII/EcoEII_server_data_tree/data/observed/GP/TideGauge/Westport_015892_20140325_1212_Z.mat', '/EcoII/EcoEII_server_data_tree/data/observed/DG/TideGauge/DigbyWharf_015893_20140115_2221_Z.mat'] # filenames for input validation structs files = {} files['july_2012_3D'] = '/EcoII/EcoEII_server_data_tree/workspace/simulated/' + \ 'FVCOM/dngrid/july_2012_3D/output/validationStruct.p' # options for vars: elev, speed, dir, tg, u, v, vel (ebb and flo to come soon) vars = [] vars.append('elev') vars.append('speed') vars.append('dir') vars.append('tg') # create validation struct, and make .csv files from it struct = makeStruct(fvFiles, adcpFiles, tideFiles, isStation=True) print 'Struct created' loadValidation(files) print 'Validation loaded' valTable(files, vars) print 'CSV files created'
def _validate_data(self, filename=[], depth=[], plot=False, save_csv=False, debug=False, debug_plot=False): """ This method computes series of standard validation benchmarks. Options: - filename = file name of the .csv file to be saved, string. - depth = depth at which the validation will be performed, float. Only applicable for 3D simulations. - plot = plot series of validation graphs, boolean. - flow = flow comparison by surface flow ('sf'), depth-averaged flow ('daf') or at any depth (float) *References* - NOAA. NOS standards for evaluating operational nowcast and forecast hydrodynamic model systems, 2003. - K. Gunn, C. Stock-Williams. On validating numerical hydrodynamic models of complex tidal flow, International Journal of Marine Energy, 2013 - N. Georgas, A. Blumberg. Establishing Confidence in Marine Forecast Systems: The design and skill assessment of the New York Harbor Observation and Prediction System, version 3 (NYHOPS v3), 2009 - Liu, Y., P. MacCready, B. M. Hickey, E. P. Dever, P. M. Kosro, and N. S. Banas (2009), Evaluation of a coastal ocean circulation model for the Columbia River plume in summer 2004, J. Geophys. Res., 114 """ debug = debug or self._debug debug_plot = debug_plot or self._debug_plot #User input if filename == []: filename = raw_input('Enter filename for csv file: ') filename = str(filename) if type(self._flow) == float: depth = self._flow if (depth == [] and self.Variables._3D): depth = input( 'Depth from surface at which the validation will be performed: ' ) depth = float(depth) if depth < 0.0: depth = -1.0 * depth if depth == []: depth = 5.0 #initialisation vars = [] threeD = self.Variables.sim._3D if self._flow == 'daf': threeD = False if self.Variables.struct['type'] == 'ADCP': (elev_suite, speed_suite, dir_suite, u_suite, v_suite, vel_suite, csp_suite) = compareUV(self.Variables.struct, threeD, plot=plot, depth=depth, save_csv=save_csv, debug=debug, debug_plot=debug_plot) self.Variables.struct['elev_val'] = elev_suite self.Variables.struct['speed_val'] = speed_suite self.Variables.struct['dir_val'] = dir_suite self.Variables.struct['u_val'] = u_suite self.Variables.struct['v_val'] = v_suite self.Variables.struct['vel_val'] = vel_suite # custom benchmark self.Variables.struct['cubic_speed_val'] = csp_suite # Variable to processed vars.append('elev') vars.append('speed') vars.append('dir') vars.append('u') vars.append('v') vars.append('vel') # custom var vars.append('cubic_speed') elif self.Variables.struct['type'] == 'TideGauge': elev_suite_dg = compareTG(self.Variables.struct, plot=plot, save_csv=save_csv, debug=debug, debug_plot=debug_plot) self.Variables.struct['tg_val'] = elev_suite_dg #Variable to processed vars.append('tg') elif self.Variables.struct['type'] == 'Drifter': (elev_suite, speed_suite, dir_suite, u_suite, v_suite, vel_suite, csp_suite) = compareUV(self.Variables.struct, self.Variables._3D, depth=depth, plot=plot, save_csv=save_csv, debug=debug, debug_plot=debug_plot) self.Variables.struct['speed_val'] = speed_suite self.Variables.struct['dir_val'] = dir_suite self.Variables.struct['u_val'] = u_suite self.Variables.struct['v_val'] = v_suite # custom benchmark self.Variables.struct['vel_val'] = vel_suite self.Variables.struct['cubic_speed_val'] = csp_suite # Variable to processed vars.append('speed') vars.append('dir') vars.append('u') vars.append('v') vars.append('vel') # custom var vars.append('vel') vars.append('cubic_speed') else: raise PyseidonError( "-This kind of measurements is not supported yet-") # Make csv file self._Benchmarks = valTable(self.Variables.struct, filename, vars, debug=debug, debug_plot=debug_plot) # Display csv print "---Validation benchmarks---" pd.set_option('display.max_rows', len(self._Benchmarks)) print(self._Benchmarks) pd.reset_option('display.max_rows')
def validate(self, filename=[], depth=[], plot=False): """ This method computes series of standard validation benchmarks. Options: ------ - filename: file name of the .csv file to be saved, string. - depth: depth at which the validation will be performed, float. Only applicable for 3D simulations. - plot: plot series of valiudation graphs, boolean. References: ---------- - NOAA. NOS standards for evaluating operational nowcast and forecast hydrodynamic model systems, 2003. - K. Gunn, C. Stock-Williams. On validating numerical hydrodynamic models of complex tidal flow, International Journal of Marine Energy, 2013 - N. Georgas, A. Blumberg. Establishing Confidence in Marine Forecast Systems: The design and skill assessment of the New York Harbor Observation and Prediction System, version 3 (NYHOPS v3), 2009 - Liu, Y., P. MacCready, B. M. Hickey, E. P. Dever, P. M. Kosro, and N. S. Banas (2009), Evaluation of a coastal ocean circulation model for the Columbia River plume in summer 2004, J. Geophys. Res., 114 """ #User input if filename==[]: filename = input('Enter filename (string) for csv file: ') filename = str(filename) if (depth==[] and self.Variables.sim._3D): depth = input('Depth from surface at which the validation will be performed: ') depth = float(depth) if depth < 0.0: depth = -1.0 * depth if depth==[]: depth=5.0 #initialisation vars = [] if self.Variables.struct['type'] == 'ADCP': (elev_suite, speed_suite, dir_suite, u_suite, v_suite, vel_suite) = compareUV(self.Variables.struct, self.Variables.sim._3D, plot=plot, depth=depth) self.Variables.struct['elev_val'] = elev_suite self.Variables.struct['speed_val'] = speed_suite self.Variables.struct['dir_val'] = dir_suite self.Variables.struct['u_val'] = u_suite self.Variables.struct['v_val'] = v_suite self.Variables.struct['vel_val'] = vel_suite #Variable to processed vars.append('elev') vars.append('speed') vars.append('dir') elif self.Variables.struct['type'] == 'TideGauge': elev_suite_dg = compareTG(self.Variables.struct) self.Variables.struct['tg_val'] = elev_suite_dg #Variable to processed vars.append('tg') else: print "-This type of measurements is not supported yet-" sys.exit() #Make csv file valTable(self.Variables.struct, filename, vars) #Display csv csvName = filename + '_val.csv' csv_con = open(csvName, 'r') csv_cont = list(csv.reader(csv_con, delimiter=',')) print "---Validation benchmarks---" print(70*'-') for row in csv_cont: row = [str(e) for e in row[:][1:]] print('\t'.join(row)) print(70*'-')
def _validate_data(self, filename=[], depth=[], plot=False, save_csv=False, debug=False, debug_plot=False): """ This method computes series of standard validation benchmarks. Options: - filename = file name of the .csv file to be saved, string. - depth = depth at which the validation will be performed, float. Only applicable for 3D simulations. - plot = plot series of validation graphs, boolean. - flow = flow comparison by surface flow ('sf'), depth-averaged flow ('daf') or at any depth (float) *References* - NOAA. NOS standards for evaluating operational nowcast and forecast hydrodynamic model systems, 2003. - K. Gunn, C. Stock-Williams. On validating numerical hydrodynamic models of complex tidal flow, International Journal of Marine Energy, 2013 - N. Georgas, A. Blumberg. Establishing Confidence in Marine Forecast Systems: The design and skill assessment of the New York Harbor Observation and Prediction System, version 3 (NYHOPS v3), 2009 - Liu, Y., P. MacCready, B. M. Hickey, E. P. Dever, P. M. Kosro, and N. S. Banas (2009), Evaluation of a coastal ocean circulation model for the Columbia River plume in summer 2004, J. Geophys. Res., 114 """ debug = debug or self._debug debug_plot = debug_plot or self._debug_plot #User input if filename==[]: filename = raw_input('Enter filename for csv file: ') filename = str(filename) if type(self._flow) == float: depth = self._flow if (depth==[] and self.Variables._3D): depth = input('Depth from surface at which the validation will be performed: ') depth = float(depth) if depth < 0.0: depth = -1.0 * depth if depth==[]: depth=5.0 #initialisation vars = [] threeD = self.Variables.sim._3D if self._flow == 'daf': threeD = False if self.Variables.struct['type'] == 'ADCP': (elev_suite, speed_suite, dir_suite, u_suite, v_suite, vel_suite, csp_suite) = compareUV(self.Variables.struct, threeD, plot=plot, depth=depth, save_csv=save_csv, debug=debug, debug_plot=debug_plot) self.Variables.struct['elev_val'] = elev_suite self.Variables.struct['speed_val'] = speed_suite self.Variables.struct['dir_val'] = dir_suite self.Variables.struct['u_val'] = u_suite self.Variables.struct['v_val'] = v_suite self.Variables.struct['vel_val'] = vel_suite # custom benchmark self.Variables.struct['cubic_speed_val'] = csp_suite # Variable to processed vars.append('elev') vars.append('speed') vars.append('dir') vars.append('u') vars.append('v') vars.append('vel') # custom var vars.append('cubic_speed') elif self.Variables.struct['type'] == 'TideGauge': elev_suite_dg = compareTG(self.Variables.struct, plot=plot, save_csv=save_csv, debug=debug, debug_plot=debug_plot) self.Variables.struct['tg_val'] = elev_suite_dg #Variable to processed vars.append('tg') elif self.Variables.struct['type'] == 'Drifter': (elev_suite, speed_suite, dir_suite, u_suite, v_suite, vel_suite, csp_suite) = compareUV(self.Variables.struct, self.Variables._3D, depth=depth, plot=plot, save_csv=save_csv, debug=debug, debug_plot=debug_plot) self.Variables.struct['speed_val'] = speed_suite self.Variables.struct['dir_val'] = dir_suite self.Variables.struct['u_val'] = u_suite self.Variables.struct['v_val'] = v_suite # custom benchmark self.Variables.struct['vel_val'] = vel_suite self.Variables.struct['cubic_speed_val'] = csp_suite # Variable to processed vars.append('speed') vars.append('dir') vars.append('u') vars.append('v') vars.append('vel') # custom var vars.append('vel') vars.append('cubic_speed') else: raise PyseidonError("-This kind of measurements is not supported yet-") # Make csv file self._Benchmarks = valTable(self.Variables.struct, filename, vars, debug=debug, debug_plot=debug_plot) # Display csv print "---Validation benchmarks---" pd.set_option('display.max_rows', len(self._Benchmarks)) print(self._Benchmarks) pd.reset_option('display.max_rows')