Skip to contents

Provides access to data related functionality provided through the web API.

Details

A new instance of this class will be created by the ServiceProvider automatically.

Super class

Myrconn.PetroVisor.Client::ApiRequests -> DataServices

Methods


Method new()

Create a new DataServices instance. This is done by the ServiceProvider automatically.

Usage

DataServices$new(url, token_type, token, sp)

Arguments

url

the URL for the API calls.

token_type

the type of the issued token.

token

the issued token.

sp

instance of the service provider


Method load()

Load data from PetroVisor. This function is deprecated. Use load_signals() or load_reference_table() instead.

Usage

DataServices$load(
  entities,
  signals,
  scenario_names = NULL,
  hierarchy_name = NULL,
  top_records = NULL,
  include_workspace_data = TRUE,
  time_increment = NULL,
  time_start = NULL,
  time_end = NULL,
  depth_increment = NULL,
  depth_start = NULL,
  depth_end = NULL,
  with_gaps = TRUE,
  gap_numeric_value = NULL,
  gap_string_value = NULL,
  depth_unit = NULL,
  pressure_unit = NULL,
  temperature_unit = NULL,
  aggregation = NULL,
  reshape = TRUE
)

Arguments

entities

List of entities to retrieve data for. Either a list of strings or a list of items of type Entity.

signals

List of parsed signals to retrieve data for.

scenario_names

List of scenario names to load data for.

hierarchy_name

Hierarchy used in the data retrieval process.

top_records

Number of records to return,

include_workspace_data

Whether workspace data shall be included in the output (only applies if scenarios are used). Defaults to TRUE.

time_increment

The time increment to load the data in.

time_start

The first time stamp data is loaded for.

time_end

The last time stamp data is loaded for.

depth_increment

The depth increment to load the data in.

depth_start

The first depth data is loaded for.

depth_end

The last depth data is loaded for.

with_gaps

Whether gaps shall be returned. Defaults to TRUE.

gap_numeric_value

Replacement value for gaps in numeric data.

gap_string_value

Replacement value for gaps in string data.

depth_unit

The depth unit for retrieving depth data.

pressure_unit

The pressure unit used when retrieving PVT data.

temperature_unit

The temperature unit used when retrieving PVT data.

aggregation

Aggregation type applied to the data.

reshape

Whether to return the raw output of the api call or reshape the data into a more user-friendly format. Defaults to TRUE.


Method load_signals()

Load signal data from PetroVisor.

Usage

DataServices$load_signals(
  entities,
  signals,
  scenario_names = NULL,
  hierarchy_name = NULL,
  top_records = NULL,
  include_workspace_data = TRUE,
  time_increment = NULL,
  time_start = NULL,
  time_end = NULL,
  depth_increment = NULL,
  depth_start = NULL,
  depth_end = NULL,
  with_gaps = TRUE,
  gap_numeric_value = NULL,
  gap_string_value = NULL,
  depth_unit = NULL,
  pressure_unit = NULL,
  temperature_unit = NULL,
  aggregation = NULL,
  reshape = TRUE
)

Arguments

entities

List of entities to retrieve data for. Either a list of strings or a list of items of type Entity.

signals

List of parsed signals to retrieve data for.

scenario_names

List of scenario names to load data for.

hierarchy_name

Hierarchy used in the data retrieval process.

top_records

Number of records to return.

include_workspace_data

Whether workspace data shall be included in the output (only applies if scenarios are used). Defaults to TRUE.

time_increment

The time increment to load the data in.

time_start

The first time stamp data is loaded for.

time_end

The last time stamp data is loaded for.

depth_increment

The depth increment to load the data in.

depth_start

The first depth data is loaded for.

depth_end

The last depth data is loaded for.

with_gaps

Whether gaps shall be returned. Defaults to TRUE.

gap_numeric_value

Replacement value for gaps in numeric data.

gap_string_value

Replacement value for gaps in string data.

