Skip to main content

A python package for astronomy educators

Project description

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astroedu-0.4.3a0.tar.gz (171.6 kB view details)

Uploaded Source

Built Distribution

astroedu-0.4.3a0-py3-none-any.whl (187.1 kB view details)

Uploaded Python 3

File details

Details for the file astroedu-0.4.3a0.tar.gz.

File metadata

  • Download URL: astroedu-0.4.3a0.tar.gz
  • Upload date:
  • Size: 171.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.12

File hashes

Hashes for astroedu-0.4.3a0.tar.gz
Algorithm Hash digest
SHA256 fe28c9675afe6aab21be8023507b649af0c0ce753d7fca865faed6089a4e6a74
MD5 bb3e69db3213bc598b4172c12dd0068d
BLAKE2b-256 9b824500dce7ee6c2d4d0fd319265051779ef5d78e4cb6c34a2b43f0ec242edc

See more details on using hashes here.

File details

Details for the file astroedu-0.4.3a0-py3-none-any.whl.

File metadata

  • Download URL: astroedu-0.4.3a0-py3-none-any.whl
  • Upload date:
  • Size: 187.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.12

File hashes

Hashes for astroedu-0.4.3a0-py3-none-any.whl
Algorithm Hash digest
SHA256 654ce5032c7263b3bfe2c36ae3dbef5cff2e8fe97b139e6269102aaa6ce6803e
MD5 d9448d07e7435e0b5efb0d7a88bea12e
BLAKE2b-256 4468e2bb3fe104bed2dcbfd6d1b95d041f775af890598f13e27880dc17fee26d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page