MyrConn.PetroVisor.Web.Client 3.9.2404.1

dotnet add package MyrConn.PetroVisor.Web.Client --version 3.9.2404.1
NuGet\Install-Package MyrConn.PetroVisor.Web.Client -Version 3.9.2404.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MyrConn.PetroVisor.Web.Client" Version="3.9.2404.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MyrConn.PetroVisor.Web.Client --version 3.9.2404.1
#r "nuget: MyrConn.PetroVisor.Web.Client, 3.9.2404.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MyrConn.PetroVisor.Web.Client as a Cake Addin
#addin nuget:?package=MyrConn.PetroVisor.Web.Client&version=3.9.2404.1

// Install MyrConn.PetroVisor.Web.Client as a Cake Tool
#tool nuget:?package=MyrConn.PetroVisor.Web.Client&version=3.9.2404.1

Welcome to PetroVisor!

PetroVisor API changes history

3.9.2401.1
  • New scenarios storage, data migration and API
  • Old data schema and reference tables removed
  • Python scripts execution support
  • Snapshots storage moved to workspace
  • Time zones for workflow schedules
  • Packages deployment and comparing improvements
  • New Access, Databricks and P2 Bolo data connections and data sources
3.8.2308.1
  • New Labels centralized storage and API
  • New data storage schema
  • Tag entries data import mode (Start/End dates)
  • Hierarchies import mode
  • New Dashboards objects and API
3.7.2303.5
  • New reference tables
  • Files service updates (file information is available)
  • Scope and Delete data options for Data Integration Sets
  • Entities data import mode
  • Override hierarchy option for workflow schedules
3.7.2302.1
  • Obsolete DataSource is replaced with DataSourceMapping object
  • Workflow activities execution progress and status is updated
3.6.2211.4
  • Rename for any named PetroVisor object
  • Smartsheet data connection and data source
  • Incremental scope processing for workflow activities
3.6.2210.4
  • Workflow activity StopWorkflow and Condition properties
  • Rename for data connections and data sources
  • Obsolete Geo data objects migrated to DataGrid object
  • Evaluate P# expression of different types
3.5.2207.8
  • New PostgreSQL and Snowflake data connections and data sources, Teradata is removed
  • User groups merged with user roles
  • New entities and view permissions
  • New custom workflow activity interface
3.4.2205.4
  • New files (Azure Blob) storage service IFilesService
  • Modified property has been added for the most of the PetroVisor objects
  • New Web custom workflow activity WebWorkflowActivity
  • Updated data import and data integration sessions DataIntegrationSession
  • New scenarios objects Scenario
3.3.2111.3
  • Description property has been added for the most of the PetroVisor objects
  • New Geo data object DataGrid
  • Updated Override Scope for workflow execution, WorkflowExecutionStatistics added
  • Updated MachineLearningModelInfo, new IModelTrainingService service

Architectural overview

PetroVisor Web API consist of the set of independent functionality blocks. Each block is a service, its functionality fully defined in corresponding service public interface.

On the server side, there is a Web API REST service implementing this interface, while on the client side, there is a corresponding proxy client service which communicates with server service. PetroVisor Web API client is a service container class which have a default set of PetroVisor API services.

To work with PetroVisor API you need to create an instance of service container (called IPetroVisorServiceProvider) and then just call the required method(s) of corresponding service.

PetroVisor Web API client encapsulates all related communication and security details - so you can work with PetroVisor Web API services as with local instances of them.

PetroVisor API Deployment

Client part of PetroVisor API consists of .NET 6 assemblies (distributed as NuGet package):

  • MyrConn.PetroVisor.API.dll contains all public interfaces of all PetroVisor Web API services and definition of PetroVisor API domain objects. It is enough to custom workflow activities using .NET.

  • MyrConn.PetroVisor.Web.Client.dll contains service container and all needed client-side internal proxy services. It is required when you want to create your own client application.

PetroVisor API assembly do not contain any references to third-party components and do not need any registration or initialization.

Typical code workflow

The typical code workflow for PetroVisor Web API is very simple: first get the instance of service provider and then call the corresponding service.

Instantiation of service provider

There are several constructors defined for creating of service provider instance.

IPetroVisorServiceProvider sp = new PetroVisorServiceProvider(EndPointConfiguration.EUCloudDiscoveryLatest, "workspace", "user", "password");
Calling the services

