06-20-2019 10:15 PM
I am currently trying to use numpy Memmap in a python file to process some data.
The python file works fine when I run it through my IDLE interface.
However, when I try to read the same file through a python operator in a spatial model,
the processing seems to stop at the point when I try to use memmap.
I was wondering if there are any limitations in using numpy memmap through Spatial modeler
or ERDAS IMAGINE.
Any information is appreciated!
06-27-2019 12:27 PM
Is this possibly a Python version problem? If there is more than one Python version on your machine spatial models may be using a different version of the interpreter to run your script. It seems like a good first step to confirm the version of Python being used. The attached file (show_version.zip) contains a Python script called show_version.py which implents a Python function called showVersion(), to will display a dialog with the version of the Python interpreter.
Follow these steps:
This will display a dialog with the Python version string displayed.
Is this the same version that is shown from within your Python IDLE Interface? If they are different then I would ask if the Spatial Modeler python version is compatible with the version of memmap?
07-11-2019 07:19 PM
Thank you for the python to check my version.
The Python versions seem to match although my IDLE interfaces showed some "on win32" comment in the end.
(Would this affect version differences in any way?)
IDLE Interface "Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)] on win32"
Python Operator output "Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]"
If my versions are OK, what could be the next point I should consider?
07-12-2019 07:45 AM
Can you please provide the details on the version of numpy that you are using? I don't seem to be able to locate a version that is compatible with Python 3.4.4.
07-12-2019 12:54 PM
After finally getting numpy installed and working, I think I may have your answer.
A memmap is created using memmap(filename, ....). I followed an existing example that used a simple name like 'memmap.dat' as the filename and that did indeed work in my IDE (VisualStudio Code) but failed in Spatial Modeler. I then change the filename to a full path like 'C:\\data\\memmap\\memmap.dat' and the code worked in both environments and produced correct results.
My theory is that when a simple filename with no path component is used the actual location is determined by the environment in which the script was run and in the case of the Spatial Modeler the environment is resulting in a default location which is write protected.
By supplying a complete path a location with proper access right can be selected and the memmap() function call will succeed.
Hopefully this will get you past this snag.