Ejemplo n.º 1
0
def GetGFOValues(ForecastName, WellList, StartDate, EndDate):
    from Model import ModelLayer as m
    import pandas as pd
    from datetime import datetime
    from datetime import date

    Success = True
    Messages = []
    GFO_df = []
    try:
        #NEW Column in Header: Netting Factor. Query For this value and append to the returned GFO_df
        ForecastObj = m.ForecastData('', [ForecastName], WellList, [])
        ForecastHdrObj = m.ForecastHeader('', [], WellList, [ForecastName])
        Rows, Success, Message = ForecastObj.ReadTable()
        HdrRows, Success, Message = ForecastHdrObj.ReadTable()
        if not Success:
            Messages.append(Message)
        else:
            GFO_df = pd.DataFrame([vars(s) for s in Rows])
            GFO_hdr_df = pd.DataFrame([vars(s) for s in HdrRows])

            if isinstance(StartDate, date):
                StartDate = datetime.combine(StartDate, datetime.min.time())

            if isinstance(EndDate, date):
                EndDate = datetime.combine(EndDate, datetime.min.time())

            GFO_df = GFO_df.query(
                'Date_Key >= @StartDate and Date_Key <= @EndDate')
            pd.merge(GFO_df, GFO_hdr_df, on='CorpID')

    except Exception as ex:
        Success = False
        Messages.append('Error attempting to obtain Forecast Values. ' +
                        str(ex))

    return GFO_df, Success, Messages
Ejemplo n.º 2
0
def GetForecastProduction(ForecastName, Wedge, WellorArea, Phase = 'Gas'):
    from datetime import datetime
    from Model import ModelLayer as m
    import pandas as pd
    from Model import BPXDatabase as bpx
    from Model import QueryFile as qf
    
    #Get the production values from the LE table by the input criteria
    Success = True
    Messages = []
    ProductionDataObj = []
    try:

        #Get all CorpIDs from Well or Area passed
        well_list = []
        corpid_list = []
        if WellorArea:
            well_list.append(WellorArea)
            EDWobj = bpx.GetDBEnvironment('ProdEDW', 'OVERRIDE')
            corpid_query = qf.EDWKeyQueryFromWellName(well_list)
            corpid_list = EDWobj.Query(corpid_query)
            corpid_list = list(corpid_list[1]['CorpID'])
        if Wedge:
            wedge_list, Success, Message = GetWellorAreaByWedge(Wedge)
            if not Success:
                Messages.append(Message)
            else:
                well_list.extend(wedge_list)

        ForecastDataRowObj = m.ForecastData('', [ForecastName], corpid_list, [])
        ForecastData, Success, Message = ForecastDataRowObj.ReadTable()
        if not Success:
            Messages.append(Message)
        else:
            prod_Forecast_rows = pd.DataFrame([vars(s) for s in ForecastData])

            dates = prod_Forecast_rows['Date_Key'].unique()
            prod_array = []
            date_array = []
            if not prod_Forecast_rows.empty:
                if Phase == 'Gas':
                    for date in dates:
                        results = prod_Forecast_rows.query('Date_Key == @date')
                        prod_array.append(results['Gas_Production'].sum())
                        date_array.append(date)
                    ProductionDataObj = ProductionData(date_array, prod_array, Phase,'scf')
                elif Phase == 'Water':
                    for date in dates:
                        results = prod_Forecast_rows.query('Date_Key == @date')
                        prod_array.append(results['Water_Production'].sum())
                        date_array.append(date)
                    ProductionDataObj = ProductionData(date_array, prod_array, Phase,'bbl')
                elif Phase == 'Oil':
                    for date in dates:
                        results = prod_Forecast_rows.query('Date_Key == @date')
                        prod_array.append(results['Oil_Production'].sum())
                        date_array.append(date)
                    ProductionDataObj = ProductionData(date_array, prod_array, Phase,'bbl')

    except Exception as ex:
        Success = False
        Messages.append('Error during collection of production data. ' + str(ex))

    return ProductionDataObj, Success, Messages