Jump to content

[Help needed] Calling python script for Astronomy application


Recommended Posts

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!

Call_python_script.png

error out.png

Result on Jupyter.png

FITS to JPG converter.zip

Link to comment

What are your respective experiences with Python and LabVIEW? It seems that you are more proficient in the former than in the latter. If so, looking at built-in examples might help (Help>>FInd Examples).

Answer 1: the way the Python node is designed requires a function to call in your script. You can have several functions in a script, but you would have to call the Python node repeatedly, one function call at a time, or those functions would have to call each other within the script. Not that this is what you are asking for, but that might clarify the node's intent.

Your first snapshot doesn't show any node output. If you want to get something back into LabVIEW, that is missing. If I understand what you are trying to do, you would want your Python function to return something like an array containing your image.

Answer 2: the easiest way would be to use a Picture control to display the image array returned by the Python node. More expensive (the toolkit is not free) would be to use the Vision Development Module, which in addition to a more advanced control, would offer a number of utilities to manipulate the image.

HTH

  • Thanks 1
Link to comment

  

6 hours ago, X___ said:

What are your respective experiences with Python and LabVIEW? It seems that you are more proficient in the former than in the latter. If so, looking at built-in examples might help (Help>>FInd Examples).

Answer 1: the way the Python node is designed requires a function to call in your script. You can have several functions in a script, but you would have to call the Python node repeatedly, one function call at a time, or those functions would have to call each other within the script. Not that this is what you are asking for, but that might clarify the node's intent.

Your first snapshot doesn't show any node output. If you want to get something back into LabVIEW, that is missing. If I understand what you are trying to do, you would want your Python function to return something like an array containing your image.

Answer: I have a bit of experience with LabVIEW and none with Python. Actually that snippet is what I modified from the built-in example. I didnt expect any output for now so I removed everything related to output in order to check if I can call the script without calling any function. Now I know it doesn't work that way.

Yes, you are right. I would like Python function to return an array containing an image. I should tweak on the code more i perhaps.

Answer 2: the easiest way would be to use a Picture control to display the image array returned by the Python node. More expensive (the toolkit is not free) would be to use the Vision Development Module, which in addition to a more advanced control, would offer a number of utilities to manipulate the image.

Answer: Yes, after getting the Python function to work. I will give it a try.

 

 

Thank you very much for you reply. I really appreciate that. :)

Edited by Su Nguyen Tien
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.