Solving the Emitter-Observer Problem¶
Calculating light signals between two curves requires
curve data,
spacetime metric.
In the previous section, curves were either loaded from H5-files or calculated with information stored in a configuration dictionary. The spacetime metric was already provided in the latter case.
In the former case, a configuration dictionary containing information on the desired spacetime metric needs to be created, either directly in Python or saved in a TOML document. Refer to the config dictionary subsection for more information. An example TOML-file looks like this, if curves were not calculated with GREOPy:
[Metric]
name = 'Schwarzschild'
params.multipole_moments = [0] # no central mass example
Let emission_curve_data and receiver_curve_data be the DataFrames containing all the data on the emitter’s and receiver’s curve, respectively.
The eop_solver function calculates a light signal for each step along the emission curve.
If not every step requires a light signal, the number of emission events can be reduced by declaring start, stop and step_size when counting through the rows:
emission_curve_reduced = emission_curve_data[start:stop:step_size]
The light signals are then calculated via
from greopy.emitter_observer_problem import eop_solver
light_rays = eop_solver(
config,
emission_curve_reduced,
receiver_curve_data,
)
providing the curves’ and config data.
The resulting light_rays lists indexed DataFrames.
Each DataFrame in turn contains a light signal curve that connects the emitter and receiver curve at one emission and reception event.
Optionally save the light rays for later data analysis:
import pandas
for light_ray in light_rays:
light_ray_index, light_ray_solution = light_ray
light_ray_solution.to_hdf(
'light_file',
key="light_ray_" + f"{light_ray_index}".rjust(3, '0'),
mode="a",
)
This saves all light ray datasets in an H5-file named light_file, each with a different key: light_ray_*, where * indexes the light ray according to their respective emission event along the emitter curve.
In this case a maximum number of 1000 light rays was assumed, so the index always consists of three digits, e.g. 003 or 010, to preserve the light ray sequence within the H5-file.
The data can be loaded again via the load_dataset function:
from greopy.common import load_dataset
light_rays_loaded = load_dataset('path/to/light_file')
Note that the variables light_rays and light_rays_loaded slightly differ in form:
light_rayscontains alist, each entry a tuple(index, DataFrame),light_rays_loadedconstains aGenerator, whose values areDataFrameobjects.