{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from numpy import genfromtxt\n",
    "from scipy import stats\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "ref=genfromtxt('Carbondioxide_Short_IIR.csv',delimiter=';',names=True)\n",
    "\n",
    "# IIR\n",
    "# s0=1e3\n",
    "# h0=2e5\n",
    "\n",
    "# ASHRAE or NBP\n",
    "s0=0\n",
    "h0=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23492 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots(nrows=1,ncols=2, sharey=False)\n",
    "ax[0].plot(ref['idealPower1'], (ref['sref']-s0), marker='x', color='b')\n",
    "ax[0].grid(b=True, linestyle=':')\n",
    "ax[1].plot(ref['idealPower2'], (ref['href']-h0), marker='x', color='r')\n",
    "ax[1].grid(b=True, linestyle=':')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "entropy slope: -188.9240578234875\n",
      "entropy intercept: -156.82802220485394\n",
      "entropy linregress r_value: -0.9999999999999999\n",
      "-0.830111442722551\n",
      "\n",
      "enthalpy slope: 57457.13364255431\n",
      "enthalpy intercept: -93872.17420192057\n",
      "enthalpy linregress r_value: 1.0\n",
      "1.633777535543407\n"
     ]
    }
   ],
   "source": [
    "# entropy\n",
    "slope, intercept, r_value, p_value, std_err = stats.linregress(ref['idealPower1'], ref['sref'])\n",
    "x_s = (s0-intercept)/slope\n",
    "print(\"entropy slope: {}\".format(slope))\n",
    "print(\"entropy intercept: {}\".format(intercept))\n",
    "print(\"entropy linregress r_value: {}\".format(r_value))\n",
    "print('{:016.15f}'.format(x_s))\n",
    "\n",
    "# enthalpy\n",
    "slope, intercept, r_value, p_value, std_err = stats.linregress(ref['idealPower2'], ref['href'])\n",
    "x_h = (h0-intercept)/slope\n",
    "print(\"\\nenthalpy slope: {}\".format(slope))\n",
    "print(\"enthalpy intercept: {}\".format(intercept))\n",
    "print(\"enthalpy linregress r_value: {}\".format(r_value))\n",
    "print('{:016.15f}'.format(x_h))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
