How to use the pastas.timeseries.TimeSeries function in pastas

To help you get started, we’ve selected a few pastas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pastas / pastas / pastas / stressmodels.py View on Github external
def __init__(self, stress, name="factor", settings=None, metadata=None):
        if isinstance(stress, list):
            stress = stress[0]  # Temporary fix Raoul, 2017-10-24
        tmin = stress.series_original.index.min()
        tmax = stress.series_original.index.max()
        StressModelBase.__init__(self, One, name, tmin=tmin, tmax=tmax,
                                 up=True, meanstress=1, cutoff=0.999)
        self.value = 1.  # Initial value
        stress = TimeSeries(stress, settings=settings, metadata=metadata)
        self.stress = [stress]
        self.set_init_parameters()
github pastas / pastas / pastas / stressmodels.py View on Github external
def __init__(self, stress, rfunc, name, up=True, cutoff=0.999,
                 settings=None, metadata=None, meanstress=None):
        if isinstance(stress, list):
            stress = stress[0]  # Temporary fix Raoul, 2017-10-24

        stress = TimeSeries(stress, settings=settings, metadata=metadata)

        if meanstress is None:
            meanstress = stress.series.std()

        StressModelBase.__init__(self, rfunc, name, stress.series.index.min(),
                                 stress.series.index.max(), up, meanstress,
                                 cutoff)
        self.freq = stress.settings["freq"]
        self.stress = [stress]
        self.set_init_parameters()
github pastas / pastas / pastas / project / project.py View on Github external
series.name = name

        if kind == "oseries":
            data = self.oseries
            if settings is None:
                settings = 'oseries'
        else:
            data = self.stresses

        if name in data.index:
            warning = ("Time series with name {} is already present in the "
                       "database. Existing series is overwitten.").format(name)
            logger.warning(warning)
        try:
            ts = TimeSeries(series=series, name=name, settings=settings,
                            metadata=metadata, **kwargs)
        except:
            logger.error("An error occurred. Time series {} is omitted "
                         "from the database.".format(name))
            return

        data.at[name, "name"] = name
        data.at[name, "series"] = ts  # Do not add as first!
        data.at[name, "kind"] = kind

        # Transfer the metadata (x, y and z) to dataframe as well to increase speed.
        for i in ts.metadata.keys():
            value = ts.metadata[i]
            data.loc[name, i] = value
github pastas / pastas / pastas / stressmodels.py View on Github external
def __init__(self, stress, rfunc, name, up=True, cutoff=0.99,
                 kind=("prec", "evap"), settings=(None, None),
                 metadata=(None, None)):
        # First check the series, then determine tmin and tmax
        stress0 = TimeSeries(stress[0], kind=kind[0], settings=settings[0],
                             metadata=metadata[0])
        stress1 = TimeSeries(stress[1], kind=kind[1], settings=settings[1],
                             metadata=metadata[1])

        # Select indices from validated stress where both series are available.
        index = stress0.series.index & stress1.series.index
        if index.size is 0:
            logger.warning('The two stresses that were provided have no '
                           'overlapping time indices. Please make sure time indices overlap or apply to separate time series objects.')

        # First check the series, then determine tmin and tmax
        stress0.update_series(tmin=index.min(), tmax=index.max())
        stress1.update_series(tmin=index.min(), tmax=index.max())

        StressModelBase.__init__(self, rfunc, name, index.min(), index.max(),
                                 up, stress0.mean() - stress1.mean(), cutoff)
github pastas / pastas / pastas / stressmodels.py View on Github external
def __init__(self, stress, rfunc, name, up=True, cutoff=0.99, kind=None,
                 settings=None, metadata=None):
        if isinstance(stress, list):
            stress = stress[0]  # Temporary fix Raoul, 2017-10-24
        stress = TimeSeries(stress, kind=kind, settings=settings,
                            metadata=metadata)

        StressModelBase.__init__(self, rfunc, name, stress.index.min(),
                                 stress.index.max(), up, stress.mean(), cutoff)
        self.freq = stress.settings["freq"]
        self.stress = [stress]
        self.set_init_parameters()
github pastas / pastas / pastas / stressmodels.py View on Github external
# Select indices where both series are available
        index = prec1.series.index & evap1.series.index

        if index.size is 0:
            raise Warning('The two stresses that were provided have no '
                          'overlapping time indices. Please make sure time '
                          'indices overlap or apply to separate time series '
                          'objects.')

        # Store tmin and tmax
        StressModelBase.__init__(self, rfunc, name, index.min(), index.max(),
                                 True,
                                 stress[0].mean() - stress[1].mean(), cutoff)

        self.stress["prec"] = TimeSeries(stress[0][index], kind=kind[0],
                                         settings=settings[0],
                                         metadata=metadata[0])
        self.stress["evap"] = TimeSeries(stress[1][index], kind=kind[0],
                                         settings=settings[0],
                                         metadata=metadata[1])

        self.freq = self.stress["prec"].settings["freq"]

        self.recharge = recharge()
        self.set_init_parameters()
        self.nparam = self.rfunc.nparam + self.recharge.nparam
github pastas / pastas / pastas / read / knmi.py View on Github external
station = knmi.stations.loc[code, :]
                metadata['x'] = station.LON_east
                metadata['y'] = station.LAT_north
                metadata['z'] = station.ALT_m
                metadata['projection'] = 'epsg:4326'
                stationname = station.NAME
            else:
                stationname = str(code)
            metadata['description'] = knmi.variables[variable]
            if variable == 'RD' or variable == 'RH':
                kind = 'prec'
            elif variable == 'EV24':
                kind = 'evap'
            else:
                kind = None
            ts.append(TimeSeries(series, name=variable + ' ' + stationname,
                                 metadata=metadata, settings=kind))
    if len(ts) == 1:
        ts = ts[0]
    return ts
github pastas / pastas / pastas / read / dinoloket.py View on Github external
raise (
            ValueError("variable %s is not in this dataset. Please use one of "
                       "the following keys: %s" % (
                           variable, dino.data.keys())))
    series = dino.data[variable] * factor  # To make it meters)
    if len(dino.meta) > 0:
        metadata = dino.meta[-1]
    else:
        metadata = None

    metadata['x'] = dino.x
    metadata['y'] = dino.y
    metadata['z'] = np.mean((dino.bovenkant_filter, dino.onderkant_filter))
    metadata['projection'] = 'epsg:28992'

    ts.append(TimeSeries(series,
                         name=dino.locatie + '_' + str(dino.filternummer),
                         metadata=metadata, settings='oseries'))
    if len(ts) == 1:
        ts = ts[0]
    return ts