From 41461646ad087fd9a5d10dd2e594f77c88cf5982 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01> Date: Tue, 15 Jun 2010 22:20:41 +0000 Subject: [PATCH] fixed links to config file in reports and formatting of filter descriptions; added check for whether user requested config file is available that will end execution with a warning if it is not git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@121 8a9318a1-56ba-4d59-b755-99d26321be01 --- pyglance/glance/compare.py | 86 ++++++++++++++++-------------- pyglance/glance/mainreport.txt | 52 +++++++++--------- pyglance/glance/variablereport.txt | 78 ++++++++++++++------------- 3 files changed, 114 insertions(+), 102 deletions(-) diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py index 2b1e5c8..a161944 100644 --- a/pyglance/glance/compare.py +++ b/pyglance/glance/compare.py @@ -295,45 +295,51 @@ def _load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) : requestedConfigFile = optionsSet['configFile'] usedConfigFile = False - if (requestedConfigFile is not None) and os.path.exists(requestedConfigFile): - - LOG.info ("Using Config File Settings") - - # this will handle relative paths - requestedConfigFile = os.path.abspath(os.path.expanduser(requestedConfigFile)) - - # split out the file base name and the file path - (filePath, fileName) = os.path.split(requestedConfigFile) - splitFileName = fileName.split('.') - fileBaseName = fileName[:-3] # remove the '.py' from the end - - # hang onto info about the config file for later - runInfo['config_file_name'] = fileName - runInfo['config_file_path'] = requestedConfigFile - - # load the file - LOG.debug ('loading config file: ' + str(requestedConfigFile)) - glanceRunConfig = imp.load_module(fileBaseName, file(requestedConfigFile, 'U'), - filePath, ('.py' , 'U', 1)) - - # this is an exception, since it is not advertised to the user we don't expect it to be in the file - # (at least not at the moment, it could be added later and if they did happen to put it in the - # config file, it would override this line) - runInfo['shouldIncludeReport'] = not optionsSet['imagesOnly'] if 'imagesOnly' in optionsSet else False - runInfo['noLonLatVars'] = optionsSet['noLonLatVars'] if 'noLonLatVars' in optionsSet else False - - # get everything from the config file - runInfo.update(glanceRunConfig.settings) - if ('noLonLatVars' not in runInfo) or (not runInfo['noLonLatVars']) : - runInfo.update(glanceRunConfig.lat_lon_info) # get info on the lat/lon variables - - # get any requested names - requestedNames = glanceRunConfig.setOfVariables.copy() - # user selected defaults, if they omit any we'll still be using the program defaults - defaultsToUse.update(glanceRunConfig.defaultValues) - - usedConfigFile = True - + if (requestedConfigFile is not None) and (requestedConfigFile != "") : + if not os.path.exists(requestedConfigFile) : + LOG.warn("Could not open config file: \"" + requestedConfigFile + "\"") + LOG.warn("Unable to continue analysis without selected configuration file.") + sys.exit(1) + + else : + + LOG.info ("Using Config File Settings") + + # this will handle relative paths + requestedConfigFile = os.path.abspath(os.path.expanduser(requestedConfigFile)) + + # split out the file base name and the file path + (filePath, fileName) = os.path.split(requestedConfigFile) + splitFileName = fileName.split('.') + fileBaseName = fileName[:-3] # remove the '.py' from the end + + # hang onto info about the config file for later + runInfo['config_file_name'] = fileName + runInfo['config_file_path'] = requestedConfigFile + + # load the file + LOG.debug ('loading config file: ' + str(requestedConfigFile)) + glanceRunConfig = imp.load_module(fileBaseName, file(requestedConfigFile, 'U'), + filePath, ('.py' , 'U', 1)) + + # this is an exception, since it is not advertised to the user we don't expect it to be in the file + # (at least not at the moment, it could be added later and if they did happen to put it in the + # config file, it would override this line) + runInfo['shouldIncludeReport'] = not optionsSet['imagesOnly'] if 'imagesOnly' in optionsSet else False + runInfo['noLonLatVars'] = optionsSet['noLonLatVars'] if 'noLonLatVars' in optionsSet else False + + # get everything from the config file + runInfo.update(glanceRunConfig.settings) + if ('noLonLatVars' not in runInfo) or (not runInfo['noLonLatVars']) : + runInfo.update(glanceRunConfig.lat_lon_info) # get info on the lat/lon variables + + # get any requested names + requestedNames = glanceRunConfig.setOfVariables.copy() + # user selected defaults, if they omit any we'll still be using the program defaults + defaultsToUse.update(glanceRunConfig.defaultValues) + + usedConfigFile = True + # if we didn't get the info from the config file for some reason # (the user didn't want to, we couldn't, etc...) get it from the command line options if not usedConfigFile: @@ -1182,6 +1188,8 @@ def reportGen_library_call (a_path, b_path, var_list=[ ], LOG.debug("Creating variable directory.") os.makedirs(variableDir) varRunInfo['doc_path'] = quote(os.path.join(pathsTemp['out'], './' + 'doc.html')) # should this be somewhere else? + if 'config_file_name' in runInfo : + varRunInfo['config_file_path'] = quote(os.path.join(pathsTemp['out'], './' + runInfo['config_file_name'])) # figure out the masks we want, and then do our statistical analysis mask_a_to_use = None diff --git a/pyglance/glance/mainreport.txt b/pyglance/glance/mainreport.txt index 9902781..e18dbeb 100644 --- a/pyglance/glance/mainreport.txt +++ b/pyglance/glance/mainreport.txt @@ -39,12 +39,37 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved. % endfor ## display info on the config file that was used, if one was - % if ('config_file_name' in runInfo) and (runInfo['config_file_name'] is not None) : + % if ('config_file_path' in runInfo) and (runInfo['config_file_path'] is not None) : <p> A configuration file was used to control the production report.<br> - Please see <a href="${runInfo['config_file_name']}">this copy of the configuration file</a> + Please see <a href="${runInfo['config_file_path']}">this copy of the configuration file</a> for details. </p> + + <p> + ## display information about any data filtering on the lons/lats + <% wasFiltered = False %> + % if ('data_filter_function_lat_in_a' in runInfo) and (not (runInfo['data_filter_function_lat_in_a'] is None)) : + Note: The latitude in file A was filtered.<br> + <% wasFiltered = True %> + % endif + % if ('data_filter_function_lat_in_b' in runInfo) and (not (runInfo['data_filter_function_lat_in_b'] is None)) : + Note: The latitude in file B was filtered.<br> + <% wasFiltered = True %> + % endif + % if ('data_filter_function_lon_in_a' in runInfo) and (not (runInfo['data_filter_function_lon_in_a'] is None)) : + Note: The longitude in file A was filtered.<br> + <% wasFiltered = True %> + % endif + % if ('data_filter_function_lon_in_b' in runInfo) and (not (runInfo['data_filter_function_lon_in_b'] is None)) : + Note: The longitude in file B was filtered.<br> + <% wasFiltered = True %> + % endif + % if wasFiltered : + Please see the original configuration file to view any data filtering functions. + % endif + </p> + % endif ## if the lon/lat variables exist, display info on them @@ -68,29 +93,6 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved. % if ('lon_lat_epsilon' in runInfo) and (runInfo['lon_lat_epsilon'] > 0.0) : longitude/latitude comparison epsilon: ${runInfo['lon_lat_epsilon']}<br> % endif - - <br> - ## display information about any data filtering on the lons/lats - % if ('data_filter_function_lat_in_a' in runInfo) and (not (runInfo['data_filter_function_lat_in_a'] is None)) : - Note: The latitude in file A was filtered. - Please see <a href="${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif - % if ('data_filter_function_lat_in_b' in runInfo) and (not (runInfo['data_filter_function_lat_in_b'] is None)) : - Note: The latitude in file B was filtered. - Please see <a href="${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif - % if ('data_filter_function_lon_in_a' in runInfo) and (not (runInfo['data_filter_function_lon_in_a'] is None)) : - Note: The longitude in file A was filtered. - Please see <a href="${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif - % if ('data_filter_function_lon_in_b' in runInfo) and (not (runInfo['data_filter_function_lon_in_b'] is None)) : - Note: The longitude in file B was filtered. - Please see <a href="${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif </p> ## if there is a problem with the longitude/latitude correlation between the two files, diff --git a/pyglance/glance/variablereport.txt b/pyglance/glance/variablereport.txt index abcdc0d..3c84004 100644 --- a/pyglance/glance/variablereport.txt +++ b/pyglance/glance/variablereport.txt @@ -48,12 +48,50 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved. % endfor ## display info on the config file that was used, if one was - % if ('config_file_name' in runInfo) and (runInfo['config_file_name'] is not None) : + % if ('config_file_path' in runInfo) and (runInfo['config_file_path'] is not None) : <p> A configuration file was used to control the production report.<br> - Please see <a href="${runInfo['config_file_name']}">this copy of the configuration file</a> + Please see <a href="${runInfo['config_file_path']}">this copy of the configuration file</a> for details. </p> + + <p> + <% wasFiltered = False %> + + ## display info about the basic data filters if the data was filtered + % if ('data_filter_function_a' in runInfo) and (not (runInfo['data_filter_function_a'] is None)) : + Note: The data for this variable from file A was filtered.<br> + <% wasFiltered = True %> + % endif + % if ('data_filter_function_b' in runInfo) and (not (runInfo['data_filter_function_b'] is None)) : + Note: The data for this variable from file B was filtered.<br> + <% wasFiltered = True %> + % endif + + ## display information about any data filtering on the lons/lats + % if ('data_filter_function_lat_in_a' in runInfo) and (not (runInfo['data_filter_function_lat_in_a'] is None)) : + Note: The latitude in file A was filtered.<br> + <% wasFiltered = True %> + % endif + % if ('data_filter_function_lat_in_b' in runInfo) and (not (runInfo['data_filter_function_lat_in_b'] is None)) : + Note: The latitude in file B was filtered.<br> + <% wasFiltered = True %> + % endif + % if ('data_filter_function_lon_in_a' in runInfo) and (not (runInfo['data_filter_function_lon_in_a'] is None)) : + Note: The longitude in file A was filtered.<br> + <% wasFiltered = True %> + % endif + % if ('data_filter_function_lon_in_b' in runInfo) and (not (runInfo['data_filter_function_lon_in_b'] is None)) : + Note: The longitude in file B was filtered.<br> + <% wasFiltered = True %> + % endif + + ## show an additional message if there was any filtering + % if wasFiltered : + Please see the original configuration file to view any data filtering functions. + % endif + </p> + % endif ## if the lon/lat variables exist, display info on them @@ -77,29 +115,6 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved. % if ('lon_lat_epsilon' in runInfo) and (runInfo['lon_lat_epsilon'] > 0.0) : longitude/latitude comparison epsilon: ${runInfo['lon_lat_epsilon']}<br> % endif - - <br> - ## display information about any data filtering on the lons/lats - % if ('data_filter_function_lat_in_a' in runInfo) and (not (runInfo['data_filter_function_lat_in_a'] is None)) : - Note: The latitude in file A was filtered. - Please see <a href="../${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif - % if ('data_filter_function_lat_in_b' in runInfo) and (not (runInfo['data_filter_function_lat_in_b'] is None)) : - Note: The latitude in file B was filtered. - Please see <a href="../${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif - % if ('data_filter_function_lon_in_a' in runInfo) and (not (runInfo['data_filter_function_lon_in_a'] is None)) : - Note: The longitude in file A was filtered. - Please see <a href="../${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif - % if ('data_filter_function_lon_in_b' in runInfo) and (not (runInfo['data_filter_function_lon_in_b'] is None)) : - Note: The longitude in file B was filtered. - Please see <a href="../${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif </p> ## if there is a problem with the longitude/latitude correlation between the two files, @@ -164,19 +179,6 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved. % else : "missing" data value: ${str(runInfo['missing_value'])}<br> % endif - - <br> - ## if the data was filtered, say so - % if ('data_filter_function_a' in runInfo) and (not (runInfo['data_filter_function_a'] is None)) : - Note: The data for this variable from file A was filtered. - Please see <a href="../${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif - % if ('data_filter_function_b' in runInfo) and (not (runInfo['data_filter_function_b'] is None)) : - Note: The data for this variable from file B was filtered. - Please see <a href="../${runInfo['config_file_name']}">this copy of - the original configuration file</a> to view the data filtering function.<br> - % endif </p> <h3>Statistical Summary</h3> -- GitLab