TimeSeriesMetaData#
- class sunpy.timeseries.TimeSeriesMetaData(meta=None, timerange=None, colnames=None)[source]#
Bases:
objectUsed to store metadata for
TimeSeriesthat enables multiplesunpy.timeseries.TimeSeriesmetadata to be concatenated in an organized fashion.Possible signatures:
TimeSeriesMetaData(meta=dict, timerange=TimeRange, colnames=list) TimeSeriesMetaData(meta=tuple) TimeSeriesMetaData(meta=list(tuples)) TimeSeriesMetaData(timerange=TimeRange) TimeSeriesMetaData(timerange=TimeRange, colnames=list)
- Parameters:
- metadata#
The list of 3-tuples which each represent a source files metadata. The tuples consist of:
(TimeRange, [colnames], MetaDict(metadata)).
Examples
>>> from sunpy.timeseries import TimeSeriesMetaData >>> from sunpy.time import TimeRange, parse_time >>> from sunpy.util import MetaDict >>> tr = TimeRange('2012-06-01 00:00','2012-06-02 00:00') >>> md = TimeSeriesMetaData(timerange=tr, colnames=['GOES'], ... meta=MetaDict([('goes_key','goes_val')])) >>> tr2 = TimeRange('2012-06-01 12:00','2012-06-02 12:00') >>> md.append(tr2, ['EVE'], MetaDict([('eve_key','eve_val')])) >>> md.find(parse_time('2012-06-01T21:08:12')) |-------------------------------------------------------------------------------------------------| |TimeRange | Columns | Meta | |-------------------------------------------------------------------------------------------------| |2012-06-01T00:00:00.000 | GOES | goes_key: goes_val | | to | | | |2012-06-02T00:00:00.000 | | | |-------------------------------------------------------------------------------------------------| |2012-06-01T12:00:00.000 | EVE | eve_key: eve_val | | to | | | |2012-06-02T12:00:00.000 | | | |-------------------------------------------------------------------------------------------------| >>> md.find(parse_time('2012-06-01T21:08:12')).columns ['EVE', 'GOES'] >>> md.find(parse_time('2012-06-01T21:08:12')).values() ['eve_val', 'goes_val'] >>> md.find(parse_time('2012-06-01T21:08:12')).metas [MetaDict([('goes_key': 'goes_val')]), MetaDict([('eve_key': 'eve_val')])] >>> md.find(parse_time('2012-06-01T21:08:12'), 'GOES') |-------------------------------------------------------------------------------------------------| |TimeRange | Columns | Meta | |-------------------------------------------------------------------------------------------------| |2012-06-01T00:00:00.000 | GOES | goes_key: goes_val | | to | | | |2012-06-02T00:00:00.000 | | | |-------------------------------------------------------------------------------------------------|
Attributes Summary
Returns a list of all the names of the columns in the metadata.
Returns a list of all the metadict objects in the
TimeSeriesMetaData.Returns the
TimeRangeof the entire timeseries metadata.Returns a list of all the
TimeRangein theTimeSeriesMetaData.Methods Summary
append(timerange, columns, metadata, **kwargs)Add the given metadata into the current metadata.
concatenate(others)Combine the metadata from a
TimeSeriesMetaDataor an iterable containing multipleTimeSeriesMetaDatawith the currentTimeSeriesMetaDataand return it as a newTimeSeriesMetaData.find([time, colname])Find all metadata matching the given filters.
find_indices([time, colname])Find the indices for all the metadata entries matching the given filters.
get(keys[, time, colname])Return a
TimeSeriesMetaDatawith all entries matching the filters which also contain the given input key.get_index(index)Return the dictionary entry at the given index.
to_string([depth, width])Print a table-like representation of the
TimeSeriesMetaData.update(dictionary[, time, colname, overwrite])Updates the
TimeSeriesMetaDatafor all matching metadata entries.values()Returns a list of all the values from the metadict objects in each entry in the
TimeSeriesMetaData.Attributes Documentation
- columns#
Returns a list of all the names of the columns in the metadata.
- metas#
Returns a list of all the metadict objects in the
TimeSeriesMetaData.
- timeranges#
Returns a list of all the
TimeRangein theTimeSeriesMetaData.
Methods Documentation
- append(timerange, columns, metadata, **kwargs)[source]#
Add the given metadata into the current metadata.
Will add the new entry so the list is in chronological order.
- Parameters:
timerange (
TimeRange) – The timerange for which a given metadict is relevant. This will generally initially be the full range of the original file, but if the TimeSeries gets truncated this may change appropriately.columns (
list) – A list of the column name strings that the metadata is relevant for.metadata (
MetaDictorcollections.OrderedDictordict) – The object holding the metadata.
- concatenate(others)[source]#
Combine the metadata from a
TimeSeriesMetaDataor an iterable containing multipleTimeSeriesMetaDatawith the currentTimeSeriesMetaDataand return it as a newTimeSeriesMetaData.- Parameters:
others (
TimeSeriesMetaDataorcollections.abc.Iterable) – The secondTimeSeriesMetaDataobject or an iterable containing multipleTimeSeriesMetaDataobjects.
- find(time=None, colname=None)[source]#
Find all metadata matching the given filters.
Will return all metadata entries if no filters are given.
- Parameters:
time (
tuple,list,str,pandas.Timestamp,pandas.Index,pandas.Series,pandas.DatetimeIndex,datetime.datetime,datetime.date,numpy.datetime64,numpy.ndarray,astropy.time.Time, optional) – Aparse_timeparsable string that you need metadata for. Defaults toNone.colname (
str, optional) – A string that can be used to narrow results to specific columns. Defaults toNone.
- Returns:
TimeSeriesMetaData– ATimeSeriesMetaDatathat contain all matching metadata entries.
- find_indices(time=None, colname=None)[source]#
Find the indices for all the metadata entries matching the given filters.
Will return all metadata entry indices if no filters are given.
- Parameters:
time (
tuple,list,str,pandas.Timestamp,pandas.Index,pandas.Series,pandas.DatetimeIndex,datetime.datetime,datetime.date,numpy.datetime64,numpy.ndarray,astropy.time.Time, optional) – Aparse_timeparsable string that you need metadata for. Defaults toNone.colname (
str, optional) – A string that can be used to narrow results to specific columns. Defaults toNone.
- Returns:
list– A list of integers that contain all matching metadata.
- get(keys, time=None, colname=None)[source]#
Return a
TimeSeriesMetaDatawith all entries matching the filters which also contain the given input key.- Parameters:
keys (
str) – The Key/s to be searched in the dictionary.time (
tuple,list,str,pandas.Timestamp,pandas.Index,pandas.Series,pandas.DatetimeIndex,datetime.datetime,datetime.date,numpy.datetime64,numpy.ndarray,astropy.time.Time, optional) – Aparse_timeparsable string that you need metadata for. Defaults toNone.colname (
str, optional) – A string that can be used to narrow results to specific columns.
- Returns:
metadata (
TimeSeriesMetaData) – A TimeSeriesMetaData that contain all matching metadata entries but with only the requested key/value pairs in the MetaDict objects.
- to_string(depth=10, width=99)[source]#
Print a table-like representation of the
TimeSeriesMetaData.
- update(dictionary, time=None, colname=None, overwrite=False)[source]#
Updates the
TimeSeriesMetaDatafor all matching metadata entries.- Parameters:
dictionary (
dict,collections.OrderedDict,MetaDict) – The secondTimeSeriesMetaDataobject.time (
tuple,list,str,pandas.Timestamp,pandas.Index,pandas.Series,pandas.DatetimeIndex,datetime.datetime,datetime.date,numpy.datetime64,numpy.ndarray,astropy.time.Time, optional) – Aparse_timeparsable string that you need metadata for. Defaults toNone.colname (
str, optional) – A string that can be used to narrow results to specific columns. Defaults toNone.overwrite (
bool, optional) – Allows the user to overwrite already present keys. Defaults toFalse
- values()[source]#
Returns a list of all the values from the metadict objects in each entry in the
TimeSeriesMetaData.