本文整理汇总了Python中sunpy.time.TimeRange.center方法的典型用法代码示例。如果您正苦于以下问题:Python TimeRange.center方法的具体用法?Python TimeRange.center怎么用?Python TimeRange.center使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sunpy.time.TimeRange
的用法示例。
在下文中一共展示了TimeRange.center方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _multi_request
# 需要导入模块: from sunpy.time import TimeRange [as 别名]
# 或者: from sunpy.time.TimeRange import center [as 别名]
def _multi_request(self, **kwargs):
"""
Make a series of requests to avoid the 100GB limit
"""
start_time = kwargs.pop('start_time', None)
end_time = kwargs.pop('end_time', None)
series = kwargs.pop('series', None)
if any(x is None for x in (start_time, end_time, series)):
return []
start_time = self._process_time(start_time)
end_time = self._process_time(end_time)
tr = TimeRange(start_time, end_time)
returns = []
response, json_response = self._send_jsoc_request(start_time, end_time,
series, **kwargs)
# We skip these lines because a massive request is not a practical test.
error_response = 'Request exceeds max byte limit of 100000MB'
if (json_response['status'] == 3 and
json_response['error'] == error_response): # pragma: no cover
returns.append(self._multi_request(tr.start(), tr.center(), series, **kwargs)[0])
# pragma: no cover
returns.append(self._multi_request(tr.center(), tr.end(), series, **kwargs)[0])
# pragma: no cover
else:
returns.append(response)
return returns
示例2: _multi_request
# 需要导入模块: from sunpy.time import TimeRange [as 别名]
# 或者: from sunpy.time.TimeRange import center [as 别名]
def _multi_request(self, start_time, end_time, series, **kwargs):
"""
Make a series of requests to avoid the 100GB limit
"""
tr = TimeRange(start_time, end_time)
returns = []
response, json_response = self._send_jsoc_request(start_time, end_time, series, **kwargs)
if json_response['status'] == 3 and json_response['error'] == 'Request exceeds max byte limit of 100000MB':
returns.append(self._multi_request(tr.start(), tr.center(), series, **kwargs)[0])
returns.append(self._multi_request(tr.center(), tr.end(), series, **kwargs)[0])
else:
returns.append(response)
return returns
示例3: backprojection
# 需要导入模块: from sunpy.time import TimeRange [as 别名]
# 或者: from sunpy.time.TimeRange import center [as 别名]
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
示例4: backprojection
# 需要导入模块: from sunpy.time import TimeRange [as 别名]
# 或者: from sunpy.time.TimeRange import center [as 别名]
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