Package: pylightcurve-torch
PyLightcurve-torchAn exoplanet transit modelling package for deep learning applications in Pytorch.Seethis open publication in the Publications of the Astronomical Society of the Pacificfor more details and official citation andjupyter notebook tutorials here.The code for orbit and flux drop computation is adapted fromPylightcurve.The modulepylightcurve_torch.functional.pycontains the functions implemented in Pytorch and computing the orbital positions,
transit durations and flux drops. (seePyLightcurve repositoryfor more information about the numerical models used).ATransitModuleclass is implemented inpylightcurve_torch.nn.pywith the following features:Computes time series of planetary positions and primary/secondary flux dropsit inheritstorch.nn.Moduleclass to benefit from its parameters  optimisation and management capabilities and facilitated combination with neural networksnative GPU compatibilityInstallation$pipinstallpylightcurve-torchBasic usefrompylightcurve_torchimportTransitModuletm=TransitModule(time,**transit_params)flux_drop=tm()If needs be, the returnedtorch.Tensorcan be converted to anumpy.ndarrrayusingflux_drop.numpy()torch method orflux.cpu().numpy()if the computation took place on a gpu.Transit parametersBelow is a summary table of the planetary orbital and transit parameters use in PyLightcurve-torch:NamePylightcurve aliasDescriptionPython typeUnitTransit typeasma_over_rsratio of semi-major axis by the stellar radiusfloatunitlessprimary/secondaryPperiodorbital periodfloatdaysprimary/secondaryeeccentricityorbital eccentricityfloatunitlessprimary/secondaryiinclinationorbital inclinationfloatdegreesprimary/secondarypperiastronorbital argument of periastronfloatdegreesprimary/secondaryt0mid_timetransit mid-time epochfloatdaysprimary/secondaryrprp_over_rsratio of planetary by stellar radiifloatunitlessprimary/secondarymethodmethodlimb-darkening lawstrprimaryldclimb_darkening_coefficientslimb-darkening coefficientslistunitlessprimaryfpfp_over_fsratio of planetary by stellar fluxesfloatunitlesssecondaryA short version of each parameter has been introduced, while maintaining a compatibility with origin PyLightcurve
parameter names. All the parameters except method are converted totorch.Parameterswhen passed to
a ``TransitModule```, with double dtype.DifferentiationOne of the main benefits of having a pytorch implementation for modelling transits is offered by its
automatic differentiation feature with torch.autograd, stemming from autograd library.Here is an example of basic usage:...tm.fit_param('rp')# activates the gradient computation for parameter 'rp'err=loss(flux,**data)# loss computation in pytorcherr.backward()# gradients computationtm.rp.grad# access to computed gradient for parameter 'rp'More Pytorch supportSeveral utility methods inherited from PyTorch modules are listed below, simplifying operations on all module's
defined tensor parameters.tm=TransitModule()# Parameters access (iterators)tm.parameters()tm.named_parameters()# dtype conversionstm.float()tm.double()# Gradient local deactivationwithtorch.no_grad():flux_no_grad=tm()# device conversiontm.cpu()tm.cuda()Running performance testsIn addition to traditional unit tests, computation performance tests can be executed this way:pythontests/performance.py--plotThis will measure the computation time for computing forward transits as a function of transit duration, time vector
length or batch size. If data have been savec previously, these will be plotted to with the name of the corresponding
tag.