Skip to content

Commit

Permalink
Merge branch 'main' of github.com:MaMMoS-project/MagneticMaterialsOnt…
Browse files Browse the repository at this point in the history
…ology
  • Loading branch information
Thomas Schrefl committed Dec 18, 2024
2 parents cfcf042 + 076a3da commit bff7779
Show file tree
Hide file tree
Showing 9 changed files with 1,480 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
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
33 changes: 33 additions & 0 deletions .github/workflows/build.yaml
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# pixi environments
.pixi
*.egg-info
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ Alternatively you can use [Protégé](https://protege.stanford.edu/)

Building
--------

MagneticMaterialsOntology is built using tools provided by EMMO. For more details see the [src directory](https://github.com/MaMMoS-project/MagneticMaterialsOntology/tree/main/src)

Installation of required software is also explained in [src/README.md](https://github.com/MaMMoS-project/MagneticMaterialsOntology/tree/main/src/README.md)


Attributions and credits
------------------------
Expand All @@ -80,3 +83,9 @@ This project is licensed under the [Creative Commons Attribution 4.0 Internation

[^1]: https://github.com/emmo-repo/EMMO
[^2]: https://mammos-project.github.io/

Status
------

[![build](https://github.com/MaMMoS-project/MagneticMaterialsOntology/actions/workflows/build.yaml/badge.svg)](https://github.com/MaMMoS-project/MagneticMaterialsOntology/actions/workflows/build.yaml)

1 change: 1 addition & 0 deletions example_use_case/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

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
}
Loading

0 comments on commit bff7779

Please sign in to comment.