Swarm-NG  1.1
logrecord_tutorial.py
Go to the documentation of this file.
1 ## @file logrecord_tutorial.py Tutorial for using the @ref swarmng.logrecord.LogRecord class for accessing records from a BDB log file.
2 
3 # @page TutorialPythonLogRecord Examining records from the log file.
4 #
5 # The Swarm-NG log files consists of records, these records are
6 # encoded in binary and are accessed through swarmng.logrecord.LogRecord
7 # class. To get an instance of LogRecord, you would need to run a query
8 # on a log file and get the records in a for loop, to learn how
9 # to do that refer to @ref TutorialPythonQueryPlot.
10 #
11 # Source code for this tutorial can be found at @ref py/logrecord_tutorial.py
12 
13 # To run the examples in this tutorial, change the code
14 # in @ref TutorialPythonQueryPlot to use the function defined
15 # here. by default the plot tutorial uses get_semi_major_axis from
16 # this module.
17 #
18 # The easiest way to access the planets in the log record is by
19 # using bodies_in_keplerian method. This methods converts the
20 # carteisan coordinates into Keplerian coordinates based on the
21 # center given. The result is an iterable object that has a 3-tuple
22 # as elements:
23 # * first: index of the planet, starting from 1 (Note that 0 is the star)
24 # * second: the original body attributes in Cartesian coordinates: contains position, velocity and mass.
25 # * third: object with orbital elements as properties, refer to \ref swarmng.logrecord.keplerian_for_cartesian for a full list of attributes.
26 def get_semi_major_axis(l,body):
27  for i, b, orbit in l.bodies_in_keplerian(center=l.star()):
28  if i == body:
29  return orbit.a