Changeset 781

Show
Ignore:
Timestamp:
04/07/11 17:02:42 (2 years ago)
Author:
jjr8
Message:

* Incremented build number.
* Fixed various bugs.
* Added GeoEco?.AssimilatedModules?.ndimage from scipy. This will be used from the new AVHRR Pathfinder cloud masking code.

Location:
MGET/Branches/Jason
Files:
26 added
8 modified

Legend:

Unmodified
Added
Removed
  • MGET/Branches/Jason/LICENSE.txt

    r714 r781  
    10421042 
    10431043This software is based in part on the work of the Independent JPEG Group. 
     1044 
     1045------------------------------------------------------------------------------- 
     1046 
     1047Files in the GeoEco.AssimilatedModules.ndimage package are from the 
     1048scipy.ndimage Python module. 
     1049 
     1050Copyright (C) 2003-2005 Peter J. Verveer 
     1051 
     1052Redistribution and use in source and binary forms, with or without 
     1053modification, are permitted provided that the following conditions are met: 
     1054 
     10551. Redistributions of source code must retain the above copyright 
     1056   notice, this list of conditions and the following disclaimer. 
     1057 
     10582. 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 
     10633. 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 
     1067THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
     1068IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
     1069WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
     1070DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 
     1071INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
     1072(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
     1073SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
     1074HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
     1075STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
     1076IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     1077POSSIBILITY OF SUCH DAMAGE. 
  • MGET/Branches/Jason/PythonPackage/setup.py

    r770 r781  
    11201120        packageData['GeoEco'].append(os.path.join('AssimilatedModules', 'rpy', os.path.basename(rpyLib))) 
    11211121 
     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 
    11221142    # Add miscellaneous package data files. 
    11231143 
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/ArcGIS.py

    r765 r781  
    11511151        sourceCode = sourceCode + ')' 
    11521152 
    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. 
    11561173 
    11571174        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. 
    11641214             
    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: 
    11661243                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 
    12071248 
    12081249        # Convert the returned value from the geoprocessor's preferred type to 
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/DataProducts/HYCOM.py

    r716 r781  
    11411141        # from the HYCOM bi-polar region. 
    11421142 
    1143         if sliceList[-2].stop >= 2172-390: 
     1143        if sliceList[-2].stop > 2172-390: 
    11441144            extendedYSlice = slice(max(sliceList[-2].start, 2172-390), sliceList[-2].stop) 
    11451145            ySliceToWrite = slice(extendedYSlice.start - sliceList[-2].start, extendedYSlice.stop - sliceList[-2].start) 
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/OceanographicAnalysis/Eddies.py

    r772 r781  
    264264                                                       eddiesFile, 
    265265                                                       eddyMetadataFile, 
     266                                                       'None',                  # We do not want FindOkuboWeissEddies.py to write the Okubo-Weiss parameter to a file. 
    266267                                                       self._OWThresholdType, 
    267268                                                       repr(self._OWThresholdValue), 
     
    532533Research Letters 34: L15606. 
    533534 
    534 Hensen, S.A., and Thomas, A.C. 2007. A census of oceanic anticyclonic 
     535Henson, S.A., and Thomas, A.C. 2007. A census of oceanic anticyclonic 
    535536eddies in the Gulf of Alaska. Deep Sea Research I 55: 163-176. 
    536537 
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/OceanographicAnalysis/FindOkuboWeissEddies.py

    r772 r781  
    2929    # Parse the command line arguments. 
    3030 
    31     if len(sys.argv) != 19: 
     31    if len(sys.argv) != 20: 
    3232        sys.exit(_(u'Error: Invalid number of arguments. Expected 19, got %i')) 
    3333 
     
    9797        sys.exit(_(u'Error: The output directory "%(dir)s" does not exist.') % {u'dir': os.path.dirname(eddyMetadataFile)}) 
    9898 
    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] 
    100109 
    101110    try: 
    102         owThresholdValue = float(sys.argv[15]) 
     111        owThresholdValue = float(sys.argv[16]) 
    103112    except: 
    104         sys.exit(_(u'Error: Invalid owThresholdValue: %(val)s') % {u'val': sys.argv[15]}) 
     113        sys.exit(_(u'Error: Invalid owThresholdValue: %(val)s') % {u'val': sys.argv[16]}) 
    105114 
    106     if sys.argv[16].lower() != 'none': 
     115    if sys.argv[17].lower() != 'none': 
    107116        try: 
    108             minArea = float(sys.argv[16]) 
     117            minArea = float(sys.argv[17]) 
    109118        except: 
    110             sys.exit(_(u'Error: Invalid minArea: %(val)s') % {u'val': sys.argv[16]}) 
     119            sys.exit(_(u'Error: Invalid minArea: %(val)s') % {u'val': sys.argv[17]}) 
    111120    else: 
    112121        minArea = 0. 
    113122 
    114     if sys.argv[17].lower() != 'none': 
     123    if sys.argv[18].lower() != 'none': 
    115124        try: 
    116             minA2P = float(sys.argv[17]) 
     125            minA2P = float(sys.argv[18]) 
    117126        except: 
    118             sys.exit(_(u'Error: Invalid minA2P: %(val)s') % {u'val': sys.argv[17]}) 
     127            sys.exit(_(u'Error: Invalid minA2P: %(val)s') % {u'val': sys.argv[18]}) 
    119128    else: 
    120129        minA2P = 0. 
    121130 
    122     if sys.argv[18].lower() != 'none': 
     131    if sys.argv[19].lower() != 'none': 
    123132        try: 
    124             minDuration = float(sys.argv[18]) 
     133            minDuration = float(sys.argv[19]) 
    125134        except: 
    126             sys.exit(_(u'Error: Invalid minDuration: %(val)s') % {u'val': sys.minDuration[18]}) 
     135            sys.exit(_(u'Error: Invalid minDuration: %(val)s') % {u'val': sys.minDuration[19]}) 
    127136    else: 
    128137        minDuration = 0. 
     
    165174        # Call the MATLAB function to find the eddies. 
    166175 
    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) 
    168177 
    169178        # Write the output files. 
     
    171180        eddies.tofile(eddiesFile) 
    172181        eddyMetadata.tofile(eddyMetadataFile) 
     182        if owParameterFile is not None: 
     183            W.tofile(owParameterFile) 
    173184 
    174185    # If we got an exception, print it and exit with error code 1.     
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/Statistics/Modeling.py

    r765 r781  
    421421                    dataFrameName, newPredictionsName = cls._PredictionsForArcGISTable(inputModelFile, 'model', evaluationDataTable, where) 
    422422                    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]]')) 
    424424 
    425425            # Create the plot. 
     
    519519                    dataFrameName, newPredictionsName = cls._PredictionsForArcGISTable(inputModelFile, 'model', evaluationDataTable, where) 
    520520                    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]]')) 
    522522 
    523523            # Create the plot. 
  • MGET/Branches/Jason/PythonPackage/src/GeoEco/__init__.py

    r765 r781  
    1 __version__ = u'0.8a25' 
     1__version__ = u'0.8a26'