Skip to content

Commit

Permalink
update wrapping function for snapshots, uncomment pressure division
Browse files Browse the repository at this point in the history
  • Loading branch information
MBueschelberger committed Sep 26, 2023
1 parent 0e31a9f commit 5a562ae
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions osp/tools/mapping_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,17 @@ def map_model_type(root_cuds_object: Cuds) -> str:
return ""


def _get_real_or_array(oclass: OntologyClass):
real = oclass.get(oclass=emmo.Real, rel=emmo.hasSpatialPart)
array = oclass.get(oclass=emmo.Array, rel=emmo.hasSpatialPart)
if real:
return [real[0].hasNumericalData]
else:
reals = array[0].get(oclass=emmo.Real, rel=emmo.hasSpatialPart)
if reals:
reals = [float(real.hasNumericalData) for real in reals]
return [min(reals), max(reals)]

def map_generic_setting(emmo_class: OntologyClass, root_cuds_object: Cuds, ) -> str:
"""Generic function to search for a parameter inside CUDS object.
Expand Down Expand Up @@ -842,7 +853,7 @@ def map_generic_setting(emmo_class: OntologyClass, root_cuds_object: Cuds, ) ->

pressure = float(search_emmo_class[0].get(oclass=emmo.Real,
rel=emmo.hasPart)[0].hasNumericalData)
pressure = pressure/100000
#pressure = pressure/100000

return pressure

Expand All @@ -859,16 +870,13 @@ def map_generic_setting(emmo_class: OntologyClass, root_cuds_object: Cuds, ) ->
rel=emmo.hasPart))[0].hasNumericalData

elif search_emmo_class[0].is_a(emmo.Snapshots):
return (search_emmo_class[0].get(oclass=emmo.Real,
rel=emmo.hasSpatialPart))[0].hasNumericalData
return _get_real_or_array(search_emmo_class[0])

elif search_emmo_class[0].is_a(emmo.ProcessStatistics):
return (search_emmo_class[0].get(oclass=emmo.Real,
rel=emmo.hasSpatialPart))[0].hasNumericalData
return _get_real_or_array(search_emmo_class[0])

elif search_emmo_class[0].is_a(emmo.SpeciesNumbers):
return (search_emmo_class[0].get(oclass=emmo.Real,
rel=emmo.hasSpatialPart))[0].hasNumericalData
return _get_real_or_array(search_emmo_class[0])

else:
raise_error(file=os.path.basename(__file__),
Expand Down Expand Up @@ -1100,7 +1108,7 @@ def map_PyZacrosSettings(root_cuds_object: Cuds) -> pz.Settings:
snapshots = float(map_generic_setting(emmo.Snapshots, root_cuds_object))
search_snapshots[0].hasSymbolData.replace("on ", "")
syntactic_settings.snapshots = (search_snapshots[0].hasSymbolData.replace("on ", ""),
snapshots)
*snapshots)

# Search process_statistics:
search_process_statistics = \
Expand Down

0 comments on commit 5a562ae

Please sign in to comment.