Note: Peak finding is a complex problem that has many potential solutions and this example is just one method of many. """ import numpy as np import matplotlib.pyplot as plt from sunpy.timeseries import TimeSeries from sunpy.data.sample import NOAAINDICES_TIMESERIES as noaa_ind ############################################################################## # We will now create a TimeSeries object from an observational data source, # Also, we will truncate it to do analysis on a smaller time duration of 10 # years. ts_noaa_ind = TimeSeries(noaa_ind, source='NOAAIndices') my_timeseries = ts_noaa_ind.truncate('1991/01/01', '2001/01/01') fig, ax = plt.subplots() my_timeseries.plot() ############################################################################## # To find extrema in any TimeSeries, we first define a function findpeaks that # takes in input an iterable data series and a DELTA value. The DELTA value # controls how much difference between values in the TimeSeries defines an # extremum point. Inside the function, we iterate over the data values of # TimeSeries and consider a point to be a local maxima if it has the maximal # value, and was preceded (to the left) by a value lower by DELTA. Similar # logic applies to find a local minima. def findpeaks(series, DELTA): """
Note: Peak finding is a complex problem that has many potential solutions and this example is just one method of many. """ import matplotlib.pyplot as plt import numpy as np from sunpy.data.sample import GOES_XRS_TIMESERIES from sunpy.timeseries import TimeSeries ############################################################################## # We will now create a TimeSeries object from an observational data source, # Also, we will truncate it to do analysis on a smaller time duration of 10 # years. goes_lc = TimeSeries(GOES_XRS_TIMESERIES) my_timeseries = goes_lc.truncate('2011/06/07 06:10', '2011/06/07 09:00') fig, ax = plt.subplots() my_timeseries.plot() ############################################################################## # To find extrema in any TimeSeries, we first define a function findpeaks that # takes in input an iterable data series and a DELTA value. The DELTA value # controls how much difference between values in the TimeSeries defines an # extremum point. Inside the function, we iterate over the data values of # TimeSeries and consider a point to be a local maxima if it has the maximal # value, and was preceded (to the left) by a value lower by DELTA. Similar # logic applies to find a local minima. def findpeaks(series, DELTA): """
############################################################################## # Start by importing the necessary modules. import numpy as np import matplotlib.pyplot as plt from sunpy.timeseries import TimeSeries from sunpy.data.sample import NOAAINDICES_TIMESERIES as noaa_ind ############################################################################## # We will now create a TimeSeries object from an observational data source, # Also, we will truncate it to do analysis on a smaller time duration of 10 # years. ts_noaa_ind = TimeSeries(noaa_ind, source='NOAAIndices') my_timeseries = ts_noaa_ind.truncate('1991/01/01', '2001/01/01') my_timeseries.peek() ############################################################################## # To find extrema in any TimeSeries, we first define a function findpeaks that # takes in input an iterable data series and a DELTA value. The DELTA value # controls how much difference between values in the TimeSeries defines an # extremum point. Inside the function, we iterate over the data values of # TimeSeries and consider a point to be a local maxima if it has the maximal # value, and was preceded (to the left) by a value lower by DELTA. Similar # logic applies to find a local minima. def findpeaks(series, DELTA): """ Finds extrema in a pandas series data.