Package: astroedu
AlphaA package containing small interactives, datasets, functions etc for teaching astronomy.Contributors:Dimitrios TheodorakisAnkit Barik, planetMagFields module,,github.com/AnkitBarik/planetMagFieldsInstallationTo installastroedurunpip install astroeduor withcondaconda install -c conda-forge astroeduCurrent FunctionalityInteractivesastroedu interactive wiens_lawLoads 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 9999DatasetsTo use a data set import the utitlity functionload_datafrom the datasets module:from astroedu.datasets import load_dataThen you can load a data set by passing its name as a string toload_data.planets = load_data('planets')The function returns a Pandas dataframe.
If the optional keyword argumentinfoisTruethen a brief explanation of the data is printed before the dataframe is loaded.ConstantsAstropy like constants for ease of access.
For full functionality use the astropyconstantssubmodule.>>> 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/sConstants 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-22FunctionsSome basic functions have been implemented:>>> from astroedu.functions import wiens_law
>>> wiens_law(1000)
2.897771955e-06You can use theget_sun()function to quickly display images of the Sun if you haveSunPyinstalled.# 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 imageBefore you can save anything run:astroedu buildin the terminal. This creates aconfig.inifile which contains paths to your astroedu install and Documents directory.
Theget_sun()function will create the directoryastroeduin your Documents directory if it doesn't exist and save files there.ClassesSome classes which are hopefully useful!Body2DThe 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 kgThere 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 kgThe 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.SubmodulesplanetMagFieldsplanetMagFields by Ankit Barik.,github.com/AnkitBarik/planetMagFieldsSee Ankit's GitHub for usage. Note: cartopy is required for some plots which requires these packages to be installed,GEOSandPROJ. 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()