Overview of Develop

The P# Editor allows you to create, modify, run, save and share scripts.

The P# Editor can be found in the Build Section under Develop in PetroVisor.

PetroVisor's P# Editor is made up of the following parts:

New P# Script

Opens a new, blank script.  The dropdown will give the option for a New Cleansing script or a New R Script.  

To view the tags associated with the script, hover over the tag symbol at the right of the script name.



After creating or editing, saves the currently open script.  The carrot will drop down and allow for Save As:  saves the currently open script with a different name.  It also has rename which allows saving the current script with a new Name


Deletes existing scripts.

Private vs Public

Make scripts visible by clicking the person icon.  The icon identifies the script owner.   It will allow all users in that workspace to see the script.


There are three run options in the P# script editor:

  • Run executes the current script, creates columns and tables but does not save anything.
  • Run with saving saves all new and modified signals to the database. Typically, while scripting only Run is used to test the script. Once the script is finished and generates proper results, Run with saving can be used to keep results.
  • Run using scenario run lets the user choose an already saved scenario. The script is then executed using the values stored in that scenario, rather than the normal values, as stored in the database. If not all of the signals used in the current script are part of the selected scenario, PetroVisor will use the normal ones then. Note: If none of the signals is saved as part of the selected scenario, PetroVisor will take all signals from the normal database. The results will then be similar to those gained from using the simple Run option.

Results are displayed at the bottom of the screen after Run

The results are display as

  • Table
  • Stats
  • Charts
  •   allows the user to include or exclude empty rows

Notice for charts, different settings can be selected via the gear icon.  

  • Styles change the line view and will only be applied to the selected graph


  • Library will search all contents.
  • To ease and increase the speed of scripting, the library can be used. They can be accessed via the Library icon on the right side of the P# editor. P# snippets are text modules of the most widely used functionalities, which can be continuously expanded (Extract function in P# snippet window). Keywords like Context, Entity Set, Scope, Table, or Column automatically insert snippets when TAB is pressed after the last character of the keyword.
  • The library is organized into these groups:
    • Entity Sets
    • Scopes
    • Contexts
    • Tables
    • Rules
    • Plots
  • These tasks can be performed in the Snippets panel:
    • drag and drop a snippet into the Code canvas to use it in your code
    • New: creates a new snippet
    • Modify: allows you to edit existing snippets
    • Delete: deletes the currently selected snippet
    • Extract: automatically extracts snippets from the currently open script and saves them

Code canvas

  • This is where the code is written
  • In P# syntax, keywords are highlighted in dark blue, functions in light blue, strings in red, and comments in green.


PetroVisor stores signals in the default unit that was selected at the time the signal was created, but it automatically converts the signal values to the assigned unit when the signal is used in a P# Script.  The alleviates the need to perform manual unit conversions. 

To simplify programming in P#, the consistency between signal units and column units is not checked.  For example, the following would be allowed: 

Column “Daily Oil Production Rate” in “STB/d”

“produced oil per time increment” in “STB” / 31

End Column
 The units "STB" (volume) and "STB/d" (flow rate) are not of the same type, but PetroVisor will still allow the assignment and respect the user assigned unit for the column. 

Note:  This could be a potential pitfall where the units of the column do not actually match the units of the values of the column.  Usually found in error if user's final results are off by a large factor.


Keyboard Shortcuts

CTRL+F:                Find

CTRL+H:               Find and Replace

CTRL+S:                Save

CTLR+SHIFT+S:  Save as

CTLR+SHIFT+Space:  Brings up function description

CTRL+N:                New

CTRL+O / CTRL+L:        Load

CTRL+K:                Comment

CTRL+U:                Uncomment

F5:                        Run

SHIFT+F5:                Run with Saving

CTRL+C:                Copy

CTRL+V:               Paste

CTRL+X:                Cut

CTRL+A:                Select All

CTRL+Z:                Undo

CTRL+Y:                Redo