Scattering and Polarization#

For a detailed list of the newest features introduced in the latest releases please check What’s new.

Quickstart#

Please import the package and some useful utilities:

import pryngles as pr
from pryngles import Consts

NOTE: If you are working in GoogleColab before producing any plot please load the matplotlib backend:

%matplotlib inline

Pryngles currently exposes two interfaces. The legacy interface is called RingedPlanet; it was used in the earliest versions of the package and in part of the published scientific work. We keep it for a limited transition period so older research code and notebooks remain reproducible. Examples based on this interface are available in tutorials/Quickstart-RingedPlanet.ipynb and in the legacy-oriented examples below. The modern interface is System, which is the most flexible interface in the package because it supports more complex configurations such as planets with rings, moons, multiple stars, and thermal-emission workflows.

System (official) interface#

The recommended quickstart for new work is the System interface. A complete executable version of the workflow is available in tutorials/Quickstart-System.ipynb.

Create a star, a planet, and a ring:

import pryngles as pr
import numpy as np
import spiceypy as spy

system = pr.System()

star = system.add(
  kind='Star',
  radius=pr.Consts.rsun / system.ul,
  limb_coeffs=[0.65],
)

planet = system.add(
  kind='Planet',
  parent=star,
  a=0.2,
  e=0.0,
  radius=pr.Consts.rsaturn / system.ul,
)

ring = system.add(
  kind='Ring',
  parent=planet,
  fi=1.5,
  fe=2.5,
  i=30 * pr.Consts.deg,
)

Set the observer geometry, initialize the dynamics, discretize the surfaces, and visualize the system:

inc = 90.0
omega = 0.0
system.n_obs = spy.eul2m(np.deg2rad(omega), np.deg2rad(inc), 0, 3, 1, 3)[0]

system.initialize_simulation()
system.spangle_system()
system.integrate_perspective(0)
system.sg.plot2d()
system.sg.fig2d.savefig('gallery/simple_system_view.png', dpi=300)

This produces the following system view:

Quickstart System geometry view

Compute the reflected/scattered flux and polarization over one orbital cycle:

n_times = 181
period_days = 365.25 * (planet.a ** 1.5)
times_days = np.linspace(0.0, period_days, n_times)
times_system = times_days * pr.Consts.day / system.ut

system.compute_lightcurve(
  times=times_system,
  effects=['polarization'],
)

scattering_df = system.lightcurve['scattering']
polarization_df = system.lightcurve['polarization']

The important difference with respect to RingedPlanet is that System stores the results in pandas objects. This makes it easy to extract the contribution from each body and then combine them explicitly:

planet_flux = scattering_df['Planet']
ring_flux = scattering_df['Ring']
total_flux = scattering_df.sum(axis=1)

planet_flux_ppm = pr.Consts.ppm * planet_flux
ring_flux_ppm = pr.Consts.ppm * ring_flux
total_flux_ppm = pr.Consts.ppm * total_flux

planet_pol = polarization_df['Planet']
ring_pol = polarization_df['Ring']