depth_unit

The depth unit for retrieving depth data.

pressure_unit

The pressure unit used when retrieving PVT data.

temperature_unit

The temperature unit used when retrieving PVT data.

aggregation

Aggregation type applied to the data.

reshape

Whether to return the raw output of the api call or reshape the data into a more user-friendly format. Defaults to TRUE.


Method load_reference_table()

Load reference table data from PetroVisor.

Usage

DataServices$load_reference_table(
  table,
  entities = NULL,
  time_start = NULL,
  time_end = NULL,
  top_records = NULL,
  key_unit_name = NULL,
  columns = NULL,
  specified_columns_only = FALSE,
  where = NULL
)

Arguments

table

The name of the reference table to load from.

entities

List of entities to retrieve data for. Either a list of strings or a list of items of type Entity.

time_start

The first time stamp data is loaded for.

time_end

The last time stamp data is loaded for.

top_records

Number of records to return.

key_unit_name

The unit in which to retrieve the key values.

columns

List of strings defining the columns and units to be retrieved. E.g. list("column name 1 unit", "column name 2 unit"). When specified_columns_only = TRUE, only columns given in this argument will be returned. Otherwise, this argument will be used to define the units in which the column data will be returned.

specified_columns_only

Whether to return the columns specified in columns only. Defaults to FALSE.

where

WHERE-like clause to filter the reference table data.


Method load_pivot_table()

Load pivot table data from PetroVisor.

Usage

DataServices$load_pivot_table(table, top_records = NULL)

Arguments

table

The name of the pivot table to load from.

top_records

Number of records to return.


Method save()

Save data to PetroVisor. This function is deprecated. Use save_signals() or save_reference_table() instead.

Usage

DataServices$save(
  data_type = c("StaticNumeric", "StaticString", "TimeNumeric", "TimeString",
    "DepthNumeric", "DepthString", "PVTNumeric"),
  data,
  signals,
  generate_logs = TRUE,
  no_range_delete = TRUE,
  values_time_increment = NULL,
  values_depth_increment = NULL,
  pressure_unit = NULL,
  temperature_unit = NULL
)

Arguments

data_type

The type of the data. One of: StaticNumeric, StaticString, TimeNumeric, TimeString, DepthNumeric, DepthString, PVTNumeric.

data

The data as data frame.

signals

List of parsed signals to save data for.

generate_logs

Whether to generate log entries. Defaults to TRUE.

no_range_delete

Whether to skip deleting all data in the saving scope before storing the new values. Defaults to TRUE.

values_time_increment

The time increment of the time-dependent values.

values_depth_increment

The depth increment of the depth-dependent values.

pressure_unit

The pressure unit of the PVT values.

temperature_unit

The temperature unit of the PVT values.


Method save_signals()

Save signal data to PetroVisor.

Usage

DataServices$save_signals(
  data_type = c("StaticNumeric", "StaticString", "TimeNumeric", "TimeString",
    "DepthNumeric", "DepthString", "PVTNumeric"),
  data,
  signals,
  generate_logs = TRUE,
  no_range_delete = TRUE,
  values_time_increment = NULL,
  values_depth_increment = NULL,
  pressure_unit = NULL,
  temperature_unit = NULL
)

Arguments

data_type

The type of the data. One of: StaticNumeric, StaticString, TimeNumeric, TimeString, DepthNumeric, DepthString, PVTNumeric.

data

The data as data frame.

signals

List of parsed signals to save data for.

generate_logs

Whether to generate log entries. Defaults to TRUE.

no_range_delete

Whether to skip deleting all data in the saving scope before storing the new values. Defaults to TRUE.

values_time_increment

The time increment of the time-dependent values.

values_depth_increment

The depth increment of the depth-dependent values.

pressure_unit

The pressure unit of the PVT values.

temperature_unit

The temperature unit of the PVT values.


Method save_reference_table()

Save reference table data to PetroVisor.

