本文整理汇总了Python中astropy.coordinates.EarthLocation.from_geodetic方法的典型用法代码示例。如果您正苦于以下问题:Python EarthLocation.from_geodetic方法的具体用法?Python EarthLocation.from_geodetic怎么用?Python EarthLocation.from_geodetic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.coordinates.EarthLocation
的用法示例。
在下文中一共展示了EarthLocation.from_geodetic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_itrs_vals_5133
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_itrs_vals_5133():
time = Time('2010-1-1')
el = EarthLocation.from_geodetic(lon=20*u.deg, lat=45*u.deg, height=0*u.km)
lons = [20, 30, 20]*u.deg
lats = [44, 45, 45]*u.deg
alts = [0, 0, 10]*u.km
coos = [EarthLocation.from_geodetic(lon, lat, height=alt).get_itrs(time)
for lon, lat, alt in zip(lons, lats, alts)]
aaf = AltAz(obstime=time, location=el)
aacs = [coo.transform_to(aaf) for coo in coos]
assert all([coo.isscalar for coo in aacs])
# the ~1 arcsec tolerance is b/c aberration makes it not exact
assert_quantity_allclose(aacs[0].az, 180*u.deg, atol=1*u.arcsec)
assert aacs[0].alt < 0*u.deg
assert aacs[0].distance > 50*u.km
# it should *not* actually be 90 degrees, b/c constant latitude is not
# straight east anywhere except the equator... but should be close-ish
assert_quantity_allclose(aacs[1].az, 90*u.deg, atol=5*u.deg)
assert aacs[1].alt < 0*u.deg
assert aacs[1].distance > 50*u.km
assert_quantity_allclose(aacs[2].alt, 90*u.deg, atol=1*u.arcsec)
assert_quantity_allclose(aacs[2].distance, 10*u.km)
示例2: compute_sun_time_offset
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def compute_sun_time_offset(LONG,LAT):
EL = el.from_geodetic( LONG , LAT )
sidingSpringEL = el.from_geodetic(149.071111, -31.273333)
### calculate time offset:
time_offsets = np.linspace(0, 24, num=24 * 6)
full_night_times = time.Time.now() + time_offsets * u.hour
full_night_aa_frames = AltAz(location=EL, obstime=full_night_times)
sun = ((coor.get_sun(full_night_times).transform_to(full_night_aa_frames)).alt.deg)
s = 0
if sun[0] < -18:
start = 0
else:
while sun[s] > -18:
s = s + 1
start = time_offsets[s]
e = s + 1
while sun[e] < -18:
e = e + 1
end = time_offsets[e]
mid = time_offsets[s + (e - s) // 2]
return [start, mid, end]
示例3: find_parallax
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def find_parallax(self, date):
'''Find the maximum parallax of self.planet on the given date
from self.observer's location -- in other words, the difference
in Mars' position between the observer's position and an
observer at the same latitude but opposite longitude:
this tells you you how much difference you would see from
your position if Mars didn't move between your sunrise and sunset.
'''
# To calculate from a point on the equator, set lat to 0.
observer_loc = EarthLocation.from_geodetic(self.location.lon,
self.location.lat,
self.location.height)
# Specify the anti-point.
# This isn't really an antipode unless lat == 0.
antipode_loc = EarthLocation.from_geodetic(-observer.lon,
observer.lat,
observer.height)
# XXX Oops, astropy doesn't offer next_rising etc.
# so we'll need a function to find that before this
# function can be implemented since it only works
# when the planet is on the horizon so both the observer
# and the anti-observer can see it.
risetime = find_next_rising(planetname, date)
obs_planet = get_body(planetname, risetime, observer_loc)
ant_planet = get_body(planetname, risetime, antipode_loc)
# First, calculate it the straightforward way using the arctan:
print()
mars_dist_miles = mars.distance.km / 1.609344
print("Miles to Mars:", mars_dist_miles)
earth_mean_radius = 3958.8 # in miles
half_dist = earth_mean_radius * math.cos(observer_loc.lat)
print("Distance between observers:", 2. * half_dist)
par = 2. * math.atan(half_dist / mars_dist_miles) \
* 180. / math.pi * 3600.
print("Calculated parallax (arcsec):", par)
# See what astropy calculates as the difference between observations:
print()
print("parallax on %s: RA %f, dec %f" % (antipode.date,
obs_planet.ra - ant_planet.ra,
obs_planet.dec - ant_planet.dec))
total_par = (math.sqrt((obs_planet.ra.radians
- ant_planet.ra.radians)**2
+ (obs_planet.dec.radians
- ant_planet.dec.radians)**2)
* 180. * 3600. / math.pi)
print("Total parallax (sum of squares): %f arcseconds" % total_par)
print()
示例4: test_new_site_info_to_json
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_new_site_info_to_json():
lon_str = "-155d28m34s"
lat_str = "+19d49m32s"
elevation = 4139*u.m
location = EarthLocation.from_geodetic(lon_str, lat_str, elevation)
short_name = "New telescope (subaru)"
aliases = ["example new telescope with subaru's coordinates"]
source = "the tests module"
new_site_json = new_site_info_to_json(short_name, location, aliases, source)
new_site = json.loads(new_site_json)
ns = new_site[short_name]
assert_quantity_allclose(Longitude(lon_str),
Longitude(ns["longitude"]*u.Unit(ns["longitude_unit"])),
atol=0.001*u.deg)
assert_quantity_allclose(Latitude(lat_str),
Latitude(ns["latitude"]*u.Unit(ns["latitude_unit"])),
atol=0.001*u.deg)
assert_quantity_allclose(elevation,
new_site[short_name]["elevation"]*u.Unit(ns["elevation_unit"]),
atol=1*u.m)
assert short_name == new_site[short_name]['name']
assert aliases == new_site[short_name]['aliases']
with pytest.raises(ValueError):
# This name already exists
new_site_info_to_json("Keck", location, aliases, source)
示例5: test_moon_rise_set
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_moon_rise_set():
pyephem_next_rise = datetime.datetime(2017, 10, 7, 23, 50, 24, 407018)
pyephem_next_set = datetime.datetime(2017, 10, 7, 12, 30, 30, 787116)
pyephem_prev_rise = datetime.datetime(2017, 10, 6, 23, 13, 43, 644455)
pyephem_prev_set = datetime.datetime(2017, 10, 6, 11, 20, 9, 340009)
time = Time('2017-10-07 12:00:00')
lat = '42:00:00'
lon = '-70:00:00'
elevation = 0.0 * u.m
pressure = 0 * u.bar
location = EarthLocation.from_geodetic(lon, lat, elevation)
obs = Observer(location=location)
astroplan_next_rise = obs.moon_rise_time(time, which='next')
astroplan_next_set = obs.moon_set_time(time, which='next')
astroplan_prev_rise = obs.moon_rise_time(time, which='previous')
astroplan_prev_set = obs.moon_set_time(time, which='previous')
threshold_minutes = 2
assert (abs(pyephem_next_rise - astroplan_next_rise.datetime) <
datetime.timedelta(minutes=threshold_minutes))
assert (abs(pyephem_next_set - astroplan_next_set.datetime) <
datetime.timedelta(minutes=threshold_minutes))
assert (abs(pyephem_prev_rise - astroplan_prev_rise.datetime) <
datetime.timedelta(minutes=threshold_minutes))
assert (abs(pyephem_prev_set - astroplan_prev_set.datetime) <
datetime.timedelta(minutes=threshold_minutes))
示例6: new_with_astropy
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def new_with_astropy(cls, starttime, stoptime, obsid=None):
"""
Add an observation to the M&C database, using Astropy to compute
the LST.
Parameters:
------------
starttime: astropy time object
observation starttime
stoptime: astropy time object
observation stoptime
obsid: long integer
observation identification number. If not provided, will be set
to the gps second corresponding to the starttime using floor.
"""
t_start = starttime.utc
t_stop = stoptime.utc
# t_start.delta_ut1_utc = iers_a.ut1_utc(t_start)
# t_stop.delta_ut1_utc = iers_a.ut1_utc(t_stop)
if obsid is None:
from math import floor
obsid = floor(t_start.gps)
t_start.location = EarthLocation.from_geodetic(HERA_LON, HERA_LAT)
return cls(obsid=obsid, start_time_jd=t_start.jd,
stop_time_jd=t_stop.jd,
lst_start_hr=t_start.sidereal_time('apparent').hour)
示例7: test_sunrise_sunset_equator_civil_twilight
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_sunrise_sunset_equator_civil_twilight():
"""
Check that time of sunrise/set for an observer on the equator is
consistent with PyEphem results (for no atmosphere/pressure=0)
"""
lat = "00:00:00"
lon = "00:00:00"
elevation = 0.0 * u.m
pressure = 0 * u.bar
location = EarthLocation.from_geodetic(lon, lat, elevation)
time = Time("2000-01-01 12:00:00")
obs = Observer(location=location, pressure=pressure)
# Manually impose horizon equivalent to civil twilight
horizon = -6 * u.degree
astroplan_next_sunrise = obs.sun_rise_time(time, which="next", horizon=horizon).datetime
astroplan_next_sunset = obs.sun_set_time(time, which="next", horizon=horizon).datetime
astroplan_prev_sunrise = obs.sun_rise_time(time, which="previous", horizon=horizon).datetime
astroplan_prev_sunset = obs.sun_set_time(time, which="previous", horizon=horizon).datetime
# Run print_pyephem_sunrise_sunset_equator_civil_twilight() to compute
# analogous result from PyEphem:
pyephem_next_rise = datetime.datetime(2000, 1, 2, 5, 37, 34, 83328)
pyephem_next_set = datetime.datetime(2000, 1, 1, 18, 29, 29, 195908)
pyephem_prev_rise = datetime.datetime(2000, 1, 1, 5, 37, 4, 701708)
pyephem_prev_set = datetime.datetime(1999, 12, 31, 18, 29, 1, 530987)
threshold_minutes = 8
assert abs(pyephem_next_rise - astroplan_next_sunrise) < datetime.timedelta(minutes=threshold_minutes)
assert abs(pyephem_next_set - astroplan_next_sunset) < datetime.timedelta(minutes=threshold_minutes)
assert abs(pyephem_prev_rise - astroplan_prev_sunrise) < datetime.timedelta(minutes=threshold_minutes)
assert abs(pyephem_prev_set - astroplan_prev_sunset) < datetime.timedelta(minutes=threshold_minutes)
示例8: test_vega_sirius_transit_seattle
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_vega_sirius_transit_seattle():
"""
Check that time of transit of Vega for an observer in Seattle is
consistent with PyEphem results (for no atmosphere/pressure=0)
"""
lat = "47d36m34.92s"
lon = "122d19m59.16s"
elevation = 0.0 * u.m
pressure = 0 * u.bar
location = EarthLocation.from_geodetic(lon, lat, elevation)
time = Time("1990-01-01 12:00:00")
vega = SkyCoord(279.23473479 * u.degree, 38.78368896 * u.degree)
sirius = SkyCoord(101.28715533 * u.degree, -16.71611586 * u.degree)
obs = Observer(location=location, pressure=pressure)
astroplan_vega_transit = obs.target_meridian_transit_time(time, vega, which="next").datetime
astroplan_sirius_transit = obs.target_meridian_transit_time(time, sirius, which="next").datetime
astroplan_vector_transit = obs.target_meridian_transit_time(time, [vega, sirius], which="next").datetime
# Run print_pyephem_vega_sirius_transit() to compute analogous
# result from PyEphem:
pyephem_vega_transit = datetime.datetime(1990, 1, 2, 3, 41, 9, 244067)
pyephem_sirius_transit = datetime.datetime(1990, 1, 1, 15, 51, 15, 135167)
# Typical difference in this example between PyEphem and astroplan
# with an atmosphere is <2 min
threshold_minutes = 8
assert abs(pyephem_vega_transit - astroplan_vega_transit) < datetime.timedelta(minutes=threshold_minutes)
assert abs(pyephem_sirius_transit - astroplan_sirius_transit) < datetime.timedelta(minutes=threshold_minutes)
# Now check vectorized solutions against scalar:
assert astroplan_vector_transit[0] == astroplan_vega_transit
assert astroplan_vector_transit[1] == astroplan_sirius_transit
示例9: test_sunrise_sunset_equator
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_sunrise_sunset_equator():
"""
Check that time of sunrise/set for an observer on the equator is
consistent with PyEphem results (for no atmosphere/pressure=0)
"""
lat = "00:00:00"
lon = "00:00:00"
elevation = 0.0 * u.m
pressure = 0 * u.bar
location = EarthLocation.from_geodetic(lon, lat, elevation)
time = Time("2000-01-01 12:00:00")
obs = Observer(location=location, pressure=pressure)
astroplan_next_sunrise = obs.sun_rise_time(time, which="next").datetime
astroplan_next_sunset = obs.sun_set_time(time, which="next").datetime
astroplan_prev_sunrise = obs.sun_rise_time(time, which="previous").datetime
astroplan_prev_sunset = obs.sun_set_time(time, which="previous").datetime
# Run print_pyephem_sunrise_sunset() to compute analogous
# result from PyEphem:
pyephem_next_sunrise = datetime.datetime(2000, 1, 2, 6, 3, 39, 150790)
pyephem_next_sunset = datetime.datetime(2000, 1, 1, 18, 3, 23, 676686)
pyephem_prev_sunrise = datetime.datetime(2000, 1, 1, 6, 3, 10, 720052)
pyephem_prev_sunset = datetime.datetime(1999, 12, 31, 18, 2, 55, 100786)
# Typical difference in this example between PyEphem and astroplan
# with an atmosphere is <2 min
threshold_minutes = 8
assert abs(pyephem_next_sunrise - astroplan_next_sunrise) < datetime.timedelta(minutes=threshold_minutes)
assert abs(pyephem_next_sunset - astroplan_next_sunset) < datetime.timedelta(minutes=threshold_minutes)
assert abs(pyephem_prev_sunrise - astroplan_prev_sunrise) < datetime.timedelta(minutes=threshold_minutes)
assert abs(pyephem_prev_sunset - astroplan_prev_sunset) < datetime.timedelta(minutes=threshold_minutes)
示例10: test_Observer_constructor_location
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_Observer_constructor_location():
"""
Show that location defined by latitude/longitude/elevation is parsed
identically to passing in an `~astropy.coordinates.EarthLocation` directly.
"""
lat = '+19:00:00'
lon = '-155:00:00'
elevation = 0.0 * u.m
location = EarthLocation.from_geodetic(lon, lat, elevation)
environment_kwargs = dict(pressure=1*u.bar, relative_humidity=0.1,
temperature=10*u.deg_C)
obs1 = Observer(name='Observatory',
latitude=lat,
longitude=lon,
elevation=elevation,
**environment_kwargs)
obs2 = Observer(name='Observatory',
location=location,
**environment_kwargs)
assert obs1.location == obs2.location, ('using latitude/longitude/'
'elevation keywords gave a '
'different answer from passing in '
'an EarthLocation directly')
示例11: test_exceptions
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_exceptions():
lat = "00:00:00"
lon = "00:00:00"
elevation = 0.0 * u.m
location = EarthLocation.from_geodetic(lon, lat, elevation)
time = Time("2000-01-01 12:00:00")
vega_coords = SkyCoord("18h36m56.33635s", "+38d47m01.2802s")
obs = Observer(location=location)
with pytest.raises(ValueError):
obs.target_rise_time(time, vega_coords, which="oops").datetime
with pytest.raises(ValueError):
obs.target_set_time(time, vega_coords, which="oops").datetime
with pytest.raises(ValueError):
obs.target_meridian_transit_time(time, vega_coords, which="oops").datetime
with pytest.raises(ValueError):
obs.target_meridian_antitransit_time(time, vega_coords, which="oops").datetime
with pytest.raises(TypeError):
FixedTarget(["00:00:00", "00:00:00"], name="VE")
with pytest.raises(TypeError):
Observer(location="Greenwich")
with pytest.raises(TypeError):
Observer(location=EarthLocation(0, 0, 0), timezone=-6)
示例12: test_solar_transit_convenience_methods
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_solar_transit_convenience_methods():
"""
Test that astroplan's noon and midnight convenience methods agree with
PyEphem's solar transit/antitransit time.
"""
lat = '00:00:00'
lon = '00:00:00'
elevation = 0.0 * u.m
pressure = 0 * u.bar
location = EarthLocation.from_geodetic(lon, lat, elevation)
time = Time('2000-01-01 12:00:00')
from astropy.coordinates import get_sun
obs = Observer(location=location, pressure=pressure)
# Compute next/previous noon/midnight using generic calc_transit methods
astroplan_next_noon = obs.noon(time, which='next').datetime
astroplan_next_midnight = obs.midnight(time, which='next').datetime
astroplan_prev_noon = obs.noon(time, which='previous').datetime
astroplan_prev_midnight = obs.midnight(time, which='previous').datetime
# Computed in print_pyephem_solar_transit_noon()
pyephem_next_transit = datetime.datetime(2000, 1, 1, 12, 3, 17, 207300)
pyephem_next_antitransit = datetime.datetime(2000, 1, 2, 0, 3, 31, 423333)
pyephem_prev_transit = datetime.datetime(1999, 12, 31, 12, 2, 48, 562755)
pyephem_prev_antitransit = datetime.datetime(2000, 1, 1, 0, 3, 2, 918943)
threshold_minutes = 8
assert (abs(astroplan_next_noon - pyephem_next_transit) <
datetime.timedelta(minutes=threshold_minutes))
assert (abs(astroplan_next_midnight - pyephem_next_antitransit) <
datetime.timedelta(minutes=threshold_minutes))
assert (abs(astroplan_prev_noon - pyephem_prev_transit) <
datetime.timedelta(minutes=threshold_minutes))
assert (abs(astroplan_prev_midnight - pyephem_prev_antitransit) <
datetime.timedelta(minutes=threshold_minutes))
示例13: test_exceptions
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_exceptions():
lat = '00:00:00'
lon = '00:00:00'
elevation = 0.0 * u.m
location = EarthLocation.from_geodetic(lon, lat, elevation)
time = Time('2000-01-01 12:00:00')
vega_coords = SkyCoord('18h36m56.33635s', '+38d47m01.2802s')
obs = Observer(location=location)
with pytest.raises(ValueError):
obs.target_rise_time(time, vega_coords, which='oops').datetime
with pytest.raises(ValueError):
obs.target_set_time(time, vega_coords, which='oops').datetime
with pytest.raises(ValueError):
obs.target_meridian_transit_time(time, vega_coords,
which='oops').datetime
with pytest.raises(ValueError):
obs.target_meridian_antitransit_time(time, vega_coords,
which='oops').datetime
with pytest.raises(TypeError):
FixedTarget(['00:00:00', '00:00:00'], name='VE')
with pytest.raises(TypeError):
Observer(location='Greenwich')
with pytest.raises(TypeError):
Observer(location=EarthLocation(0, 0, 0), timezone=-6)
示例14: test_local_sidereal_time
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_local_sidereal_time():
time = Time('2005-02-03 00:00:00')
location = EarthLocation.from_geodetic(10*u.deg, 40*u.deg, 0*u.m)
obs = Observer(location=location)
# test sidereal time
astroplan_lst = obs.local_sidereal_time(time)
# Compute this with print_pyephem_lst()
pyephem_lst = 2.5005375428099104*u.rad
assert_quantity_allclose(astroplan_lst, pyephem_lst, atol=0.01*u.deg)
示例15: test_hour_angle
# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geodetic [as 别名]
def test_hour_angle():
# TODO: Add tests for different targets/times with tools other than PyEphem
time = Time('2005-02-03 00:00:00')
location = EarthLocation.from_geodetic(10*u.deg, 40*u.deg, 0*u.m)
obs = Observer(location=location)
vernal_eq = FixedTarget(SkyCoord(ra=0*u.deg, dec=0*u.deg))
hour_angle = obs.target_hour_angle(time, vernal_eq)
lst = obs.local_sidereal_time(time)
assert_quantity_allclose(hour_angle, lst, atol=0.001*u.deg)