Compare commits

..

No commits in common. "d6ad53abe2915b5a291b497e9f7fa30a6e121117" and "cf86793e1fc29aaab76004d3870d487c1dde14bd" have entirely different histories.

3 changed files with 180 additions and 131 deletions

View file

@ -2,56 +2,12 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:40: SyntaxWarning: invalid escape sequence '\\w'\n",
" warning_text = '\\warning WARNING'\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:43: SyntaxWarning: invalid escape sequence '\\w'\n",
" warning_text = '\\warning DANGER'\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:51: SyntaxWarning: invalid escape sequence '\\B'\n",
" block_start_string = '\\BLOCK{',\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:53: SyntaxWarning: invalid escape sequence '\\V'\n",
" variable_start_string = '\\VAR((',\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:55: SyntaxWarning: invalid escape sequence '\\#'\n",
" comment_start_string = '\\#{',\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:104: SyntaxWarning: invalid escape sequence '\\w'\n",
" warning_text = '\\warning WARNING'\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:107: SyntaxWarning: invalid escape sequence '\\w'\n",
" warning_text = '\\warning DANGER'\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:137: SyntaxWarning: invalid escape sequence '\\B'\n",
" block_start_string = '\\BLOCK{',\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:139: SyntaxWarning: invalid escape sequence '\\V'\n",
" variable_start_string = '\\VAR((',\n",
"/home/jeff/projects/JEPL/jepl/jepl_templates.py:141: SyntaxWarning: invalid escape sequence '\\#'\n",
" comment_start_string = '\\#{',\n"
]
},
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: 'JEPL/jepl/Tables/CEC-Tables/CEC21-table1.csv'",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mFileNotFoundError\u001b[39m Traceback (most recent call last)",
"\u001b[36mFile \u001b[39m\u001b[32m~/projects/JEPL/jepl/jeplinit.py:60\u001b[39m\n\u001b[32m 47\u001b[39m \u001b[33;03m'''\u001b[39;00m\n\u001b[32m 48\u001b[39m \u001b[33;03m This is all the tables and their sources that will be added to the databases.\u001b[39;00m\n\u001b[32m 49\u001b[39m \u001b[33;03m \u001b[39;00m\n\u001b[32m 50\u001b[39m \u001b[33;03m'''\u001b[39;00m\n\u001b[32m 52\u001b[39m CEC21_database = [\n\u001b[32m 53\u001b[39m [\u001b[33m'\u001b[39m\u001b[33mjepl-cec21.db\u001b[39m\u001b[33m'\u001b[39m,\u001b[33m'\u001b[39m\u001b[33mTable1\u001b[39m\u001b[33m'\u001b[39m,location+\u001b[33m'\u001b[39m\u001b[33mTables/CEC-Tables/CEC21-table1.csv\u001b[39m\u001b[33m'\u001b[39m],\n\u001b[32m 54\u001b[39m [\u001b[33m'\u001b[39m\u001b[33mjepl-cec21.db\u001b[39m\u001b[33m'\u001b[39m,\u001b[33m'\u001b[39m\u001b[33mTable2\u001b[39m\u001b[33m'\u001b[39m,location+\u001b[33m'\u001b[39m\u001b[33mTables/CEC-Tables/CEC21-table2.csv\u001b[39m\u001b[33m'\u001b[39m],\n\u001b[32m (...)\u001b[39m\u001b[32m 58\u001b[39m [\u001b[33m'\u001b[39m\u001b[33mjepl-cec21.db\u001b[39m\u001b[33m'\u001b[39m,\u001b[33m'\u001b[39m\u001b[33mTable16\u001b[39m\u001b[33m'\u001b[39m,location+\u001b[33m'\u001b[39m\u001b[33mTables/CEC-Tables/CEC21-table16.csv\u001b[39m\u001b[33m'\u001b[39m],\n\u001b[32m 59\u001b[39m ]\n\u001b[32m---> \u001b[39m\u001b[32m60\u001b[39m \u001b[43mcreate_database\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mjepl-cec21.db\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43mCEC21_database\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 62\u001b[39m Z46215_database = [\n\u001b[32m 63\u001b[39m [\u001b[33m'\u001b[39m\u001b[33mjepl-z46215.db\u001b[39m\u001b[33m'\u001b[39m,\u001b[33m'\u001b[39m\u001b[33mTable1A\u001b[39m\u001b[33m'\u001b[39m,location+\u001b[33m'\u001b[39m\u001b[33mTables/Z462-Tables/Z46215-table1A.csv\u001b[39m\u001b[33m'\u001b[39m],\n\u001b[32m 64\u001b[39m [\u001b[33m'\u001b[39m\u001b[33mjepl-z46215.db\u001b[39m\u001b[33m'\u001b[39m,\u001b[33m'\u001b[39m\u001b[33mTable1B\u001b[39m\u001b[33m'\u001b[39m,location+\u001b[33m'\u001b[39m\u001b[33mTables/Z462-Tables/Z46215-table1B.csv\u001b[39m\u001b[33m'\u001b[39m],\n\u001b[32m 65\u001b[39m ]\n\u001b[32m 66\u001b[39m create_database(\u001b[33m'\u001b[39m\u001b[33mjepl-z46215.db\u001b[39m\u001b[33m'\u001b[39m,Z46215_database)\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/projects/JEPL/jepl/jeplinit.py:42\u001b[39m, in \u001b[36mcreate_database\u001b[39m\u001b[34m(name, tables)\u001b[39m\n\u001b[32m 40\u001b[39m table = tables[i][\u001b[32m1\u001b[39m]\n\u001b[32m 41\u001b[39m source = tables[i][\u001b[32m2\u001b[39m]\n\u001b[32m---> \u001b[39m\u001b[32m42\u001b[39m data = \u001b[43mpd\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread_csv\u001b[49m\u001b[43m(\u001b[49m\u001b[43msource\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 44\u001b[39m insert(db,table,data)\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/projects/JEPL/.venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1026\u001b[39m, in \u001b[36mread_csv\u001b[39m\u001b[34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[39m\n\u001b[32m 1013\u001b[39m kwds_defaults = _refine_defaults_read(\n\u001b[32m 1014\u001b[39m dialect,\n\u001b[32m 1015\u001b[39m delimiter,\n\u001b[32m (...)\u001b[39m\u001b[32m 1022\u001b[39m dtype_backend=dtype_backend,\n\u001b[32m 1023\u001b[39m )\n\u001b[32m 1024\u001b[39m kwds.update(kwds_defaults)\n\u001b[32m-> \u001b[39m\u001b[32m1026\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/projects/JEPL/.venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:620\u001b[39m, in \u001b[36m_read\u001b[39m\u001b[34m(filepath_or_buffer, kwds)\u001b[39m\n\u001b[32m 617\u001b[39m _validate_names(kwds.get(\u001b[33m\"\u001b[39m\u001b[33mnames\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m))\n\u001b[32m 619\u001b[39m \u001b[38;5;66;03m# Create the parser.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m620\u001b[39m parser = \u001b[43mTextFileReader\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 622\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m chunksize \u001b[38;5;129;01mor\u001b[39;00m iterator:\n\u001b[32m 623\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m parser\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/projects/JEPL/.venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1620\u001b[39m, in \u001b[36mTextFileReader.__init__\u001b[39m\u001b[34m(self, f, engine, **kwds)\u001b[39m\n\u001b[32m 1617\u001b[39m \u001b[38;5;28mself\u001b[39m.options[\u001b[33m\"\u001b[39m\u001b[33mhas_index_names\u001b[39m\u001b[33m\"\u001b[39m] = kwds[\u001b[33m\"\u001b[39m\u001b[33mhas_index_names\u001b[39m\u001b[33m\"\u001b[39m]\n\u001b[32m 1619\u001b[39m \u001b[38;5;28mself\u001b[39m.handles: IOHandles | \u001b[38;5;28;01mNone\u001b[39;00m = \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m1620\u001b[39m \u001b[38;5;28mself\u001b[39m._engine = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_make_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mengine\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/projects/JEPL/.venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1880\u001b[39m, in \u001b[36mTextFileReader._make_engine\u001b[39m\u001b[34m(self, f, engine)\u001b[39m\n\u001b[32m 1878\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[33m\"\u001b[39m\u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m mode:\n\u001b[32m 1879\u001b[39m mode += \u001b[33m\"\u001b[39m\u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m-> \u001b[39m\u001b[32m1880\u001b[39m \u001b[38;5;28mself\u001b[39m.handles = \u001b[43mget_handle\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 1881\u001b[39m \u001b[43m \u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1882\u001b[39m \u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1883\u001b[39m \u001b[43m \u001b[49m\u001b[43mencoding\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mencoding\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1884\u001b[39m \u001b[43m \u001b[49m\u001b[43mcompression\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mcompression\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1885\u001b[39m \u001b[43m \u001b[49m\u001b[43mmemory_map\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmemory_map\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1886\u001b[39m \u001b[43m \u001b[49m\u001b[43mis_text\u001b[49m\u001b[43m=\u001b[49m\u001b[43mis_text\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1887\u001b[39m \u001b[43m \u001b[49m\u001b[43merrors\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mencoding_errors\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstrict\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1888\u001b[39m \u001b[43m \u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43moptions\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstorage_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 1889\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1890\u001b[39m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m.handles \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[32m 1891\u001b[39m f = \u001b[38;5;28mself\u001b[39m.handles.handle\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/projects/JEPL/.venv/lib/python3.12/site-packages/pandas/io/common.py:873\u001b[39m, in \u001b[36mget_handle\u001b[39m\u001b[34m(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)\u001b[39m\n\u001b[32m 868\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(handle, \u001b[38;5;28mstr\u001b[39m):\n\u001b[32m 869\u001b[39m \u001b[38;5;66;03m# Check whether the filename is to be opened in binary mode.\u001b[39;00m\n\u001b[32m 870\u001b[39m \u001b[38;5;66;03m# Binary mode does not support 'encoding' and 'newline'.\u001b[39;00m\n\u001b[32m 871\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m ioargs.encoding \u001b[38;5;129;01mand\u001b[39;00m \u001b[33m\"\u001b[39m\u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m ioargs.mode:\n\u001b[32m 872\u001b[39m \u001b[38;5;66;03m# Encoding\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m873\u001b[39m handle = \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[32m 874\u001b[39m \u001b[43m \u001b[49m\u001b[43mhandle\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 875\u001b[39m \u001b[43m \u001b[49m\u001b[43mioargs\u001b[49m\u001b[43m.\u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 876\u001b[39m \u001b[43m \u001b[49m\u001b[43mencoding\u001b[49m\u001b[43m=\u001b[49m\u001b[43mioargs\u001b[49m\u001b[43m.\u001b[49m\u001b[43mencoding\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 877\u001b[39m \u001b[43m \u001b[49m\u001b[43merrors\u001b[49m\u001b[43m=\u001b[49m\u001b[43merrors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 878\u001b[39m \u001b[43m \u001b[49m\u001b[43mnewline\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 879\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 880\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 881\u001b[39m \u001b[38;5;66;03m# Binary mode\u001b[39;00m\n\u001b[32m 882\u001b[39m handle = \u001b[38;5;28mopen\u001b[39m(handle, ioargs.mode)\n",
"\u001b[31mFileNotFoundError\u001b[39m: [Errno 2] No such file or directory: 'JEPL/jepl/Tables/CEC-Tables/CEC21-table1.csv'"
]
}
],
"outputs": [],
"source": [
"import jepl.jepl as jmk\n",
"%run jepl/jeplinit.py JEPL/jepl/ "
"import JEPL.jepl.jepl as jmk\n",
"%run JEPL/jepl/jeplinit.py JEPL/jepl/ "
]
},
{
@ -959,7 +915,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@ -973,7 +929,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
"version": "3.10.1"
}
},
"nbformat": 4,

