Commit 18f32be6 authored by Carlson Moses Büth's avatar Carlson Moses Büth 🌝

make composer class with basic functions

parent be89192e
import numpy as np #Liefert wichtige Rechenfunktionen und numpy-arrays; vergleichsweise schnelle Befehle
import uncertainties as uc #Rechnen mit Größen, die fehlerbehaftet sind.
from uncertainties import ufloat as uf
from uncertainties.unumpy import uarray as ua
import uncertainties.unumpy as unp
unv=unp.nominal_values
usd=unp.std_devs
def FormUF(u, n = 3, d = 0):
if (d == 0):
prt = str(np.round(unv(u),n)) + "+-" + str(np.round(usd(u),n))
else:
prt = str(np.round(unv(u)*10**(-d),n)) + "+-" + str(np.round(usd(u)*10**(-d),n)) + "d"+ str(d)
return prt
def numFromUF(u, n = 3, d = 0): # uncertainty float, Nachkommastelen, Größenordnung
return "\num{" + FromUF(u, n, d) + "}"
def siFromUF(u, unit, n = 3, d = 0): # uncertainty float, Nachkommastelen, Größenordnung
return "\SI{" + FromUF(u, n, d) + "}{" + unit + "}"
def strFromUF(u, n = 3, d = 0, wLatex = True): # uncertainty float, Nachkommastelen, Größenordnung
if (d == 0):
prt = "(" + str(np.round(unv(u),n)) + "\pm" + str(np.round(usd(u),n)) + ")"
else:
prt = "(" + str(round(unv(u)*10**(-d),n)) + "\pm" + str(round(usd(u)*10**(-d),n)) + ")\cdot 10^{" + str(d) + "}"
if (wLatex == True):
prt = "$" + prt + "$"
return prt
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment