From bed9527882eeb909ca6fb107d5319b7eca8ec590 Mon Sep 17 00:00:00 2001 From: Cagtay Fabry <43667554+CagtayFabry@users.noreply.github.com> Date: Tue, 13 Jul 2021 14:52:38 +0200 Subject: [PATCH] support string units in get_groove (#416) * enable string quantity syntax in get_groove and update tutorial * formatting and wording * update CHANGELOG.md * simplify * formatting --- CHANGELOG.md | 5 ++-- tutorials/groove_types_01.ipynb | 38 ++++++++---------------------- weldx/welding/groove/iso_9692_1.py | 2 +- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43029fead..c09edd09d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### added -- add support for quality standards. Further information can be found in the corresponding new tutorial. +- add support for quality standards. Further information can be found in the corresponding new tutorial. [[#211]](https://github.com/BAMWelDX/weldx/pull/211) - added `asdf.util.get_schema_path` helper function [[#325]](https://github.com/BAMWelDX/weldx/pull/325) - added `util.compare_nested` to check equality of two nested data @@ -41,13 +41,12 @@ - Removed `Data` class - Updated asdf schemas of all modified classes and the ones that contained references to those classes - allow input of string quantities in `MathematicalExpression` parameters and a few other - places [[#402]](https://github.com/BAMWelDX/weldx/pull/402) + places [[#402]](https://github.com/BAMWelDX/weldx/pull/402) [[#416]](https://github.com/BAMWelDX/weldx/pull/416) - `LocalCoordinateSystem.__init__` now accepts a `TimeSeries` as input. All methods of the `CoordinateSystemManager` also support this new behavior [[#366]](https://github.com/BAMWelDX/weldx/pull/366) - During the creation of a `WeldxFile` the path of a passed custom schema is resolved automatically [[#412]](https://github.com/BAMWelDX/weldx/pull/412). - ### documentation - Add new tutorial about the `MeasurementChain` [[#326]](https://github.com/BAMWelDX/weldx/pull/326) diff --git a/tutorials/groove_types_01.ipynb b/tutorials/groove_types_01.ipynb index 2ef7b9b2a..7b0ead801 100644 --- a/tutorials/groove_types_01.ipynb +++ b/tutorials/groove_types_01.ipynb @@ -20,9 +20,9 @@ "* Converting a groove to a profile\n", "* Using `plot` on a profile constructed by a groove\n", "* All possible groove types as plot\n", - "* saving and loading grooves with ASDF\n", + "* Saving and loading grooves to/from weldx files\n", "\n", - "First starting with the imports:" + "First starting with the imports needed for this tutorial:" ] }, { @@ -31,14 +31,7 @@ "metadata": {}, "outputs": [], "source": [ - "# ASDF imports\n", - "import asdf\n", - "\n", - "# Creating grooves\n", - "import weldx\n", - "from weldx import Q_ as Quantity # pint quantity from the weldx package\n", - "from weldx.asdf.extension import WeldxAsdfExtension, WeldxExtension\n", - "from weldx.welding.groove.iso_9692_1 import get_groove" + "from weldx import WeldxFile, get_groove" ] }, { @@ -58,21 +51,12 @@ "metadata": {}, "outputs": [], "source": [ - "# Workpiece thickness (note the use of 'cm')\n", - "t = Quantity(1, \"cm\")\n", - "# groove angle\n", - "alpha = Quantity(55, \"deg\")\n", - "# root gap\n", - "b = Quantity(2, \"mm\")\n", - "# root face\n", - "c = Quantity(1, \"mm\")\n", - "\n", "v_groove = get_groove(\n", " groove_type=\"VGroove\",\n", - " workpiece_thickness=t,\n", - " groove_angle=alpha,\n", - " root_gap=b,\n", - " root_face=c,\n", + " workpiece_thickness=\"1 cm\", # (note the use of 'cm')\n", + " groove_angle=\"55 deg\",\n", + " root_gap=\"2 mm\",\n", + " root_face=\"1 mm\",\n", ")\n", "\n", "display(v_groove)\n", @@ -188,10 +172,8 @@ "metadata": {}, "source": [ "## using ASDF\n", + "All groove types can be saved to *weldx*-files.\n", "\n", - "All groove types can be saved to _ASDF_-files with the included schemas and _ASDF_-extension from the weldx-package.\n", - "Note that these schemas and extensions are being handled automatically and you do not have\n", - "to worry about these.\n", "Here we demonstrate the writing of the groove data into a buffer (in-memory file):" ] }, @@ -202,7 +184,7 @@ "outputs": [], "source": [ "tree = dict(test_v_groove=v_groove)\n", - "file = weldx.WeldxFile(tree=tree)" + "file = WeldxFile(tree=tree)" ] }, { @@ -236,7 +218,7 @@ "outputs": [], "source": [ "file_copy = file.write_to()\n", - "data = weldx.WeldxFile(file_copy)\n", + "data = WeldxFile(file_copy)\n", "data[\"test_v_groove\"]" ] }, diff --git a/weldx/welding/groove/iso_9692_1.py b/weldx/welding/groove/iso_9692_1.py index 21a4bcdf6..bbf0c73bb 100644 --- a/weldx/welding/groove/iso_9692_1.py +++ b/weldx/welding/groove/iso_9692_1.py @@ -1946,7 +1946,7 @@ def get_groove( _mapping = groove_cls._mapping # convert function arguments to groove arguments - args = {k: _loc[v] for k, v in _mapping.items() if _loc[v] is not None} + args = {k: Q_(_loc[v]) for k, v in _mapping.items() if _loc[v] is not None} if _loc["code_number"] is not None: args["code_number"] = _loc["code_number"]