Changeset 781
- Timestamp:
- 04/07/11 17:02:42 (2 years ago)
- Location:
- MGET/Branches/Jason
- Files:
-
- 26 added
- 8 modified
-
LICENSE.txt (modified) (1 diff)
-
PythonPackage/setup.py (modified) (1 diff)
-
PythonPackage/src/GeoEco/ArcGIS.py (modified) (1 diff)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/LICENSE.txt (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/__init__.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/_ni_support.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/filters.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/fourier.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/info.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/interpolation.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/io.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/measurements.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/morphology.py (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/nd_image.c (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/nd_image.h (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_filters.c (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_filters.h (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_fourier.c (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_fourier.h (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_interpolation.c (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_interpolation.h (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_measure.c (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_measure.h (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_morphology.c (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_morphology.h (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_support.c (added)
-
PythonPackage/src/GeoEco/AssimilatedModules/ndimage/src/ni_support.h (added)
-
PythonPackage/src/GeoEco/DataProducts/HYCOM.py (modified) (1 diff)
-
PythonPackage/src/GeoEco/OceanographicAnalysis/Eddies.py (modified) (2 diffs)
-
PythonPackage/src/GeoEco/OceanographicAnalysis/FindOkuboWeissEddies.py (modified) (4 diffs)
-
PythonPackage/src/GeoEco/Statistics/Modeling.py (modified) (2 diffs)
-
PythonPackage/src/GeoEco/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
MGET/Branches/Jason/LICENSE.txt
r714 r781 1042 1042 1043 1043 This software is based in part on the work of the Independent JPEG Group. 1044 1045 ------------------------------------------------------------------------------- 1046 1047 Files in the GeoEco.AssimilatedModules.ndimage package are from the 1048 scipy.ndimage Python module. 1049 1050 Copyright (C) 2003-2005 Peter J. Verveer 1051 1052 Redistribution and use in source and binary forms, with or without 1053 modification, are permitted provided that the following conditions are met: 1054 1055 1. Redistributions of source code must retain the above copyright 1056 notice, this list of conditions and the following disclaimer. 1057 1058 2. Redistributions in binary form must reproduce the above 1059 copyright notice, this list of conditions and the following 1060 disclaimer in the documentation and/or other materials provided 1061 with the distribution. 1062 1063 3. The name of the author may not be used to endorse or promote 1064 products derived from this software without specific prior 1065 written permission. 1066 1067 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1068 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 1069 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 1070 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 1071 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 1072 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 1073 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1074 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 1075 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 1076 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1077 POSSIBILITY OF SUCH DAMAGE. -
MGET/Branches/Jason/PythonPackage/setup.py
r770 r781 1120 1120 packageData['GeoEco'].append(os.path.join('AssimilatedModules', 'rpy', os.path.basename(rpyLib))) 1121 1121 1122 # Add assimilated module: ndimage (from scipy). Because this 1123 # module depends on numpy's C interface and that interface is not 1124 # backwards/forwards compatible between numpy versions, we have to 1125 # generate one for each version of numpy that we support. 1126 1127 if sys.platform.lower() == 'win32': 1128 packages.append('GeoEco.AssimilatedModules.ndimage') 1129 extensionModules.extend(CreateNumpyDependentExtensionModules(srcDir, 1130 'GeoEco.AssimilatedModules.ndimage._nd_image', 1131 sources=['build/src/GeoEco/AssimilatedModules/ndimage/src/nd_image.c', 1132 'build/src/GeoEco/AssimilatedModules/ndimage/src/ni_filters.c', 1133 'build/src/GeoEco/AssimilatedModules/ndimage/src/ni_fourier.c', 1134 'build/src/GeoEco/AssimilatedModules/ndimage/src/ni_interpolation.c', 1135 'build/src/GeoEco/AssimilatedModules/ndimage/src/ni_measure.c', 1136 'build/src/GeoEco/AssimilatedModules/ndimage/src/ni_morphology.c', 1137 'build/src/GeoEco/AssimilatedModules/ndimage/src/ni_support.c'], 1138 include_dirs=['build/src/GeoEco/AssimilatedModules/ndimage/src']) 1139 else: 1140 sys.exit('GeoEco cannot be built on this platform yet because support has not been added for building the GeoEco.AssimilatedModules.ndimage module.') 1141 1122 1142 # Add miscellaneous package data files. 1123 1143 -
MGET/Branches/Jason/PythonPackage/src/GeoEco/ArcGIS.py
r765 r781 1151 1151 sourceCode = sourceCode + ')' 1152 1152 1153 # Invoke the method. 1154 1155 self._LogDebug(_(u'ArcGIS %s object 0x%08X: Invoking %s%s...') % (self._Name, id(self._Object), method.__name__, inspect.formatargvalues(_args, _varargs, _varkw, _locals))) 1153 # Before invoking the method, check whether it is a Spatial 1154 # Analyst tool, which is indicated by it ending in "_sa". If 1155 # it is, create a temp directory and set the ScratchWorkspace 1156 # to it. 1157 # 1158 # We do this because some Spatial Analyst tools, particularly 1159 # the Map Algebra tools, create temporary ArcInfo binary grids 1160 # as part of their processing, but they do not delete them 1161 # upon completion. These will accumulate in the user's TEMP 1162 # directory unless a ScratchWorkspace has been set. Once 1163 # several thousand exist, the Spatial Analyst tools will stop 1164 # working (ArcCatalog or ArcMap will crash) until they are 1165 # deleted. 1166 # 1167 # Users typically encounter this only after running several 1168 # thousand Spatial Analyst tools without logging off. Windows 1169 # deletes the contents of the TEMP directory at logoff. 1170 # Nonetheless, certain batch jobs, such as converting 1171 # thousands of HDFs to rasters, are common scenarios for 1172 # GeoEco users so we must protect them from this problem. 1156 1173 1157 1174 try: 1158 # If we imported pythoncom successfully, invoke the method 1159 # and catch com_error. Raise com_error as ArcGISError. 1160 # Note: call raise, rather than Logger.RaiseException. 1161 # This is so the caller can swallow the exception, if 1162 # needed. 1163 1175 tempDir = None 1176 scratchDir = None 1177 if self._Name == u'Geoprocessor' and method.__name__.endswith('_sa'): 1178 scratchDir = self.ScratchWorkspace 1179 from GeoEco.DataManagement.Directories import TemporaryDirectory 1180 tempDir = TemporaryDirectory() 1181 self.ScratchWorkspace = tempDir.Path 1182 1183 # Invoke the method. 1184 1185 self._LogDebug(_(u'ArcGIS %s object 0x%08X: Invoking %s%s...') % (self._Name, id(self._Object), method.__name__, inspect.formatargvalues(_args, _varargs, _varkw, _locals))) 1186 1187 try: 1188 # If we imported pythoncom successfully, invoke the method 1189 # and catch com_error. Raise com_error as ArcGISError. 1190 # Note: call raise, rather than Logger.RaiseException. 1191 # This is so the caller can swallow the exception, if 1192 # needed. 1193 1194 1195 if sys.modules.has_key('pythoncom'): 1196 try: 1197 value = eval(sourceCode, globals(), locals()) 1198 except sys.modules['pythoncom'].com_error, (hr, msg, exc, arg): 1199 self._LogReturnedGeoprocessingMessages(method.__name__) 1200 from GeoEco.COM import FormatCOMError 1201 if self._Name == u'Geoprocessor' and method.__name__.lower() not in _ArcGISObjectWrapper._NonGeoprocessingToolMethods: 1202 raise ArcGISError(_(u'The ArcGIS %(tool)s geoprocessing tool failed when given the parameters %(params)s and reported %(error)s') % {u'tool': method.__name__, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': FormatCOMError(hr, msg, exc, arg)}) 1203 else: 1204 raise ArcGISError(_(u'The %(func)s function of the ArcGIS %(obj)s object failed when given the parameters %(params)s and reported %(error)s') % {u'func': method.__name__, u'obj': self._Name, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': FormatCOMError(hr, msg, exc, arg)}) 1205 1206 # If we did not import pythoncom, invoke the method and allow the 1207 # outer exception handler to catch any errors. 1208 1209 else: 1210 value = eval(sourceCode, globals(), locals()) 1211 1212 # If we catch ArcGISError here, it is the com_error we just caught. 1213 # Reraise it. 1164 1214 1165 if sys.modules.has_key('pythoncom'): 1215 except ArcGISError: 1216 raise 1217 1218 # If we catch some other exception, raise it as ArcGISError. 1219 # Note: call raise, rather than Logger.RaiseException. This is 1220 # so the caller can swallow the exception, if needed. 1221 1222 except Exception, e: 1223 self._LogReturnedGeoprocessingMessages(method.__name__) 1224 if self._Name == u'Geoprocessor' and method.__name__.lower() not in _ArcGISObjectWrapper._NonGeoprocessingToolMethods: 1225 raise ArcGISError(_(u'The ArcGIS %(tool)s geoprocessing tool failed when given the parameters %(params)s and reported %(error)s: %(msg)s') % {u'tool': method.__name__, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': e.__class__.__name__, u'msg': unicode(e)}) 1226 else: 1227 raise ArcGISError(_(u'The %(func)s function of the ArcGIS %(obj)s object failed when given the parameters %(params)s and reported %(error)s') % {u'func': method.__name__, u'obj': self._Name, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': e.__class__.__name__, u'msg': unicode(e)}) 1228 1229 # The method executed successfully. Log any geoprocessing messages it 1230 # generated. 1231 1232 self._LogReturnedGeoprocessingMessages(method.__name__) 1233 1234 # Log the returned value. 1235 1236 self._LogDebug(_(u'ArcGIS %s object 0x%08X: %s returned %s') % (self._Name, id(self._Object), method.__name__, repr(value))) 1237 1238 # If we created a temporary directory to manage the rasters 1239 # leaked by the Spatial Analyst tools, delete it now. 1240 1241 finally: 1242 if tempDir is not None: 1166 1243 try: 1167 value = eval(sourceCode, globals(), locals()) 1168 except sys.modules['pythoncom'].com_error, (hr, msg, exc, arg): 1169 self._LogReturnedGeoprocessingMessages(method.__name__) 1170 from GeoEco.COM import FormatCOMError 1171 if self._Name == u'Geoprocessor' and method.__name__.lower() not in _ArcGISObjectWrapper._NonGeoprocessingToolMethods: 1172 raise ArcGISError(_(u'The ArcGIS %(tool)s geoprocessing tool failed when given the parameters %(params)s and reported %(error)s') % {u'tool': method.__name__, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': FormatCOMError(hr, msg, exc, arg)}) 1173 else: 1174 raise ArcGISError(_(u'The %(func)s function of the ArcGIS %(obj)s object failed when given the parameters %(params)s and reported %(error)s') % {u'func': method.__name__, u'obj': self._Name, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': FormatCOMError(hr, msg, exc, arg)}) 1175 1176 # If we did not import pythoncom, invoke the method and allow the 1177 # outer exception handler to catch any errors. 1178 1179 else: 1180 value = eval(sourceCode, globals(), locals()) 1181 1182 # If we catch ArcGISError here, it is the com_error we just caught. 1183 # Reraise it. 1184 1185 except ArcGISError: 1186 raise 1187 1188 # If we catch some other exception, raise it as ArcGISError. 1189 # Note: call raise, rather than Logger.RaiseException. This is 1190 # so the caller can swallow the exception, if needed. 1191 1192 except Exception, e: 1193 self._LogReturnedGeoprocessingMessages(method.__name__) 1194 if self._Name == u'Geoprocessor' and method.__name__.lower() not in _ArcGISObjectWrapper._NonGeoprocessingToolMethods: 1195 raise ArcGISError(_(u'The ArcGIS %(tool)s geoprocessing tool failed when given the parameters %(params)s and reported %(error)s: %(msg)s') % {u'tool': method.__name__, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': e.__class__.__name__, u'msg': unicode(e)}) 1196 else: 1197 raise ArcGISError(_(u'The %(func)s function of the ArcGIS %(obj)s object failed when given the parameters %(params)s and reported %(error)s') % {u'func': method.__name__, u'obj': self._Name, u'params': inspect.formatargvalues(_args, _varargs, _varkw, _locals), u'error': e.__class__.__name__, u'msg': unicode(e)}) 1198 1199 # The method executed successfully. Log any geoprocessing messages it 1200 # generated. 1201 1202 self._LogReturnedGeoprocessingMessages(method.__name__) 1203 1204 # Log the returned value. 1205 1206 self._LogDebug(_(u'ArcGIS %s object 0x%08X: %s returned %s') % (self._Name, id(self._Object), method.__name__, repr(value))) 1244 del tempDir 1245 except: 1246 pass 1247 self.ScratchWorkspace = scratchDir 1207 1248 1208 1249 # Convert the returned value from the geoprocessor's preferred type to -
MGET/Branches/Jason/PythonPackage/src/GeoEco/DataProducts/HYCOM.py
r716 r781 1141 1141 # from the HYCOM bi-polar region. 1142 1142 1143 if sliceList[-2].stop > =2172-390:1143 if sliceList[-2].stop > 2172-390: 1144 1144 extendedYSlice = slice(max(sliceList[-2].start, 2172-390), sliceList[-2].stop) 1145 1145 ySliceToWrite = slice(extendedYSlice.start - sliceList[-2].start, extendedYSlice.stop - sliceList[-2].start) -
MGET/Branches/Jason/PythonPackage/src/GeoEco/OceanographicAnalysis/Eddies.py
r772 r781 264 264 eddiesFile, 265 265 eddyMetadataFile, 266 'None', # We do not want FindOkuboWeissEddies.py to write the Okubo-Weiss parameter to a file. 266 267 self._OWThresholdType, 267 268 repr(self._OWThresholdValue), … … 532 533 Research Letters 34: L15606. 533 534 534 Hens en, S.A., and Thomas, A.C. 2007. A census of oceanic anticyclonic535 Henson, S.A., and Thomas, A.C. 2007. A census of oceanic anticyclonic 535 536 eddies in the Gulf of Alaska. Deep Sea Research I 55: 163-176. 536 537 -
MGET/Branches/Jason/PythonPackage/src/GeoEco/OceanographicAnalysis/FindOkuboWeissEddies.py
r772 r781 29 29 # Parse the command line arguments. 30 30 31 if len(sys.argv) != 19:31 if len(sys.argv) != 20: 32 32 sys.exit(_(u'Error: Invalid number of arguments. Expected 19, got %i')) 33 33 … … 97 97 sys.exit(_(u'Error: The output directory "%(dir)s" does not exist.') % {u'dir': os.path.dirname(eddyMetadataFile)}) 98 98 99 owThresholdType = sys.argv[14] 99 owParameterFile = sys.argv[14] 100 if owParameterFile.lower() != 'none': 101 if os.path.exists(owParameterFile): 102 sys.exit(_(u'Error: The output Okubo-Weiss parameter file "%(file)s" already exists.') % {u'file': owParameterFile}) 103 if not os.path.isdir(os.path.dirname(owParameterFile)): 104 sys.exit(_(u'Error: The output directory "%(dir)s" does not exist.') % {u'dir': os.path.dirname(owParameterFile)}) 105 else: 106 owParameterFile = None 107 108 owThresholdType = sys.argv[15] 100 109 101 110 try: 102 owThresholdValue = float(sys.argv[1 5])111 owThresholdValue = float(sys.argv[16]) 103 112 except: 104 sys.exit(_(u'Error: Invalid owThresholdValue: %(val)s') % {u'val': sys.argv[1 5]})113 sys.exit(_(u'Error: Invalid owThresholdValue: %(val)s') % {u'val': sys.argv[16]}) 105 114 106 if sys.argv[1 6].lower() != 'none':115 if sys.argv[17].lower() != 'none': 107 116 try: 108 minArea = float(sys.argv[1 6])117 minArea = float(sys.argv[17]) 109 118 except: 110 sys.exit(_(u'Error: Invalid minArea: %(val)s') % {u'val': sys.argv[1 6]})119 sys.exit(_(u'Error: Invalid minArea: %(val)s') % {u'val': sys.argv[17]}) 111 120 else: 112 121 minArea = 0. 113 122 114 if sys.argv[1 7].lower() != 'none':123 if sys.argv[18].lower() != 'none': 115 124 try: 116 minA2P = float(sys.argv[1 7])125 minA2P = float(sys.argv[18]) 117 126 except: 118 sys.exit(_(u'Error: Invalid minA2P: %(val)s') % {u'val': sys.argv[1 7]})127 sys.exit(_(u'Error: Invalid minA2P: %(val)s') % {u'val': sys.argv[18]}) 119 128 else: 120 129 minA2P = 0. 121 130 122 if sys.argv[1 8].lower() != 'none':131 if sys.argv[19].lower() != 'none': 123 132 try: 124 minDuration = float(sys.argv[1 8])133 minDuration = float(sys.argv[19]) 125 134 except: 126 sys.exit(_(u'Error: Invalid minDuration: %(val)s') % {u'val': sys.minDuration[1 8]})135 sys.exit(_(u'Error: Invalid minDuration: %(val)s') % {u'val': sys.minDuration[19]}) 127 136 else: 128 137 minDuration = 0. … … 165 174 # Call the MATLAB function to find the eddies. 166 175 167 eddies, eddyMetadata = MatlabFunctions.IdentifyOkuboWeissEddies(latitudes, widths, heights, ssh, owThresholdType, owThresholdValue, minArea, minA2P, minDuration)[1:]176 W, eddies, eddyMetadata = MatlabFunctions.IdentifyOkuboWeissEddies(latitudes, widths, heights, ssh, owThresholdType, owThresholdValue, minArea, minA2P, minDuration) 168 177 169 178 # Write the output files. … … 171 180 eddies.tofile(eddiesFile) 172 181 eddyMetadata.tofile(eddyMetadataFile) 182 if owParameterFile is not None: 183 W.tofile(owParameterFile) 173 184 174 185 # If we got an exception, print it and exit with error code 1. -
MGET/Branches/Jason/PythonPackage/src/GeoEco/Statistics/Modeling.py
r765 r781 421 421 dataFrameName, newPredictionsName = cls._PredictionsForArcGISTable(inputModelFile, 'model', evaluationDataTable, where) 422 422 predictedValues = newPredictionsName 423 actualValues = ' %s$%s' % (dataFrameName, r('all.vars(attr(terms(model$formula), "variables")[[2]])[[1]]'))423 actualValues = 'na.omit(%s)$%s' % (dataFrameName, r('all.vars(attr(terms(model$formula), "variables")[[2]])[[1]]')) 424 424 425 425 # Create the plot. … … 519 519 dataFrameName, newPredictionsName = cls._PredictionsForArcGISTable(inputModelFile, 'model', evaluationDataTable, where) 520 520 predictedValues = newPredictionsName 521 actualValues = ' %s$%s' % (dataFrameName, r('all.vars(attr(terms(model$formula), "variables")[[2]])[[1]]'))521 actualValues = 'na.omit(%s)$%s' % (dataFrameName, r('all.vars(attr(terms(model$formula), "variables")[[2]])[[1]]')) 522 522 523 523 # Create the plot. -
MGET/Branches/Jason/PythonPackage/src/GeoEco/__init__.py
r765 r781 1 __version__ = u'0.8a2 5'1 __version__ = u'0.8a26'
