Skip to content

Commit

Permalink
Merge pull request #55 from emolter/cosmetics
Browse files Browse the repository at this point in the history
Cosmetics
  • Loading branch information
emolter authored Feb 19, 2024
2 parents 2a03701 + d449152 commit 78afa5b
Show file tree
Hide file tree
Showing 175 changed files with 8,679 additions and 3,281 deletions.
57 changes: 40 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. image:: docs/wide-logo.png
:width: 400
:alt: Pylanetary logo

data processing and modeling tools for ring, moon, and planet observations
--------------------------------------------------------------------------

Expand All @@ -16,37 +20,51 @@ data processing and modeling tools for ring, moon, and planet observations
.. image:: https://zenodo.org/badge/459414964.svg
:target: https://zenodo.org/badge/latestdoi/459414964
:alt: Zenodo DOI Badge


Installation
------------

* download the requirements.txt file using the "download raw" option
* ``conda create -n pylanetary-tester python=3.9`` (or any Python from 3.7 to 3.10)
* ``conda activate pylanetary-tester``
* ``pip install -r requirements.txt``
* ``pip install git+https://github.com/emolter/pylanetary.git@main``

Pylanetary relies on as-yet-unreleased versions of the image\_registration and astroquery packages, and pypi does not support installation of unreleased packages. This is the reason that simply pip install pylanetary will not work right.
``pip install python`` (Python 3.9 to 3.12)

Features
--------
* Navigation and re-projection for solar system imaging observations (makes use of Cartopy); `Tutorial <https://pylanetary.readthedocs.io/en/latest/nav-tutorial.html>`_ and `example workflow <https://pylanetary.readthedocs.io/en/latest/nav-examples.html>`_.

* Read/write navigated solar system images and backplanes in the NAV multi-extension fits format, originally developed for the HST OPAL program

* Utilities for solar-system-specific unit conversions like I/F; `Tutorial <https://pylanetary.readthedocs.io/en/latest/utils-tutorial.html#I/F-calculation>`_.

* Ring-moon system modeling and model-data comparison; `Tutorial <https://pylanetary.readthedocs.io/en/latest/rings-tutorial.html>`_.

* (coming soon) Compute Doppler winds from image cubes and compare with simulation output (e.g. EPIC)

Usage
-----
See our `readthedocs page <https://pylanetary.readthedocs.io/en/latest/>`_

Scope and Goal
--------------
The idea behind pylanetary is to bring solar system science tools into the open-source Python 3 / Astropy ecosystem. We, and many of our colleagues, rely heavily on useful code snippets passed down from other solar system scientists. But these pieces of code are untested, in multiple languages, closed-source, and have many untracked dependencies. We want to fix that.

At present, two main packages are reasonably well-supported:
1. navigation: Tools to make and use ellipsoidal models of planets/large moons. This subpackage projects planet models into arbitrary observing geometries and pixel scales, compares those models with observational data, assigns latitudes, longitudes, and emission angles to observational data, and projects images onto latitude-longitude grids.
2. rings: Tools to model planetary ring systems. This subpackage projects ring models into arbitrary observing geometries and pixel scales, compares those models with observational data, and makes radial and azimuthal profiles of observed rings.

The eventual goal is to become Astropy-affiliated, but that is a long way off. We would love your help developing it! See Contributing.
The idea behind pylanetary is to bring solar system science tools into
the open-source Python 3 / Astropy ecosystem. We, and many of our colleagues,
rely heavily on useful code snippets passed down from other solar system scientists.
But these pieces of code are untested, in multiple languages, closed-source,
and have many untracked dependencies. We want to fix that.
The eventual goal is to become Astropy-affiliated, but that is a long way off.
We would love your help developing it! See Contributing.

Disclaimer
----------
Pylanetary is developed and maintained by a small group of scientists.
Most of us are not primarily software engineers, and we do not get paid to do this.
While we do our best, there is no guarantee that every function works as intended.
Use these tools with caution, and ensure that what you're getting out makes sense.
If you do discover a problem, please help us out by submitting an issue
on our issues page, or fix it yourself! See Contributing.

License
-------
This project is Copyright (c) Ned Molter & Chris Moeckel and licensed under
the terms of the BSD 3-Clause license. This package is based upon
This project is Copyright (c) Edward Molter & Chris Moeckel and licensed under
the terms of the GNU general public license. This package is based upon
the `Astropy package template <https://github.com/astropy/package-template>`_
which is licensed under the BSD 3-clause license. See the licenses folder for
more information.
Expand Down Expand Up @@ -83,3 +101,8 @@ Note: This disclaimer was originally written by
`PyCon talk <https://www.youtube.com/watch?v=6Uj746j9Heo>`_, and was adapted by
pylanetary based on its use in the README file for the
`MetPy project <https://github.com/Unidata/MetPy>`_.

