X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 22 Oct 2018 12:53 PM by  Ben Castellani
IDL-Python bridge
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Irina Tkatcheva



New Member


Posts:
New Member


--
17 Oct 2018 12:51 PM

    I am trying to use IDL-Python bridge to call IDL (Interactive Data Language) procedures from Python. Could anybody tell how to access IDL system variables that starts with '!' from Python? For example, a call in Python

    from idlpy import *

    d2r = IDL.!DDTOR

    gives SyntaxError: invalid syntax.

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    22 Oct 2018 12:53 PM
    Hi Irina,

    To retrieve an IDL system variable such as !DTOR or !CONST, you can use the Python getattr() method:

    >>> from idlpy import *
    >>> getattr(IDL, "!dtor")
    0.017453292

    >>> const = getattr(IDL, "!const")
    >>> const.keys()
    dict_keys(['ALPHA', 'AU', 'C', 'DTOR', 'E', 'EPS0', 'EULER', 'F', 'G', 'GN', 'H', 'HBAR', 'I', 'K', 'LY', 'M_EARTH', 'M_SUN', 'ME', 'MN', 'MP', 'MU0', 'N0', 'NA', 'P0', 'PARSEC', 'PHI', 'PI', 'R', 'R_EARTH', 'RTOD', 'RE', 'RYDBERG', 'SIGMA', 'T0', 'U', 'VM'])
    >>> const['PARSEC']
    30856775814671912.0

    Good luck!
    You are not authorized to post a reply.