Lesson 18: Create a P# Script called Value Summary

This script calculates the value of each well based on the production forecast.

Training Guide

Creating a table from a script requires a code to be written.  

  • Navigate to Develop.

  • Add a P# Script.
  • Select the green plus to add a new script.

  • Copy and paste the following code in the script area.

SCRIPT FOR VALUE SUMMARY


/// Value Summary
///
/// Description:
///  Calculate the remaining gas, and value of the remaining gas
///  from forecast signals
///
/// Input:
///  produced gas per time increment forecast [Bscf]
///
/// Output:
///  Rem Gas [BCF]
///  Value of Rem Gas [MMUSD]
///  Percent of Total Value [%]
///
/// Author: Tarek Ghazi, 2022-08-12
 
Context "For Dashboard"
    Entity Set "Entities To Forecast"
    Scope "2018 to 2032"
End Context

Table "Value Summary"

    Column "Rem Gas" in "BSCF"
        Sum("produced gas per time increment forecast" in "BSCF")
    End Column

    Column "Value of Rem Gas" in "MMUSD"
        Column "Rem Gas" in "BSCF" * 6
    End Column

    Column "Percent of Total Value" in "%"
        Column "Value of Rem Gas" in "MMUSD" / 6455.7 * 100
    End Column

End Table

Notes on the Script:

  • // mean those are comments and are not calculated values
  • Errors will appear at the bottom of the script
  • Best practice has a description, input and output for the script
  • Context is the Entity and Scope (all P# scripts need a context)
  • The Table then creates the column definitions
  • Save the script.

  • Name the script "Value Summary." 
  • Click Save.

  • Run the script.

  • Hide the Library by clicking Library.

  • Enlarge the table.

Notice that the table columns align with the columns from the code. 

A

  • At the top of the screen, make the script public by clicking the user icon.

  • Select Save.