From 00bb4ca36ec20e26be6c36d7387020689c6b5fac Mon Sep 17 00:00:00 2001 From: ddclark Date: Thu, 6 Feb 2025 16:49:41 -0800 Subject: [PATCH] Initial commit --- eseriesnumbers.ipynb | 254 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 eseriesnumbers.ipynb diff --git a/eseriesnumbers.ipynb b/eseriesnumbers.ipynb new file mode 100644 index 0000000..058d5ae --- /dev/null +++ b/eseriesnumbers.ipynb @@ -0,0 +1,254 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "966b3d0d-7931-4334-be34-c4a8527bfdea", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "1a25519c-b66a-4d98-9780-2f698bc60eea", + "metadata": {}, + "outputs": [], + "source": [ + "import ddceetools.resistors as res" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "66fb1b51-80f5-4f9b-9a49-fc997cc8f6d9", + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "%matplotlib widget" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "1f157ff3-2fae-425e-b031-2f2896bfe9e5", + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2" + ] + }, + { + "cell_type": "markdown", + "id": "2c8f6504-5300-426a-b5ad-f2e4e122ea2c", + "metadata": {}, + "source": [ + "Resistor values in a decade, $d$, can be calculated with\n", + "\n", + "$$\n", + "\\label{eq:resistance}\n", + "R_m = d \\cdot 10^{(m/N)} \\quad m=0,\\,1,\\,\\ldots,\\,N-1\n", + "$$\n", + "\n", + "Where $R_m$ is the $m^{th}$ logarithmically evenly spaced resistance, $d$ is the decade multiplier, and $N$ is the number of points for the tolerance. The values of $N$ are shown in the following table." + ] + }, + { + "cell_type": "markdown", + "id": "77ccbf0b-8606-44e8-a94b-3325f7f3c819", + "metadata": {}, + "source": [ + ":::{table} $N$ Values\n", + ":widths: auto\n", + ":align: center\n", + "\n", + "| Tolerance | $N$ |\n", + "| --- | --- |\n", + "| < 1 % | 192 |\n", + "| 1 % | 96 |\n", + "| 2 % | 48 |\n", + "| 5 % | 24 |\n", + "| 10 % | 12 |\n", + ":::" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "5bc45e01-2e06-4ab5-9012-96cb4137b8c9", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Foo!\n" + ] + } + ], + "source": [ + "pcttol = 0.01\n", + "N = 96\n", + "d = 1\n", + "n = np.arange(N)\n", + "rseries = res.rm(n, d = d)\n", + "rthresh = 10 * d * (1 - pcttol)\n", + "#Rseries = pd.DataFrame(res.rm(m, d = d))\n", + "#Rseries" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "c46c8f34-f783-4d7a-b014-3d57b0691967", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "R0 = d\n", + "R0" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "5794275b-4c23-424a-8d7c-be984c8b7d64", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "tolrseries = 0.01 * rseries" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "f684f426-e2f2-43eb-afe3-355674281521", + "metadata": {}, + "outputs": [], + "source": [ + "figno = 0" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "92af23b4-dcbd-4315-93ab-33a629cd1ed7", + "metadata": {}, + "outputs": [], + "source": [ + "figno += 1" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "2cca1fe6-df10-450e-8edd-949ee15f06e9", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "basefig = plt.figure('Decade Resistance')\n", + "#basefig.clf()\n", + "\n", + "baseax = basefig.add_subplot(111)\n", + "\n", + "baseax.set_yscale('log')\n", + "baseax.set_xticks(n)\n", + "\n", + "baseax.errorbar(n, rseries, fmt='o', yerr=tolrseries)\n", + "\n", + "baseax.axhline(R0)\n", + "baseax.axhline(R0 + pcttol)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "5aba64bd-ef40-4d84-a0de-c793d47593eb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(9.76)" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rseries[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f352a13a-bd9e-410c-a07f-c95c8bc03acd", + "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.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}