Once you have created an instance of IPetroVisorServiceProvider, you can call methods of PetroVisor API services. Just get the instance of the service from service provider:

// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//only names
var allEntityNames = serviceProvider.RepositoryService.Get<Entity>().GetNamesOfItems();

//all entities at once
var allEntities = serviceProvider.RepositoryService.GetWithList<Entity>().GetItems();

//all information about contexts
var allContextsInfo = serviceProvider.RepositoryService.GetWithPetroVisorItems<Context>().GetPetroVisorItems();

All services are stateless, the methods are returning the information on the moment of calling. All services defined in PetroVisor API are already available in service container (IPetroVisorServiceProvider) - no additional initialization or configuration is required.

Repository

All of PetroVisor API objects can be retrieved, added, modified, renamed or deleted by using typed repository service. Depending of PetroVisor API type you can choose from the following Repository service types which are available in IRepositoryServicesContainer of IPetroVisorServiceProvider.

IRepositoryServiceAsync

Any basic PetroVisor API object has a Name property as unique case-insensitive identifier of the object across PetroVisor workspace. IRepositoryServiceAsync<T> provides operations for such objects. IRepostoryServiceAsync provides the following operations:

  • GetNamesOfItemsAsync(CancellationToken) - returns the names of available PetroVisor object of specified type

  • GetItemByNameAsync(String, CancellationToken) - return the item with specified name

  • AddOrEditItemAsync(T, CancellationToken) - adds new or updates existing item

  • DeleteItemAsync(String, CancellationToken) - deletes the item with specified name

  • GetItemsAsync(CancellationToken) - return all available PetroVisor objects of specified type

  • GetItemsPagedAsync(int, int, CancellationToken) - return all available PetroVisor objects of specified type by pages of specified size

  • RenameItemAsync(String, String, CancellationToken) - renames the item with specified name, keeping its data intact

Use Get<TNamedItem>() to get the instance of IRepositoryServiceAsync of required type. You can use Contains<TNamedItem>() to check if required type supported IRepositoryServiceAsync.

IPetroVisorItemRepositoryServiceAsync

Many of PetroVisor API objects supporting some additional (beside Name) common properties. See IPetroVisorItem reference for details. IPetroVisorItemRepositoryServiceAsync<T> provides GetPetroVisorItems() method to get the list of the objects as PetroVisorItem.

Use GetWithPetroVisorItems<TPetroVisorItem>() to get the instance of IPetroVisorItemRepositoryServiceAsync of required type. You can use ContainsWithPetroVisorItems<TPetroVisorItem>() to check if required type supported IPetroVisorItemRepositoryServiceAsync.

// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//only names
var allEntityNames = serviceProvider.RepositoryService.Get<Entity>().GetNamesOfItems();

//all entities at once
var allEntities = serviceProvider.RepositoryService.GetWithList<Entity>().GetItems();

//all information about contexts
var allContextsInfo = serviceProvider.RepositoryService.GetWithPetroVisorItems<Context>().GetPetroVisorItems();

Entities

An Entity object represents named entity which has entity type set (see EntityType).

It is an abstraction of any object of interest. Entity names are unique across the workspace. Entity can have an optional Alias.

There is also some operations available in IPerformanceService for entities.

Units and Unit Measurements

PetroVisor API data is stored and can be retrieved using units. Additionally, units are important in different calculations.

There is predefined set of more than 900 units and more than 20 unit measurements - they all are the same for every workspace.

Units are grouped by their physical sense in unit measurements (like Length, Pressure, Temperature, etc.). The value specified in one unit can be converted to value in different unit only if these 2 units belong to the same unit easement. For example, you can convert the value specified in meter to value in feet unit because they belong to the same measurement Length (but conversion to cubic meter is not possible because it is different unit measurement Volume).

An UnitMeasurement object has only the name and canonical unit name (base unit used for unit conversion).

An Unit object has name, unit measurement, numeric factor and summand (used for unit conversion).

Units and unit measurements names are unique. Additionally, unit names are case-sensitive (unlike any other PetroVisor API objects names).

There is also some operations available in IPerformanceService for units.

Signals

A Signal object represents named property of the Entity (for example, produced oil, x-coordinate, gas rate, etc.).

There is a set of default signals which exists in any workspace, additional signals could be added to workspace too.

Signals are divided by 6 types: static, string, time dependent, depth dependent, string time dependent and PVT.

