Skip to content

SDK timeseries

Create empty dataset

Project for upload must already exist.

var dataset = await _tsClient.CreateDatasetAsync(_projectId, "Some timeseries");

Add timeseries to dataset

//add timeseries
var item = new ItemDefinition
{
    Name = "Temperature",
    DataType = AttributeDataType.Single,
    Item = Generic.MikeZero.eumItem.eumITemperature,
    Unit = Generic.MikeZero.eumUnit.eumUdegreeCelsius
};
var ts = await _tsClient.AddTimeSeriesAsync(_projectId, dataset.Id, item);

//add timeseries values
var data1 = new TimeSeriesData<float>(new[] { DateTime.Today.ToUniversalTime() }, new float?[] { 12.34f });
await _tsClient.AddTimeSeriesValuesAsync<float>(_projectId, dataset.Id, ts.Id, ts1data1);
var data2 = new TimeSeriesData<float>(new[] { DateTime.Today.ToUniversalTime().AddMinutes(1) }, new float?[] { 16.8f });
await _tsClient.AddTimeSeriesValuesAsync<float>(_projectId, dataset.Id, ts.Id, ts1data2);

Query timeseries

Query timeseries for items with Name field equal to "Temperature".

var query = new QueryFilter
{
    Conditions = new List<QueryCondition>()
    {
        new AttributeQueryCondition()
        {
            Name = "Item",
            Operator = AttributeOperator.Equal,
            Value = "Temperature"
        }
    }
};
var result = await _tsClient.QueryTimeSeriesAsync(_projectId, dataset.Id, query);

Samples in SDK

Finally, SDK samples which can serve as examples. Visit MIKE Cloud Platform SDK to get more information about SDK.