예제 #1
0
def CallUpdateOilNetting():
    """Interface Package Description"""
    interface = {
        "WellName": str,
        "CorpID": str,
        "NettingValue": float,
        "NettingDate": datetime,
        "UpdateUser": str
    }

    pkg, success, msg = InitializePayload(request, interface)

    if success:
        WellName = pkg['WellName']
        CorpID = pkg['CorpID']
        NettingValue = pkg['NettingValue']
        NettingDate = pkg['NettingDate']
        UpdateUser = pkg['UpdateUser']

        #Check CorpID if Wellname is passed and vice versa
        WellName, CorpID = iu.GetWellandCorpID(WellName, CorpID)

        NettingRow = m.GasNettingRow(WellName, CorpID, NettingValue,
                                     NettingDate, '')
        success, msg = NettingRow.Update(UpdateUser, datetime.now())

    output = ConfigureOutput('', success, msg)
    return output
예제 #2
0
def CallUpdateLEHeader():
    """Interface Package Description"""
    interface = {
        "LEName": str,
        "CorpID": str,
        "ForecastGeneratedFrom": str,
        "WellName": str,
        "Wedge": str,
        "LE_Date": datetime,
        "UserName": str
    }

    pkg, success, msg = InitializePayload(request, interface)

    if success:
        LEName = pkg['LEName']
        CorpID = pkg['CorpID']
        ForecastGeneratedFrom = pkg['ForecastGeneratedFrom']
        WellName = pkg['WellName']
        Wedge = pkg['Wedge']
        LE_Date = pkg['LE_Date']
        UserName = pkg['UserName']

        #Check CorpID if Wellname is passed and vice versa
        WellName, CorpID = iu.GetWellandCorpID(WellName, CorpID)

        LEHeaderRowObj = m.LEHeaderRow(LEName, WellName, CorpID,
                                       ForecastGeneratedFrom, Wedge, LE_Date,
                                       '')
        success, msg = LEHeaderRowObj.Update(UserName, datetime.now())

        output = ConfigureOutput('', success, msg)

    return output
예제 #3
0
def CallUpdateProduction():
    """Interface Package Description"""
    interface = {
        "LEName": str,
        "CorpID": str,
        "WellorArea": str,
        "ProductionGas": list,
        "ProductionOil": list,
        "ProductionWater": list,
        "Dates": list,
        "UserName": str
    }

    pkg, success, msg = InitializePayload(request, interface)
    msgs = []
    if success:
        dates = pkg['Dates']
        oil_production = pkg['ProductionOil']
        gas_production = pkg['ProductionGas']
        water_production = pkg['ProductionWater']
        UserName = pkg['UserName']
        WellName = pkg['WellorArea']
        CorpID = pkg['CorpID']
        LEName = pkg['LEName']

        #Check CorpID if Wellname is passed and vice versa
        WellName, CorpID = iu.GetWellandCorpID(WellName, CorpID)

        idx = 0
        for date in dates:
            #Create object and update
            if oil_production:
                oil = oil_production[idx]
            else:
                oil = ''
            if gas_production:
                gas = gas_production[idx]
            else:
                gas = ''
            if water_production:
                water = water_production[idx]
            else:
                water = ''

            row = m.ProductionAdjustmentsRow(LEName, WellName, CorpID, date,
                                             gas, oil, water, '')
            success, msg = row.Update(UserName, datetime.now())
            if not success:
                msgs.append(msg)
            else:
                msgs.append(CorpID + ' : ' + date +
                            ' successfully updated prodcution value.')

            idx = idx + 1

    output = ConfigureOutput('', success, msgs)
    return output
예제 #4
0
def CallUpdateForecastHeader():
    """Interface Package Description"""
    interface = {
        "HeaderName": str,
        "WellName": str,
        "CorpID": str,
        "ForecastName": str,
        "ForecastYear": str,
        "scenarioName": str,
        "GFO": str,
        "UpdateUser": str
    }

    pkg, success, msg = InitializePayload(request, interface)

    if success:
        HeaderName = pkg['HeaderName']
        WellName = pkg['WellName']
        CorpID = pkg['CorpID']
        ForecastName = pkg['ForecastName']
        ForecastYear = pkg['ForecastYear']
        scenarioName = pkg['scenarioName']
        GFO = pkg['GFO']
        UserName = pkg['UpdateUser']

        Arps = {}
        Arps['Di'] = ''
        Arps['qi'] = ''
        Arps['b'] = ''

        #Check CorpID if Wellname is passed and vice versa
        WellName, CorpID = iu.GetWellandCorpID(WellName, CorpID)

        ForecastHeaderRow = m.ForecastHeaderRow(WellName, CorpID, ForecastName,
                                                ForecastYear, scenarioName,
                                                Arps, GFO, '')
        success, msg = ForecastHeaderRow.Update(UserName, datetime.now())

    output = ConfigureOutput('', success, msg)

    return output
