{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "00e8db9e-dbd4-4906-9194-7bfdf5158cac", "metadata": {}, "outputs": [], "source": [ "# Beispiel für die Anwendung des Python-Pakets MetroloPy:\n", "# Berechnung des Luftdrucks in der Höhe h aus dem Luftdruck p0 auf Meereshöhe und der Skalenhöhe H\n", "# unter Einbeziehung der Unsicherheiten nach der Formel\n", "# p(h) = p0 * exp(-(h-h0)/H)\n", "# Weiterhin wird ein Beispiel für die Durchführung einer Monte-Carlo-Simulation gezeigt." ] }, { "cell_type": "code", "execution_count": 2, "id": "7714ac60-8233-4c8a-ad7e-1fb09ea7ef07", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "'de_DE'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np # importiere diverse mathematische Funktionen, \n", " # z. B. die in Python nicht von vornherein enthaltene Exponentialfunktion np.exp()\n", " # Diese spezielle Funktion ist zwar auch als uc.exp() verfügbar, aber im Paket numpy ist noch viel mehr enthalten, es lohnt sich also ggf., dieses zu importieren.\n", "import metrolopy as uc # importiere das Packet MetroloPy zum Arbeiten mit Messunsicherheiten\n", "import locale # importiere landesspezifische Einstellungen\n", "locale.setlocale(locale.LC_ALL, 'de_DE')" ] }, { "cell_type": "code", "execution_count": 3, "id": "0e02ecb0-90ca-4366-96ca-910bbc831498", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "Normluftdruck p0 = 101 325 Pa" ], "text/plain": [ "Normluftdruck p0 = 101 325 Pa" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Definiere den Normluftdruck auf Meereshöhe als Konstante ohne Unsicherheit. \n", "# Der Name der Größe wird auf \"Normaldruck\" gesetzt.\n", "p0 = uc.gummy(101325, 0, unit='Pa', name = 'Normluftdruck p0')\n", "p0" ] }, { "cell_type": "code", "execution_count": 4, "id": "8a5427ca-84b7-4cb5-9f7c-6f619e9f53dd", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "Meereshöhe h0 = 0 m" ], "text/plain": [ "Meereshöhe h0 = 0 m" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Definiere die Meereshöhe h0=0 als Konstante ohne Unsicherheit\n", "h0 = uc.gummy(0, 0, unit = 'm', name = 'Meereshöhe h0')\n", "h0" ] }, { "cell_type": "code", "execution_count": 5, "id": "ba75f8fe-c455-4a82-acb3-ba1b33c68bf4", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "Skalenhöhe H = 8000(58) m" ], "text/plain": [ "Skalenhöhe H = 8000(58) m" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Definiere die Skalenhöhe H der Atmosphäre als Messergebnis des Typs B mit Rechteckverteilung, \n", "# Wert 8000 m und Halbbreite 100 m. \n", "# Der Name der Größe wird auf \"Skalenhöhe\" gesetzt.\n", "H = uc.gummy(uc.UniformDist(center=8000,half_width=100), unit='m', utype='B', name = 'Skalenhöhe H')\n", "H" ] }, { "cell_type": "code", "execution_count": 6, "id": "b6784f68-f586-45fa-b55d-a528f2674283", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "Höhe h = 450.0(10) m" ], "text/plain": [ "Höhe h = 450.0(10) m" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Definiere die Höhe h als Messergebnis des Typs B mit Normalverteilung,\n", "# Wert 450 m und Standardunsicherheit 1 m. \n", "# Der Erweiterungsfaktor k wird auf 1 gesetzt (das ist auch der Standardwert). \n", "# Der Name der Größe wird auf \"Höhe\" gesetzt.\n", "h = uc.gummy(uc.NormalDist(450, 1), unit = 'm', k = 1, utype='B', name = 'Höhe h')\n", "h" ] }, { "cell_type": "code", "execution_count": 7, "id": "51f5e76a-27db-4ca7-ac42-9b002beee9a2", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "Druck p = 95783(41) Pa" ], "text/plain": [ "Druck p = 95783(41) Pa" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Definiere neue Größe Druck p in Abhängigkeit von p0, h, h0 und H.\n", "p = p0*uc.exp(-(h-h0)/H)\n", "p.name = 'Druck p'\n", "p" ] }, { "cell_type": "code", "execution_count": 8, "id": "9a23141f-78b5-4bb8-80f1-51fbc98ca0c2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "