timeseries class¶
- class csi.timeseries(name, utmzone=None, verbose=True, lon0=None, lat0=None, ellps='WGS84')¶
A class that handles generic time series
- Args:
name : Name of the dataset.
- Kwargs:
utmzone : UTM zone (optional, default=None)
lon0 : Longitude of the center of the UTM zone
lat0 : Latitude of the center of the UTM zone
ellps : ellipsoid (optional, default=’WGS84’)
verbose : Talk to me
- SortInTime()¶
Sort ascending in time.
- Returns:
None
- addPointInTime(time, value=0.0, std=0.0)¶
Augments the time series by one point.
- Args:
time : datetime.datetime object
- Kwargs:
value : Value of the time series at time {time}
std : Uncertainty at time {time}
- adddata(time, values=None, std=None)¶
Augments the time series
- Args:
time : list of datetime objects
- Kwargs:
values : list array or None
std : list array or None
- Returns:
None
- checkNaNs()¶
Returns the index of NaNs
- Returns:
numpy array of integers
- computeDoubleDifference()¶
Compute the derivative of the TS with a central difference scheme.
- Returns:
None. Results is stored in self.derivative
- findZeroIntersect(data='data')¶
Returns all the points just before the function crosses 0.
- Kwargs:
data : Can be ‘data’, ‘synth’ or ‘derivative’.
- Returns:
None
- fitFunction(function, m0, solver='L-BFGS-B', iteration=1000, tol=1e-08)¶
Fits a function to the timeseries
- Args:
function : Prediction function,
m0 : Initial model
- Kwargs:
solver : Solver type (see list of solver in scipy.optimize.minimize)
iteration : Number of iteration for the solver
tol : Tolerance
- Returns:
None. Model vector is stored in the {m} attribute
- fitTidalConstituents(steps=None, linear=False, tZero=datetime.datetime(2000, 1, 1, 0, 0), chunks=None, cossin=False, constituents='all')¶
Fits tidal constituents on the time series.
- Kwargs:
steps : list of datetime instances to add step functions in the estimation process.
linear : estimate a linear trend.
tZero : origin time (datetime instance).
chunks : List [ [start1, end1], [start2, end2]] where the fit is performed.
cossin : Add a cosine+sine term in the procedure.
constituents : list of tidal constituents to include (default is all). For a list, go check tidalfit class
- Returns:
None
- getOffset(date1, date2, nodate=nan, data='data')¶
Get the offset between date1 and date2.
- Args:
date1 : datetime object
date2 : datetime object
- Kwargs:
nodate : Value to be returned in case no value is available
data : can be ‘data’ or ‘std’
- Returns:
float
- initialize(time=None, start=None, end=None, increment=1)¶
Initialize the time series.
- Kwargs:
time : list of datetime instances
start : datetime instance of the first period
end : datetime instance of the ending period
increment : increment of time between periods
- Returns:
None
- plot(figure=1, styles=['.r'], show=True, data='data', subplot=None)¶
Plots the time series.
- Args:
figure : Figure id number (default=1)
styles : List of styles (default=[‘.r’])
show : Show to me (default=True)
data : can be ‘data’, ‘derivative’, ‘synth’ or a list of those
subplot : axes instance to be used for plotting. If None, creates a new one
- Returns:
None
- readAscii(infile, header=0)¶
Reads from an ascii file. Format of the file is
year
month
day
hour
min
second
value
err (optional)
- Args:
infile : Input file (ascii)
- Kwargs:
header : length of the file header
- Returns:
None
- reference2timeseries(timeseries)¶
Removes to another gps timeseries the difference between self and timeseries
- Args:
timeseries : Another timeseries
- Returns:
float
- removeMean(start=None, end=None)¶
Removes the mean between start and end.
- Kwargs:
start : datetime.datetime object. If None, takes the first point of the time series
end : datetime.datetime object. If None, takes the last point of the time series
- Returns:
None. Attribute {value} is directly modified.
- removePoints(indexes)¶
Removes the points from the time series
- Args:
indexes: Indexes of the poitns to remove
- Returns:
None
- smoothGlitches(biggerThan=999999.0, smallerThan=-999999.0, interpNum=5, interpolation='linear')¶
Removes the glitches and replace them by a value interpolated on interpNum points.
- Kwargs:
biggerThan : Values higher than biggerThan are glitches.
smallerThan : Values smaller than smallerThan are glitches.
interpNum : Number of points to take before and after the glicth to predict its values.
interpolation : Interpolation method.
- Returns:
None
- trimTime(start, end=datetime.datetime(2100, 1, 1, 0, 0))¶
Keeps the data between start and end. start and end are 2 datetime.datetime objects.
- Args:
start : datetime.datetime object
- Kwargs:
end : datetime.datetime object
- Returns:
None
- write2file(outfile, steplike=False)¶
Writes the time series to a file.
- Args:
outfile : output file.
- Kwargs:
steplike : doubles the output each time so that the plot looks like steps.
- Returns:
None