本文整理汇总了Python中sunpy.map.basemap.BaseMap类的典型用法代码示例。如果您正苦于以下问题:Python BaseMap类的具体用法?Python BaseMap怎么用?Python BaseMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, data, header):
BaseMap.__init__(self, header)
self.detector = "AIA"
self.instrument = "AIA"
self.observatory = "SDO"
self.cmap = cm.get_cmap('sdoaia%d' % header.get('wavelnth'))
示例2: __init__
def __init__(self, data, header):
BaseMap.__init__(self, header)
# MDI sometimes has an "60" in seconds field
datestr = header['date_obs']
if datestr[17:19] == "60":
datestr = datestr[:17] + "30" + datestr[19:]
rsun = header.get('radius')
# Solar radius in arc-seconds at 1 au
# @TODO: use sunpy.sun instead
radius_1au = 959.644
# MDI images may have radius = 0.0
if not rsun:
dsun = constants.au
else:
scale = header.get("cdelt1")
dsun = (radius_1au / (rsun * scale)) * constants.au
# Determine measurement
dpcobsr = header.get('dpc_obsr')
meas = "magnetogram" if dpcobsr.find('Mag') != -1 else "continuum"
self.date = parse_time(datestr)
self.detector = "MDI"
self.measurement = meas
self.dsun = dsun
self.name = "MDI %s" % meas
示例3: __init__
def __init__(self, data, header):
BaseMap.__init__(self, header)
self.detector = "SWAP"
self.instrument = "SWAP"
self.observatory = "PROBA2"
self.name = "SWAP %s" % header.get('wavelnth')
self.cmap = cm.get_cmap(name='sdoaia171')
示例4: __init__
def __init__(self, data, header):
BaseMap.__init__(self, header)
self.date = parse_time(header.get('date_obs'))
self.detector = header.get('detector')
self.instrument = "SECCHI"
self.observatory = header.get('obsrvtry')
self.measurement = "white-light"
self.name = "SECCHI %s" % header.get('detector')
示例5: __init__
def __init__(self, data, header):
BaseMap.__init__(self, header)
self.date = parse_time(header.get('date_obs'))
self.detector = header.get('telescop')
self.instrument = header.get('telescop')
self.measurement = [header.get('energy_l'), header.get('energy_h')]
self.name = "RHESSI %d - %d keV" % (header.get('energy_l'),
header.get('energy_h'))
self.cmap = cm.get_cmap('rhessi')
self.exposure_time = (parse_time(header.get('date_end')) -
parse_time(header.get('date_obs'))).seconds
示例6: add_map
def add_map(self, input_, zorder=None, alpha=1):
"""Adds a map to the CompositeMap
Parameters
----------
input_ : {sunpy.map, string}
Map instance or filepath to map to be added
zorder : int
The index to use when determining where the map should lie along
the z-axis; maps with higher z-orders appear above maps with lower
z-orders.
alpha : float
Opacity at which the map should be displayed. An alpha value of 0
results in a fully transparent image while an alpha value of 1
results in a fully opaque image. Values between result in semi-
transparent images.
"""
if zorder is None:
zorder = max([m.zorder for m in self._maps]) + 10
m = BaseMap.read(input_)
m.zorder = zorder
m.alpha = alpha
self._maps.append(m)
示例7: Map
def Map(filepath):
"""Creates a map from specified file.
.. deprecated:: 0.1
Use `make_map` instead.
Parameters
----------
filepath : string
Filepath to a FITs or JPEG 2000 file
Returns
-------
out : Map
Creates a map instance using the specific file and return it
"""
import warnings
warnings.warn("sunpy.Map is deprecated: use sunpy.make_map instead.", DeprecationWarning)
if isinstance(filepath, basestring):
return BaseMap.read(filepath)
else:
raise InvalidMapInput("Invalid input for make_map. Please specify "
"one or more filepaths, Maps, directories, "
"or wildcard expressions.")
示例8: __new__
def __new__(cls, *args, **kwargs):
"""Creates a new Map instance"""
maps = []
data = []
headers = []
# convert input to maps
for item in args:
if isinstance(item, BaseMap):
maps.append(item)
else:
maps.append(BaseMap.read(item))
# sort data
sortby = kwargs.get("sortby", "date")
if hasattr(cls, '_sort_by_%s' % sortby):
maps.sort(key=getattr(cls, '_sort_by_%s' % sortby)())
# create data cube
for map_ in maps:
data.append(np.array(map_))
headers.append(map_.header)
obj = np.asarray(data).view(cls)
obj._headers = headers
return obj
示例9: __new__
def __new__(cls, input_, sortby="date"):
"""Creates a new Map instance"""
# Directory of files
if isinstance(input_, basestring):
filepaths = []
fits_arr = []
data = []
headers = []
# directory
if os.path.isdir(input_):
for filename in os.listdir(input_):
filepaths.append(os.path.join(input_, filename))
# glob string
else:
from glob import glob
filepaths = glob(input_)
# read in files
for filepath in filepaths:
fits = pyfits.open(filepath)
# append normalized header tags for use during sorting
found_header_match = False
for subcls in BaseMap.__subclasses__(): #pylint: disable=E1101
if subcls.is_datasource_for(fits[0].header):
found_header_match = True
fits.norm_header = subcls.get_properties(fits[0].header)
if not found_header_match:
raise UnrecognizedDataSouceError
fits_arr.append(fits)
# sort data
if sortby and hasattr(cls, '_sort_by_%s' % sortby):
fits_arr.sort(key=getattr(cls, '_sort_by_%s' % sortby)())
# create data cube
for fits in fits_arr:
data.append(fits[0].data)
headers.append(fits[0].header)
obj = np.asarray(data).view(cls)
obj._headers = headers
# List of data or filepaths
elif isinstance(input_, list):
obj = np.asarray(input_).view(cls)
# ndarray
elif isinstance(input_, np.ndarray):
obj = input_
return obj
示例10: __getitem__
def __getitem__(self, key):
"""Overiding indexing operation"""
if self.ndim is 3 and isinstance(key, int):
data = np.ndarray.__getitem__(self, key)
header = self._headers[key]
for cls in BaseMap.__subclasses__():
if cls.is_datasource_for(header):
return cls(data, header)
raise UnrecognizedDataSouceError
else:
return np.ndarray.__getitem__(self, key)
示例11: Map
def Map(input_):
"""Map class factory
Attempts to determine the type of data associated with input and returns
an instance of either the generic BaseMap class or a subclass of BaseMap
such as AIAMap, EUVIMap, etc.
Parameters
----------
input_ : filepath, data array
The data source used to create the map object. This can be either a
filepath to an image, a 2d list, or an ndarray.
Returns
-------
out : BaseMap
Returns a BaseMap or BaseMap subclass instance
Notes
-----
PyFITS
[1] Due to the way PyFITS works with images the header dictionary may
differ depending on whether is accessed before or after the fits[0].data
is requested. If the header is read before the data then the original
header will be returned. If the header is read after the data has been
accessed then the data will have been scaled and a modified header
reflecting these changes will be returned: BITPIX may differ and
BSCALE and B_ZERO may be dropped in the modified version.
[2] The verify('fix') call attempts to handle violations of the FITS
standard. For example, nan values will be converted to "nan" strings.
Attempting to cast a pyfits header to a dictionary while it contains
invalid header tags will result in an error so verifying it early on
makes the header easier to work with later.
References
----------
| http://stackoverflow.com/questions/456672/class-factory-in-python
| http://stsdas.stsci.edu/download/wikidocs/The_PyFITS_Handbook.pdf
"""
if isinstance(input_, basestring):
fits = pyfits.open(input_)
fits.verify('silentfix')
data = fits[0].data
header = fits[0].header
for cls in BaseMap.__subclasses__():
if cls.is_datasource_for(header):
return cls(data, header)
raise UnrecognizedDataSouceError
else:
return BaseMap(input_)
示例12: get_properties
def get_properties(cls, header):
"""Parses EUVI image header"""
properties = BaseMap.get_properties(header)
properties.update({
"date": parse_time(header.get('date_obs')),
"detector": "EUVI",
"instrument": "SECCHI",
"observatory": header.get('obsrvtry'),
"cmap": cm.get_cmap('sohoeit%d' % header.get('wavelnth')),
"nickname": "EUVI-" + header.get('obsrvtry')[-1]
})
return properties
示例13: get_properties
def get_properties(cls, header):
"""Parses SWAP image header"""
properties = BaseMap.get_properties(header)
properties.update({
"detector": "SWAP",
"instrument": "SWAP",
"observatory": "PROBA2",
"name": "SWAP %s" % header.get('wavelnth'),
"nickname": "SWAP",
"cmap": cm.get_cmap(name='sdoaia171')
})
return properties
示例14: get_properties
def get_properties(cls, header):
"""Returns the default and normalized values to use for the Map"""
# Note: Trailing "Z" in date was dropped on 2010/12/07
properties = BaseMap.get_properties()
properties.update({
'date': util.anytim(header['date-obs'][0:22]),
'det': "AIA",
'inst': "AIA",
'meas': header['wavelnth'],
'obs': "SDO",
'name': "AIA %s" % header['wavelnth'],
'cmap': cm.get_cmap(name = 'sdoaia' + str(header['wavelnth']))
})
return properties
示例15: get_properties
def get_properties(cls, header):
"""Returns the default and normalized values to use for the Map"""
properties = BaseMap.get_properties()
properties.update({
'date': util.anytim(header.get('date_obs')),
'det': header.get('telescop'),
'inst': header.get('telescop'),
'meas': [header.get('energy_l'), header.get('energy_h')],
'obs': header.get('telescop'),
'name': "RHESSI " + str(header.get('energy_l')) + '-' + str(header.get('energy_h')) + ' keV',
'cmap': cm.get_cmap(name = 'rhessi'),
# 'norm': mpl.colors.Normalize(vmin=cls.min(), vmax=cls.max())
})
return properties