Package: gefera
geferaInstallationBasic UsageThe LikelihoodInstallationTo install gefera begin by cloning the github repository.git clone https://www.github.com/tagordon/geferaOnce the repository has downloaded cd into the main directory and install with pip.cd gefera; pip install .Basic UsageGefera has two components: the dynamical model which is used to compute the positions of two bodies at a given time or array of times, and the photometric model which computes the observed flux given the positions of the bodies. Gefera implements two dynamical systems. The first is aHierarchicalSystem, which describes an exomoon/exoplanet pair. To instantiate this system let's start by defining the dynamical parameters:For the planet:ap=215.0# semimajor axis in stellar radiitp=-91.25# starting epoch in daysep=0.0# eccentricitypp=365# period in dayswp=0.1*np.pi/180# longitude of periastron in degreesip=89.8*np.pi/180# inclination in degreesand for the moon:am=2# semimajor axis of the moon's orbit around the planet in stellar radiitm=-4.2# starting epoch in daysem=0.0# eccentricitypm=8# period in daysom=90*np.pi/180# longitude of the ascending node in degreeswm=-90*np.pi/180# longitude of periastron in degreesim=90.0*np.pi/180# inclination in degreesmm=0.01# mass of the moon in units of the mass of the planetWe can then instantiate the system as follows:importgeferaasgfpo=gf.orbits.PrimaryOrbit(ap,tp,ep,pp,wp,ip)mo=gf.orbits.SatelliteOrbit(am,tm,em,pm,om,wm,im,mm)sys=gf.systems.HierarchicalSystem(po,mo)To compute the light curve we also need the radii of both bodies and the quadratic limb darkening parameters (right now gefera only supports quadratic limb darkening)rp=0.1rm=0.05u1=0.5u2=0.3We can then compute the light curve:t=np.linspace(-0.6,0.3,10000)# The out-of-transit flux is set to zero by default, so we add 1 to get the normalized flux.flux=sys.lightcurve(t,u1,u2,rp,rm)+1When plotted, the lightcurve for this system looks like this:If the gradient is required we useflux,grad=sys.lightcurve(t,u1,u2,rp,rm,grad=True)This will return the gradient of the light curve with respect to each of the input parameters as a dictionary keyed by the name of the parameter. The keys area1, t1, e1... a2, t2, e2...where the1parameters are for the larger body and2refers to the smaller body.The LikelihoodIn order to conduct inference using the gefera model we need to compute the likelihood with respect to some observations. Iftis an array containing the times of the observations andyis an array containing flux measurements (normalized to an out-of-transit flux of 1) then we can compute the likelihood for the model as follows:ll=sys.loglike(y-1,t,u1,u2,r1,r2,sigma)wheresigmais the uncertainty, assumed to be the same for each measurement. If we want to make use of the gradient in our inference then we can call:ll,dll=sys.loglike(y-1,t,u1,u2,r1,r2,sigma,grad=True)The gradient is returned as an array of arrays containing the gradients with respect to each parameter in the ordera1, t1, e1, p1, w1, i1, a2, t2, e2, p2, om2, w2, i2, mm2, r1, r2, u1, u2. Iffuncis a callable function that returns-ll, -dllandinitis an array of initial parameter guesses in the same order as the gradients are returned then we can usescipy.optimize.minimizeto optimize the model as follows:res=minimize(func,init,jac=True,method='TNC')