This open source python package allows for easy access to the majority of KOC data products for KOC employees. Currently on version 3.4.0
Developed and Maintained by Michael Tanner and Gabe Tatman. Please email development@kingoperating.com with any questions.
Visit KOC Development Site for our ongoing front-end application development
There are four different modules withing kingscripts
- afe
, finance
operations
and analytics
. Each of these packages connect with different data products within the King ecosystem.
To import these modules, you must git clone https://github.com/kingoperating/v2.git
and then connect to our KOC Datawarehouse. See Michael Tanner for access to database
Then, import the packages below:
from kingscripts.operations import greasebook, combocurve, joyn
from kingscripts.analytics import enverus, king, tech
from kingscripts.afe import afe
from kingscripts.finance import wenergy
-
greasebook.getProductionData
- pulls production data from Greasebook, formats and exports CSV into working data folder- Arguments
workingDataDirectory
: Data directory where all exports and imports come fromstr
pullProd
:True
to pull all GB production data,False
to pull limited number and update master filedays
: Number of days to pull - ifpullProd=True
set to 0int
greasebookApi
: Greasebook API keystr
- Arguments
-
greasebook.getComments
- returns a JSON object of all comments within greasebook within 150 days up to 250- Arguments -
workingDataDirectory
: Data directory where all exports and imports come fromstr
greasebookApi
: Greasebook API keystr
- Arguments -
-
greasebook.allocateWells
- returns a dataframe containing allocated well volumes- Arguments
pullProd
:True
to pull all GB production data,False
to pull limited number and update master filedays
: Number of days to pull - ifpullProd=True
set to 0int
workingDataDirectory
: Data directory where all exports and imports come fromstr
greasebookApi
: Greasebook API keystr
edgeCaseRollingAverage
: for all edge case wells, set toint
value to replace oil volume with rolling average
- Arguments
-
greasebook.sendPumperEmail
- sends email to specific users for pumpers who have missed there data- Arugments:
pumperNotReportedList
: list ofstr
that represent pumpers who have failed to submit production dataworkingDataDirectory
: Data directory where all exports and imports come fromstr
- Arugments:
-
greasebook.getTankGauges
- returns a dataframe of tank gauge data for a given well- Arguments
greasebookApi
: Greasebook API keystr
startDate
: Start date of tank gauge datadatetime
endDate
: End date of tank gauge datadatetime
- Arguments
-
combocurve.putJoynWellProductionData
- takes last modifed JOYN data and loads it into ComboCurve- Arguments
currentJoynData
: pandas Dataframe of modifed data in JOYN for last 7 daysdataframe
serviceAccount
: ComboCurve Service Account - see ComboCurve PyPIobject
comboCurveApi
: ComboCurve Api connection - see ComboCurve PyPIjson
- Arguments
-
combocurve.putGreasebookWellProductionData
- requests data from Greasebooks and inserts into ComboCurve- Arguments
workingDataDirectory
: Data directory where all exports and imports come fromstr
pullFromAllocation
:True
to pull all GB production data,False
to pull limited number and update master fileserviceAccount
: ComboCurve Service Account - see ComboCurve PyPIobject
comboCurveApi
: ComboCurve Api connection - see ComboCurve PyPIjson
daysToPull
: Number of days to pull, ifpullFromAllocation=True
set to 0int
- Arguments
-
combocurve.getLatestScenario
- returns pandas dataframe of the latest scenerio given a projectId and scenerioId- Arguments
workingDataDirectory
: Data directory where all exports and imports come fromstr
projectIdKey
: ComboCurve specific project id - get through front-end UIstr
scenarioIdKey
: ComboCurve specific scenerio id - get through front-end UIstr
serviceAccount
: ComboCurve Service Account - see ComboCurve PyPIobject
comboCurveApi
: ComboCurve Api connection - see ComboCurve PyPIjson
- Arguments
-
combocurve.putGreasebookWellComments
- takes Greasebook well comments and load them in ComboCurve under customString2- Arguments
cleanJson
: takes JSON formatted comment datasetjson
serviceAccount
: ComboCurve Service Account - see ComboCurve PyPIobject
comboCurveApi
: ComboCurve Api connection - see ComboCurve PyPIjson
- Arguments
-
combocurve.getDailyForecastVolume
- gets daily forecast volumes for given CC project ID and forecast ID
- Arguments
projectIdKey
: ComboCurve specific project id - get through front-end UIstr
forecastIdKey
: ComboCurve specific scenerio id - get through front-end UIstr
serviceAccount
: ComboCurve Service Account - see ComboCurve PyPIobject
comboCurveApi
: ComboCurve Api connection - see ComboCurve PyPIjson
combocurve.getLatestScenarioMonthly
- gets monthly aggerate cash flow statement for given CC project ID and scenarioI ID
- Arguments
projectIdKey
: ComboCurve specific project id - get through front-end UIstr
forecastIdKey
: ComboCurve specific scenerio id - get through front-end UIstr
serviceAccount
: ComboCurve Service Account - see ComboCurve PyPIobject
comboCurveApi
: ComboCurve Api connection - see ComboCurve PyPIjson
-
combocurve.ccScenarioToCrestFpSingleWell
- injests getLatestScenarioMonthly() pandas dataframe and converts it to crestFp Single Well Forecast- Arguments
comboCurveScenarioData
: pandas dataframe with specific rows and columns that have discounted net present values -dataframe
nglYield
: Natural Gas Liquids yield - 1 represents 100% yieldgasBtuFactor
: gas BTU factor - always 1 unless gas is paid off BTU factordouble
gasShrinkFactor
: gas shrinkage factor (0-1)double
oilPricePercent
: 1 unless oil price differential is not 100%double
gasPricePercent
: 1 unless gas price differential is not 100%double
nglPricePercnet
: 1 unless ngl price differential is not 100%double
oilVariableCost
: $/bbl LOE costdouble
gasVariableCost
: $/MCF LOE costdouble
nglVariableCost
: $/bbl LOE costdouble
waterVariableCost
: water dispoal cost ($/bbl)double
state
: state intials - onlytx
avaiable at the momentstr
- Arguments
-
combocurve.ccScenarioToCrestFpPdp
- injests getLatestScenarioMonthly() pandas dataframe and converts it to crestFp PDP Forecast
- Arguments
-
comboCurveScenarioData
: pandas dataframe with specific rows and columns that have discounted net present values -dataframe
-nglYield
: Natural Gas Liquids yield - 1 represents 100% yield -gasBtuFactor
: gas BTU factor - always 1 unless gas is paid off BTU factordouble
-gasShrinkFactor
: gas shrinkage factor (0-1)double
-oilPricePercent
: 1 unless oil price differential is not 100%double
-gasPricePercent
: 1 unless gas price differential is not 100%double
-nglPricePercnet
: 1 unless ngl price differential is not 100%double
-
joyn.getDailyAllocatedProductionRawWithDeleted
- returns pandas dataframe of modified production data from JOYN during given data length with deleted wells- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
daysToLookBack
- how many days to look back for modified production data?int
- Arguments
-
joyn.getDailyAllocatedProductionRaw
- returns pandas dataframe of modified production data from JOYN during given data length with and without deleted wells- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
daysToLookBack
- how many days to look back for modified production data?int
- Arguments
-
joyn.getJoynUser
- returns specific user XID from JOYN give a name- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
nameToFind
- name of JOYN user to findstr
- Arguments
-
joyn.getWellObjectId
- returns specific well object id from JOYN given a well name- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
nameOfWell
- name of JOYN well to findstr
- Arguments
-
joyn.putJoynData
- loads data from dataframe into JOYN - seeoperations.docs
for sample upload`- Arguments
userId
- JOYN user id which is return ingetJoynUser
-str
data
- pandas dataframe of data to load into JOYNdataframe
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
- Arguments
-
joyn.compareJoynSqlDuplicates
- compares JOYN data to SQL data to find duplicates- Arguments
sqlData
- data fromdaily_production
table in SQLdataframe
joynData
- last XX days of modified JOYN datadataframe
- Arguments
-
joyn.getProductList
- returns product listing for a given well- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
- Arguments
-
joyn.getPicklistOptions
- returns picklist options and returns JSON- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
- Arguments
-
joyn.getEntityIdList
- returns entity id list for a given well- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
- Arguments
-
joyn.getDailyWellReading
- returns a dataframe with the well comments from the Daily Well Reading View- Arguments
joynUsername
- username for login to JOYNstr
joynPassword
- password for JOYNstr
daysToLookBack
- how many days to look back for modified production dataint
- Arguments
enverus.getWellData
- returns pandas dataframe of monthly oil/gas/water production
- Arguments:
apiKey
: Enverus API authenticationobject
wellApi14
: Well API14 of intereststr
-
enverus.checkWellStatus
- chekcs the status a specific operator in a specific basin- Arguments:
apiKey
: Enverus API authenticationobject
operatorName
: Name of operator of intereststr
basin
: Name of basin of interest `str
- Arguments:
-
king.sendEmail
- Arugments:
emailRecipient
- email address of the person to emailstr
emailRecipientName
- name of the person emailing - used for loopingstr
emailSubject
- email subject linestr
emailMessage
- email message bodystr
nameOfFile
(optional) name of the file - user createdattachment
- (optional) attachment to be sent (Excel File only)
- Arugments:
-
king.getAverageDailyVolumes
- Arugments:
masterKingProdData
- master allocated volumes excel sheet in KOC Datawarehousedataframe
startDate
- YYYY-MM-DDdatetime
endDate
- YYYY-MM-DDdatetime
- Arugments:
-
king.getNotReportedPumperList
- refactored pumper naughty list which creates and returns a list of pumpers who have not entered there data- Arugments:
masterKingProdData
- master allocated volumes excel sheet in KOC Datawarehousedataframe
checkDate
- date to checkdatetime
-
king.createPumperMessage
- takes a list of names and orders them by well to create the email message that goes out the operations team about missing pumper data on a given data- Arugments
badPumperData
- dataframe of wells,names and pumper number for naughty listdataframe
badPumperTrimmedList
- list of bad pumpers trimmed to only unquie pumper nameslist
badPumperMessage
- any header information you want to begin the message withstr
- Arugments
-
king.getHCEFProduction
- gets raw HCEF production data from KOC Datawarehouse- Arguments
pathToFolder
- path to Read datastr
- Arguments
-
king.getWorlandUnit108Production
- gets raw HCEF production data from KOC Datawarehouse- Arguments
pathToFolder
- path to Worland datastr
- Arguments
-
king.updateUsageStatsEtl
- returns dataframe of select usage stats for ETL- Arguments
etlStartTime
- start time of ETLdatetime
- Arguments
-
king.updateUsageStatsEtlRuntime
- returns dataframe of select usage stats for ETL runtime and automatically loads into SQL stats- Arguments
etlStartTime
- start time of ETLdatetime
etlEndTime
- end time of ETLdatetime
function
- name of functionstr
runtime
- runtime of functionstr
- Arguments
-
tech.getData
- returns a dataframe given KOC Datawarehouse parameters- Arguments:
serverName
- name of serverstr
databaseName
- name of databasestr
tableName
- specific table to accessstr
- Arguments:
-
tech.putDataReplace
- replaces entire table with dataframne given KOC Datawarehouse parameters- Arguments:
serverName
- name of serverstr
databaseName
- name of databasestr
tableName
- specific table to access - optionalstr
- Arguments:
-
tech.putDataAppend
- appends entire table with dataframne given KOC Datawarehouse parameters- Arguments:
serverName
- name of serverstr
databaseName
- name of databasestr
tableName
- specific table to access - optionalstr
- Arguments:
-
tech.deleteDuplicateRecords
- deletes the duplicateIdList from SQL server- Arguments:
serverName
- name of serverstr
databaseName
- name of databasestr
tableName
- specific table to access - optionalstr
duplicateList
- list of duplicate ids to deletelist
- Arguments:
One (1) package afe.py
and three (3) functions
-
afe.dailyCost
- calculates and outputs two csv files, daysvsdepth.csv and dailyItemCost.csv for givennameOfWell
- Note: see
afe.py
to set correct paths to data folder - Arguments
workingDataDirectory
: Data directory where all exports and imports come fromstr
name
: Name of the well, see masterWellList for detailsstr
- Note: see
-
afe.variance
- Note: see
afe.py
to set correct paths to data folder- Arguments
workingDataDirectory
: Data directory where all exports and imports come fromstr
name
: Name of the well, see masterWellList for details
- Arguments
- Note: see
-
afe.combineAfeFiles
- Note: see
afe.py
to set correct paths to data folder- Arguments
workingDataDirectory
: Data directory where all exports and imports come fromstr
listOfWells
: List of wells in KOC Datawarehouse afe folder and is alist
- Arguments
- Note: see
wenergy
- COMING SOON