Ogs6py doesn't replace text when Medium ID defined

Problem Definition

I am extensively using the feature replaceTxt of ogs6py in order to adapt existing .prj files.
Usually, the command replaceMediumProperty is sufficient to replace constant medium parameters.
Well, for changing a linear dependent parameter definition one needs the command replaceText. Unfortunately, replaceTxt does not work for me being assigned to a certain medium with a specific medium id. At least I couldn’t make it until now…


model_example=OGS(INPUT_FILE="example.prj", PROJECT_FILE="example.prj")
slope = 6.0463e-10

I want to change the value of slope in example.prj

        <medium id="0">

by using:


Python executes but doesn’t change the Parameter in .prj file.
At the same time, the following command works but can not be assigned to a certain medium id:


@joergbuchwald , you might have any idea what I might have done wrong?

Thank you very for your help in advance and thanks for this all in all really great tool ogs6py. :rocket: :slightly_smiling_face:

Best regards

Hi @Linusvagabund
as id is an attribute it needs to be addressed differently:


alternatively, you can also use the occurrence keyword to denote that you want to change only the zeroth occurrence:

model_example.replaceTxt(slope,xpath="./media/medium/phases/phase[type='Gas']/properties/property[name='viscosity']/independent_variable/slope", occurrence=0)
1 Like