LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call Python script for Astronomy applications

Solved!
Go to solution

Hi All,

I am trying to implement a Python script in LabVIEW to convert FITS file into visible image (JPG,PNG).

My progress so far:

1. I am able to call a simple Python script and it runs perfectly (AddTwoDoubles).

2. I am able to download and display an image on Jupyter (see screenshot Result on Jupyter.png)

3. I downloaded Jupyter notebook file as Python file (FITS to JPG converter.py), trying to call it in LabVIEW (see snippet Call_python_script.png).

My issues:

1. When I call the Python script without indicating a Function, LabVIEW gave me an error (error out.png) saying Function could not be found in the module. I wonder if I can just call the script without calling any function and the script can be executed thoroughly?

2. In case the script can be executed, how do I display plotted image in LabVIEW?

Does anybody have experience or idea on this issue?

Thank you for your time checking my post!

0 Kudos
Message 1 of 5
(790 Views)
Solution
Accepted by topic author suxu

If you need to run the whole python file, just call them using the CMD line (Sys Exec function). LabVIEW expects you to call a Python function when using the call python node.

 

Instead of trying to transfer the image to LabVIEW, save the image on a disc, and let LabVIEW read the image from the disk.

 

The data transfer part between LabVIEW and Python may not support complex data structures.

 

The problem is that you're trying to approach from a JupyterNB workflow and not a traditional Python workflow.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 2 of 5
(756 Views)

Thank you for your reply. I really appreciate that.

 

Seems like using CMD line is a wiser approach in my situation.

 

I have no experience iin Python. Could you please tell me what's difference between 2 workflow? I did download the jupyter notebook as a Python file it worked just fine.

0 Kudos
Message 3 of 5
(720 Views)

Hi Santo,

 

I have been trying several ways including your suggestion using CMD line. Here are results so far:

 

1. Calling script by Python node (called_using_python_node.png): I am able to call the script without calling any function. The script could run and plot the image in a pop-up window. Only the plt.savefig("image.png") did not work. No output image was created (I ran LabVIEW as Administration)

 

2. Calling script by CMD line (called_using_CMD.png): same result
 
3. Calling script directly in CMD window (not via LabVIEW): same result
 
However, when I ran the script in VSC, everything worked just fine. There was output image created.
 
Do you have any idea what is the problem here? 
Download All
0 Kudos
Message 4 of 5
(706 Views)

Dear Santo,

 

I think I figured it out. When calling script in VSC, it saved image to the same folder with the script so I could see it rightaway. When calling in CMD, it saved image to "user name" folder, I accidently found it today. Now I can try to save it into a specific directory.

Thanks again for your help

0 Kudos
Message 5 of 5
(676 Views)