{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Residue Plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from smpl import plot\n", "from smpl import io\n", "from smpl import functions as f\n", "import numpy as np\n", "import uncertainties.unumpy as unp\n", "import matplotlib.pyplot as plt\n", "import smpl\n", "smpl.__version__" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dat = np.loadtxt(io.find_file(\"dat.dat\",3), skiprows=0, delimiter=\" \")\n", "\n", "\n", "xdata = dat[:,0]\n", "ydata = dat[:,1]\n", "ymodel = dat[:,-2]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.data(xdata,ydata,logy=True,ss=False)\n", "plot.data(xdata,ymodel,fmt=\"-\",logy=True,init=False,label=\"model\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "data = np.loadtxt(io.find_file('test_linear_data.txt',3))\n", "xdata = data[:,0]\n", "xerr = data[:,2]\n", "ydata = data[:,1]\n", "yerr = data[:,3]\n", "x = unp.uarray(xdata,xerr)\n", "y = unp.uarray(ydata,yerr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "plot.fit(x,y,function=f.line,residue=True,xaxis=\"t\",yaxis=\"s\",units=[\"l\",\"b\"],sigmas=1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.fit(x,y,function=f.line,residue=True,xaxis=\"t\",yaxis=\"s\",units=[\"l\",\"b\"],sigmas=1,residue_err=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.15" } }, "nbformat": 4, "nbformat_minor": 4 }