Logo Credit
-----------
Our logo was designed by graphic designer Jacob Waliszewski.
Check out his website at `https://www.jwdesignco.com/ <https://www.jwdesignco.com/>`_.
Binary file added docs/_build/doctrees/api/index.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/api/navigation_api.doctree
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/doctrees/api/utils_api.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/citing.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/contributing.doctree
Binary file not shown.
Binary file removed docs/_build/doctrees/description.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/installation.doctree
Binary file not shown.
Binary file removed docs/_build/doctrees/navigation_api.doctree
Binary file not shown.
222 changes: 222 additions & 0 deletions docs/_build/doctrees/nbsphinx/tutorials/body-tutorial.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "32bbcf29",
"metadata": {},
"source": [
"# Planetary Body Attributes & Ephemerides"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b0055d49",
"metadata": {},
"outputs": [],
"source": [
"# imports\n",
"from pylanetary.utils import Body\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"id": "76c07f7b",
"metadata": {},
"source": [
"## The Body utility\n",
"\n",
"Body is a convenience tool for simultaneously accessing static data and ephemeris information for a given solar system body. \n",
"\n",
"Given the name of a planet or large moon, loads mass, equatorial and polar radii, orbital parameters, etc, with units. A complete specification of the available data for different body types (planet, moon, small body) is coming soon - for now, check utils/data/bodyname.yaml for what is available. Feel free to add what is useful to you, and submit a pull request if you think it would be useful to others. \n",
"\n",
"Body also loads an ephemeris from Horizons as an Astropy table using astroquery."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "9210d119",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Jupiter has equatorial, polar radii 71492.0 km, 66854.0 km\n",
"Jupiter has a mass of 1.89813e+27 kg and a rotation period of 9.925 h\n",
" targetname datetime_str datetime_jd solar_presence lunar_presence RA DEC RA_app DEC_app RA_rate DEC_rate AZ EL AZ_rate EL_rate sat_X sat_Y sat_PANG siderealtime airmass magextinct V surfbright illumination illum_defect sat_sep sat_vis ang_width PDObsLon PDObsLat PDSunLon PDSunLat SubSol_ang SubSol_dist NPole_ang NPole_dist EclLon EclLat r r_rate delta delta_rate lighttime vel_sun vel_obs elong elongFlag alpha lunar_elong lunar_illum sat_alpha sunTargetPA velocityPA OrbPlaneAng constellation TDB-UT ObsEclLon ObsEclLat NPole_RA NPole_DEC GlxLon GlxLat solartime earth_lighttime RA_3sigma DEC_3sigma SMAA_3sigma SMIA_3sigma Theta_3sigma Area_3sigma RSS_3sigma r_3sigma r_rate_3sigma SBand_3sigma XBand_3sigma DoppDelay_3sigma true_anom hour_angle alpha_true PABLon PABLat\n",
" --- --- d --- --- deg deg deg deg arcsec / h arcsec / h deg deg arcsec / min arcsec / min arcsec arcsec deg h --- mag mag mag / arcsec2 % arcsec arcsec --- arcsec deg deg deg deg deg arcsec deg arcsec deg deg AU km / s AU km / s min km / s km / s deg --- deg deg % deg deg deg deg --- s deg deg deg deg deg deg h min arcsec arcsec arcsec arcsec deg arcsec2 arcsec km km / s Hz Hz s deg h deg deg deg \n",
"------------- -------------------- ----------------- -------------- -------------- -------- -------- -------- ------- ---------- ---------- --- --- ------------ ------------ ---------- --------- -------- ------------ ------- ---------- ------ ------------- ------------ ------------ -------- ------- --------- ---------- -------- ---------- -------- ---------- ----------- --------- ---------- ------- ------ -------------- --------- ---------------- ---------- ----------- ---------- ---------- ------- --------- ------- ----------- ----------- --------- ----------- ---------- ----------- ------------- --------- ---------- ---------- --------- --------- ---------- ---------- --------- --------------- --------- ---------- ----------- ----------- ------------ ----------- ---------- -------- ------------- ------------ ------------ ---------------- --------- ---------- ---------- ------- -------\n",
"Jupiter (599) 2024-Feb-16 22:27:44 2460357.435925926 36.85163 13.55608 37.17703 13.6638 20.24777 7.405086 -- -- -- -- 236592.038 93318.397 70.883 -- 999 -- -2.247 5.367 99.11266 0.3352 257467.2 * 37.77511 341.477974 3.321298 330.654615 3.5616 251.84 3.54 340.4461 17.633 49.7359 -1.01 4.994368223878 0.3705009 5.21892932831983 26.5051497 43.40451169 13.5960881 34.8759252 71.5187 /T 10.8122 22.7 53.4432 97.6692 71.762 250.787 -0.1803 Ari 69.185123 39.2554843 -0.9641561 268.05798 64.49676 155.720533 -43.123915 -- 0.0 -- -- -- -- -- -- -- -- -- -- -- -- 35.3806 -- 10.8104 44.3273 -0.9926\n"
]
}
],
"source": [
"jup = Body('Jupiter')\n",
"print(f'{jup.name} has equatorial, polar radii {jup.req}, {jup.rpol}')\n",
"print(f'{jup.name} has a mass of {jup.mass} and a rotation period of {jup.t_rot}')\n",
"print(jup.ephem)"
]
},
{
"cell_type": "markdown",
"id": "ef5bbca6",
"metadata": {},
"source": [
"Here, no datetime or observer location is specified, so datetime.now() and center of Earth were assumed. If we instead wanted to observe from the VLA site at the time of the first SL9 impact, we could say:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "30d6e637",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"North pole angle 20.6435 degrees\n"
]
}
],
"source": [
"jup = Body('Jupiter', epoch='1994-07-16 20:13', location='VLA')\n",
"print(f'North pole angle {jup.ephem[\"NPole_ang\"]} degrees')"
]
},
{
"cell_type": "markdown",
"id": "55cbc166",
"metadata": {},
"source": [
"Note that the location string must be readable by JPL Horizons.\n",
"\n",
"The ephemeris table is an Astroquery Horizons tool output; below are listed the available keys. See [this astroquery docs page](https://astroquery.readthedocs.io/en/latest/api/astroquery.jplhorizons.HorizonsClass.html#astroquery.jplhorizons.HorizonsClass.ephemerides) for descriptions of these keywords, and [the Horizons page](https://ssd.jpl.nasa.gov/horizons/manual.html#obsquan) for even more details. Note that for some reason, the astroquery wrapper does NOT use the same short names for these parameters as the Horizons system itself."
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "f8a18d2f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"targetname\n",
"datetime_str\n",
"datetime_jd\n",
"solar_presence\n",
"lunar_presence\n",
"RA\n",
"DEC\n",
"RA_app\n",
"DEC_app\n",
"RA_rate\n",
"DEC_rate\n",
"AZ\n",
"EL\n",
"AZ_rate\n",
"EL_rate\n",
"sat_X\n",
"sat_Y\n",
"sat_PANG\n",
"siderealtime\n",
"airmass\n",
"magextinct\n",
"V\n",
"surfbright\n",
"illumination\n",
"illum_defect\n",
"sat_sep\n",
"sat_vis\n",
"ang_width\n",
"PDObsLon\n",
"PDObsLat\n",
"PDSunLon\n",
"PDSunLat\n",
"SubSol_ang\n",
"SubSol_dist\n",
"NPole_ang\n",
"NPole_dist\n",
"EclLon\n",
"EclLat\n",
"r\n",
"r_rate\n",
"delta\n",
"delta_rate\n",
"lighttime\n",
"vel_sun\n",
"vel_obs\n",
"elong\n",
"elongFlag\n",
"alpha\n",
"lunar_elong\n",
"lunar_illum\n",
"sat_alpha\n",
"sunTargetPA\n",
"velocityPA\n",
"OrbPlaneAng\n",
"constellation\n",
"TDB-UT\n",
"ObsEclLon\n",
"ObsEclLat\n",
"NPole_RA\n",
"NPole_DEC\n",
"GlxLon\n",
"GlxLat\n",
"solartime\n",
"earth_lighttime\n",
"RA_3sigma\n",
"DEC_3sigma\n",
"SMAA_3sigma\n",
"SMIA_3sigma\n",
"Theta_3sigma\n",
"Area_3sigma\n",
"RSS_3sigma\n",
"r_3sigma\n",
"r_rate_3sigma\n",
"SBand_3sigma\n",
"XBand_3sigma\n",
"DoppDelay_3sigma\n",
"true_anom\n",
"hour_angle\n",
"alpha_true\n",
"PABLon\n",
"PABLat\n"
]
}
],
"source": [
"for key in jup.ephem.keys():\n",
" print(key)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "e80844e9",
"metadata": {},
"source": [
"# Example navigation workflow\n",
"# Navigation Workflow\n",
"\n",
"## lat-lon grid for Jupiter HST data"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Navigation tutorial\n",
"# Navigation Basics\n",
"\n",
"This tutorial showcases the utilities contained in the navigation subpackage of pylanetary. Learn how to use the ModelEllipsoid and Nav classes, how to find a navigation solution for observational data, how to re-project that solution to a rectilinear grid, and how to save a navigation solution to a multi-extension fits file."
]
Expand Down Expand Up @@ -421,11 +421,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### summary of nav.colocate methods\n",
"\n",
"The following was written in support of Souami et al. 2023, in prep. If you use this for your own work, please cite the pylanetary package, and also consider citing the image\\_registration and astroquery packages.\n",
"### Learn More\n",
"\n",
"The centroid of the stacked Keck frames was found by cross-correlating the images with a limb-darkened disk model of Neptune. The model disk was assumed ellipsoidal, with equatorial and polar radii of 24764 km and 24341 km, respectively \\footnote{\\url{https://nssdc.gsfc.nasa.gov/planetary/factsheet/neptunefact.html}}. The model was scaled to the distance and orientation of Neptune as viewed from Keck Observatory using the JPL Horizons system, accessed using the Astropy-affiliated \\texttt{astroquery} Python package. The limb darkening was applied using a Minnaert law with coefficient k = 0.867 \\footnote{Wong et al 2018 value in HST blue filter; LMK if anyone finds a better value for the IR somewhere https://doi.org/10.3847/1538-3881/aaa6d6}. The model was convolved with a Gaussian beam to simulate the optics of the telescope. The FWHM of this beam was estimated based on the point-spread function of point sources in the field-of-view (e.g., Proteus). The surface brightness of the limb-darkened disk was set to be the approximate surface brightness of Neptune in cloud-free regions. Image registration between model and data was then carried out using a matrix-multiply discrete Fourier transform technique, implemented using the \\texttt{chi2_shift} function within the Astropy-affiliated \\texttt{image_registration} Python package \\footnote{\\url{https://github.com/keflavich/image_registration}}. Given the RMS noise in the image as input, this technique also yields errors in the shifts using a delta-chi-square criterion. The values of the FWHM, model brightness, and limb-darkening parameter were varied within reasonable ranges, and the resulting x,y position was found not to change by more than 1 sigma in either direction."
"We highly recommend checking out the short Navigation Examples tutorial to better understand a typical workflow before applying this to real science data."
]
},
{
Expand Down Expand Up @@ -634,10 +632,19 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"source": [
"### summary of nav.colocate methods\n",
"\n",
"The following was written in support of Souami et al. 20234. If you use this for your own work, please cite the pylanetary package, and also consider citing the image\\_registration and astroquery packages.\n",
"\n",
"The centroid of the stacked Keck frames was found by cross-correlating the images with a limb-darkened disk model of Neptune. The model disk was assumed ellipsoidal, with equatorial and polar radii of 24764 km and 24341 km, respectively \\footnote{\\url{https://nssdc.gsfc.nasa.gov/planetary/factsheet/neptunefact.html}}. The model was scaled to the distance and orientation of Neptune as viewed from Keck Observatory using the JPL Horizons system, accessed using the Astropy-affiliated \\texttt{astroquery} Python package. The limb darkening was applied using a Minnaert law with coefficient k = 0.867 \\footnote{Wong et al 2018 value in HST blue filter; LMK if anyone finds a better value for the IR somewhere https://doi.org/10.3847/1538-3881/aaa6d6}. The model was convolved with a Gaussian beam to simulate the optics of the telescope. The FWHM of this beam was estimated based on the point-spread function of point sources in the field-of-view (e.g., Proteus). The surface brightness of the limb-darkened disk was set to be the approximate surface brightness of Neptune in cloud-free regions. Image registration between model and data was then carried out using a matrix-multiply discrete Fourier transform technique, implemented using the \\texttt{chi2_shift} function within the Astropy-affiliated \\texttt{image_registration} Python package \\footnote{\\url{https://github.com/keflavich/image_registration}}. Given the RMS noise in the image as input, this technique also yields errors in the shifts using a delta-chi-square criterion. The values of the FWHM, model brightness, and limb-darkening parameter were varied within reasonable ranges, and the resulting x,y position was found not to change by more than 1 sigma in either direction."
]
},
{
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": []
}
],
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 78afa5b

Please sign in to comment.