Each Entity can have only one value for every static signal. It has one or several time dependent values for every time-dependent signal (time-dependent value means the value at specified date-time moment). Depth dependent signals can have one or several depth dependent values (values at specified depth).

A Signal object has some important properties:

  • Name - unique name of the signal
  • ShortName - unique short name of the signal
  • AggregationType - the type of aggregation (Max, Average, Min, etc.) which is automatically used during data retrieval (see below)
  • ContainerAggregationType - the type of aggregation (Max, Average, Min, etc.) which is automatically used during data retrieval when Hierarchy is specified
  • SignalType - signal type
  • MeasurementName - the unit measurement of signal, the values of the signal data could be converted to other units only from that unit measurement
  • StorageUnitName - the default unit from MeasurementName, the signal data is stored using this unit
Aggregation

When signal data is retrieved, time and container aggregation is done automatically as in the following examples:

  • Time aggregation: For example, the data is stored using hourly increment. When data is retrieved using monthly increment, the values will be automatically aggregated using aggregation specified in AggregationType property
  • Container aggregation: For example there is a data for 2 entities Well1 and Well2. They both have parent entity Field 1 - this is set in Hierarchy. So, if entity Field 1 does not have a value for specified signal, the aggregated value using aggregation specified in ContainerAggregationType property, calculated from values of Well1 and Well2, will be automatically calculated and returned.

There is also some operations available in IPerformanceService for signals.

Hierarchies

A Hierarchy object represents named relationship of the entities. The hierarchy is optional and could be used for container aggregation.

The hierarchy defined by set of child-parent pairs. All entities in hierarchy can have only one parent entity. Only one element, called Root has no parent entity specified.

You can get all the required information about hierarchy form its Relationship property (as dictionary of child-parent pairs). However, there are some helper methods to work with hierarchy:

  • Root - returns root entity (the entity which has no parent)
  • GetChildren(Entity) - returns direct children entities of specified entity
  • GetParent(Entity) - returns the parent entity of specified entity
  • ValidationError - validates hierarchy and returns the errors (if any), useful to validate the hierarchy

For example, to traverse the hierarchy, you can get the root entity and then recursively call GetChidren method.

Data retrieval and saving

There is IDataServicesContainer in IPetroVisorServiceProvider which contains data services to save, delete and retrieve PetroVisor API data. You can get the instance of the data service of specified data type to manipulate the data of this type.

Most important data types:

  • DataRequest - combination of Entity, Signal and Unit. Used as request in data retrieval. The returned data is automatically converted to specified unit. If unit is not specified explicitly, Signal.StorageUnitName is used.
  • StaticNumericData - represents static data returned in data retrieval or as source data for data writing. Data is a single value of C# type double. Empty or NULL value is represented as Double.NaN value.
  • TimeNumericData - represents time-dependent data returned in data retrieval or as source data for data writing. Data is a list of DataPoint values. Each DataPoint value consist of C# type double value and DataTime value. Empty or NULL value is represented as Double.NaN value. When TimeNumericData is returned as result of P# script execution, Result property could be used instead of Signal property (because P# can contains complex expression instead of just signal data).
  • DepthNumericData - represents depth-dependent data returned in data retrieval or as source data for data writing. Data is a list of DepthDataPoint values. Each DepthDataPoint value consist of double value as point value and double value as point depth. Empty or NULL value is represented as Double.NaN value.
  • StaticStringData - represents static string data returned in data retrieval or as source data for data writing. Data is a single value of C# type string.
  • TimeStringData - represents string time-dependent data returned in data retrieval or as source data for data writing. Data is a list of StringDataPoint values.
  • PVTNumericData - represents PVT (Pressure-Volume-Temperature) data returned in data retrieval or as source data for data writing. Data is a list of PVTDataPoint values. Each PVTDataPoint value consist of double value as point value and double values as point pressure and temperature. Empty or NULL value is represented as Double.NaN value.
Data services

IDataServicesContainer contains the following methods to get the data service which works with required data type:

  • GetStaticNumeric() - the service to work with StaticNumericData
  • GetTimeNumeric() - the service to work with TimeNumericData
  • GetDepthNumeric() - the service to work with DepthNumericData
  • GetPVTNumeric() - the service to work with PVTNumericData
  • GetStaticString() - the service to work with StaticStringData
  • GetTimeString() - the service to work with TimeStringData

Each of the service supports the following data operations:

  • Load or Retrieve - loads the data using specified data requests or signals and entities combinations
  • Save - saves specified data (existing data is deleted first)
  • Delete - deletes data specified by data requests
  • Acquire - imports, aggregates and cleanses specified data using specified options

