#!/usr/bin/env python from __future__ import print_function """ This example serves as an illustration how to call slalib functions from aanet. And as example of how to get the position in the sky of the Sun or Moon (and the planets, if there will ever be a use for that) """ from math import * import aa, ROOT, copy from ROOT import sla #s = ROOT.SkyMap() t = ROOT.TTimeStamp( 2020, 1,1, 0,0,0 ) # we need a detector for the geographical coordinates det = ROOT.Det("../data/KM3NeT_-00000001_20171212.detx") planets = { 0 : "Sun", # from the slalib rd_plan documentation 1 : "Mercury", 2 : "Venus", 3 : "Moon", 4 : "Mars", 5 : "Jupiter", 6 : "Saturn", 7 : "Uranus", 8 : "Neptune", 9 : "Pluto" } M = ROOT.SkyMap('raw') # raw skymap, because otherwise its equatorial for iii in range ( 1000 ) : # time step of half an hour delta = ROOT.TTimeStamp(); delta.SetSec( 1800 ) # half an hour t.Add( delta ) M.objects.clear() # remove earlier makers and text # km3net coordinates: phi=0 =east, phi=90 = north txt = ROOT.TLatex( 0,0, "E"); txt.SetTextSize(0.025); M.add( txt ) txt = ROOT.TLatex( pi/2,0, "N"); txt.SetTextSize(0.025); M.add( txt ) txt = ROOT.TLatex( pi,0, "W"); txt.SetTextSize(0.025); M.add( txt ) txt = ROOT.TLatex( -pi/2,0,"S"); txt.SetTextSize(0.025); M.add( txt ) for i,name in planets.items() : # see http://star-www.rl.ac.uk/star/docs/sun67.htx/sun67ss155.html#Q1-159-952 # in aanet, slalib functions return a structure with the return parameters as # members; in this case RA, DEC, DIAM mjd = t.AsJulianDate() -2400000.5 R = sla.rdplan( mjd , i, det.longitude, det.latitude) #note the minus as usual track-direction -> source location dir = -ROOT.EquatorialCoords( R.RA, R.DEC ).track_direction( det, t ) zenith, azimuth = dir.theta(), dir.phi() elevation = pi/2 - zenith marker = ROOT.TMarker(azimuth, elevation, 20 ) marker.SetMarkerColor(i+1) M.add( marker ) txt = ROOT.TLatex( azimuth, elevation, name) txt.SetTextSize(0.025); M.add( txt ) ROOT.SetOwnership( txt , False ) ROOT.SetOwnership( marker , False ) if name == "Sun" : print ( t.AsString("c"), "zenith angle of Sun :", zenith ) M.Draw() ROOT.gPad.Update()