GeoDict Forum

GeoDict Modules and their functionality => Automation => Topic started by: w_creig on May 23, 2024, 12:24:12 PM

Title: Extract saturated structures with Python
Post by: w_creig on May 23, 2024, 12:24:12 PM
Hi,

I am creating a GeoApp, and one of the steps ideally would involve getting saturated structures from the "capillary pressure curve" result file. I know that the .gdt files of the saturated structures are saved in a folder, but those are only labeled as "step_index.gdt" without the specified amount of saturation. Is there a way, for example, to obtain only the structures at 0.1, 0.5, and 0.8 saturation (or as close to those saturations as possible) using Python?
Title: Re: Extract saturated structures with Python
Post by: Janine Hilden on May 23, 2024, 04:03:11 PM
Hi,

yes, there is. The values can be found in the Resultmap. Thus, you can access them from Python via the stringmap package. Find a detailed description for the stringmap options in the GeoPy Scripting User Guide on page 81 (https://www.math2market.com/fileadmin/UserGuide/GeoDict2024/Automation2024.pdf (https://www.math2market.com/fileadmin/UserGuide/GeoDict2024/Automation2024.pdf)). Below find an example how the file with the saturation closest to 0.5 can be found.


import stringmap

gdr = stringmap.parseGDR("CapillaryPressureResult.gdr")
gdr.push("ResultMap")
saturationlist = gdr.getList("SaturationInvading")
print(saturationlist)

def getSaturationIndex(saturationvalue):
  saturationdifference = 1
  for saturation in saturationlist:
    diff = abs(saturationvalue-float(saturation))
    print(diff)
    if diff < saturationdifference:
      saturationdifference=diff
    else:
      saturationindex = saturationlist.index(saturation)
      break
  return saturationindex
 
file = f"CapillaryPressureResult/Step_{getSaturationIndex(0.5):06}.gdt"