View file

@ -1,33 +0,0 @@
# CEC 2021, Table 1
table1 = [
#['size', '60', '75', '90'],
['14', 25, 30, 35],
['12', 30, 35, 40],
['10', 40, 50, 55],
['8', 60, 70,80],
['6', 80, 95, 105],
['4', 105, 125, 140],
['3', 120, 145, 165],
['2', 140, 170, 190],
['1', 165, 195, 220],
['1/0', 195, 230, 260],
['2/0', 220, 265, 300],
['3/0', 260, 310, 350],
['4/0', 300, 360, 405],
['250', 340, 405, 455],
['300', 370, 445, 500],
['350', 425, 505, 570],
['400', 455, 545, 615],
['500', 520, 620, 700],
['600', 580, 690, 780],
['700', 630, 755, 850],
['750', 655, 785, 885],
['800', 680, 815, 920],
['1000', 785, 870, 980],
['1250', 890, 1065, 1200],
['1500', 985, 1175, 1325],
['1750', 1070, 1280, 1445],
['2000', 1160, 1385, 1560]
]

View file

@ -11,7 +11,6 @@ import pandas as pd
import numpy as np
import math
import sqlite3
import bisect
def vd(current,length,resistance,runs=1):
@ -222,11 +221,12 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
return print(load_type + " is not a valid load_type.")
if temp == 90:
column = '90C'
conductor_current_index = 3
elif temp == 75:
column = '75C'
conductor_current_index = 2
else:
column = '60C'
conductor_current_index = 1
'''
Per CEC rules 26-256 and 28-106 Transformer and Motor conductors should be sized 125% of the rated current.
@ -235,18 +235,138 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
if load_type in list_125:
current = 1.25 * current
# select the correct code table
if (code == 'CEC') & (material == 'CU') & (raceway == False): # CEC Table 1
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table1" WHERE "size" = ? ', (max,))
max_conductor_current = cur.fetchone()
max_current = max_conductor_current[conductor_current_index]
# Seclect the proper table
except sqlite3.OperationalError as e:
print(e)
if (code == 'CEC'):
import Tables.CEC21Tables
current_lookup = current_for_lookup(current,max_current)
current = current_lookup[0]
num_parallel = current_lookup[1]
if (material == 'CU') & (raceway == False):
df = pd.DataFrame(cec21tables.table1, columns=['size', '60C', '75C', '90C'])
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
if temp == 90:
cur.execute('SELECT size FROM "Table1" WHERE "90" > ? ', (current,))
elif (material == 'CU') & (raceway == True):
df = pd.DataFrame(cec21tables.table3, columns=['size', '60C', '75C', '90C'])
elif temp ==75:
cur.execute('SELECT size FROM "Table1" WHERE "75" > ? ', (current,))
else:
cur.execute('SELECT size FROM "Table1" WHERE "60" > ? ', (current,))
conductor_size = cur.fetchone()[0]
#print(conductor_size)
except sqlite3.OperationalError as e:
print(e)
elif (code == 'CEC') & (material == 'CU') & (raceway == True): # CEC Table 2
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table2" WHERE "size" = ? ', (max,))
max_conductor_current = cur.fetchone()
max_current = max_conductor_current[conductor_current_index]
except sqlite3.OperationalError as e:
print(e)
current_lookup = current_for_lookup(current,max_current)
current = current_lookup[0]
num_parallel = current_lookup[1]
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
if temp == 90:
cur.execute('SELECT size FROM "Table2" WHERE "90" > ? ', (current,))
elif temp ==75:
cur.execute('SELECT size FROM "Table2" WHERE "75" > ? ', (current,))
else:
cur.execute('SELECT size FROM "Table2" WHERE "60" > ? ', (current,))
conductor_size = cur.fetchone()[0]
#print(conductor_size)
except sqlite3.OperationalError as e:
print(e)
elif (code =='CEC') & (material =='AL') & (raceway == False): # CEC Table 3
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table3" WHERE "size" = ? ', (max,))
max_conductor_current = cur.fetchone()
max_current = max_conductor_current[conductor_current_index]
except sqlite3.OperationalError as e:
print(e)
current_lookup = current_for_lookup(current,max_current)
current = current_lookup[0]
num_parallel = current_lookup[1]
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
if temp == 90:
cur.execute('SELECT size FROM "Table3" WHERE "90" > ? ', (current,))
elif temp ==75:
cur.execute('SELECT size FROM "Table3" WHERE "75" > ? ', (current,))
else:
cur.execute('SELECT size FROM "Table3" WHERE "60" > ? ', (current,))
conductor_size = cur.fetchone()[0]
#print(conductor_size)
except sqlite3.OperationalError as e:
print(e)
elif (code =='CEC') & (material =='AL') & (raceway == True): # CEC Table 4
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table4" WHERE "size" = ? ', (max,))
max_conductor_current = cur.fetchone()
max_current = max_conductor_current[conductor_current_index]
except sqlite3.OperationalError as e:
print(e)
current_lookup = current_for_lookup(current,max_current)
current = current_lookup[0]
num_parallel = current_lookup[1]
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
if temp == 90:
cur.execute('SELECT size FROM "Table4" WHERE "90" > ? ', (current,))
elif temp ==75:
cur.execute('SELECT size FROM "Table4" WHERE "75" > ? ', (current,))
else:
cur.execute('SELECT size FROM "Table4" WHERE "60" > ? ', (current,))
conductor_size = str(cur.fetchone()[0])
#print(conductor_size)
except sqlite3.OperationalError as e:
print(e)
elif (code =='NEC') & (material =='CU'):
return (' I haven\'t created this table yet')
elif (code =='NEC') & (material =='AL'):
@ -254,30 +374,6 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
else:
return ('The variables were\'t right, but I\'m a loss to why.')
'''
Using the correct table, calculate the number of parallel runs needed with the maximum conductor size,
and the resulting wire size.
'''
# Determine the ampacity of the max conductor size
max_df = df.loc[df['size'] == max_wire,column]
max_current = max_df.item()
#print(max_current)
# The current that we will need to
current_lookup = current_for_lookup(current,max_current)
current = current_lookup[0]
num_parallel = current_lookup[1]
# Calculate the absolute difference for all values and find the index of the minimum difference
sectioned_df = df.loc[df[column] >= current,column]
closest_index = sectioned_df.idxmin()
# Retrieve the nearest value using the found index
conductor_size = df['size'].iloc[closest_index]
return [conductor_size,num_parallel]
def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', raceway = True, ambient = 30):
@ -298,20 +394,55 @@ def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', race
]
if temp == 90:
column = '90C'
conductor_current_index = 3
elif temp == 75:
column = '75C'
conductor_current_index = 2
else:
column = '60C'
conductor_current_index = 1
if (code == 'CEC') & (material == 'CU') & (raceway == False): # CEC Table 1
df = pd.DataFrame(cec21tables.table1, columns=['size', '60C', '75C', '90C'])
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table1" WHERE "size" = ? ', (conductor,))
max_conductor_current = cur.fetchone()
conductor_ampacity = max_conductor_current[conductor_current_index]
except sqlite3.OperationalError as e:
print(e)
elif (code == 'CEC') & (material == 'CU') & (raceway == True): # CEC Table 2
df = pd.DataFrame(cec21tables.table2, columns=['size', '60C', '75C', '90C'])
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table2" WHERE "size" = ? ', (conductor,))
max_conductor_current = cur.fetchone()
conductor_ampacity = max_conductor_current[conductor_current_index]
except sqlite3.OperationalError as e:
print(e)
elif (code =='CEC') & (material =='AL') & (raceway == False): # CEC Table 3
df = pd.DataFrame(cec21tables.table3, columns=['size', '60C', '75C', '90C'])
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table3" WHERE "size" = ? ', (conductor,))
max_conductor_current = cur.fetchone()
conductor_ampacity = max_conductor_current[conductor_current_index]
except sqlite3.OperationalError as e:
print(e)
elif (code =='CEC') & (material =='AL') & (raceway == True): # CEC Table 4
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table4" WHERE "size" = ? ', (conductor,))
max_conductor_current = cur.fetchone()
conductor_ampacity = max_conductor_current[conductor_current_index]
except sqlite3.OperationalError as e:
print(e)
elif (code =='NEC') & (material =='CU'):
return (' I haven\'t created this table yet')
@ -320,11 +451,6 @@ def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', race
else:
return ('The variables were\'t right, but I\'m a loss to why.')
# Determine the ampacity of the conductor size
result_df = df.loc[df['size'] == conductor,column]
conductor_ampacity = result_df.item()
#print(conductor_ampacity)
return conductor_ampacity
def bonding_conductor(conductor_ampacity,bus=False,material='cu',code = 'CEC'):