diff --git a/Vorversuch/Vorversuch.pdf b/Vorversuch/Vorversuch.pdf deleted file mode 100644 index 95280a8429639231a703f55f351122c313a33556..0000000000000000000000000000000000000000 Binary files a/Vorversuch/Vorversuch.pdf and /dev/null differ diff --git a/Vorversuch/figures/Logo_KIT.svg b/Vorversuch/figures/Logo_KIT.svg deleted file mode 100644 index 33b825ec005d538f7d59b31349ef00b54576acaa..0000000000000000000000000000000000000000 --- a/Vorversuch/figures/Logo_KIT.svg +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="500" width="1000" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> - <metadata> - <rdf:RDF> - <cc:Work rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> - <dc:title/> - </cc:Work> - </rdf:RDF> - </metadata> - <path d="m984.5105,25.415961-230.51422,0,0,78.511439,67.39781,0,0,270.66615,95.71893,0,0-270.66615,67.39748,0,0-78.511439zm-253.45829,348.81894h-95.71919v-348.81894h95.71919v348.81894zm-111.85159,0-106.47385,0-126.54981-135.87062,0-77.79425,122.60625-135.51274,109.70066,0-141.24836,175.66465,141.96511,173.51296z" fill-rule="evenodd" fill="#000"/> - <path d="m363.2329,374.2349,0,0,0,0,0,0z" fill-rule="evenodd" fill="#000"/> - <path d="m363.2329,374.2349,0,0,0,0,0,0z" fill-rule="evenodd" fill="#000"/> - <path d="M90.415838,153.04142c-18.283583,22.22712-34.057265,46.60505-46.246544,72.77533l319.06361,148.41815-272.81706-221.19348z" fill-rule="evenodd" fill="#32a189"/> - <path d="M363.2329,374.2349,214.45625,57.681003c-26.52903,12.188587-50.90675,27.24608-73.13364,45.170947l221.91029,271.38295z" fill-rule="evenodd" fill="#32a189"/> - <path d="m363.2329,374.2349,0.35846-348.81894h-2.86773c-28.32151,0-55.9259,3.585389-82.45464,10.038217l84.96391,338.78072z" fill-rule="evenodd" fill="#000"/> - <path d="m363.2329,374.2349,0,0,0,0,0,0,0,0z" fill-rule="evenodd" fill="#000"/> - <path d="m363.2329,374.2349,0,0,0,0,0,0,0,0z" fill-rule="evenodd" fill="#000"/> - <path d="M21.225547,288.91246c-7.169814,27.24608-10.754847,55.92567-11.113434,85.32244h353.12079l-342.00735-85.32244z" fill-rule="evenodd" fill="#32a189"/> - <path fill-rule="nonzero" fill="#000" d="m989.33109,452.77847c-1.44216,1.19131-5.95591,3.19757-9.84307,3.19757-5.58122,0-10.53349-4.32639-10.53349-10.65844h22.82176c0-10.28324-3.44884-18.05798-14.10697-18.05798-9.02821,0-14.98579,6.70993-14.98579,16.17705,0,10.40815,5.20478,17.31512,16.55317,17.31512,5.26576,0,7.83717-1.26476,10.09439-2.07972v-5.8936zm-20.37656-11.84928c0.43881-4.1385,2.82115-8.90364,8.58997-8.90364,5.07818,0,7.96189,4.0123,7.96189,8.90364h-16.55186zm-19.07245,19.05915,5.89349,0,0-31.97639-5.89349,0,0,31.97639zm6.26966-45.76941-6.646,0,0,6.64602,6.646,0,0-6.64602zm-376.41865,1.38813,6.5511,0,0,6.67707-6.5511,0zm14.01317,0,6.5511,0,0,6.67707-6.5511,0zm18.77129,44.38128,5.89359,0,0-14.54578c0-8.02449,3.44859-13.04061,8.71454-13.04061,1.00367,0,2.19497,0.12495,3.26126,0.5638v-5.26609c-1.25373-0.25119-2.13262-0.44004-3.88735-0.44004-3.38615,0-6.77237,2.38375-8.33984,5.70613h-0.12495v-4.9538h-5.51723v31.97639zm-8.36416-32.73985-5.8936,0,0,14.79694c0,7.7748-3.00852,13.16716-9.71835,13.16716-5.14106-0.31395-6.77084-3.94995-6.77084-11.41085v-16.55325h-5.89359v18.99828c0,8.5894,3.69861,13.74157,11.97578,13.74157,4.45104,0,8.71475-2.20468,10.471-5.84209h0.12494v5.07864h5.70469v-31.9764zm-317.75366,32.73985,5.89359,0,0-14.54578c0-8.02449,3.44859-13.04061,8.71453-13.04061,1.00368,0,2.19498,0.12495,3.26127,0.5638v-5.26609c-1.25373-0.25119-2.13263-0.44004-3.88735-0.44004-3.38616,0-6.77237,2.38375-8.33984,5.70613h-0.12495v-4.9538h-5.51723v31.97639zm654.98132-31.97639-5.45477,0,0,4.76636-0.12495,0c-1.7551-3.44852-4.8898-5.51869-10.53347-5.51869-9.65567,0-14.29554,8.77823-14.29554,16.99202,0,8.27577,4.51485,15.7367,13.66954,15.7367,4.07452,0,8.21335-1.63013,10.72058-4.9522h0.12515v3.13467c0,6.78232-3.6988,10.9833-9.90591,10.9833-4.326,0-7.02239-0.81639-11.537-2.88508l-0.62631,5.45485c5.14092,1.75618,8.08696,2.19507,11.47334,2.19507,11.47447,0,16.48919-5.58123,16.48919-15.30935v-30.59765zm-15.23572,27.21154c-5.51729,0-8.90182-5.26609-8.90182-11.28578,0-5.45477,2.94603-11.91216,8.90182-11.91216,6.2699,0,9.34241,5.70502,9.34241,12.35105,0,5.95722-3.82371,10.84689-9.34241,10.84689zm-53.48143-11.22331c0,9.15472,6.646,16.75161,16.3018,16.75161,9.59354,0,16.23948-7.59689,16.23948-16.75161,0-9.7182-6.52097-16.74056-16.23948-16.74056-9.78072,0-16.3018,7.02236-16.3018,16.74056zm6.27115,0c0-6.08074,3.69845-11.97463,10.03065-11.97463,6.26986,0,9.9699,5.89389,9.9699,11.97463,0,5.70608-3.07253,11.97586-9.9699,11.97586-6.95964,0-10.03065-6.26978-10.03065-11.97586zm-20.81663,15.98816,5.89355,0,0-47.02312-5.89355,0,0,47.02312zm-41.19324-15.98816c0,9.15472,6.64569,16.75161,16.30175,16.75161,9.59324,0,16.23931-7.59689,16.23931-16.75161,0-9.7182-6.5211-16.74056-16.23931-16.74056-9.78094,0-16.30175,7.02236-16.30175,16.74056zm6.27082,0c0-6.08074,3.69849-11.97463,10.03093-11.97463,6.26971,0,9.9696,5.89389,9.9696,11.97463,0,5.70608-3.07239,11.97586-9.9696,11.97586-6.95951,0-10.03093-6.26978-10.03093-11.97586zm-42.44695,15.98816,5.89359,0,0-14.79684c0-7.77343,3.01004-13.16595,9.71821-13.16595,5.1412,0.3127,6.77103,3.95024,6.77103,11.41112v16.55167h5.89359v-18.99667c0-8.58972-3.69852-13.73205-11.97433-13.73205-4.45236,0-8.71621,2.19508-10.47099,5.83106h-0.12494v-5.07873h-5.7062v31.97639zm-38.30816,0,5.89359,0,0-14.79684c0-7.77343,3.00974-13.16595,9.71821-13.16595,5.14096,0.3127,6.77074,3.95024,6.77074,11.41112v16.55167h5.89388v-18.99667c0-8.58972-3.6988-13.73205-11.97463-13.73205-4.45236,0-8.15087,1.94364-10.28319,5.32973h-0.12495v-19.62413h-5.89359v47.02312zm-7.0223-31.47347c-1.69231-0.69-4.76451-1.25525-7.14713-1.25525-9.78083,0-16.30173,7.02236-16.30173,16.74056,0,9.15472,6.64577,16.75161,16.30173,16.75161,2.13122,0,4.9535-0.18885,7.39851-1.32725l-0.43857-5.26584c-1.81876,1.19129-4.32626,1.81734-6.33244,1.81734-7.58718,0-10.65953-6.26978-10.65953-11.97586,0-6.08074,3.69985-11.97463,10.28324-11.97463,1.88001,0,4.13734,0.43884,6.39479,1.37868l0.50113-4.88936zm-31.16138,24.2636c-1.44215,1.19131-5.95589,3.19757-9.84301,3.19757-5.58129,0-10.53352-4.32639-10.53352-10.65844h22.82174c0-10.28324-3.44883-18.05798-14.1069-18.05798-9.02823,0-14.98582,6.70993-14.98582,16.17705,0,10.40815,5.20483,17.31512,16.55311,17.31512,5.26579,0,7.83719-1.26476,10.0944-2.07972v-5.8936zm-20.37653-11.84928c0.43885-4.1385,2.82114-8.90364,8.58996-8.90364,5.07816,0,7.96187,4.0123,7.96187,8.90364h-16.55183zm-25.08009,19.05915,6.26983,0,0-38.24596,13.60555,0,0-5.51725-33.48131,0,0,5.51725,13.60593,0,0,38.24596zm-104.32843,0,5.89368,0,0-27.21003,8.46447,0,0-4.76636-8.46447,0,0-3.44698c0-4.32752,0.62609-7.58744,5.70438-7.58744,1.00403,0,2.13273,0.12495,2.82266,0.37611l0.24973-4.76447c-1.19106-0.18907-2.44466-0.37642-3.9497-0.37642-8.71437,0-10.72075,5.07873-10.72075,12.85321v2.94599h-7.52474v4.76636h7.52474v27.21003zm-27.06455-31.97639-8.46462,0,0-9.27811-5.89359,1.87971,0,7.3984-7.21102,0,0,4.76636,7.21102,0,0,18.68427c0,6.39461,3.76111,9.28921,9.84347,9.28921,1.88106,0,3.69852-0.50095,5.01606-0.88836v-5.01622c-0.87744,0.56495-2.19508,1.12883-4.0139,1.12883-2.6946,0-4.95204-2.00626-4.95204-5.70476v-17.49297h8.46462v-4.76636zm-27.0238,0-5.89359,0,0,14.79693c0,7.77481-3.00853,13.16716-9.71835,13.16716-5.14107-0.31395-6.77085-3.94994-6.77085-11.41085v-16.55324h-5.89359v18.99827c0,8.5894,3.69862,13.74157,11.97578,13.74157,4.45104,0,8.71476-2.20468,10.47101-5.84208h0.12493v5.07863h5.7047v-31.97639zm-35.67485,0-8.46461,0,0-9.27811-5.89342,1.87971,0,7.3984-7.21117,0,0,4.76636,7.21117,0,0,18.68427c0,6.39461,3.76101,9.28921,9.84319,9.28921,1.88124,0,3.69864-0.50095,5.01622-0.88836v-5.01622c-0.87741,0.56495-2.19516,1.12883-4.01388,1.12883-2.69465,0-4.95211-2.00626-4.95211-5.70476v-17.49297h8.46461v-4.76636zm-33.6698,31.97639,5.89349,0,0-31.97639-5.89349,0,0,31.97639zm6.26966-45.76941-6.646,0,0,6.64602,6.646,0,0-6.64602zm-14.42052,13.79302-8.46474,0,0-9.27811-5.89359,1.87971,0,7.3984-7.21101,0,0,4.76636,7.21101,0,0,18.68427c0,6.39461,3.76092,9.28921,9.84329,9.28921,1.88125,0,3.69864-0.50095,5.01618-0.88836v-5.01622c-0.8775,0.56495-2.19492,1.12883-4.0137,1.12883-2.69477,0-4.95218-2.00626-4.95218-5.70476v-17.49297h8.46474v-4.76636zm-44.07831,30.97376c2.69619,1.45224,5.76853,1.76608,8.77692,1.76608,5.70613,0,11.16084-3.14597,11.16084-9.97918,0-10.21978-13.85549-8.33972-13.85549-14.85966,0-2.63369,2.63215-3.8874,5.64214-3.8874,1.38009,0,4.89115,0.8152,6.20723,1.63011l0.50126-5.14079c-2.32007-0.69-4.57599-1.25525-7.33592-1.25525-6.33232,0-11.28586,3.19865-11.28586,9.84463,0,8.96607,13.85699,8.46322,13.85699,14.29434,0,3.44862-3.32221,4.57745-6.01855,4.57745-1.69372,0-5.01586-0.75255-7.33592-2.25763l-0.31364,5.2673zm-35.61229,1.00263,5.89359,0,0-14.79684c0-7.77343,3.00987-13.16595,9.71825-13.16595,5.14097,0.3127,6.77094,3.95024,6.77094,11.41112v16.55167h5.8936v-18.99667c0-8.58972-3.69869-13.73205-11.97444-13.73205-4.45242,0-8.71602,2.19508-10.47082,5.83106h-0.12495v-5.07873h-5.70615v31.97639zm-16.86687,0,6.26977,0,0-43.76321-6.26977,0,0,43.76321zm-51.94799-7.20987c-1.44257,1.19131-5.95598,3.19757-9.84337,3.19757-5.58117,0-10.53342-4.32639-10.53342-10.65844h22.82174c0-10.28324-3.44881-18.05798-14.10704-18.05798-9.02826,0-14.98566,6.70993-14.98566,16.17705,0,10.40815,5.20475,17.31512,16.55311,17.31512,5.26596,0,7.83717-1.26476,10.09464-2.07972v-5.8936zm-20.37679-11.84928c0.43883-4.1385,2.82126-8.90364,8.58971-8.90364,5.07858,0,7.96208,4.0123,7.96208,8.90364h-16.55179zm-42.44682,19.05915,5.89347,0,0-14.79684c0-7.77343,3.00985-13.16595,9.71834-13.16595,5.14103,0.3127,6.77085,3.95024,6.77085,11.41112v16.55167h5.89359v-18.99667c0-8.58972-3.69851-13.73205-11.9745-13.73205-4.45238,0-8.15081,1.94364-10.28338,5.32973h-0.12494v-19.62413h-5.89347v47.02312zm-10.03225-31.97639-5.89338,0,0,14.79693c0,7.77481-3.00857,13.16716-9.71838,13.16716-5.14103-0.31395-6.77097-3.94994-6.77097-11.41085v-16.55324h-5.89348v18.99827c0,8.5894,3.69869,13.74157,11.97585,13.74157,4.45103,0,8.71449-2.20468,10.47082-5.84208h0.12495v5.07863h5.70463v-31.97639zm-52.6665,31.97639,5.89359,0,0-14.54578c0-8.02449,3.44859-13.04061,8.71453-13.04061,1.00368,0,2.19498,0.12495,3.26127,0.5638v-5.26609c-1.25373-0.25119-2.13263-0.44004-3.88735-0.44004-3.38616,0-6.77237,2.38375-8.33985,5.70613h-0.12494v-4.9538h-5.51723v31.97639zm-27.0864-1.00263c2.69628,1.45224,5.76863,1.76608,8.77714,1.76608,5.70602,0,11.16079-3.14597,11.16079-9.97918,0-10.21978-13.85556-8.33972-13.85556-14.85966,0-2.63369,2.6323-3.8874,5.6422-3.8874,1.38004,0,4.89101,0.8152,6.20709,1.63011l0.5014-5.14079c-2.31994-0.69-4.57607-1.25525-7.33606-1.25525-6.33218,0-11.28579,3.19865-11.28579,9.84463,0,8.96607,13.8572,8.46322,13.8572,14.29434,0,3.44862-3.32245,4.57745-6.01869,4.57745-1.69366,0-5.01593-0.75255-7.33598-2.25763l-0.31374,5.2673zm-13.98187,1.00263,5.89348,0,0-47.02312-5.89348,0,0,47.02312zm-25.142816,0,5.893593,0,0-14.54578c0-8.02449,3.448563-13.04061,8.714486-13.04061,1.003861,0,2.194954,0.12495,3.261287,0.5638v-5.26609c-1.253771-0.25119-2.132461-0.44004-3.88745-0.44004-3.386029,0-6.772306,2.38375-8.339593,5.70613h-0.12515v-4.9538h-5.517173v31.97639zm-33.042359-24.70284c2.382393-2.00624,5.956024-3.25995,9.278344-3.25995,5.894747,0,7.900926,2.82143,7.900926,8.33867-2.319941-0.12494-3.9497-0.12494-6.269642-0.12494-6.082329,0-14.860854,2.5069-14.860854,10.53341,0,6.95964,4.82866,9.97919,11.725848,9.97919,5.39095,0,8.525937-2.95708,9.905786-4.90081h0.124944v4.13735h5.517153c-0.124945-0.93985-0.249868-2.63245-0.249868-6.26993v-13.22922c0-8.71474-3.699895-13.22957-12.853212-13.22957-4.076067,0-7.587185,1.25525-10.533291,3.00998l0.313763,5.01591zm17.17927,12.28975c0,4.7647-3.072328,8.40079-8.903449,8.40079-2.696093,0-5.9559-1.81734-5.9559-5.20343,0-5.64368,7.899607-6.14495,11.097024-6.14495,1.253607,0,2.507213,0.12495,3.762325,0.12495v2.82266zm-59.939979,12.41309,6.2698486,0,0-21.44286,19.499026,21.44286,9.154699,0-22.195389-23.07276,20.565444-20.69045-8.339654,0-18.684126,19.24922,0-19.24922-6.2698486,0,0,43.76321z"/> -</svg> diff --git a/Vorversuch/params/parameters_task_3.py b/Vorversuch/params/parameters_task_3.py deleted file mode 100644 index a82315632cf46c0a2ca22da7bb54c56723934827..0000000000000000000000000000000000000000 --- a/Vorversuch/params/parameters_task_3.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -Parameters required for task 3. - -The only parameter required for the model of the mathematical pendulum of task -3 is the distance l of the center of mass of the smartphone from the pivotal -point of the pendulum. It is a derived quantity, since it implies knowledge of -the center of mass of the smartphone, but its derivation is not too evolved. -The value of l is given in SI units -""" - -l = 0.6285 # Distance of the center of mass of the smartphone from the pivotal point of the pendulum (in m) -l_UPPER = 0.6280 # +uncertainty -l_LOWER = 0.6290 # -uncertainty - -__version__ = 1.0 diff --git a/Vorversuch/params/parameters_task_4.py b/Vorversuch/params/parameters_task_4.py deleted file mode 100644 index b1affc21efa655ed775979d2ee5b329929c5d6fe..0000000000000000000000000000000000000000 --- a/Vorversuch/params/parameters_task_4.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Parameters required for task 4. - -The momentum of inertia (I), mass (m), and distance (ell) of the center of mass -to the pivotal point of the physical pendulum. All quantities have been derived -from direct parameter estimates and rounded within their estimated uncertainties. -They have been derived assuming simplified shapes of the corresponding objects, -e.g. the smartphone has been approximated by a homogeneous box. All quantities -are given in SI units. -""" - -I = 0.23523 # Momentum of inertia in kg*m**2 -I_UPPER = 0.2378 # +uncertainty -I_LOWER = 0.2328 # -uncertatiny - -m = 0.789 # Mass of the pendulum in kg -m_UPPER = 0.794 # +uncertainty -m_LOWER = 0.784 # -uncertainty - -ell = 0.473 # Distance of the center of mass from the pivotal point of the pendulum in m 0.473 -ell_UPPER = 0.480 # +uncertainty -ell_LOWER = 0.466 # -uncertainty - -__version__ = 1.0 diff --git a/Vorversuch/tools/csv2yml.py b/Vorversuch/tools/csv2yml.py deleted file mode 100755 index 8beca8301df8f711bbbbde4006aebef2e75efe3b..0000000000000000000000000000000000000000 --- a/Vorversuch/tools/csv2yml.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python3 -"""csv2yml.py - read floating-point column-data in very general .txt formats - and write an output block in yaml format - - keys taken from 1st header line - - Usage: - - ./cvs2yml [options] <input file name> - - Input: - - - file name - - Output: - - - yaml data block - - -.. moduleauthor:: Guenter Quast <g.quast@kit.edu> - -""" - -if __name__ == "__main__": # ------------------------------------------- - - import sys, os, yaml, argparse - from PhyPraKit import csv2yaml - if os.name == 'nt': # interactive mode on windows if error occurs - os.environ['PYTHONINSPECT']='x' - - # - - - Parse command-line arguments - # parser = argparse.ArgumentParser(usage=__doc__) - parser = argparse.ArgumentParser( - description="convert csv to yaml format") - - parser.add_argument('filename', type=str, - help="name of input file in csv format") - parser.add_argument('-s', '--save', - action='store_const', const=True, default=False, - help="save result in file") - parser.add_argument('-H', '--Header', - action='store_const', const=True, default=False, - help="print csv Header lines") - parser.add_argument('-q', '--quiet', - action='store_const', const=True, default=False, - help="quiet - no output to screen") - parser.add_argument('-d','--delimiter', - type=str, default=',', - help="delimiter, default=','") - parser.add_argument('-n','--header_lines', - type=int, default=1, - help="numer of header lines, default=1") - - if len(sys.argv)==1: # print help message if no input given - parser.print_help() - raise ValueError('!!! not input given -exit !') - - # collect input from ArgumentParser - args = parser.parse_args() - fnam = args.filename - - nlhead = args.header_lines - delim = args.delimiter - showHeader = args.Header - sav_flg = args.save - quiet = args.quiet - if quiet: sav_flg = True - - # ---- end argument parsing ------------------- - - f = open(fnam, 'r') - hlines, ylines = csv2yaml(f, nlhead, delim) - - if not quiet: - print('-->', fnam, 'to yaml', end='') - - if showHeader: - print(' csv header:') - for l in hlines: - print(l) - - # print results to screen - if not quiet: - print(' yaml block:') - for l in ylines: - print(l) - - # write to file - if sav_flg: - ymlfn = fnam.split('.')[0] + '.yaml' - with open(ymlfn, 'w') as f: - for l in ylines: - print(l, file=f) - print(' -> yaml saved in file',ymlfn) diff --git a/Vorversuch/tools/plotCSV.py b/Vorversuch/tools/plotCSV.py deleted file mode 100755 index 7739f8212d7bb91d0bd3b296aea0f7b1c99f0c78..0000000000000000000000000000000000000000 --- a/Vorversuch/tools/plotCSV.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/python3 - -"""plotCSV.py - uses PhyPraKkt.readtxt() to read floating-point column-data in csv format - - - usage: - - ./plotCSV.py [options] <input file name> - - Input: - - - input file in csv format - - Options: - - - s : character used as field separator, default ',' - - H : number of header lines, default 1 - - Output: - - - figure - - - -""" - -from PhyPraKit import readtxt - -# --- helper function -def wexit(code): - # keep Python window open on MS Windows - import os, sys - if os.name == 'nt': - _ = input('\n ==> type <ret> to end > ') - sys.exit(code) - -if __name__ == "__main__": - import sys, argparse, numpy as np, matplotlib.pyplot as plt - - # - - - Parse command-line arguments - parser = argparse.ArgumentParser(description = \ - "plot contents of CSV file") - - parser.add_argument('filename', type=str, nargs='+', - help="name of csv file") - parser.add_argument('-v', '--verbose', - action='store_const', const=True, default=False, - help="full printout to screen") - parser.add_argument('-s', '--separator', - type=str, default=',', - help="character used as field separator ") - parser.add_argument('-H', '--Headerlines', - type=int, default = 1, - help="number of header lines") - - if len(sys.argv)==1: # print help message if no input given - parser.print_help() - print(" \n !!! no input file given - exiting \n") - wexit(1) - - # collect input from ArgumentParser - args = parser.parse_args() - fname = args.filename[0] - quiet_flg = not args.verbose - separator = args.separator # field separator: , or \t, or \_ or ; etc. - nHlines = args.Headerlines # number of header lines - # print(args) - - # end parsing input ------------------------------------------ - - # read data from file in .txt format - hlines, data = readtxt(fname, delim=separator, nlhead=nHlines) - nColumns = data.shape[0] - nRows = data.shape[1] - keys = hlines[0].split(separator)[:] - # output to terminal - print(hlines) - print(" --> number of columns", nColumns) - print(" --> number of data points", nRows) - -# make plots - columns 1, 2, 3, ... vs. column 0 - fig=plt.figure(1, figsize=(10, 2.25*nColumns)) - fig.tight_layout() - fig.suptitle('contents of file '+fname, size='x-large', color='b') - fig.subplots_adjust(left=0.14, bottom=0.1, right=0.97, top=0.93, - wspace=None, hspace=.33)# - x = data[0] - axes = [] - ncol = nColumns - 1 - for i in range(1, ncol+1): - axes.append(fig.add_subplot(ncol, 1, i)) - ax = axes[i-1] - ax.plot(x, data[i], alpha=0.3, label='Column' + str(i)) - ax.set_ylabel(keys[i], size='large') - ax.set_xlabel(keys[0], size='large') - ax.legend(loc='best', numpoints=1, prop={'size':10}) - ax.grid() - - plt.show() diff --git a/Vorversuch/tools/plotData.py b/Vorversuch/tools/plotData.py deleted file mode 100755 index 009b9ddf09743389e68b0e77a88460219b02cce4..0000000000000000000000000000000000000000 --- a/Vorversuch/tools/plotData.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python3 -"""**plotData.py** [options] <input file name> - - Plot (several) data set(s) with error bars in x- and y- directions - or histograms from file in yaml format - - usage: - - ./plotData.py [options] <input file name> - - Input: - - - input file in yaml format - - Output: - - - figure - - yaml-format for (x-y) data: - - .. code-block:: yaml - - title: <title of plot> - x_label: <label for x-axis> - y_label: <label for y-axis> - - label: <name of data set> - x_data: [ x values ] - y_data: [ y values ] - x_errors: x-uncertainty or [x-uncertainties] - y_errors: y-uncertainty or [y-uncertainties] - - *Remark*: more than one input data sets are also possible. - Data sets and models can be overlayed in one plot if option - `showplots = False` ist specified. Either provide more than - one input file, or use yaml syntax, as shown here: - - .. code-block:: yaml - - # several input sets to be separated by - ... - --- - - yaml-format for histogram: - - .. code-block:: yaml - - title: <title of plot> - x_label: <label for x-axis> - y_label: <label for y-axis> - - label: <name of data set> - raw_data: [x1, ... , xn] - # define binning - n_bins: n - bin_range: [x_min, x_max] - # alternatively: - # bin edges: [e0, ..., en] - - several input sets to be separated by - ... - --- - - In case a model function is supplied, it is overlayed in the - output graph. The corresponding *yaml* block looks as follows: - - .. code-block:: yaml - - # optional model specification - model_label: <model name> - model_function: | - <Python code of model function> - - If no `y_data` or `raw_data` keys are provided, only the model function - is shown. Note that minimalistic `x_data` and `bin_range` or `bin_edges` - information must be given to define the x-range of the graph. - -""" - -from PhyPraKit import plot_xy_from_yaml,plot_hist_from_yaml - -# --- helper function -def wexit(code): - # keep Python window open on MS Windows - import os, sys - if os.name == 'nt': - _ = input('\n ==> type <ret> to end > ') - sys.exit(code) - -if __name__ == "__main__": # -------------------------------------- - - import os, sys, yaml, argparse, matplotlib.pyplot as plt - if os.name == 'nt': # interactive mode on windows if error occurs - os.environ['PYTHONINSPECT']='x' - - # - - - Parse command-line arguments - parser = argparse.ArgumentParser(description = \ - "Plot data with error bars or a histrogram from file in yaml format") - # parser = argparse.ArgumentParser(usage=__doc__) - - parser.add_argument('filename', type=str, nargs='+', - help="name(s) of input file(s) in yaml format") - parser.add_argument('-s', '--saveplot', - action='store_const', const=True, default=False, - help="save plot(s) in file(s)") - parser.add_argument('-f','--format', - type=str, default='pdf', - help="graphics output format, default=pdf") - parser.add_argument('-n', '--noplot', - action='store_const', const=True, default=False, - help="suppress ouput of plots on screen") - - if len(sys.argv)==1: # print help message if no input given - parser.print_help() - print(" \n !!! no input file given - exiting \n") - wexit(1) - - # collect input from ArgumentParser - args = parser.parse_args() - fnames = args.filename - sav_flg = args.saveplot - pltfmt = args.format - plt_flg = not args.noplot - - ddata = [] - for fnam in fnames: - f = open(fnam,'r') - try: - ymldata = yaml.load_all(f, Loader=yaml.Loader) - except (OSError, yaml.YAMLError) as exception: - print('!!! failed to read configuration file ' + fnam) - print(str(exception)) - wexit(1) - - data_type = 'xy' - for d in ymldata: - if 'type' in d: - data_type = d['type'] - ddata.append(d) - - # create a figure - if data_type == 'xy': - fignam = 'plotxyData' - elif data_type == 'histogram': - fignam = 'plothistData' - else: - print('!!! invalid data type', data_type) - wexit(1) - - # create figure - figsize = (7.5, 6.5) - figure = plt.figure(num=fignam, figsize=figsize) - - # decode yaml input and plot data for each yaml file - for d in ddata: - if data_type == 'xy': - plot_xy_from_yaml(d) - elif data_type == 'histogram': - plot_hist_from_yaml(d) - f.close() - - # output to file or screen - if (sav_flg): - oname = fnames[0].split('.')[0] + '.'+pltfmt - plt.savefig( oname ) - print(' -> graph saved to file ', oname) - # show plot on screen - if plt_flg: - plt.show() - - wexit(0) diff --git a/Vorversuch/tools/run_phyFit.py b/Vorversuch/tools/run_phyFit.py deleted file mode 100755 index b3898cd957743e65b42736985da84e0deb1b68ce..0000000000000000000000000000000000000000 --- a/Vorversuch/tools/run_phyFit.py +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/env python3 -"""**run_phyFit.py** [options] <input file name> - - Perform fit with data and model from yaml file - - Uses functions xyFit and hFit from PhyPraKit.phyFit - - This code performs fits - - - to x-y data with independent and correlated, absolute - and relative uncertainties in the x and y directions - - - and to histogram data with a binned likelihood fit. - - usage: - - ./run_phyFit.py [options] <input file name> - - ./run_phyFit.py --help for help - - - Input: - - - input file in yaml format - - output: - - - text and/or file, graph depending on options - - - **yaml format for x-y fit:** - - .. code-block:: yaml - - label: <str data-set name> - - x_label: <str name x-data> - x_data: [ list of float ] - - y_label: <str name y-data> - y_data: [ list of float ] - - x_errors: <float>, [list of floats], or {dictionary/ies} - y_errors: <float>, [list of floats], or {dictionary/ies} - - # optionally, add Gaussian constraints on parameters - parameter_constraints: - <parameter name>: - value: <value> - uncertaintiy: <value> - - model_label: <str model name> - model_function: | - <Python code> - - format of uncertainty dictionary: - - error_value: <float> or [list of floats] - - correlation_coefficient: 0. or 1. - - relative: true or false - relative errors may be spcified as <float>% - - - Simple example of *yaml* input: - - .. code-block:: yaml - - label: 'Test Data' - - x_data: [.05,0.36,0.68,0.80,1.09,1.46,1.71,1.83,2.44,2.09,3.72,4.36,4.60] - x_errors: 3% - x_label: 'x values' - - y_data: [0.35,0.26,0.52,0.44,0.48,0.55,0.66,0.48,0.75,0.70,0.75,0.80,0.90] - y_errors: [.06,.07,.05,.05,.07,.07,.09,.1,.11,.1,.11,.12,.1] - y_label: 'y values' - - model_label: 'Parabolic Fit' - model_function: | - def quadratic_model(x, a=0., b=1., c=0. ): - return a * x*x + b*x + c - - - **Example of yaml input for histogram fit:** - - .. code-block:: yaml - - # Example of a fit to histogram data - type: histogram - - label: example data - x_label: 'h' - y_label: 'pdf(h)' - - # data: - raw_data: [ 79.83,79.63,79.68,79.82,80.81,79.97,79.68,80.32,79.69,79.18, - 80.04,79.80,79.98,80.15,79.77,80.30,80.18,80.25,79.88,80.02 ] - - n_bins: 15 - bin_range: [79., 81.] - # alternatively an array for the bin edges can be specified - #bin_edges: [79., 79.5, 80, 80.5, 81.] - - model_density_function: | - def normal_distribution(x, mu=80., sigma=1.): - return np.exp(-0.5*((x - mu)/sigma)** 2)/np.sqrt(2.*np.pi*sigma** 2) - - - *Remark*: more than one input data sets are also possible. - Data sets and models can be overlayed in one plot if option - `showplots = False` ist specified. Either provide more than - one input file, or use yaml syntax, as shown here: - - .. code-block:: yaml - - # several input sets to be separated by - ... - --- -""" - -from PhyPraKit.phyFit import xyFit_from_yaml, hFit_from_yaml -from pprint import pprint - -# --- helper function -def wexit(code): - # keep Python window open on MS Windows - import os, sys - if os.name == 'nt': - _ = input('\n ==> type <ret> to end > ') - sys.exit(code) - -if __name__ == "__main__": # -------------------------------------- - # - # xyFit.py: Example of an application of PhyPraKit.phyFit.xyFit_from_yaml() - # - - # package imports - import os, sys, argparse, yaml, numpy as np, matplotlib.pyplot as plt - if os.name == 'nt': # interactive mode on windows if error occurs - os.environ['PYTHONINSPECT']='x' - - # - - - Parse command-line arguments - parser = argparse.ArgumentParser(description = \ - "Perform a fit with PhyPraKit.phyFit package driven by input file") - # parser = argparse.ArgumentParser(usage=__doc__) - - parser.add_argument('filename', type=str, nargs='+', - help="name(s) of fit input file(s) in yaml format") - parser.add_argument('-v', '--verbose', - action='store_const', const=True, default=False, - help="full printout to screen") - parser.add_argument('-r', '--result_to_file', - action='store_const', const=True, default=False, - help="store results to file") - parser.add_argument('-n', '--noplot', - action='store_const', const=True, default=False, - help="suppress ouput of plots on screen") - parser.add_argument('-s', '--saveplot', - action='store_const', const=True, default=False, - help="save plot(s) in file(s)") - parser.add_argument('-c', '--contour', - action='store_const', const=True, default=False, - help="plot contours and profiles") - parser.add_argument('--noband', - action='store_const', const=True, default=False, - help="suppress 1-sigma band around function") - parser.add_argument('-f','--format', - type=str, default='pdf', - help="graphics output format, default=pdf") - - if len(sys.argv)==1: # print help message if no input given - parser.print_help() - print(" \n !!! no input file given - exiting \n") - wexit(1) - - # collect input from ArgumentParser - args = parser.parse_args() - fnames=args.filename - quiet_flg = not args.verbose - store_result = args.result_to_file - plt_flg= not args.noplot - sav_flg=args.saveplot - cont_flg=args.contour - band_flg=not args.noband - pltfmt=args.format - - # - - - End: Parse command-line arguments - - ddata = [] - # open and read input yaml file - for fnam in fnames: - f = open(fnam, 'r') - try: - ymldata = yaml.load_all(f, Loader=yaml.Loader) - except (OSError, yaml.YAMLError) as exception: - print('!!! failed to read configuration file ' + fnam) - print(str(exception)) - wexit(1) - - fitType = 'xy' - for d in ymldata: - if 'type' in d: - fitType = d['type'] - ddata.append(d) - f.close() - - # select appropriate wrapper - if fitType == 'xy': - fit = xyFit_from_yaml - elif fitType == 'histogram': - fit = hFit_from_yaml - else: - print('!!! unsupported type of fit:', fitType) - wexit(1) - - for fd in ddata: - if 'type' in fd.keys(): - fitType = fd['type'] - print("*==*", sys.argv[0], "received valid yaml data for fit:") - if 'parametric_model' in fd: # for complex kafe2go format - pprint(fd, compact=True) - else: # "nice" printout for simple xyFit format - print(' ** Type of Fit:', fitType) - for key in fd: - if type(fd[key]) is not type([]): # got a scalar or string - print(key + ': ', fd[key]) - elif type(fd[key][0]) is not type({}): # got list of scalars - print(key + ': ', fd[key]) - else: # got list of uncertainty dictionaries - print(key+':') - for d in fd[key]: - for k in d: - print(' '+ k +': ', d[k], end=' ') - print() - # run fit - rdict = fit(fd, # the input dictionary defining the fit - plot=plt_flg, # show plot of data and model - plot_band=band_flg, # plot model confidence-band - plot_cor=cont_flg, # plot profiles likelihood and contours - showplots= False, # show plots on screen - quiet=quiet_flg, # suppress informative printout - return_fitObject=False - ) - - # print results to illustrate how to use output - print('\n*==* Fit Result:') - pvals, perrs, cor, chi2, pnams= rdict.values() - print(" chi2: {:.3g}".format(chi2)) - print(" parameter names: ", pnams) - print(" parameter values: ", pvals) - np.set_printoptions(precision=3) - print(" neg. parameter errors: ", perrs[:,0]) - print(" pos. parameter errors: ", perrs[:,1]) - print(" correlation matrix : \n", cor) - - if store_result: - outfile = (fnames[0].split('.')[0]+ '.result') - with open(outfile, 'a') as outf: - for key in rdict: - print("{}\n".format(key), rdict[key], file=outf) - print(' -> result saved to file ', outfile) - - if (sav_flg): - # save all figures to file(s) - n_fig = 0 - tag = '' - for n in plt.get_fignums(): - plt.figure(n) - oname = (fnames[0].split('.')[0] + '%s.' + pltfmt) %(tag) - plt.savefig( oname) - print(' -> figure saved to file ', oname) - n_fig += 1 - tag = '_'+str(n_fig) - else: - # show on screen - plt.show() - - wexit(0)