Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

AP Logo

PyPI version Contributor Covenant DOI Alpha

A package containing small interactives, datasets, functions etc for teaching astronomy.

Contributors:

Installation

To install astroedu run

pip install astroedu

or with conda

conda install -c conda-forge astroedu

Current Functionality

Interactives

astroedu interactive wiens_law

Loads the interactive notebook file exploring Wien's Law. Jupyter lab arguments can be passed after the interactive name for instance:

astroedu interactive wiens_law --port 9999

Datasets

To use a data set import the utitlity function load_data from the datasets module:

from astroedu.datasets import load_data

Then you can load a data set by passing its name as a string to load_data.

planets = load_data('planets')

The function returns a Pandas dataframe. If the optional keyword argument info is True then a brief explanation of the data is printed before the dataframe is loaded.

Constants

Astropy like constants for ease of access. For full functionality use the astropy constants submodule.

>>> from astroedu.constants import c
>>> c
Constant(c, 299792458, m/s, Speed of light)

or

>>> import astroedu.constants as const
>>> print(const.c)
Name = Speed of light
Value = 299792458
Unit = m/s

Constants can perform simple maths with other constants or int/float/np.array. The returned value is an int/float/np.array not a Constant class instance:

>>> from astroedu.constants import c, m_e
>>> c*m_e
2.7309245302881346e-22

Functions

Some basic functions have been implemented:

>>> from astroedu.functions import wiens_law
>>> wiens_law(1000)
2.897771955e-06

You can use the get_sun() function to quickly display images of the Sun if you have SunPy installed.

# From the command line:
astroedu get_sun                          # plots today's Sun
astroedu get_sun 2022/02/02               # plots Sun on diff date than today
astroedu get_sun save                     # plots then saves image
astroedu get_sun 2022/02/02 save
# In .py or IPython
>>> from astroedu.functions import get_sun
>>> get_sun()                                 # plots today's Sun
>>> get_sun('2022/02/02')                     # plots Sun on diff date than today
>>> get_sun('2022/02/02', save=True)          # plots then saves image

Before you can save anything run:

astroedu build

in the terminal. This creates a config.ini file which contains paths to your astroedu install and Documents directory. The get_sun() function will create the directory astroedu in your Documents directory if it doesn't exist and save files there.

Classes

Some classes which are hopefully useful!

Body2D

The Body2D class is the main body class for planets and other objects. Usage - Body2D(str-name, float-x pos in AU, float-y pos in AU, float-radius in km, float-mass in kg) for instance:

>>> from astroedu.classes import Body2D
>>> moon = Body2D('Moon', 0, 0, 1737.4, 0.07346*10**24)
>>> print(moon)
Moon at (0.00, 0.00) AU with r = 1.74E+03 km and m = 7.35E+22 kg

There are pre-defined class methods for the Earth, Sun, and Moon:

>>> from astroedu.classes import Body2D
>>> moon = Body2D.Moon(0, 0)
>>> print(moon)
Moon at (0.00, 0.00) AU with r = 1.74E+03 km and m = 7.35E+22 kg

The class has built in methods. For instance to calculate the tides on the Earth due to the Moon:

>>> from astroedu.classes import Body2D
>>> earth = Body2D.Earth(0, 0)
>>> moon = Body2D.Moon(384400000/au, 0)
>>> forces = earth.tides(moon, step=0.25, scale=5.972*10**24)

Documentation coming soon. More methods will be added at a later date including calculating gravitational potentials and plotting tides & potentials.

Submodules

planetMagFields

planetMagFields by Ankit Barik. DOI, github.com/AnkitBarik/planetMagFields

See Ankit's GitHub for usage. Note: cartopy is required for some plots which requires these packages to be installed, GEOS and PROJ. Some functions also require other libraries such as SHTns (no Windows version) and PyEVTK, see Ankit's GitHub for more info.

Since the dataset location is defined relative to the astroedu install there is no need to specify a datDir for instance:

>>> import matplotlib.pyplot as plt
>>> from astroedu.planetmagfields import *
>>> p = planet(name='jupiter')
>>> # not p = planet(name='jupiter',datDir='planetmagfields/data/')
>>> p.plot(r=0.85,proj='Mollweide')
>>> plt.show()

Metadata

Release files for astroedu 0.4.3a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for astroedu 0.4.3a0
File Size Uploaded Provenance
astroedu-0.4.3a0.tar.gz 171.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for astroedu 0.4.3a0
File Interpreter ABI Platform
astroedu-0.4.3a0-py3-none-any.whl Python 3 none any Details

Total release size: 358.7 kB

Release files / astroedu-0.4.3a0.tar.gz

Download URL astroedu-0.4.3a0.tar.gz
Size 171.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fe28c9675afe6aab21be8023507b649af0c0ce753d7fca865faed6089a4e6a74
BLAKE2b-256 checksum
How to use checksums
9b824500dce7ee6c2d4d0fd319265051779ef5d78e4cb6c34a2b43f0ec242edc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.12

Release files / astroedu-0.4.3a0-py3-none-any.whl

Download URL astroedu-0.4.3a0-py3-none-any.whl
Size 187.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
654ce5032c7263b3bfe2c36ae3dbef5cff2e8fe97b139e6269102aaa6ce6803e
BLAKE2b-256 checksum
How to use checksums
4468e2bb3fe104bed2dcbfd6d1b95d041f775af890598f13e27880dc17fee26d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.12

Security for astroedu 0.4.3a0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page