From ef56e794914c2f165bfc8eb0153af5bba9dd074c Mon Sep 17 00:00:00 2001 From: WesIngwersen Date: Fri, 20 Sep 2019 14:22:41 -0400 Subject: [PATCH] Update example with changes to matio --- example/example.ipynb | 121 +++++++++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 44 deletions(-) diff --git a/example/example.ipynb b/example/example.ipynb index 4c41706..d9085e6 100644 --- a/example/example.ipynb +++ b/example/example.ipynb @@ -625,7 +625,7 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", @@ -851,7 +851,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1440,7 +1440,7 @@ "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", - "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", + "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n", "\n", @@ -1666,7 +1666,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1693,7 +1693,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -1834,7 +1834,7 @@ "6/government & other/us 0.009160 " ] }, - "execution_count": 3, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -1857,7 +1857,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -2643,7 +2643,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -2655,10 +2655,10 @@ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 4, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -2687,7 +2687,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -2706,7 +2706,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": { "scrolled": true }, @@ -3494,7 +3494,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -3506,10 +3506,10 @@ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 6, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -3534,7 +3534,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -3555,7 +3555,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -3564,10 +3564,10 @@ "

Validation result

no errors or warnings, everything seems to be fine

information

  • all units in satellite table are known
  • all compartments in satellite table are known
  • all sectors in the satellite matrix match a sector in the direct requirements matrix
  • all location codes of sectors are ok
  • all elementary flows have the same UUIDs in the satellite and LCIA table
  • 2 more
" ], "text/plain": [ - "" + "" ] }, - "execution_count": 14, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -3589,9 +3589,17 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 11, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "c:\\users\\wesle\\io-model-builder\\iomb\\calc.py:71: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.\n", + " r.lcia_flow_contributions = scale_columns(iaf, r.lci_total.as_matrix())\n" + ] + }, { "data": { "text/html": [ @@ -3645,7 +3653,7 @@ "useeio-lcia/htox-hc/ctuh 8.866966e-12" ] }, - "execution_count": 15, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -3666,7 +3674,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -4464,10 +4472,10 @@ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 17, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -4504,7 +4512,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -4515,22 +4523,7 @@ }, { "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "#Export model as binary and csv files for use in the USEEIO API\n", - "import iomb.matio as matio\n", - "import os\n", - "model_export = matio.Export(eeio_model)\n", - "matrix_dir = './matrices'\n", - "os.mkdir(matrix_dir)\n", - "model_export.to_dir(matrix_dir,exportDQImatrices=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 20, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -4550,14 +4543,54 @@ " 'U_dqi.csv']" ] }, - "execution_count": 20, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Export model as files for use in the USEEIO API\n", + "import iomb.matio as matio\n", + "import os\n", + "matrices = matio.Matrices(eeio_model,DQImatrices=True)\n", + "data_dir = './data/'\n", + "os.mkdir(data_dir)\n", + "matrices.export_for_api(data_dir,exportDQImatrices=True)\n", + "#Show the api files exported\n", + "os.listdir(data_dir)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['A.csv',\n", + " 'B.csv',\n", + " 'B_dqi.csv',\n", + " 'C.csv',\n", + " 'D.csv',\n", + " 'D_dqi.csv',\n", + " 'L.csv',\n", + " 'U.csv',\n", + " 'U_dqi.csv']" + ] + }, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "#Show the binary and csv files exported\n", - "os.listdir(matrix_dir)" + "#Export all matrices as csv\n", + "mat_dir = './data/'\n", + "os.mkdir(mat_dir)\n", + "matrices.export_to_csv(mat_dir,exportDQImatrices=True)\n", + "#Show the csv files exported\n", + "os.listdir(mat_dir)" ] }, {