TimeSeriesMetaData#

class sunpy.timeseries.TimeSeriesMetaData(meta=None, timerange=None, colnames=None)[source]#

Bases: object

Used to store metadata for TimeSeries that enables multiple sunpy.timeseries.TimeSeries metadata 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)).

Type:

list of tuple

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

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.

time_range

Returns the TimeRange of the entire timeseries metadata.

timeranges

Returns a list of all the TimeRange in the TimeSeriesMetaData.

Methods Summary

append(timerange, columns, metadata, **kwargs)

Add the given metadata into the current metadata.

concatenate(others)

Combine the metadata from a TimeSeriesMetaData or an iterable containing multiple TimeSeriesMetaData with the current TimeSeriesMetaData and return it as a new TimeSeriesMetaData.

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 TimeSeriesMetaData with 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 TimeSeriesMetaData for 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.

time_range#

Returns the TimeRange of the entire timeseries metadata.

timeranges#

Returns a list of all the TimeRange in the TimeSeriesMetaData.

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 (MetaDict or collections.OrderedDict or dict) – The object holding the metadata.

concatenate(others)[source]#

Combine the metadata from a TimeSeriesMetaData or an iterable containing multiple TimeSeriesMetaData with the current TimeSeriesMetaData and return it as a new TimeSeriesMetaData.

Parameters:

others (TimeSeriesMetaData or collections.abc.Iterable) – The second TimeSeriesMetaData object or an iterable containing multiple TimeSeriesMetaData objects.

find(time=None, colname=None)[source]#

Find all metadata matching the given filters.

Will return all metadata entries if no filters are given.

Parameters:
Returns:

TimeSeriesMetaData – A TimeSeriesMetaData that 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:
Returns:

list – A list of integers that contain all matching metadata.

get(keys, time=None, colname=None)[source]#

Return a TimeSeriesMetaData with all entries matching the filters which also contain the given input key.

Parameters:
Returns:

metadata (TimeSeriesMetaData) – A TimeSeriesMetaData that contain all matching metadata entries but with only the requested key/value pairs in the MetaDict objects.

get_index(index)[source]#

Return the dictionary entry at the given index.

Parameters:

index (int) – The integer index of the metadata entry in the list.

Returns:

MetaDict – An ordered Dictionary containing the metadata at the given index.

to_string(depth=10, width=99)[source]#

Print a table-like representation of the TimeSeriesMetaData.

Parameters:
  • depth (int, optional) – The maximum number of lines to show for each entry. Metadata dictionaries and column lists will be truncated if this is small. Defaults to 10.

  • width (int, optional) – The number of characters wide to make the entire table. Defaults to 99.

update(dictionary, time=None, colname=None, overwrite=False)[source]#

Updates the TimeSeriesMetaData for all matching metadata entries.

Parameters:
values()[source]#

Returns a list of all the values from the metadict objects in each entry in the TimeSeriesMetaData.