-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:MaMMoS-project/MagneticMaterialsOnt…
…ology
- Loading branch information
Showing
9 changed files
with
1,480 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SCM syntax highlighting | ||
pixi.lock linguist-language=YAML linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
- name: Install pixi | ||
uses: prefix-dev/[email protected] | ||
with: | ||
pixi-version: v0.39.2 | ||
# cache: true | ||
# auth-host: prefix.dev | ||
# auth-token: ${{ secrets.PREFIX_DEV_TOKEN }} | ||
- name: pixi run clean | ||
run: | | ||
pixi run clean | ||
- name: pixi run build | ||
run: | | ||
pixi run build | ||
- name: pixi run check | ||
run: | | ||
pixi run check | ||
- name: pixi run docs | ||
run: | | ||
pixi run docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
# pixi environments | ||
.pixi | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
282 changes: 282 additions & 0 deletions
282
example_use_case/example_on_using_the_ontology_for_checking_units.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Introduction\n", | ||
"\n", | ||
"This Jupyter notebook demonstrates how to use the `emmontopy` Python library to test and validate physical quantities, such as magnetic field strength, against their corresponding SI units.\n", | ||
"\n", | ||
"The ontology used is based on EMMO and was developed for magnetic materials within the EU-funded project MaMMoS (101135546 - HORIZON-CL4-2023-DIGITAL-EMERGING-01)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ontopy import ontology" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"get_ontology(\"http://www.emmc.info/emmc-csa/demo_magnetic_material#\")" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# Load the local stored ontology file\n", | ||
"emmo = ontology.get_ontology('./magnetic_material_mammos_20241211_1131.ttl')\n", | ||
"emmo.load()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{emmo.Coercivity,\n", | ||
" magnetic_material_mammos_20241211_1131.CoercivityBHc,\n", | ||
" magnetic_material_mammos_20241211_1131.CoercivityBHcExternal,\n", | ||
" magnetic_material_mammos_20241211_1131.CoercivityHc,\n", | ||
" magnetic_material_mammos_20241211_1131.CoercivityHcExternal,\n", | ||
" magnetic_material_mammos_20241211_1131.LocalCoercivity,\n", | ||
" magnetic_material_mammos_20241211_1131.SwitchingFieldCoercivity,\n", | ||
" magnetic_material_mammos_20241211_1131.SwitchingFieldCoercivityExternal}" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# Get all classes containing the word 'Coercivity'\n", | ||
"emmo.get_by_label_all('*Coercivity*')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## MagneticFieldStrength" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Get the class in EMMO with the label 'MagneticFieldStrength'\n", | ||
"mfs = emmo.get_by_label('MagneticFieldStrength') # same as emmo.MagneticFieldStrength" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{emmo.iupacReference,\n", | ||
" rdf-schema.comment,\n", | ||
" emmo.hasMeasurementUnit,\n", | ||
" rdf-schema.isDefinedBy,\n", | ||
" emmo.wikidataReference,\n", | ||
" emmo.IEVReference,\n", | ||
" emmo.ISO80000Reference,\n", | ||
" core.altLabel,\n", | ||
" emmo.elucidation,\n", | ||
" emmo.qudtReference,\n", | ||
" core.prefLabel,\n", | ||
" rdf-schema.label}" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# Get all properties of the class 'MagneticFieldStrength'\n", | ||
"mfs.get_class_properties()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"emmo.MagneticFieldStrengthUnit" | ||
] | ||
}, | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# Get the measurement unit of 'MagneticFieldStrength'\n", | ||
"mfs_unit = mfs.hasMeasurementUnit[0]\n", | ||
"mfs_unit" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{emmo.hasDimensionString,\n", | ||
" rdf-schema.label,\n", | ||
" rdf-schema.comment,\n", | ||
" rdf-schema.isDefinedBy,\n", | ||
" emmo.elucidation,\n", | ||
" core.prefLabel}" | ||
] | ||
}, | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"mfs_unit.get_class_properties()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Query the unit of MagneticFieldStrength" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'T0 L-1 M0 I+1 Θ0 N0 J0'" | ||
] | ||
}, | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# Get the unit extressed by the seven SI base units (m, kg, s, A, K, mol, cd); See https://en.wikipedia.org/wiki/International_System_of_Units https://en.wikipedia.org/wiki/SI_base_unit\n", | ||
"# The number next to the quantity is the power of the base unit, e.g. L-1 means 1/L where L is the base unit of length in meters\n", | ||
"mfs_unit.hasDimensionString " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"emmo.AmperePerMetre" | ||
] | ||
}, | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# Get the measurement unit that is SICoherentDerivedUnit\n", | ||
"mfs_SIunit = [unit for unit in list(mfs_unit.subclasses()) if issubclass(unit, emmo.SICoherentDerivedUnit)][0]\n", | ||
"mfs_SIunit" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"['A.m-1', 'A/m']" | ||
] | ||
}, | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"mfs_SIunit.ucumCode" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[1.0]" | ||
] | ||
}, | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"mfs_SIunit.hasSIConversionMultiplier # should be 1 in case of SI units" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "base", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.19" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.