Exemple #1
0
def test_enable_unit_groupings():
    from astropy.units import cds

    with cds.enable():
        assert cds.geoMass in u.kg.find_equivalent_units()

    from astropy.units import imperial
    with imperial.enable():
        assert imperial.inch in u.m.find_equivalent_units()
Exemple #2
0
def test_enable_unit_groupings():
    from astropy.units import cds

    with cds.enable():
        assert cds.geoMass in u.kg.find_equivalent_units()

    from astropy.units import imperial
    with imperial.enable():
        assert imperial.inch in u.m.find_equivalent_units()
Exemple #3
0
def test_angle_with_cds_units_enabled():
    """Regression test for #5350

    Especially the example in
    https://github.com/astropy/astropy/issues/5350#issuecomment-248770151
    """
    from astropy.units import cds
    # the problem is with the parser, so remove it temporarily
    from astropy.coordinates.angle_utilities import _AngleParser
    del _AngleParser._thread_local._parser
    with cds.enable():
        Angle('5d')
    del _AngleParser._thread_local._parser
    Angle('5d')
Exemple #4
0
def test_angle_with_cds_units_enabled():
    """Regression test for #5350

    Especially the example in
    https://github.com/astropy/astropy/issues/5350#issuecomment-248770151
    """
    from astropy.units import cds
    # the problem is with the parser, so remove it temporarily
    from astropy.coordinates.angle_utilities import _AngleParser
    del _AngleParser._parser
    with cds.enable():
        Angle('5d')
    del _AngleParser._parser
    Angle('5d')
Exemple #5
0
# -*- coding: utf-8 -*-

import astropy.units as u
import lightkurve as lk
import numpy as np
import pytest

from astropy.units import cds
from sloscillations import granulation

import matplotlib.pyplot as plt

cds.enable()

def test_granulation():

    dt = 29.4*60
    t = np.arange(0, 1000*86400, dt)
    nyq = 1.0 / (2*dt)
    bw = 1.0 / t[-1]
    t = (t/86400.0) * u.day
    numax = 100.0

    a = 3382 * numax ** -0.609
    b1 = 0.317 * numax ** 0.970
    b2 = 0.948 * numax ** 0.992

    amps = np.array([a, a])# * cds.ppm
    freqs = np.array([b1, b2])# * u.Hertz

    gran = granulation.Granulation(t, numax)
#! /usr/bin/env python
from __future__ import print_function

from astropy import units as u
from astropy.units import cds
cds.enable()

def orbital_radius(M, omega):
    G = cds.G
    return (G * M / omega**2)**(1.0/3.0)

revolution = u.cycle.in_units(u.radian)

geosynchronous_orbital_radius = orbital_radius(cds.geoMass, revolution/u.sday).decompose()

earth_radius = 1 * cds.Rgeo
orbital_altitude = geosynchronous_orbital_radius - earth_radius

print(orbital_altitude.to(u.km))
Exemple #7
0
def test_cds_non_ascii_unit():
    """Regression test for #5350.  This failed with a decoding error as
    μas could not be represented in ascii."""
    from astropy.units import cds
    with cds.enable():
        u.radian.find_equivalent_units(include_prefix_units=True)
Exemple #8
0
def test_cds_non_ascii_unit():
    """Regression test for #5350.  This failed with a decoding error as
    μas could not be represented in ascii."""
    from astropy.units import cds
    with cds.enable():
        u.radian.find_equivalent_units(include_prefix_units=True)