Some of the data services provide additional functionality as described below.

Static numeric data

The corresponding data service supports also the following operations:

  • CleanseStaticValueAsync(Double, String, String, String, CleansingOptions, CancellationToken) - attempts to cleanse the specified value using cleansing options
Depth numeric data

The corresponding data service supports also the following operations:

  • GetDepthRangeOfAvailableDataAsync(CancellationToken) - returns minimum and maximum depths of the whole depth data stored in workspace
  • GetFirstValuesAsync(IEnumerable<DataRequest>, Int32, CancellationToken) - gets specified number of first existing values for specified several data requests without any aggregation and regardless of increment (with unit conversion)
  • GetLastValuesAsync(IEnumerable<DataRequest>, Int32, CancellationToken) - gets specified number of last existing values for specified several data requests without any aggregation and regardless of increment (with unit conversion)
Time numeric data

The corresponding data service supports also the following operations:

  • CleanseTimeValueAsync(Double, String, String, String, DateTime, CleansingOptions, CancellationToken) - attempts to cleanse the specified value using cleansing options
  • GetFirstValuesAsync(IEnumerable<DataRequest>, Int32, CancellationToken) - gets specified number of first existing values for specified several data requests without any aggregation and regardless of increment (with unit conversion)
  • GetLastValuesAsync(IEnumerable<DataRequest>, Int32, CancellationToken) - gets specified number of last existing values for specified several data requests without any aggregation and regardless of increment (with unit conversion)
  • GetTimeRangeOfAvailableDataAsync(CancellationToken) - returns the time range of all available data
  • GetTimeRangeOfAvailableDataForSignalAsync(String, CancellationToken) - returns the time range of all available data for specified signal
  • GetTimeRangeOfAvailableDataForDataSetAsync(String, String, CancellationToken) - returns the time range of all available data for specified signal and entity

Tags and tag entries

There is ITagEntriesService service to work with tag entries.

Tags and tag entries

A Tag object represents special mark which could be associated with Entity on some time range.

For example, entity Well 1 one has Tag Sand Production from 1/1/2010 to 2/1/2010. So the Tag name is a mark or event name.

Tags are organized in tag groups.

TagEntry is a combination of Entity, Tag and time range - in other words it is a record that specified Tag was valid for specified Entity in specified time range. Time range for a TagEntry could be not closed which means that it contains only start date and end date is not defined. This means that Tag is still valid for the Entity.

ITagEntriesService
  • AddOrEditTagEntryAsync(TagEntry, CancellationToken) - adds new or edit existing tag entry
  • AddOrEditTagEntriesAsync(IEnumerable<TagEntry>, CancellationToken) - performance optimized adding of several tag entries at once, optionally deleting overlapping existing tag entries
  • GenerateTagEntriesAsync(ScriptWithExecutionOptions, CancellationToken) - returns tag entries generating using specified P# script
  • GetTagEntriesAsync(TagEntriesFilter, CancellationToken) - returns all existing tag entries which are valid for specified filter
  • DeleteTagEntryAsync(String, String, DateTime, CancellationToken) - deletes tag entry for specified entity, tag and start date
  • DeleteTagEntriesAsync(String, String, TimeRange, CancellationToken) - deletes all tag entry for specified entity, tag and time range

Parsing P#

P# objects

P# objects have corresponding representation in P# language. So all of them have ToPSharp() method to get corresponding P# language string. There is IPSharpService which can do the reverse operation - it parses the P# script and returns the instances of corresponding PetroVisor API objects.

Mentioned above objects can be saved to storage. In this case, when the object missed in the P# script, but exists in storage, its definition will be automatically loaded from storage. So only the P# context and one of the calculation objects are required parts of any P# script - the missed parts could be loaded from storage.

The following PetroVisor API objects can be used in P# scripts:

P# calculations: TableCalculation, EventCalculation, CleansingCalculation

There are 3 types of P# calculation objects:

  • TableCalculation - named set of TableColumn objects, represents Table objects in P#
  • EventCalculation - named set of EventCondition objects, represents Rule objects in P#
  • CleansingCalculation - named set of CleansingFilter objects, represents Cleansing objects in P# EventCalculation and CleansingCalculation could be represented as TableCalculation using ToTableCalculationPSharp() method.
P# EntitySet

