#!/usr/bin/env python import sla # also loads aanet from math import * # The slalib resides in a namespace 'sla'. The sla namespace # is resides in root as usual, so we can do import ROOT print ROOT.sla.de2h # # sla.py also adds this namespace to sys.modules, so we can also # just do import sla print sla.de2h # # note that from sla import * does not work, so import your functions # one by one from sla import de2h, dh2e print dh2e # import sla lattitude = ( 36 + 16 / 60.0 ) * pi / 180 # ARCA: 36deg 16 sec # convert equatorial to horizontal hour_angle, declination = 1.3, 0.1 hor = sla.de2h( hour_angle, declination , lattitude ) print hor # AZ,EL : 4.6323 0.277191 print hor.AZ # 4.6323 sys.exit() # ================================================== # slalib function that have multiple output parameters # are represented by a c++ class with the output varialbes # as members and the contructor computing them. from math import * lattitude = ( 36 + 16 / 60.0 ) * pi / 180 # ARCA: 36deg 16 sec declination = 0 for ha in range (0,360,10): hor = sla.de2h( ha * pi / 180 , declination, lattitude ) eq = sla.dh2e( hor.AZ, hor.EL, lattitude ) print ha, eq.HA * 180/pi, eq.DEC #================================================== date = ( 2018, 3, 12 ) mjd = sla.caldj ( *date ) print mjd cal = sla.djcal( 2, mjd.DJM ) print cal # c arrays become a python buffer object, which can be unpacked if cal.J > 0 : print "A slalib error occured." else : yr,mo,da,s = cal.IYMDF print yr,mo,da # also for interest # - galeq / eqgal # - dmoon # - planet (coord systems?) # In C++, we call exactly the same clases cpp = """ #include "sla.hh" void test_galeq() { double gal_lon = 2; double gal_lat = 0.5; auto eq = sla::galeq( gal_lon, gal_lat ); cout << eq << endl; cout << eq.DR << " " << eq.DD <