X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



3046 Rate this article:
No rating

Example: how to call IDL codes from Multiprocessing Python Package

 

Below is an example about how to call IDL commands from the multiprocessing Python library. The multiprocessing Python package can be used to parallelize processes in Python. IDL can take benefit of this package using the Python to IDL bridge

 

1. Create a python module to import the IDL package and call the IDL commands.

For example, create a defs.py file with f function including

  • The import of the IDL package
  • The calls to IDL commands

def f(i):

        from idlpy import IDL

        i = IDL.sqrt(i); IDL.wait(10)

        return i+1

 

​2. Create a python code to call the python module created at step 1, and run it using the multiprocessing python package

For example, create a run.py file including

  • The import of the python multiprocessing package
  • The import of the defs.py python module
  • The call to defs.f function using the multiprocessing package

import time

start = time.time()

from multiprocessing import Pool

import defs       

if __name__ == '__main__':

                with Pool(3) as p:

                                print(p.map(defs.f, [9,16,25]))

end = time.time()

print(end - start)

 

3. Run the main python code in Python, after configuring the Python to IDL bridge.

https://www.l3harrisgeospatial.com/docs/python.html

For example run at a prompt:

python run.py

This example should return:

IDL 8.8 (linux x86_64 m64).

(c) 2021, Harris Geospatial Solutions, Inc.

IDL 8.8 (linux x86_64 m64).

(c) 2021, Harris Geospatial Solutions, Inc.

IDL 8.8 (linux x86_64 m64).

(c) 2021, Harris Geospatial Solutions, Inc.

Licensed for use by: xxxxxx

License: 1234

Licensed for use by: xxxxx

License: 1234

Licensed for use by: xxxxx

License: 1234-server-linux

[4.0, 5.0, 6.0]

10.561610221862793

 

 

 

______________________________

created by BC on 8/17/2021 - reviewed by BC(US)

 

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »