Swarm-NG  1.1
Examining records from the log file.

The Swarm-NG log files consists of records, these records are encoded in binary and are accessed through swarmng.logrecord.LogRecord class.

To get an instance of LogRecord, you would need to run a query on a log file and get the records in a for loop, to learn how to do that refer to Plotting results from a log file.

Source code for this tutorial can be found at py/logrecord_tutorial.py

To run the examples in this tutorial, change the code in Plotting results from a log file to use the function defined here. by default the plot tutorial uses get_semi_major_axis from this module.

The easiest way to access the planets in the log record is by using bodies_in_keplerian method. This methods converts the carteisan coordinates into Keplerian coordinates based on the center given. The result is an iterable object that has a 3-tuple as elements:

  • first: index of the planet, starting from 1 (Note that 0 is the star)
  • second: the original body attributes in Cartesian coordinates: contains position, velocity and mass.
  • third: object with orbital elements as properties, refer to swarmng.logrecord.keplerian_for_cartesian for a full list of attributes.
1 def get_semi_major_axis(l,body):
2  for i, b, orbit in l.bodies_in_keplerian(center=l.star()):
3  if i == body:
4  return orbit.a *