{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-01-26T10:21:02.403702Z",
     "start_time": "2021-01-26T10:21:02.182512Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-30T07:02:57.433285Z",
     "start_time": "2020-12-30T07:02:57.421574Z"
    }
   },
   "outputs": [],
   "source": [
    "def Bx0_func(y,V_A,Lm):\n",
    "    return y/Lm* V_A* np.exp(-y**2/(2*Lm**2)) * np.exp(0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-01-26T10:23:18.289161Z",
     "start_time": "2021-01-26T10:23:18.286160Z"
    }
   },
   "outputs": [],
   "source": [
    "y = np.linspace(-2*np.pi,2*np.pi,200)\n",
    "x = np.linspace(-2*np.pi,2*np.pi,200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-30T07:03:04.295779Z",
     "start_time": "2020-12-30T07:03:04.284676Z"
    }
   },
   "outputs": [],
   "source": [
    "Bx0 = Bx0_func(y,1,1.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-12-30T07:03:04.920233Z",
     "start_time": "2020-12-30T07:03:04.714346Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7fbee42adbb0>]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 16264 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(y,Bx0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-01-26T10:28:49.549735Z",
     "start_time": "2021-01-26T10:28:49.534091Z"
    }
   },
   "outputs": [],
   "source": [
    "def s0(x,y,kx):\n",
    "    return np.exp(-(y/2)**2/2)*np.exp(1j*kx*x)\n",
    "def s01(x,y,R):\n",
    "    return np.cos(x/R)*np.cos(y/R)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-01-26T10:28:51.121527Z",
     "start_time": "2021-01-26T10:28:50.575582Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-7-838b7325e8f5>:5: ComplexWarning: Casting complex values to real discards the imaginary part\n",
      "  S0[j,i] = s0(x[i],y[j],0.5)\n"
     ]
    }
   ],
   "source": [
    "S0 = np.zeros((len(x),len(y)))\n",
    "S01 = np.zeros((len(x),len(y)))\n",
    "for i in range(len(x)):\n",
    "    for j in range(len(y)):\n",
    "        S0[j,i] = s0(x[i],y[j],0.5)\n",
    "        if(abs(y[j])<= np.pi):\n",
    "            S01[j,i] = s01(x[i],y[j],2)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-01-26T10:28:52.351932Z",
     "start_time": "2021-01-26T10:28:52.010057Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-11-c038dba91ce3>:2: UserWarning: The following kwargs were not used by contour: 'linewidth'\n",
      "  plt.contourf(x,y,S0,20,cmap=plt.cm.hot,linewidth=0.1,alpha = 0.75)\n",
      "<ipython-input-11-c038dba91ce3>:3: UserWarning: The following kwargs were not used by contour: 'linewidth'\n",
      "  C=plt.contour(x,y,S0,20,colors='black',linewidth=0.1,alpha = 0.7)\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 137740 characters]\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize = (8,5))\n",
    "plt.contourf(x,y,S0,20,cmap=plt.cm.hot,linewidth=0.1,alpha = 0.75)\n",
    "C=plt.contour(x,y,S0,20,colors='black',linewidth=0.1,alpha = 0.7)\n",
    "# plt.clabel(C,inline=True,fontsize=8)\n",
    "plt.ylim(-np.pi,np.pi)\n",
    "plt.xlabel('Eastward distance',fontsize = 15)\n",
    "plt.ylabel('Northward distance',fontsize = 15)\n",
    "plt.title('Radiative-equilibrium',fontsize = 15)\n",
    "plt.savefig('1.png',dpi = 200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-01-26T10:26:00.172965Z",
     "start_time": "2021-01-26T10:25:59.833548Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\Anaconda3\\conda\\lib\\site-packages\\matplotlib\\contour.py:1004: UserWarning: The following kwargs were not used by contour: 'linewidth'\n",
      "  s)\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 73988 characters]\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize = (5,5))\n",
    "plt.contourf(x,y,S01,20,cmap=plt.cm.hot,linewidth=0.1,alpha = 0.75)\n",
    "C=plt.contour(x,y,S01,20,colors='black',linewidth=0.1,alpha = 0.7)\n",
    "# plt.clabel(C,inline=True,fontsize=8)\n",
    "plt.savefig('2.png',dpi = 200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 6232 characters]\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize = (5,5))\n",
    "\n",
    "for i in range(5):\n",
    "    c1=plt.get_cmap('RdYlBu')(np.linspace(0, 1, 5))[i]\n",
    "    plt.plot(np.linspace(1,5,4),[i]*4,color = c1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "k = 1\n",
    "n = 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "omega = k/(k**2+2*n+1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.125\n"
     ]
    }
   ],
   "source": [
    "print(omega)"
   ]
  },
  {
   "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.8.5"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "position": {
    "height": "218.208px",
    "left": "1090.33px",
    "right": "20px",
    "top": "37px",
    "width": "454px"
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
