Subject: Marine Geospatial Ecology Tools (MGET) help
Text archives
- From: Jason Roberts <>
- To: Lesley Thorne <>
- Cc: "" <>
- Subject: RE: [mget-help] Error importing MGET toolbox in Python
- Date: Fri, 25 Sep 2015 17:30:32 +0000
- Accept-language: en-US
- Authentication-results: spf=none (sender IP is ) ;
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:23
Hi Lesley,
Nice to hear from you. The problem here is that when arcpy imports a .tbx file that contains script tools, it scans all of the script tools and tries to extract their documentation and attach it to Python classes it builds on the fly to wrap the toolbox. The documentation-scanning code in arcpy contains a bug (I am pretty sure) that prevents it from correctly parsing the documentation of specific MGET tools.
I looked into this problem previously and thought I isolated the tools that tripped up arcpy and fixed their documentation. But I just reproed it myself with the latest MGET on Arc 10.3. I will try to fix it again.
In any case, when it works, it is still very slow. It often takes 30 seconds or even a couple of minutes for the import procedure to complete. A faster approach, which we have not totally documented and do not totally support but generally works fine, is to access the MGET Python modules directly rather than going through arcpy. From the ArcGIS Python window, you can do this:
>>> from GeoEco.OceanographicAnalysis.Fronts import CayulaCornillonEdgeDetection >>> CayulaCornillonEdgeDetection.DetectEdgesInArcGISRaster(...) Parsing error SyntaxError: invalid syntax (line 1)
Of course, you need to replace the … with the actual parameters in order for it to work. This function is for finding fronts in a raster that you provide. If you are using some other tool in MGET, such as the one specifically designed for finding fronts in Pathfinder AVHRR, you will have to import a different module and call a different function. Let me know what tool you’re using and I can help with that.
Another thing is that may be helpful to see MGET’s logging messages. To do that, you need to initialize MGET’s logging system first, like this:
>>> from GeoEco.Logging import Logger >>> Logger.Initialize() >>> from GeoEco.R import R >>> x = R.Evaluate(["print(1+1)"]) 2015-09-25 13:11:00,141 INFO [1] 2 >>> x 2.0
That is an example showing how to call R from within ArcGIS via MGET. I used the R statement print(1+1)instead of simply 1+1 so that a log message would be printed. (I also showed that the print statement returned the value 2.0, which was propagated back to Python, but that is not really relevant to what we’re discussing.)
Hope that helps,
Jason
From: [mailto:]
On Behalf Of Lesley Thorne
Hi Jason,
I hope everything is well with you.
I am using MGET's Cayula-Cornillon fronts tool to look at Gulf Stream fronts relative to pilot whale habitat use over a 1 year period. It works well when I run it in ModelBuilder in Arc, but when I run this via python code pasted into the python window in Arc, and I'm getting the error below when I try to import the MGET toolbox.
Any suggestions about this?
Many thanks, Lesley
>>> # Load required toolboxes ... arcpy.ImportToolbox("C:/Program Files/GeoEco/ArcGISToolbox/Marine Geospatial Ecology Tools.tbx") ... Runtime error Traceback (most recent call last): File "<string>", line 2, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\__init__.py", line 124, in ImportToolbox return import_toolbox(input_file, module_name) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\toolbox_code.py", line 443, in import_toolbox mymodule = generate_toolbox_module(toolbox, None, False, False, False, module_name, use_alt_alias) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\toolbox_code.py", line 418, in generate_toolbox_module 'exec') File "C:\Program Files\GeoEco\ArcGISToolbox\Marine Geospatial Ecology Tools.tbx", line 35518 """CoastWatchAVHRRCopyNavigationOffsets_GeoEco(sourceFile, sourceVariable, destFile, {destVariables;destVariables...})
Copies the navigation offsets from one variable in a CoastWatch POES AVHRR CWF or HDF file to one or more variables in another file.The navigation offsets are the e and f coefficients of the navigation affine attribute of each variable (the HDF nav_affine attribute). Prior to setting the navigation offsets in the destination file, the entire navigation affine is reset by invoking the cwnavigate utility with the -R option.
INPUTS: sourceFile (File): CoastWatch POES AVHRR CWF or HDF file containing the variable from which the navigation offsets should be copied.Only CoastWatch POES AVHRR files are supported. An error will be raised for other CoastWatch files, such as those for the GOES satellite series. sourceVariable (String): CoastWatch variable in the source file from which navigation offsets should be copied. destFile (File): CoastWatch POES AVHRR CWF or HDF file containing the variables to which the navigation offsets should be applied. This file can be the same as the source file.Only CoastWatch POES AVHRR files are supported. An error will be raised for other CoastWatch files, such as those for the GOES satellite series. destVariables {String}: CoastWatch variables in the destination file to which the navigation offsets should be applied. In general, navigation offsets should only be applied to variables that are derived from sensor data. At the time of this writing, the variables derived from sensor data included:avhrr_ch1 avhrr_ch2 avhrr_ch3 avhrr_ch3a avhrr_ch4 avhrr_ch5 cloud cloudx sstPeter Hollemans, one of the lead CoastWatch researchers at NOAA, suggested that navigation offsets should not be applied to the graphics, rel_azimuth, sat_zenith, and sun_zenith variables. With respect to the last three, he said:"I've thought about it for a while and my inclination is to say don't correct the angle data. It's not a perfect solution -- ie: if we knew the satellite's position and orientation perfectly and recomputed the angle data, we would find very small discrepancies compared with the navigation-corrected version.""""
^ SyntaxError: EOL while scanning string literal ____________________________________________________ Lesley Thorne, Assistant Professor School of Marine and Atmospheric Sciences 631.632.5117 |
- [mget-help] Error importing MGET toolbox in Python, Lesley Thorne, 09/25/2015
- RE: [mget-help] Error importing MGET toolbox in Python, Jason Roberts, 09/25/2015
Archive powered by MHonArc 2.6.19.