An EntitySet object represents a set of entities. Entity set can be defined as list of entities or using P# entity functions (like All(), EntitiesByTag(), EntitiesByCondition(), etc.). It is possible to define entity set in P# using other entity sets and operators like Union, Except and Intersect:

Entity Set "No Tags" = "All Entities" Except "With Tags"
P# Scope

A Scope object represents a time range with time increment and depth range with depth increment. A scope object can be defined with time range or using P# functions (like StartOf(), EndOf(), Now(), etc.). It contains ScopeDates property which returns all valid dates from scope time range using scope time increment.

P# Context

A Context object represents a P# context - combination of EntitySet, Scope and optionally Hierarchy.

P# Plot

IPSharpService

  • Parse(String, ParsingOptions) - returns instances of objects parsed from specified P# script or its fragment
  • ParseMissed(String, ParsingOptions) - returns the names of objects used in the scripts, which definition does not exists in the specified P# script
  • ParseSignals(String, ParsingOptions) - returns the list of all signals and their units used in specified P# scripts
  • ParseFunctions(String, ParsingOptions) - returns the list of all functions used in specified P# scripts
  • ParseNamedParameters(String, ParsingOptions) - returns the list of all named parameters (placeholders) with their default values used in specified P# scripts
  • ApplyNamedParametersValues(ScriptWithNamedParameterValues) - applies specified named parameters (placeholders) values to P# script

Logging

A LogEntry represents one record in the log.

There is ILoggingService service to work with log entries.

ILoggingService

  • AddLogEntryAsync(LogEntry, CancellationToken) - adds a new log entry
  • AddLogEntriesAsync(IEnumerable<LogEntry>, CancellationToken) - performance optimized adding of several log entries at once
  • GetLogEntriesAsync(LogFilter, CancellationToken) - returns all existing log entries which are valid for specified filter
  • GetAvailableCategoriesAsync(CancellationToken) - returns the list of all existing log categories
  • CleanUpLogEntriesAsync(TimeSpan, String, CancellationToken) - deletes all log entries for specified category (optionally for all categories) leaving entries not older then specified time span value

LogFilter

Log entries filter consist of optional properties which can be set to filter log entries:

  • LastEntries - the filter will return the number of last entries, use 0 for all entries
  • Category - the filter will returns all log entries with this category
  • Start - the filter will returns all log entries starting specified date
  • End - the filter will returns all log entries starting before specified date
  • User - the filter will return all log entries created by specified user
  • Severity - the filter will return all log entries with specified message severity

These properties could be combined in any way. If all of them are not set - all existing log entries will be returned (the same as when Empty used).

Configuration

There is IConfigurationService service which allows to make some configuration-related tasks.

IConfigurationService

  • Ping(CancellationToken)- checks the connection to the server.
  • VerifyAsync(CancellationToken)- verifies the connection to the server and workspace. This is recommend method to check the correctness of host, workspace and user credentials. It does not throw an exception on error, but returns error message as a result. So, when the result is an empty string, the test is successful. Additionally, it creates the required database schema if it does not exists.
  • GetCurrentConfigurationAsync(CancellationToken)- returns current server configuration
  • GetWorkspaceSizeAsync(CancellationToken) - returns the size of workspace data in megabytes

Samples

Data retrieval using P# script

P# script (whole script or its parts) could be created in the following ways:

  • From storage - see samples below
  • Concatenation of strings - you can construct the final script (as string) in code
  • From P# PetroVisor API objects (ToPSharp() method) - all script components have corresponding PetroVisor API object (see also below samples)
  • Using script execution options - use existing P# snippets and P# named parameters
  • Combination of all above - for example, get the script, parse it, replace some element with required values, generate updated script
// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//get data using P# script stored in resources
IEnumerable<NumericDataTable> tables = serviceProvider.PSharpService.Execute(new ScriptWithExecutionOptions
{
    ScriptContent = "Some P# script content",
    Options = ScriptExecutionOptions.Default
});

//output data has at least one table (defined in P# script)
foreach (var table in tables)
{
    //every table has a set of columns (defined in P# script)
    foreach (var timeData in table.Data)
    {
        //timeData.Result - signal (result) name - e.g. produced oil
        //timeData.Entity - entity name - e.g Well01
        //timeData.Unit - unit - e.g. STB

        // .Data property contains the data points
        foreach (var point in timeData.Data)
        {
            //point.Date is data date
            //point.Value is data value
        }
    }
}

