Commit 3ff241ae authored by Ole Streicher's avatar Ole Streicher

Beta release 0.2b1

parent 18346b31
Metadata-Version: 1.1
Name: astropy
Version: 0.1
Version: 0.2b1
Summary: Community-developed python astronomy tools
Home-page: http://astropy.org
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD
Download-URL: http://cloud.github.com/downloads/astropy/astropy/astropy-0.1.tar.gz
Download-URL: http://pypi.python.org/packages/source/a/astropy/astropy-0.2b1.tar.gz
Description:
Astropy is a package intended to contain core functionality and some
common tools needed for performing astronomy and astrophysics research with
......@@ -14,5 +14,16 @@ Description:
managing them.
Platform: UNKNOWN
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: C
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Astronomy
Classifier: Topic :: Scientific/Engineering :: Physics
Requires: numpy
Provides: astropy
......@@ -30,7 +30,6 @@ except ImportError:
__githash__ = ''
# set up the test command
_test_runner = None
def _get_test_runner():
from .tests.helper import TestRunner
return TestRunner(__path__[0])
......@@ -101,4 +100,4 @@ def test(package=None, test_path=None, args=None, plugins=None,
#if we are *not* in setup mode, import the logger
if not _ASTROPY_SETUP_:
from logger import log
from .logger import log
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This is a hidden sub-package containing the definitions of the constants used
in `astropy.units` and `astropy.constants`. These need to be included outside
both of those sub-packages to avoid circular dependencies.
"""
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astronomical and physics constants in cgs units. The constants
available (with approximate values) are:
"""
# This docstring is extended by __init__.py
# The values of constants are defined here instead of `astropy/constants` in
# order to avoid circular dependencies, since Constant depends on Quantity,
# Quantity depends on Unit, and Unit depends on the value of some of the
# constants, so they need to be kept separately.
from .definition import ConstantDefinition
from . import si
# PHYSICAL CONSTANTS
# Planck constant
h = ConstantDefinition(si.h * 1.e7, si.h.uncertainty * 1.e7,
si.h.name, si.h.reference, 'erg.s')
# Reduced Planck constant
hbar = ConstantDefinition(si.hbar * 1.e7, si.hbar.uncertainty * 1.e7,
si.hbar.name, si.hbar.reference, 'erg.s')
# Boltzmann constant [CODATA]
k_B = ConstantDefinition(si.k_B * 1.e7, si.k_B.uncertainty * 1.e7,
si.k_B.name, si.k_B.reference, 'erg.s')
# Speed of light [CODATA]
c = ConstantDefinition(si.c * 1.e2, si.c.uncertainty * 1.e2,
si.c.name, si.c.reference, 'cm/s')
# Gravitional constant [CODATA]
G = ConstantDefinition(si.G * 1.e3, si.G.uncertainty * 1.e3,
si.G.name, si.G.reference, 'cm3.g-1.s-2')
# Proton mass [CODATA]
m_p = ConstantDefinition(si.m_p * 1.e3, si.m_p.uncertainty * 1.e3,
si.m_p.name, si.m_p.reference, 'g')
# Neutron mass [CODATA]
m_n = ConstantDefinition(si.m_n * 1.e3, si.m_n.uncertainty * 1.e3,
si.m_n.name, si.m_n.reference, 'g')
# Electron mass [CODATA]
m_e = ConstantDefinition(si.m_e * 1.e3, si.m_e.uncertainty * 1.e3,
si.m_e.name, si.m_e.reference, 'g')
# Stefan-Boltzmann constant
sigma_sb = ConstantDefinition(si.sigma_sb * 1.e3, si.sigma_sb.uncertainty * 1.e3,
si.sigma_sb.name, si.sigma_sb.reference,
'erg.cm-2.K-4.s-1')
# Electron charge
e = ConstantDefinition(si.e * si.c * 10., si.e.uncertainty * si.c * 10.,
si.e.name, si.e.reference, 'statC')
# Avogadro's number
N_A = ConstantDefinition(si.N_A, si.N_A.uncertainty,
si.N_A.name, si.N_A.reference, 'mol-1')
# Gas constant
R = ConstantDefinition(si.R * 1.e7, si.R.uncertainty * 1.e7,
si.R.name, si.R.reference, 'erg.K-1.mol-1')
# Rydberg constant
Ryd = ConstantDefinition(si.Ryd * 1.e-2, si.Ryd.uncertainty * 1.e-2,
si.Ryd.name, si.Ryd.reference, 'cm-1')
# DISTANCE
# Astronomical Unit
au = ConstantDefinition(si.au * 1.e2, si.au.uncertainty * 1.e2,
si.au.name, si.au.reference, 'cm')
# Parsec
pc = ConstantDefinition(si.pc * 1.e2, si.pc.uncertainty * 1.e2,
si.pc.name, si.pc.reference, 'cm')
# Kiloparsec
kpc = ConstantDefinition(si.kpc * 1.e2, si.kpc.uncertainty * 1.e2,
si.kpc.name, si.kpc.reference, 'cm')
# SOLAR QUANTITIES
# Solar luminosity
L_sun = ConstantDefinition(si.L_sun * 1.e7, si.L_sun.uncertainty * 1.e7,
si.L_sun.name, si.L_sun.reference, 'erg/s')
# Solar mass
M_sun = ConstantDefinition(si.M_sun * 1.e3, si.M_sun.uncertainty * 1.e3,
si.M_sun.name, si.M_sun.reference, 'g')
# Solar radius
R_sun = ConstantDefinition(si.R_sun * 1.e2, si.R_sun.uncertainty * 1.e2,
si.R_sun.name, si.R_sun.reference, 'cm')
# OTHER SOLAR SYSTEM QUANTITIES
# Jupiter mass
M_jup = ConstantDefinition(si.M_jup * 1.e3, si.M_jup.uncertainty * 1.e3,
si.M_jup.name, si.M_jup.reference, 'g')
# Jupiter equatorial radius
R_jup = ConstantDefinition(si.R_jup * 1.e2, si.R_jup.uncertainty * 1.e2,
si.R_jup.name, si.R_jup.reference, 'cm')
# Earth mass
M_earth = ConstantDefinition(si.M_earth * 1.e3, si.M_earth.uncertainty * 1.e3,
si.M_earth.name, si.M_earth.reference, 'g')
# Earth equatorial radius
R_earth = ConstantDefinition(si.R_earth * 1.e2, si.R_earth.uncertainty * 1.e2,
si.R_earth.name, si.R_earth.reference, 'cm')
class ConstantDefinition(float):
"""
A float with meta-data related to physical constants
"""
def __init__(self, value, uncertainty, name, reference, units):
super(ConstantDefinition, self).__init__()
self.value = value
self.uncertainty = uncertainty
self.name = name
self.reference = reference
self.units = units
def __new__(cls, value, uncertainty, name, reference, units):
return super(ConstantDefinition, cls).__new__(cls, value)
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astronomical and physics constants in SI units. The constants
available (with approximate values) are:
"""
# This docstring is extended by __init__.py
# The values of constants are defined here instead of `astropy/constants` in
# order to avoid circular dependencies, since Constant depends on Quantity,
# Quantity depends on Unit, and Unit depends on the value of some of the
# constants, so they need to be kept separately.
import numpy as np
from .definition import ConstantDefinition
# PHYSICAL CONSTANTS
# Planck constant
h = ConstantDefinition(6.62606957e-34, 0.00000029e-34,
"Planck constant",
'CODATA 2010', 'J.s')
# Reduced Planck constant
hbar = ConstantDefinition(h * 0.5 / np.pi, h.uncertainty * 0.5 / np.pi,
"Reduced Planck constant",
'CODATA 2010', 'J.s')
# Boltzmann constant
k_B = ConstantDefinition(1.3806488e-23, 0.0000013e-23,
"Boltzmann constant",
'CODATA 2010', 'J/K')
# Speed of light
c = ConstantDefinition(2.99792458e8, 0.,
"Speed of light in vacuum",
'CODATA 2010', 'm/s')
# Gravitional constant
G = ConstantDefinition(6.67384e-11, 0.00080e-11,
"Gravitational constant",
'CODATA 2010', 'm3.kg-1.s-2')
# Proton mass
m_p = ConstantDefinition(1.672621777e-27, 0.000000074e-27,
"Proton mass",
'CODATA 2010', 'kg')
# Neutron mass
m_n = ConstantDefinition(1.674927351e-27, 0.000000074e-27,
"Neutron mass",
'CODATA 2010', 'kg')
# Electron mass
m_e = ConstantDefinition(9.10938291e-31, 0.00000040e-31,
"Electron mass",
'CODATA 2010', 'kg')
# Stefan-Boltzmann constant
sigma_sb = ConstantDefinition(5.670373e-8, 0.000021e-8,
"Stefan-Boltzmann constant",
'CODATA 2010', 'W.m-2.K-4')
# Electron charge
e = ConstantDefinition(1.602176565e-19, 0.000000035e-19,
"Electron charge",
'CODATA 2010', 'C')
# Avogadro's number
N_A = ConstantDefinition(6.02214129e23, 0.00000027e23,
"Avogadro's number",
'CODATA 2010', 'mol-1')
# Gas constant
R = ConstantDefinition(8.3144621, 0.0000075,
"Gas constant",
'CODATA 2010', 'J.mol-1.K-1')
# Rydberg constant
Ryd = ConstantDefinition(10973731.568539, 0.000055,
'Rydberg constant',
'CODATA 2010', 'm-1')
# DISTANCE
# Astronomical Unit
au = ConstantDefinition(1.49597870700e11, 0.0,
"Astronomical Unit",
"IAU 2012 Resolution B2", 'm')
# Parsec
pc = ConstantDefinition(au / np.tan(np.radians(1. / 3600.)),
au.uncertainty / np.tan(np.radians(1. / 3600.)),
"Parsec",
"Derived from au", 'm')
# Kiloparsec
kpc = ConstantDefinition(1000. * au / np.tan(np.radians(1. / 3600.)),
1000. * au.uncertainty / np.tan(np.radians(1. / 3600.)),
"Kiloparsec",
"Derived from au", 'm')
# SOLAR QUANTITIES
# Solar luminosity
L_sun = ConstantDefinition(3.846e26, 0.0005e26,
"Solar luminosity",
"Allen's Astrophysical Quantities 4th Ed.", 'W')
# Solar mass
M_sun = ConstantDefinition(1.9891e30, 0.00005e30,
"Solar mass",
"Allen's Astrophysical Quantities 4th Ed.", 'kg')
# Solar radius
R_sun = ConstantDefinition(6.95508e8, 0.00026e8,
"Solar radius",
"Allen's Astrophysical Quantities 4th Ed.", 'm')
# OTHER SOLAR SYSTEM QUANTITIES
# Jupiter mass
M_jup = ConstantDefinition(1.8987e27, 0.00005e27,
"Jupiter mass",
"Allen's Astrophysical Quantities 4th Ed.", 'kg')
# Jupiter equatorial radius
R_jup = ConstantDefinition(7.1492e7, 0.00005e7,
"Jupiter equatorial radius",
"Allen's Astrophysical Quantities 4th Ed.", 'm')
# Earth mass
M_earth = ConstantDefinition(5.9742e24, 0.00005e24,
"Earth mass",
"Allen's Astrophysical Quantities 4th Ed.", 'kg')
# Earth equatorial radius
R_earth = ConstantDefinition(6.378136e6, 0.0000005e6,
"Earth equatorial radius",
"Allen's Astrophysical Quantities 4th Ed.", 'm')
......@@ -8,5 +8,4 @@ affiliated package index.
from .paths import *
from .configuration import *
from .data import *
from .affiliated import *
......@@ -99,7 +99,7 @@ def get_config_dir(create=True):
#first look for XDG_CONFIG_HOME
xch = environ.get('XDG_CONFIG_HOME')
if xch is not None:
if xch is not None and path.exists(xch):
xchpth = path.join(xch, 'astropy')
if not path.islink(xchpth):
if path.exists(xchpth):
......@@ -133,7 +133,7 @@ def get_cache_dir():
#first look for XDG_CACHE_HOME
xch = environ.get('XDG_CACHE_HOME')
if xch is not None:
if xch is not None and path.exists(xch):
xchpth = path.join(xch, 'astropy')
if not path.islink(xchpth):
if path.exists(xchpth):
......
def get_package_data():
# Installs the testing data files
return {
'astropy.config.tests': ['data/*.dat']
}
......@@ -127,7 +127,7 @@ def test_configitem_save(tmpdir):
def test_configitem_types():
from ..configuration import ConfigurationItem
from pytest import raises
from ...tests.helper import pytest
ci1 = ConfigurationItem('tstnm1', 34)
assert isinstance(ci1(), int)
......@@ -141,18 +141,18 @@ def test_configitem_types():
ci4 = ConfigurationItem('tstnm4', 'astring')
assert isinstance(ci4(), str)
with raises(TypeError):
with pytest.raises(TypeError):
ci1.set(34.3)
ci2.set(12) # this would should succeed as up-casting
with raises(TypeError):
with pytest.raises(TypeError):
ci3.set('fasd')
with raises(TypeError):
with pytest.raises(TypeError):
ci4.set(546.245)
def test_configitem_options(tmpdir):
from ..configuration import ConfigurationItem, get_config
from pytest import raises
from ...tests.helper import pytest
cio = ConfigurationItem('tstnmo', ['op1', 'op2', 'op3'])
sec = get_config(cio.module)
......@@ -162,7 +162,7 @@ def test_configitem_options(tmpdir):
assert sec['tstnmo'] == 'op1'