forked from google/globalfoundries-pdk-libs-gf180mcu_fd_pr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request google#54 from mabrains/ngspice_tst_notebooks_plt
add notebooks to plot the measurements against the simulation
- Loading branch information
Showing
7 changed files
with
583 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
models/ngspice/testing/regression/bjt_beta/plotting.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "dc364796", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"measured is blue\n", | ||
"simulated is red\n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"python3: can't open file '/home/mgomaa/klayout/old_versions/globalfoundries-pdk-libs-gf180mcu_fd_pr/models/ngspice/testing/regression/bjt_beta/model_reg.py': [Errno 2] No such file or directory\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"import pandas as pd\n", | ||
"import glob\n", | ||
"from matplotlib import pyplot as plt\n", | ||
"\n", | ||
"%matplotlib notebook\n", | ||
"os.system(f\"python3 models_regression.py \")\n", | ||
"\n", | ||
"\n", | ||
"def draw(measured, simulated):\n", | ||
" \"\"\"draw func draw measured data vs simulated data\n", | ||
"\n", | ||
" Args:\n", | ||
" measured (list[str]): measured files paths\n", | ||
" simulated (list[str]): simulated files paths\n", | ||
" \"\"\" \n", | ||
" print(\"measured is blue\")\n", | ||
" print(\"simulated is red\")\n", | ||
" measured.sort()\n", | ||
" simulated.sort()\n", | ||
" for i in range(len(measured)):\n", | ||
" space = measured[i].rfind(\"/\")\n", | ||
" read_dev_name = measured[i][space + 1:]\n", | ||
" df = pd.read_csv(measured[i])\n", | ||
" ax = df.plot(x=df.columns[0], y=df.columns[1:], color=\"b\")\n", | ||
" df = pd.read_csv(simulated[i])\n", | ||
" df.plot(ax=ax, x=df.columns[0], y=df.columns[1:], color=\"r\")\n", | ||
" plt.title(read_dev_name)\n", | ||
" plt.show()\n", | ||
"\n", | ||
"\n", | ||
"device = [\"npn\",\"pnp\"]\n", | ||
"# 1 for \"pnp\"\n", | ||
"# for \"npn\"\n", | ||
"dev=0\n", | ||
"\n", | ||
"measured_ib = glob.glob(f\"{device[dev]}/measured_Ib/*.csv\")\n", | ||
"simulated_ib = glob.glob(f\"{device[dev]}/simulated_Ib/*.csv\")\n", | ||
"\n", | ||
"measured_ic = glob.glob(f\"{device[dev]}/measured_Ic/*.csv\")\n", | ||
"simulated_ic = glob.glob(f\"{device[dev]}/simulated_Ic/*.csv\")\n", | ||
"\n", | ||
"\n", | ||
"draw(measured_ic, simulated_ic)\n", | ||
"# draw(measured_ib,simulated_ib,device)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "33eb12ca", | ||
"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.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "dc364796", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import pandas as pd\n", | ||
"import glob\n", | ||
"from matplotlib import pyplot as plt\n", | ||
"\n", | ||
"%matplotlib notebook\n", | ||
"os.system(f\"python3 models_regression.py \")\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"def draw(measured, simulated):\n", | ||
" \"\"\"draw func draw measured data vs simulated data\n", | ||
"\n", | ||
" Args:\n", | ||
" measured (list[str]): measured files paths\n", | ||
" simulated (list[str]): simulated files paths\n", | ||
" \"\"\" \n", | ||
" print(\"measured is blue\")\n", | ||
" print(\"simulated is red\")\n", | ||
"\n", | ||
" for i in range(len(measured)):\n", | ||
" space = measured[i].rfind(\"/\")\n", | ||
" read_dev_name = measured[i][space + 1:]\n", | ||
" df = pd.read_csv(measured[i])\n", | ||
" ax = df.plot(x=df.columns[0], y=df.columns[1:], color=\"b\")\n", | ||
" df = pd.read_csv(simulated[i])\n", | ||
" df.plot(ax=ax, x=df.columns[0], y=df.columns[1:], color=\"r\")\n", | ||
" plt.title(read_dev_name)\n", | ||
" plt.show()\n", | ||
"\n", | ||
"\n", | ||
"device = [\"npn\",\"pnp\"]\n", | ||
"# 1 for pnp\n", | ||
"# 0 for npn\n", | ||
"dev=0\n", | ||
"measured = glob.glob(f\"bjt_cj_regr/{device[dev]}/cj_measured/*.csv\")\n", | ||
"simulated = [s.replace(\"measured\", \"simulated\") for s in measured]\n", | ||
"\n", | ||
"draw(measured, simulated)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f75575cf", | ||
"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.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "dc364796", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import pandas as pd\n", | ||
"import glob\n", | ||
"from matplotlib import pyplot as plt\n", | ||
"\n", | ||
"%matplotlib notebook\n", | ||
"os.system(f\"python3 models_regression.py \")\n", | ||
"\n", | ||
"\n", | ||
"def draw(measured, simulated):\n", | ||
" \"\"\"draw func draw measured data vs simulated data\n", | ||
"\n", | ||
" Args:\n", | ||
" measured (list[str]): measured files paths\n", | ||
" simulated (list[str]): simulated files paths\n", | ||
" \"\"\" \n", | ||
" print(\"measured is blue\")\n", | ||
" print(\"simulated is red\")\n", | ||
"\n", | ||
" for i in range(len(measured)):\n", | ||
" space = measured[i].rfind(\"/\")\n", | ||
" read_dev_name = measured[i][space + 1:]\n", | ||
" df = pd.read_csv(measured[i])\n", | ||
" ax = df.plot(x=df.columns[1], y=df.columns[2:], color=\"b\")\n", | ||
" df = pd.read_csv(simulated[i])\n", | ||
" df.plot(ax=ax, x=df.columns[1], y=df.columns[2:], color=\"r\")\n", | ||
" plt.title(read_dev_name)\n", | ||
" plt.show()\n", | ||
"\n", | ||
"\n", | ||
"device = [\"npn\",\"pnp\"]\n", | ||
"# 1 for pnp\n", | ||
"# 0 for npn\n", | ||
"dev=0\n", | ||
"measured = glob.glob(f\"bjt_iv_regr/{device[dev]}/ib_measured/*.csv\")\n", | ||
"simulated = glob.glob(f\"bjt_iv_regr/{device[dev]}/ib_simulated/*.csv\")\n", | ||
"measured.sort()\n", | ||
"simulated.sort()\n", | ||
"\n", | ||
"draw(measured, simulated)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "69f06f65", | ||
"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.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "dc364796", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import pandas as pd\n", | ||
"import glob\n", | ||
"from matplotlib import pyplot as plt\n", | ||
"\n", | ||
"%matplotlib notebook\n", | ||
"os.system(f\"python3 models_regression.py \")\n", | ||
"\n", | ||
"\n", | ||
"def draw(measured: list[str], simulated: list[str]) -> None:\n", | ||
" \"\"\"draw func draw measured data vs simulated data\n", | ||
"\n", | ||
" Args:\n", | ||
" measured (list[str]): measured files paths\n", | ||
" simulated (list[str]): simulated files paths\n", | ||
" \"\"\"\n", | ||
" print(\"measured is blue\")\n", | ||
" print(\"simulated is red\")\n", | ||
" measured.sort()\n", | ||
" simulated.sort()\n", | ||
" for i in range(len(measured)):\n", | ||
" space = measured[i].rfind(\"/\")\n", | ||
" read_dev_name = measured[i][space + 1:]\n", | ||
" df = pd.read_csv(measured[i])\n", | ||
" ax = df.plot(x=df.columns[1], y=df.columns[2:], color=\"b\")\n", | ||
" df = pd.read_csv(simulated[i])\n", | ||
" df.plot(ax=ax, x=df.columns[1], y=df.columns[2:], color=\"r\")\n", | ||
" plt.title(read_dev_name)\n", | ||
" plt.show()\n", | ||
"\n", | ||
"\n", | ||
"device = [\n", | ||
" \"diode_regr/diode_dw2ps\",\n", | ||
" \"diode_regr/diode_nd2ps_03v3\",\n", | ||
" \"diode_regr/diode_nd2ps_06v0\",\n", | ||
" \"diode_regr/diode_nw2ps_03v3\",\n", | ||
" \"diode_regr/diode_nw2ps_06v0\",\n", | ||
" \"diode_regr/diode_pd2nw_03v3\",\n", | ||
" \"diode_regr/diode_pd2nw_06v0\",\n", | ||
" \"diode_regr/diode_pw2dw\",\n", | ||
" \"diode_regr/sc_diode\",\n", | ||
"]\n", | ||
"\n", | ||
"iv_cv_m = [\"measured_iv\", \"measured_cv\"]\n", | ||
"iv_cv_s = [\"simulated_iv\", \"simulated_cv\"]\n", | ||
"# 0 for diode_dw2ps\n", | ||
"# 1 for diode_nd2ps_03v3\n", | ||
"# 2 for diode_nd2ps_06v0\n", | ||
"# 3 for diode_nw2ps_03v3\n", | ||
"# 4 for diode_nw2ps_06v0\n", | ||
"# 5 for diode_pd2nw_03v3\n", | ||
"# 6 for diode_pd2nw_06v0\n", | ||
"# 7 for diode_pw2dw\n", | ||
"dev = 0\n", | ||
"\n", | ||
"# 1 for cv 0 for iv\n", | ||
"iv_cv = 1\n", | ||
"measured = glob.glob(f\"{device[dev]}/{iv_cv_m[iv_cv]}/*.csv\")\n", | ||
"simulated = glob.glob(f\"{device[dev]}/{iv_cv_s[iv_cv]}/*.csv\")\n", | ||
"# caling the draw func\n", | ||
"draw(measured, simulated)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ddeaa9c0", | ||
"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.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.