Getting P# script from storage

You can get other stored PetroVisor API objects (Scopes, Contexts, TableCalculations) in the similar way - just use corresponding service for that.

// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//get the content of P# script stored as "Production History"
string script = serviceProvider.RepositoryService.Get<PSharpScript>.GetItemByName("Production History")?.Content;

Data retrieval using PetroVisor API objects

For performance reasons, it is recommended in most situations to cache objects like entities, signals or units locally - so get the full list of them using corresponding service first and then get individual items from those lists.

In this sample, units for data set requests are not specified - so default signal units are used. To get the data in another units - just specify the required units in data set requests. Unit conversion is done automatically - do not implement additional unit conversion.

// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//create data requests
var requests = new List<DataRequest>(new[]
{ 
    new DataRequest(
    serviceProvider.RepositoryService.Get<Signal>().GetItemByName("produced oil"),
    serviceProvider.RepositoryService.Get<Entity>().GetItemByName("Well 1")) 
    ,
    new DataRequest(
    serviceProvider.RepositoryService.Get<Signal>().GetItemByName("produced oil"),
    serviceProvider.RepositoryService.Get<Entity>().GetItemByName("Well 2")) 
    ,
    new DataRequest(
    serviceProvider.RepositoryService.Get<Signal>().GetItemByName("produced gas"),
    serviceProvider.RepositoryService.Get<Entity>().GetItemByName("Well 1")) 
});

//create scope
var scope = new Scope()
{ 
    Name = "Data scope",
    Start = DateTime.Now.AddHours(-24),
    End = DateTime.Now,
    TimeIncrement = TimeIncrement.Hourly
};

//get existing hierarchy (optional)
var hierarchy = serviceProvider.RepositoryService.Get<Hierarchy>().GetItemByName("Producers");

//finally, get the data
var data = serviceProvider.DataServices.GetTimeNumeric().Load(requests, scope, hierarchy, DataRetrievalOptions.Default);

//output data has a set of columns (one column per data set request)
foreach (var timeData in data)
{
    //timeData.Signal - signal (result) name - e.g. produced oil 
    //timeData.Entity - entity name - e.g Well 1
    //timeData.Unit - unit - e.g. STB

    // .Data property contains the data points
    foreach (var point in timeData.Data)
    {
        //point.Date is data date
        //point.Value is data value
    }
}

Extracting PetroVisor API object from P# script

You can generate P# script from a PetroVisor API object by calling its ToPSharp() method.

// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//parse P# script stored in resources
ParseResult pr = serviceProvider.PSharpService.Parse("Some P# content", ParsingOptions.Default);
//ParseResult contains extracted objects in corresponding properties (Scopes, EntitySets, Tables, etc.)

Data saving

Saving of time-dependent data.

// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//define the data to save
var signal = serviceProvider.RepositoryService.Get<Signal>().GetItemByName("produced oil");
var entity = serviceProvider.RepositoryService.Get<Entity>().GetItemByName("Well 1");
var unit = serviceProvider.RepositoryService.Get<Unit>().GetItemByName("STB");
var startRangeDate = DateTime.Today;

var data = new List<DataPoint>();
data.Add(new DataPoint(startRangeDate.AddHours(0), -23.45));
data.Add(new DataPoint(startRangeDate.AddHours(1), 23));
data.Add(new DataPoint(startRangeDate.AddHours(3), 45.7));
data.Add(new DataPoint(startRangeDate.AddHours(4), -76.8));
data.Add(new DataPoint(startRangeDate.AddHours(5), 2));
data.Add(new DataPoint(startRangeDate.AddHours(6), -0.66));
data.Add(new DataPoint(startRangeDate.AddHours(9), 4.5));
data.Add(new DataPoint(startRangeDate.AddHours(10), 3.786));
data.Add(new DataPoint(startRangeDate.AddHours(11), 3.66));
data.Add(new DataPoint(startRangeDate.AddHours(12), 2.786));
data.Add(new DataPoint(startRangeDate.AddHours(15), 6.87));
data.Add(new DataPoint(startRangeDate.AddHours(16), 12.4));
data.Add(new DataPoint(startRangeDate.AddHours(17), 24.5));
data.Add(new DataPoint(startRangeDate.AddHours(18), -3.66));
data.Add(new DataPoint(startRangeDate.AddHours(19), 2.44));
data.Add(new DataPoint(startRangeDate.AddHours(20), 1.45));
data.Add(new DataPoint(startRangeDate.AddHours(22), -54.22));
data.Add(new DataPoint(startRangeDate.AddHours(25), -34.55));
data.Add(new DataPoint(startRangeDate.AddHours(26), 11.11));
data.Add(new DataPoint(startRangeDate.AddHours(27), 0.344));
data.Add(new DataPoint(startRangeDate.AddHours(29), -1.23));
data.Add(new DataPoint(startRangeDate.AddHours(30), 3.123));