예제 #5
0
def CallUpdateFracMultiplier():
    """Interface Package Description"""
    interface = {
        "WellorArea": str,
        "CorpID": str,
        "LEName": str,
        "Multipliers": list,
        "Dates": list,
        "UserName": str
    }

    pkg, success, msg = InitializePayload(request, interface)
    msgs = []
    if success:
        LEName = pkg['LEName']
        WellName = pkg['WellorArea']
        CorpID = pkg['CorpID']
        Dates = pkg['Dates']
        Multipliers = pkg['Multipliers']
        UserName = pkg['UserName']

        #Check CorpID if Wellname is passed and vice versa
        WellName, CorpID = iu.GetWellandCorpID(WellName, CorpID)

        idx = 0
        for date in Dates:
            row = m.FracHitMultipliersRow(LEName, CorpID, date,
                                          Multipliers[idx], '')
            success, msg = row.Update(UserName, datetime.now())
            if not success:
                msgs.append(msg)
            else:
                msgs.append(CorpID + ' : ' + date +
                            ' successfully updated frac hit multiplier.')
            idx = idx + 1

    output = ConfigureOutput('', success, msgs)
    return output
예제 #6
0
def WriteLEFromTemplate(all_data_df,
                        InterpolationMethod,
                        LEName,
                        LE_Date,
                        Update_User,
                        IDCol='WellName'):
    from datetime import datetime, date
    import pandas as pd
    from Model import QueryFile as qf
    from Model import BPXDatabase as bpx
    from Model import ImportUtility as i

    Success = True
    Messages = []
    results = []
    try:
        #Data Frame must be the same structure as the output from the 'Read From Excel Function
        #'CorpID', 'WellName', 'Wedge', 'Date', 'Gas', 'Oil', 'Water', 'OilNF', 'GasNF'

        wellname = ''
        if not Success:
            Messages.append(Message)

        if IDCol == 'CorpID':
            corpid_list = list(all_data_df['CorpID'].unique())
            corpid_query = qf.EDWKeyQueryFromCorpID(corpid_list)
            corpid_results, corpid_df = bpx.GetDBEnvironment(
                'ProdEDW', 'OVERRIDE').Query(corpid_query)
            well_list = list(corpid_df['WellName'].unique())

            well_query = 'CorpID == @corpid'
        else:
            well_list = list(all_data_df['WellName'].unique())
            well_query = 'WellName == @wellname'

        well_list = [i for i in well_list if i]

        for wellname in well_list:

            wellname, corpid = i.GetWellandCorpID(wellname, '')
            if not corpid:
                corpid = wellname

            data_df = all_data_df.query(well_query)

            row_count = 1
            if not data_df.empty:
                df_previous_row = (0, data_df.iloc[1])

                for idx, df_row in data_df.iterrows():
                    if InterpolationMethod == 'MonthlyRates':
                        if row_count == 1:
                            df_next_row = data_df.iloc[row_count]
                            results = InterpolateDailyRatesFromMonthlyRates(
                                CurrentMonthVal=df_row,
                                NextMonthVal=df_next_row,
                                GasProduction='Gas',
                                OilProduction='Oil')

                        elif row_count != data_df.shape[0] and row_count != 1:
                            df_next_row = data_df.iloc[row_count]
                            results = InterpolateDailyRatesFromMonthlyRates(
                                CurrentMonthVal=df_row,
                                NextMonthVal=df_next_row,
                                PreviousMonthVal=df_previous_row,
                                GasProduction='Gas',
                                OilProduction='Oil')

                        elif row_count == data_df.shape[0]:
                            results = InterpolateDailyRatesFromMonthlyRates(
                                CurrentMonthVal=df_row,
                                PreviousMonthVal=df_previous_row,
                                GasProduction='Gas',
                                OilProduction='Oil')

                    elif InterpolationMethod == 'MonthlyVolume':
                        if row_count == 1:
                            df_next_row = data_df.iloc[row_count]
                            results = InterpolateDailyRatesFromMonthlyVolumes(
                                CurrentMonthVal=df_row[1],
                                NextMonthVal=df_next_row)
                        else:
                            results = InterpolateDailyRatesFromMonthlyVolumes(
                                CurrentMonthVal=df_row[1],
                                PreviousMonthVal=df_previous_row[1])

                    elif InterpolationMethod == 'None':
                        results = ConvertNonInterpolatedResults(df_row)

                    Wedge, Message = i.GetWedgeData(corpid, True)
                    Success, Message = WriteInterpolatedLEToDB(
                        LEName, wellname, corpid, '', Wedge, LE_Date,
                        Update_User, results)
                    if not Success:
                        Messages.append(Message)

                    df_previous_row = df_row
                    row_count = row_count + 1

    except Exception as ex:
        Success = False
        Messages.append('Error during the writing of the LE from template. ' +
                        str(ex))

    return Success, Messages