本文整理汇总了Python中sunpy.sun.sun.sunearth_distance函数的典型用法代码示例。如果您正苦于以下问题:Python sunearth_distance函数的具体用法?Python sunearth_distance怎么用?Python sunearth_distance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sunearth_distance函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dsun
def dsun(self):
"""The observer distance from the Sun."""
dsun = self.meta.get('dsun_obs', None)
if dsun is None:
warnings.warn_explicit("Missing metadata for Sun-spacecraft separation: assuming Sun-Earth distance",
Warning, __file__, inspect.currentframe().f_back.f_lineno)
dsun = sun.sunearth_distance(self.date).to(u.m)
return dsun
开发者ID:amhuertash,项目名称:sunpy,代码行数:10,代码来源:mapbase.py
示例2: dsun
def dsun(self, **kwargs):
"""
The observer distance from the Sun.
"""
dsun = self.meta.get('dsun_obs', None)
if dsun is None:
warnings.warn("Missing metadata for Sun-spacecraft separation: assuming Sun-Earth distance",
Warning)
dsun = sun.sunearth_distance(self.date).to(u.m)
return u.Quantity(dsun, 'm')
开发者ID:Alex-Ian-Hamilton,项目名称:solarbextrapolation,代码行数:12,代码来源:map3dclasses.py
示例3: test_sunearth_distance
def test_sunearth_distance():
assert_array_almost_equal(sun.sunearth_distance("2010/02/04"), 0.9858, decimal=4)
assert_array_almost_equal(sun.sunearth_distance("2009/04/13"), 1.003, decimal=4)
assert_array_almost_equal(sun.sunearth_distance("2008/06/20"), 1.016, decimal=4)
assert_array_almost_equal(sun.sunearth_distance("2007/08/15"), 1.013, decimal=4)
assert_array_almost_equal(sun.sunearth_distance("2007/10/02"), 1.001, decimal=4)
assert_array_almost_equal(sun.sunearth_distance("2006/12/27"), 0.9834, decimal=4)
开发者ID:zuccap,项目名称:sunpy,代码行数:7,代码来源:test_sun.py
示例4: backprojection
def backprojection(calibrated_event_list, pixel_size=(1.0, 1.0), image_dim=(64, 64)):
"""Given a stacked calibrated event list fits file create a back projection image."""
import sunpy.sun.constants as sun
from sunpy.sun.sun import angular_size
from sunpy.sun.sun import sunearth_distance
from sunpy.time.util import TimeRange
calibrated_event_list = sunpy.RHESSI_EVENT_LIST
fits = pyfits.open(calibrated_event_list)
info_parameters = fits[2]
xyoffset = info_parameters.data.field("USED_XYOFFSET")[0]
time_range = TimeRange(info_parameters.data.field("ABSOLUTE_TIME_RANGE")[0])
image = np.zeros(image_dim)
# find out what detectors were used
det_index_mask = fits[1].data.field("det_index_mask")[0]
detector_list = (np.arange(9) + 1) * np.array(det_index_mask)
for detector in detector_list:
if detector > 0:
image = image + _backproject(
calibrated_event_list, detector=detector, pixel_size=pixel_size, image_dim=image_dim
)
dict_header = {
"DATE-OBS": time_range.center().strftime("%Y-%m-%d %H:%M:%S"),
"CDELT1": pixel_size[0],
"NAXIS1": image_dim[0],
"CRVAL1": xyoffset[0],
"CRPIX1": image_dim[0] / 2 + 0.5,
"CUNIT1": "arcsec",
"CTYPE1": "HPLN-TAN",
"CDELT2": pixel_size[1],
"NAXIS2": image_dim[1],
"CRVAL2": xyoffset[1],
"CRPIX2": image_dim[0] / 2 + 0.5,
"CUNIT2": "arcsec",
"CTYPE2": "HPLT-TAN",
"HGLT_OBS": 0,
"HGLN_OBS": 0,
"RSUN_OBS": angular_size(time_range.center()),
"RSUN_REF": sun.radius,
"DSUN_OBS": sunearth_distance(time_range.center()) * sunpy.sun.constants.au,
}
header = sunpy.map.MapHeader(dict_header)
result_map = sunpy.map.BaseMap(image, header)
return result_map
开发者ID:ndchorley,项目名称:sunpy,代码行数:49,代码来源:rhessi.py
示例5: test_sunearth_distance
def test_sunearth_distance():
# Source for these values
# wolframalpha.com
# http://www.wolframalpha.com/input/?i=earth-sun+distance+on+2010%2F02%2F04
assert_array_almost_equal(sun.sunearth_distance("2010/02/04"), 0.9858, decimal=3)
assert_array_almost_equal(sun.sunearth_distance("2009/04/13"), 1.003, decimal=3)
assert_array_almost_equal(sun.sunearth_distance("2008/06/20"), 1.016, decimal=3)
assert_array_almost_equal(sun.sunearth_distance("2007/08/15"), 1.013, decimal=3)
assert_array_almost_equal(sun.sunearth_distance("2007/10/02"), 1.001, decimal=3)
assert_array_almost_equal(sun.sunearth_distance("2006/12/27"), 0.9834, decimal=3)
开发者ID:abooij,项目名称:sunpy,代码行数:10,代码来源:test_sun.py
示例6: test_sunearth_distance
def test_sunearth_distance():
# Source for these values
# wolframalpha.com
# http://www.wolframalpha.com/input/?i=earth-sun+distance+on+2010%2F02%2F04
assert_quantity_allclose(sun.sunearth_distance("2010/02/04"), 0.9858 * u.AU, atol=1e-3 * u.AU)
assert_quantity_allclose(sun.sunearth_distance("2009/04/13"), 1.003 * u.AU, atol=1e-3 * u.AU)
assert_quantity_allclose(sun.sunearth_distance("2008/06/20"), 1.016 * u.AU, atol=1e-3 * u.AU)
assert_quantity_allclose(sun.sunearth_distance("2007/08/15"), 1.013 * u.AU, atol=1e-3 * u.AU)
assert_quantity_allclose(sun.sunearth_distance("2007/10/02"), 1.001 * u.AU, atol=1e-3 * u.AU)
assert_quantity_allclose(sun.sunearth_distance("2006/12/27"), 0.9834 * u.AU, atol=1e-3 * u.AU)
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:10,代码来源:test_sun.py
示例7: _dsunAtSoho
def _dsunAtSoho(date, rad_d, rad_1au = None):
"""Determines the distance to the Sun from SOhO following
d_{\sun,Object} =
D_{\sun\earth} \frac{\tan(radius_{1au}[rad])}{\tan(radius_{d}[rad])}
though tan x ~ x for x << 1
d_{\sun,Object} =
D_{\sun\eart} \frac{radius_{1au}[rad]}{radius_{d}[rad]}
since radius_{1au} and radius_{d} are dividing each other we can use [arcsec]
instead.
---
TODO: Does this apply just to observations on the same Earth-Sun line?
If not it can be moved outside here.
"""
if not rad_1au:
rad_1au = sun.solar_semidiameter_angular_size(date)
return sun.sunearth_distance(date) * constants.au * (rad_1au / rad_d)
开发者ID:quintusdias,项目名称:sunpy,代码行数:17,代码来源:soho.py
示例8: rot_hpc
def rot_hpc(x, y, tstart, tend, frame_time='synodic', rot_type='howard', **kwargs):
"""Given a location on the Sun referred to using the Helioprojective
Cartesian co-ordinate system (typically quoted in the units of arcseconds)
use the solar rotation profile to find that location at some later or
earlier time. Note that this function assumes that the data was observed
from the Earth or near Earth vicinity. Specifically, data from SOHO and
STEREO observatories are not supported. Note also that the function does
NOT use solar B0 and L0 values provided in source FITS files - these
quantities are calculated.
Parameters
----------
x : `~astropy.units.Quantity`
Helio-projective x-co-ordinate in arcseconds (can be an array).
y : `~astropy.units.Quantity`
Helio-projective y-co-ordinate in arcseconds (can be an array).
tstart : `sunpy.time.time`
date/time to which x and y are referred.
tend : `sunpy.time.time`
date/time at which x and y will be rotated to.
rot_type : {'howard' | 'snodgrass' | 'allen'}
| howard: Use values for small magnetic features from Howard et al.
| snodgrass: Use Values from Snodgrass et. al
| allen: Use values from Allen, Astrophysical Quantities, and simpler
equation.
frame_time: {'sidereal' | 'synodic'}
Choose type of day time reference frame.
Returns
-------
x : `~astropy.units.Quantity`
Rotated helio-projective x-co-ordinate in arcseconds (can be an array).
y : `~astropy.units.Quantity`
Rotated helio-projective y-co-ordinate in arcseconds (can be an array).
Examples
--------
>>> import astropy.units as u
>>> from sunpy.physics.transforms.differential_rotation import rot_hpc
>>> rot_hpc( -570 * u.arcsec, 120 * u.arcsec, '2010-09-10 12:34:56', '2010-09-10 13:34:56')
(<Angle -562.9105822671319 arcsec>, <Angle 119.31920621992195 arcsec>)
Notes
-----
SSWIDL code equivalent: http://hesperia.gsfc.nasa.gov/ssw/gen/idl/solar/rot_xy.pro .
The function rot_xy uses arcmin2hel.pro and hel2arcmin.pro to implement the
same functionality as this function. These two functions seem to perform
inverse operations of each other to a high accuracy. The corresponding
equivalent functions here are convert_hpc_hg and convert_hg_hpc
respectively. These two functions seem to perform inverse
operations of each other to a high accuracy. However, the values
returned by arcmin2hel.pro are slightly different from those provided
by convert_hpc_hg. This leads to very slightly different results from
rot_hpc compared to rot_xy.
"""
# must have pairs of co-ordinates
if np.array(x).shape != np.array(y).shape:
raise ValueError('Input co-ordinates must have the same shape.')
# Make sure we have enough time information to perform a solar differential
# rotation
# Start time
dstart = parse_time(tstart)
dend = parse_time(tend)
interval = (dend - dstart).total_seconds() * u.s
# Get the Sun's position from the vantage point at the start time
vstart = kwargs.get("vstart", _calc_P_B0_SD(dstart))
# Compute heliographic co-ordinates - returns (longitude, latitude). Points
# off the limb are returned as nan
longitude, latitude = convert_hpc_hg(x.to(u.arcsec).value,
y.to(u.arcsec).value,
b0_deg=vstart["b0"].to(u.deg).value,
l0_deg=vstart["l0"].to(u.deg).value,
dsun_meters=(constants.au * sun.sunearth_distance(t=dstart)).value,
angle_units='arcsec')
longitude = Longitude(longitude, u.deg)
latitude = Angle(latitude, u.deg)
# Compute the differential rotation
drot = diff_rot(interval, latitude, frame_time=frame_time,
rot_type=rot_type)
# Convert back to heliocentric cartesian in units of arcseconds
vend = kwargs.get("vend", _calc_P_B0_SD(dend))
# It appears that there is a difference in how the SSWIDL function
# hel2arcmin and the sunpy function below performs this co-ordinate
# transform.
newx, newy = convert_hg_hpc(longitude.to(u.deg).value + drot.to(u.deg).value,
latitude.to(u.deg).value,
b0_deg=vend["b0"].to(u.deg).value,
l0_deg=vend["l0"].to(u.deg).value,
dsun_meters=(constants.au * sun.sunearth_distance(t=dend)).value,
#.........这里部分代码省略.........
开发者ID:abigailStev,项目名称:sunpy,代码行数:101,代码来源:differential_rotation.py
示例9: backprojection
def backprojection(calibrated_event_list, pixel_size=(1.,1.), image_dim=(64,64)):
"""Given a stacked calibrated event list fits file create a back
projection image.
.. warning:: The image is not in the right orientation!
Parameters
----------
calibrated_event_list : string
filename of a RHESSI calibrated event list
detector : int
the detector number
pixel_size : 2-tuple
the size of the pixels in arcseconds. Default is (1,1).
image_dim : 2-tuple
the size of the output image in number of pixels
Returns
-------
out : RHESSImap
Return a backprojection map.
Examples
--------
>>> import sunpy.instr.rhessi as rhessi
>>> map = rhessi.backprojection(sunpy.RHESSI_EVENT_LIST)
>>> map.show()
"""
calibrated_event_list = sunpy.RHESSI_EVENT_LIST
fits = pyfits.open(calibrated_event_list)
info_parameters = fits[2]
xyoffset = info_parameters.data.field('USED_XYOFFSET')[0]
time_range = TimeRange(info_parameters.data.field('ABSOLUTE_TIME_RANGE')[0])
image = np.zeros(image_dim)
#find out what detectors were used
det_index_mask = fits[1].data.field('det_index_mask')[0]
detector_list = (np.arange(9)+1) * np.array(det_index_mask)
for detector in detector_list:
if detector > 0:
image = image + _backproject(calibrated_event_list, detector=detector, pixel_size=pixel_size, image_dim=image_dim)
dict_header = {
"DATE-OBS": time_range.center().strftime("%Y-%m-%d %H:%M:%S"),
"CDELT1": pixel_size[0],
"NAXIS1": image_dim[0],
"CRVAL1": xyoffset[0],
"CRPIX1": image_dim[0]/2 + 0.5,
"CUNIT1": "arcsec",
"CTYPE1": "HPLN-TAN",
"CDELT2": pixel_size[1],
"NAXIS2": image_dim[1],
"CRVAL2": xyoffset[1],
"CRPIX2": image_dim[0]/2 + 0.5,
"CUNIT2": "arcsec",
"CTYPE2": "HPLT-TAN",
"HGLT_OBS": 0,
"HGLN_OBS": 0,
"RSUN_OBS": solar_semidiameter_angular_size(time_range.center()),
"RSUN_REF": sun.radius,
"DSUN_OBS": sunearth_distance(time_range.center()) * sunpy.sun.constants.au
}
header = sunpy.map.MapHeader(dict_header)
result_map = sunpy.map.Map(image, header)
return result_map
开发者ID:quintusdias,项目名称:sunpy,代码行数:70,代码来源:rhessi.py
示例10: dsun
def dsun(self):
"""KPVT at earth."""
dsun = sun.sunearth_distance(self.date).to(u.m)
return u.Quantity(dsun, 'm')
开发者ID:ZachWerginz,项目名称:Catalogue_cross_calibration,代码行数:4,代码来源:kpvt.py
示例11: backprojection
def backprojection(calibrated_event_list, pixel_size=(1.,1.) * u.arcsec, image_dim=(64,64) * u.pix):
"""
Given a stacked calibrated event list fits file create a back
projection image.
.. warning:: The image is not in the right orientation!
Parameters
----------
calibrated_event_list : string
filename of a RHESSI calibrated event list
detector : int
the detector number
pixel_size : `~astropy.units.Quantity` instance
the size of the pixels in arcseconds. Default is (1,1).
image_dim : `~astropy.units.Quantity` instance
the size of the output image in number of pixels
Returns
-------
out : RHESSImap
Return a backprojection map.
Examples
--------
>>> import sunpy.instr.rhessi as rhessi
>>> map = rhessi.backprojection(sunpy.RHESSI_EVENT_LIST)
>>> map.peek()
"""
if not isinstance(pixel_size, u.Quantity):
raise ValueError("Must be astropy Quantity in arcseconds")
try:
pixel_size = pixel_size.to(u.arcsec)
except:
raise ValueError("'{0}' is not a valid pixel_size unit".format(pixel_size.unit))
if not (isinstance(image_dim, u.Quantity) and image_dim.unit == 'pix'):
raise ValueError("Must be astropy Quantity in pixels")
calibrated_event_list = sunpy.RHESSI_EVENT_LIST
afits = fits.open(calibrated_event_list)
info_parameters = afits[2]
xyoffset = info_parameters.data.field('USED_XYOFFSET')[0]
time_range = TimeRange(info_parameters.data.field('ABSOLUTE_TIME_RANGE')[0])
image = np.zeros(image_dim.value)
#find out what detectors were used
det_index_mask = afits[1].data.field('det_index_mask')[0]
detector_list = (np.arange(9)+1) * np.array(det_index_mask)
for detector in detector_list:
if detector > 0:
image = image + _backproject(calibrated_event_list, detector=detector, pixel_size=pixel_size.value
, image_dim=image_dim.value)
dict_header = {
"DATE-OBS": time_range.center().strftime("%Y-%m-%d %H:%M:%S"),
"CDELT1": pixel_size[0],
"NAXIS1": image_dim[0],
"CRVAL1": xyoffset[0],
"CRPIX1": image_dim[0].value/2 + 0.5,
"CUNIT1": "arcsec",
"CTYPE1": "HPLN-TAN",
"CDELT2": pixel_size[1],
"NAXIS2": image_dim[1],
"CRVAL2": xyoffset[1],
"CRPIX2": image_dim[0].value/2 + 0.5,
"CUNIT2": "arcsec",
"CTYPE2": "HPLT-TAN",
"HGLT_OBS": 0,
"HGLN_OBS": 0,
"RSUN_OBS": solar_semidiameter_angular_size(time_range.center()).value,
"RSUN_REF": sunpy.sun.constants.radius.value,
"DSUN_OBS": sunearth_distance(time_range.center()) * sunpy.sun.constants.au.value
}
header = sunpy.map.MapMeta(dict_header)
result_map = sunpy.map.Map(image, header)
return result_map
开发者ID:bsipocz,项目名称:sunpy,代码行数:79,代码来源:rhessi.py
注:本文中的sunpy.sun.sun.sunearth_distance函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论