var dataToSave = new TimeNumericData[] { new TimeNumericData(signal, entity, unit, data) };

//save the data
serviceProvider.DataServices.GetTimeNumeric().Save(dataToSave);

Data acquisition with data cleansing

Data cleansing (filtering) is optional.

Data cleansing works on raw data (not aligned or aggregated).

Data acquisition automatically aggregates and saves cleansed data.

// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//define the data to acquire
var signal = serviceProvider.RepositoryService.Get<Signal>().GetItemByName("produced oil");
var entity = serviceProvider.RepositoryService.Get<Entity>().GetItemByName("Well 1");
var unit = serviceProvider.RepositoryService.Get<Unit>().GetItemByName("STB");
var startRangeDate = DateTime.Today;

var data = new List<DataPoint>();
data.Add(new DataPoint(startRangeDate.AddHours(0), -23.45));
data.Add(new DataPoint(startRangeDate.AddHours(1), 23));
data.Add(new DataPoint(startRangeDate.AddHours(3), 45.7));
data.Add(new DataPoint(startRangeDate.AddHours(4), -76.8));
data.Add(new DataPoint(startRangeDate.AddHours(5), 2));
data.Add(new DataPoint(startRangeDate.AddHours(6), -0.66));
data.Add(new DataPoint(startRangeDate.AddHours(9), 4.5));
data.Add(new DataPoint(startRangeDate.AddHours(10), 3.786));
data.Add(new DataPoint(startRangeDate.AddHours(11), 3.66));
data.Add(new DataPoint(startRangeDate.AddHours(12), 2.786));
data.Add(new DataPoint(startRangeDate.AddHours(15), 6.87));
data.Add(new DataPoint(startRangeDate.AddHours(16), 12.4));
data.Add(new DataPoint(startRangeDate.AddHours(17), 24.5));
data.Add(new DataPoint(startRangeDate.AddHours(18), -3.66));
data.Add(new DataPoint(startRangeDate.AddHours(19), 2.44));
data.Add(new DataPoint(startRangeDate.AddHours(20), 1.45));
data.Add(new DataPoint(startRangeDate.AddHours(22), -54.22));
data.Add(new DataPoint(startRangeDate.AddHours(25), -34.55));
data.Add(new DataPoint(startRangeDate.AddHours(26), 11.11));
data.Add(new DataPoint(startRangeDate.AddHours(27), 0.344));
data.Add(new DataPoint(startRangeDate.AddHours(29), -1.23));
data.Add(new DataPoint(startRangeDate.AddHours(30), 3.123));

var dataToSave =  new TimeNumericData[] { new TimeNumericData(signal, entity, unit, data) };

//acquire the data
await serviceProvider.DataServices.GetTimeNumeric().AcquireWithLogsAsync(new TimeNumericDataWithCleansingOptions
{
    Data = dataToSave,
    Options = CleansingOptions.Default
});

Generating tag entries

The instances of all P# PetroVisor API objects (like Contexts, Scopes, EntitySets, etc.) could be received in the following ways:

  • Created as new instance when needed:
new Context();
  • Retrieved from storage:
serviceProvider.RepositoryService.Get<EntitySet>.GetItemByName("All entities");
  • Extracted from P# scripts:
serviceProvider.PSharpService.Parse("Some P# content", ParsingOptions.Default).Scopes.First();
Generating tag entries
// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//get event calculation stored as "Production History"
var eventCalculation = serviceProvider.RepositoryService.Get<EventCalculation>().GetItemByName("Production Events");

//create new context
var ctx = new Context()
{
    Name = "Event Context",
    EntitySet = serviceProvider.RepositoryService.Get<EntitySet>().GetItemByName("All entities"),
    Scope = serviceProvider.RepositoryService.Get<Scope>().GetItemByName("Current scope")
};

