r"""Assert that the series is daily and monotonic (no jumps in time index).

    A ValueError is raised otherwise.
429144
def assert_daily(var):
    """

    t0, t1 = var.time[:2]

    # This won't work for non-standard calendars. Needs to be implemented in xarray. Comment for now
    if isinstance(t0.values, np.datetime64):
        if pd.infer_freq(var.time.to_pandas()) != 'D':
            raise ValueError("time series is not recognized as daily.")

    # Check that the first time step is one day.
    if np.timedelta64(dt.timedelta(days=1)) != (t1 - t0).data:
        raise ValueError("time series is not daily.")

    # Check that the series has the same time step throughout
    if not var.time.to_pandas().is_monotonic_increasing:
        raise ValueError("time index is not monotonically increasing.")
361019
def _assert_same(values):
    """"""
    assert len(values) > 0
    first, rest = values[0], values[1:]
    for v in rest:
        assert v == first
    return first
1130517
def deviation(self, series, start, limit, mean):
        '''
        
        '''
        d = []
        for x in range(start, limit):
            d.append(float(series[x] - mean))
        return d
1311990
private boolean doesAnyTimeSeriesHaveData() {
		for (int i = 0; i < iterators.length; i++) {
			if ((timestamps[iterators.length + i]) !=  MARK_END_TIME_SERIES) {
				return true;
			}
		}
		return false;
	}
1216022
def is_continuous(self):
        """"""
        if self._validated_a_period is True and \
                len(self.values) == len(self.header.analysis_period.months_int):
            return True
        else:
            return False
1089891
def in_zstack(self, s, c, t):
        
        if (self.series == s
            and self.channel == c
            and self.timepoint == t):
            return True
        return False
899978
def normalize(self, dt, is_dst=False):
        """"""
        if dt.tzinfo is self:
            return dt
        if dt.tzinfo is None:
            raise ValueError('Naive time - no tzinfo set')
        return dt.astimezone(self)
905781
def _compute(self, data):
        """"""
        local_ts = self._local_ts(*data)
        dt = local_ts[internal_names.TIME_WEIGHTS_STR]
        # Convert dt to units of days to prevent overflow
        dt = dt / np.timedelta64(1, 'D')
        return local_ts, dt
81790
def daily_plots(
    df,
    variable,
    renormalize = True,
    plot        = True,
    scatter     = False,
    linestyle   = "-",
    linewidth   = 1,
    s           = 1
    ):
    
    if not df.index.dtype in ["datetime64[ns]", "<M8[ns]", ">M8[ns]"]:
        log.error("index is not datetime")
        return False
    days = []
    for group in df.groupby(df.index.day):
        days.append(group[1])
    scaler = MinMaxScaler()
    plt.xlabel("hours")
    plt.ylabel(variable);
    for day in days:
        if renormalize:
            values = scaler.fit_transform(day[[variable]])
        else:
            values = day[variable]
        if plot:
            plt.plot(day["hours_through_day"], values, linestyle = linestyle, linewidth = linewidth)
        if scatter:
            plt.scatter(day["hours_through_day"], values, s = s)
1341965
def mean(self, series, start, limit):
        '''
        
        '''
        return float(np.mean(series[start:limit]))
858464
def get_freq(self):
        
        if not self.is_monotonic or not self.index._is_unique:
            return None

        delta = self.deltas[0]
        if _is_multiple(delta, _ONE_DAY):
            return self._infer_daily_rule()

        # Business hourly, maybe. 17: one day / 65: one weekend
        if self.hour_deltas in ([1, 17], [1, 65], [1, 17, 65]):
            return 'BH'
        # Possibly intraday frequency.  Here we use the
        # original .asi8 values as the modified values
        # will not work around DST transitions.  See #8772
        elif not self.is_unique_asi8:
            return None

        delta = self.deltas_asi8[0]
        if _is_multiple(delta, _ONE_HOUR):
            # Hours
            return _maybe_add_count('H', delta / _ONE_HOUR)
        elif _is_multiple(delta, _ONE_MINUTE):
            # Minutes
            return _maybe_add_count('T', delta / _ONE_MINUTE)
        elif _is_multiple(delta, _ONE_SECOND):
            # Seconds
            return _maybe_add_count('S', delta / _ONE_SECOND)
        elif _is_multiple(delta, _ONE_MILLI):
            # Milliseconds
            return _maybe_add_count('L', delta / _ONE_MILLI)
        elif _is_multiple(delta, _ONE_MICRO):
            # Microseconds
            return _maybe_add_count('U', delta / _ONE_MICRO)
        else:
            # Nanoseconds
            return _maybe_add_count('N', delta)
342904
def _consistent(self):
        """"""
        if len(self.__order) != sum(len(values) for values in self.__index.values()):
            return False
        import copy
        tmp = copy.copy(self.__order)
        for key, values in self.__index.items():
            for value in values:
                if value.name != key:
                    return False
                if value in tmp:
                    tmp.remove(value)
                else:
                    return False
                if isinstance(value, CP2KSection):
                    if not value._consistent():
                        return False
        return True
58393
def is_series(data):
    
    dd = None
    if 'dask' in sys.modules:
        import dask.dataframe as dd
    return((pd is not None and isinstance(data, pd.Series)) or
          (dd is not None and isinstance(data, dd.Series)))
31838
def timeseries(X, **kwargs):
    """"""
    pl.figure(figsize=(2*rcParams['figure.figsize'][0], rcParams['figure.figsize'][1]),
              subplotpars=sppars(left=0.12, right=0.98, bottom=0.13))
    timeseries_subplot(X, **kwargs)
484865
def absolute(self):
        
        return Timeseries(np.absolute(self), self.tspan, self.labels)
537400
def sd(series):
    

    if np.issubdtype(series.dtype, np.number):
        return series.std()
    else:
        return np.nan
374392
def is_valid_interval(self, lower, upper):
        """"""
        try:
            lower_idx = self.data.index(lower)
            upper_idx = self.data.index(upper)
            return (lower_idx, upper_idx) if lower_idx <= upper_idx else False
        except ValueError:
            return False