Swarm-NG
1.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Swarm-NG
Overview
Text Formats
Getting Started with Swarm-NG
Advanced Options for Building Swarm
Configuration Files
Release notes
swarm-query.py command-line interface
Swarm command-line interface
How to Test Swarm
Using Swarm
Examining records from the log file.
Plotting results from a log file
Tutorial on using the Ensemble data structure.
Advanced tutorial for using GPU integrators
Tutorial for implementing an Integrator
Tutorial for making a monitor (stopper/logger)
Tutorial for Making a Propagator
Beginner Python Tutorial
Testing for ejection of planets
Tutorial for generating ensembles
Advanced Python Integration Tutorial
Resume an integration
Extracting statistical information from data files
Beginner tutorial for using the API
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
swarm
py
bin
swarmng
tests
ejection_tutorial.py
ensemble_tutorial.py
integration_plot_tutorial.py
logrecord_tutorial.py
plot_tutorial.py
resume_tutorial.py
stats_tutorial.py
tutorial.py
src
File Members
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
swarm
py
logrecord_tutorial.py
Generated on Sun Jul 21 2013 11:11:53 for Swarm-NG by
1.8.4