//generate tag entries
var tagEntries = serviceProvider.TagEntriesService.GenerateTagEntries(new ScriptWithExecutionOptions
{
    ScriptContent = ctx.ToPSharp() + " " + eventCalculation.ToPSharp(),
    Options  = ScriptExecutionOptions.Default
});

//if needed, make some processing of tag entries
//...
//save generated entries if needed
serviceProvider.TagEntriesService.AddTagEntries(tagEntries);

Full P# script execution

Full P# script execution means:

  • Running specified P# script
  • Saving the results (if defined in script)
  • Running event calculations (tag rules) (if defined in script)
  • Saving event calculations results as tag entries (if any)
  • Applying cleansing filters (if defined in script) on script results (if any)
  • Returning the final results
// Get an instance of service provider
IPetroVisorServiceProvider serviceProvider = new PetroVisorServiceProvider(...);

//process the script, including saving the results (SAVING clause in P#), generating and saving tag entries, cleansing of returned data
var data = serviceProvider.PSharpService.Execute(new ScriptWithExecutionOptions
{
    ScriptContent = "Some P# script content",
    Options = ScriptExecutionOptions.Default
});
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.9.2404.1 86 4/17/2024
3.9.2403.3 89 3/22/2024
3.9.2403.1 86 3/12/2024
3.9.2402.3 98 2/27/2024
3.9.2402.1 90 2/12/2024
3.9.2401.2 81 1/17/2024
3.9.2401.1 87 1/9/2024
3.8.2311.2 76 11/27/2023
3.8.2310.2 126 10/17/2023
3.8.2309.3 136 9/22/2023
3.8.2309.1 122 9/6/2023
3.8.2308.1 144 8/1/2023
3.7.2307.1 126 7/27/2023
3.7.2306.1 110 6/15/2023
3.7.2305.1 143 5/11/2023
3.7.2304.3 143 4/24/2023
3.7.2303.5 218 3/29/2023
3.7.2302.3 292 3/1/2023
3.6.2301.4 228 2/10/2023
3.6.2212.1 271 12/15/2022
3.6.2211.4 287 11/25/2022
3.6.2210.4 375 10/27/2022
3.6.2210.2 394 10/14/2022
3.6.2209.1 362 10/3/2022
3.5.2209.3 370 9/29/2022
3.5.2207.5 404 7/25/2022
3.5.2206.3 454 6/26/2022
3.5.2205.5 402 6/2/2022
3.5.2205.1 442 5/12/2022
3.4.2204.8 430 4/27/2022
3.4.2203.8 427 3/29/2022
3.4.2203.1 456 3/3/2022
3.4.2201.2 267 1/10/2022
3.3.2112.3 292 12/20/2021
3.3.2111.1 329 11/15/2021
3.3.2110.5 329 10/19/2021
3.3.2110.2 339 10/11/2021
3.3.2109.3 342 9/14/2021
3.3.2109.1 328 9/7/2021
3.3.2108.6 319 8/26/2021
3.3.2108.3 323 8/17/2021
3.3.2108.2 328 8/16/2021
3.2.2108.1 322 8/9/2021
3.2.2107.2 363 7/29/2021
3.2.2106.5 362 7/5/2021
3.2.2106.3 310 6/25/2021
3.2.2106.1 322 6/9/2021
3.2.2105.3 338 5/25/2021
3.2.2104.5 398 4/14/2021
3.2.2104.4 329 4/7/2021
3.2.2104.3 315 4/1/2021
3.1.2103.7 397 3/24/2021
3.1.2103.1 336 3/5/2021
3.1.2102.4 330 2/26/2021
3.1.2102.2 322 2/15/2021
3.1.2012.2 386 12/10/2020
3.0.2011.1 376 11/16/2020
3.0.2010.1 404 10/8/2020
3.0.2009.2 445 9/18/2020
2.2.2005.1 497 6/2/2020
2.2.2004.1 456 4/1/2020
2.2.2003.3 478 3/20/2020
2.1.2002.1 512 2/17/2020
2.1.1911.1 507 11/12/2019
2.0.1909.4 514 11/15/2019
2.0.1909.2 533 9/18/2019
2.0.1909.1 514 9/11/2019
2.0.1908.2 528 8/28/2019
2.0.1908.1 506 8/7/2019
2.0.1907.2 505 7/16/2019
2.0.1906.3 516 6/27/2019
2.0.1906.1 551 6/11/2019
1.4.1906.1 604 6/4/2019
1.4.1905.1 565 5/10/2019

Latest PetroVisor 3.9 release