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.
Develop has the following parts:
Expanded Menu Options
Selecting the ellipse next to a P# script displays the expanded menu.
- Add to Favorites - If this item is selected, it will move the script to the top of the list.
- Edit Description - Description of the item also stored in the Workspace Description.
- Manage Labels - Add labels to be able to filter.
- Delete - Removes the item from the workspace.
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.
Add P# Script
Opens a new, blank script. The dropdown will give the option for a New Cleansing script or a New R Script.
- Add P# Script - Adds a script.
- Add Cleansing Script - Adds a script to be stored in the Cleansing section.
- Add R Script - Adds an R Script to be stored in the R section.
The Preview menu allows users to preview the script, run the script, and run and save the script.
- Preview - Runs the script for the top 500 entities and top 500 scope steps (time or depth).
- Run All - Runs complete data set in the script (entity set and scope).
- Run & Save Data - Runs the scripts and saves the data if there is a saving clause.
- Run with Options... Runs the script with options
Run with Options
There are four run options in the P# script editor:
- Run and Save executes the current script, creates columns and tables but does not save anything.
- Save Saving columns 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, Save Saving columns can be used to keep results.
- Generate tag entries has the same logic as Save Saving columns. If this item is selected, tags will be generated.
- Apply default cleansing scripts applies cleansing rules to the result of the script if the script contains cleansing rules.
- Filter hierarchy by script entity set is an option to exclude entities from the hierarchy that are not part of the context. For example, only use Field A entities, but the hierarchy used in the context also has Field B and C.
- 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, the system will use the normal ones then. Note: If none of the signals is saved as part of the selected scenario, the platform 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
- 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
After creating or editing, saves the currently open script.
- Save As - Saves the currently open script with a different name.
- Rename - Saves the current script with a new name.
- View in Github - To view in Github, Github account needs to be provided.
The Library button will expand the Library. The Library will insert already created items directly into a script.
- Filters will filter the library contents by name, content, or lable,
- 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
- 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
- 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
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.
|CTRL+H:||Find and Replace|
|CTLR+SHIFT+Space:||Brings up function description|
|SHIFT+F5:||Run & Save|