APSIMInitiative / ApsimX

ApsimX is the next generation of APSIM
http://www.apsim.info
Other
130 stars 160 forks source link

Converter to remove full xml structure from released models #3040

Closed HamishBrownPFR closed 5 years ago

HamishBrownPFR commented 5 years ago

I have come across a few cases recently where simulations have the crops have full model configuration below them instead of using the released configuration. There was a bug at one stage that caused this. Should we write something into the converter so it strips out full configurations for released models and replaces them with the pointer to the released model

hol430 commented 5 years ago

How would the converter know which resource file to use for a given model?

HamishBrownPFR commented 5 years ago

Anything that is not under a replacements node?

HamishBrownPFR commented 5 years ago

I should say any plant model that is not under a replacement node. Not sure if this should extent to other types of models also.

hol430 commented 5 years ago

I mean, the converter will need to replace the full XML structure of the released model with something like this:

<Plant>
        <Name>Maize</Name>
        <IncludeInDocumentation>true</IncludeInDocumentation>
        <ResourceName>Maize</ResourceName>
        <CropType>Maize</CropType>
</Plant>

Apsim uses the ResourceName property to choose the xml file. In this case, it will look for a file at .../ApsimX/Models/Resources/Maize.xml.

However, the converter will need to figure out which model it is looking at in order to choose the correct ResourceName for the file. We can't just use the name of the model, as the user can change this by renaming the model in the UI (or a text editor).

hol353 commented 5 years ago

Use the Maize element and look for a resource of that name. The user doesn't really change this name in reality.

hol430 commented 5 years ago

There is no Maize element - do you mean the CropType element?

hol353 commented 5 years ago

Ahh. GitHub removed my xml tags that I had in the comment. I meant use the Name XML element.

hol430 commented 5 years ago

Will do.