Usage

DataServices$save_reference_table(table, data, skip_existing = FALSE)

Arguments

table

The name of the reference table to save to.

data

The data to save as data frame.

skip_existing

Whether to skip existing rows (defined by key!) or update all rows. Defaults to FALSE, which means all rows will be updated.


Method save_pivot_table()

Generate and save the data of the specified pivot table.

Usage

DataServices$save_pivot_table(table)

Arguments

table

The name of the pivot table to generate and save.


Method delete()

Remove data from PetroVisor. This function is deprecated. Use delete_signals() or delete_reference_table() instead.

Usage

DataServices$delete(
  entities,
  signal_names,
  scenario_names = NULL,
  include_workspace_data = TRUE,
  time_start = NULL,
  time_end = NULL,
  depth_start = NULL,
  depth_end = NULL
)

Arguments

entities

List of entities to delete data for. Either a list of strings or a list of items of type Entity.

signal_names

List of signal names to delete data for.

scenario_names

List of scenario names to delete data from.

include_workspace_data

Whether workspace data shall be deleted as well (only applies if scenarios are used). Defaults to TRUE.

time_start

The first time stamp data is deleted for.

time_end

The last time stamp data is deleted for.

depth_start

The first depth data is deleted for.

depth_end

The last depth data is deleted for.


Method delete_signals()

Remove signal data from PetroVisor.

Usage

DataServices$delete_signals(
  entities,
  signal_names,
  scenario_names = NULL,
  include_workspace_data = TRUE,
  time_start = NULL,
  time_end = NULL,
  depth_start = NULL,
  depth_end = NULL
)

Arguments

entities

List of entities to delete data for. Either a list of strings or a list of items of type Entity.

signal_names

List of signal names to delete data for.

scenario_names

List of scenario names to delete data from.

include_workspace_data

Whether workspace data shall be deleted as well (only applies if scenarios are used). Defaults to TRUE.

time_start

The first time stamp data is deleted for.

time_end

The last time stamp data is deleted for.

depth_start

The first depth data is deleted for.

depth_end

The last depth data is deleted for.


Method delete_reference_table()

Remove reference table data from PetroVisor.

Usage

DataServices$delete_reference_table(table, where = NULL)

Arguments

table

The name of the reference table to delete from.

where

WHERE-like clause to filter the reference table data to delete. If NULL (default), all data will be deleted.


Method delete_pivot_table()

Remove pivot table data from PetroVisor.

Usage

DataServices$delete_pivot_table(table)

Arguments

table

The name of the pivot table to delete the data for.


Method clone()

The objects of this class are cloneable with this method.

Usage

DataServices$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # \dontrun{
# create a new instance of the service provider
sp <- ServiceProvider$new(
  url = discovery_url,
  workspace = workspace,
  user = user,
  password = password
)

# load data
data <- sp$data$load(
  c("entity_one", "entity_two"),
  lapply(
    c("test time string signal one [ ]",
      "test time string signal two [ ]"),
    function(x) {
      sp$parse_signal(x)
    }
  ),
  time_increment = "Daily",
  time_start = "2025-01-01T00:00:00",
  time_end = "2025-01-02T00:00:00",
  reshape = TRUE
)

# save data
time_numeric_data <- data.frame(
  c("", ""),
  c("2025-01-01T00:00:00", "2025-01-02T00:00:00"),
  c("entity_one", "entity_two"),
  c(23.45, 45.56),
  c(78.89, NaN)
)

colnames(time_numeric_data) <- c("scenario",
                                 "date",
                                 "entity",
                                 time_numeric_signal_1_name,
                                 time_numeric_signal_2_name)

result <- sp$data$save(
  "TimeNumeric",
  time_numeric_data,
  signals = lapply(
    c("test time numeric signal one [m3]",
      "test time numeric signal two [m3]"),
    function(x) {
      sp$parse_signal(x)
    }
  )
)
} # }