from modFuncs import xldate_to_datetime as conv_date from modFuncs import now gap = win.Dispatch("PX32.Openserver.1") print ("New GAP connection initialised: " + now()) # Intialise GAP Run, Set start/end date, time step interval start_date = datetime.date(2016,1,1) end_date = datetime.date(2017,1,1) prev_date = start_date step_size = 3 # (Months) gap.SetValue("GAP.MOD[{PROD}].PREDINFO.START", start_date.strftime('%d/%m/%Y')) gap.SetValue("GAP.MOD[{PROD}].PREDINFO.END", end_date.strftime('%d/%m/%Y')) gap.SetValue("GAP.MOD[{PROD}].PREDINFO.STEP", step_size) gap.DoCommand('GAP.PREDINIT()') while (prev_date < end_date): gap.DoCommand("GAP.PREDDOSTEP()") prev_date = conv_date(float(gap.GetValue("GAP.PREDCURSTEPDATE"))) current_step = gap.GetValue("GAP.PREDCURSTEPNO") print(gap.GetValue("GAP.MOD[{PROD}].PredResSystemTotal[{" + prev_date.strftime('%d/%m/%Y') + "}].CUMGAS")) del gap print ("GAP connection destroyed : " + now())
# Build Pipe data frame dfPipe = pd.DataFrame({'Label': GAP.GetValue("GAP.MOD[{PROD}].PIPE[$].label").split("|"), 'UniqueID': GAP.GetValue("GAP.MOD[{PROD}].PIPE[$].UniqueID").split("|")}).sort_values(['Label']) dfPipe['Label'].replace('', np.nan, inplace=True) dfPipe = dfPipe[(dfPipe.Label.notnull())] # Build Tank data frame Size = 'Size_(BCF)' CumProd = 'Cum_Production(BCF)' RF = 'Recovery_Factor (%)' dtLastDate = conv_date(max(GAP.GetValue("GAP.MOD[{PROD}].WELL[$].PREDRES.DATES[$]").split("|"))) strTankID = GAP.GetValue("GAP.MOD[{PROD}].TANK[$].UniqueID")[:-1] strTankCumProd = GAP.GetValue("GAP.MOD[{PROD}].TANK[" + strTankID.replace('|', ', ') + "].PREDRES[{" + dtLastDate.strftime('%d/%m/%Y') + "}].CUMGAS") dfTank = pd.DataFrame({'Label': GAP.GetValue("GAP.MOD[{PROD}].TANK[$].label").split("|"), 'UniqueID': GAP.GetValue("GAP.MOD[{PROD}].TANK[$].UniqueID").split("|"), Size: GAP.GetValue("GAP.MOD[{PROD}].TANK[$].GasInPlace").split("|"), CumProd: strTankCumProd.split("|")}) dfTank['Label'].replace('', np.nan, inplace=True) dfTank = dfTank[(dfTank.Label.notnull())]