diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..7c71fe6 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,2 @@ +[lint] +ignore = ["E741"] diff --git a/docs/example_2-synthetic-dustpol.ipynb b/docs/example_2-synthetic-dustpol.ipynb index 65d4040..5ff5144 100644 --- a/docs/example_2-synthetic-dustpol.ipynb +++ b/docs/example_2-synthetic-dustpol.ipynb @@ -35,14 +35,16 @@ "# add path to astro_tigress module\n", "# this can also be done using PYTHONPATH environment variable\n", "import sys\n", - "sys.path.insert(0,'../')\n", + "\n", + "sys.path.insert(0, \"../\")\n", "\n", "import astro_tigress\n", + "\n", "# Need to set the master directory where the data is stored\n", "dir_master = \"../data/\"\n", "# name of the simulation model\n", - "model_id = \"R8_4pc\" \n", - "model = astro_tigress.Model(model_id,dir_master) #reading the model information" + "model_id = \"R8_4pc\"\n", + "model = astro_tigress.Model(model_id, dir_master) # reading the model information" ] }, { @@ -51,7 +53,7 @@ "metadata": {}, "outputs": [], "source": [ - "#load the MHD data set for the snapshot ivtk=300\n", + "# load the MHD data set for the snapshot ivtk=300\n", "model.load(300, dataset=\"MHD\")" ] }, @@ -69,11 +71,11 @@ "metadata": {}, "outputs": [], "source": [ - "Temp = model.MHD.grid[('gas','temperature')].in_units(\"K\").value.T\n", - "nH = model.MHD.grid[('gas','nH')].in_units(\"cm**-3\").value.T\n", - "Bx = model.MHD.grid[('gas','magnetic_field_x')].in_units(\"uG\").value.T\n", - "By = model.MHD.grid[('gas','magnetic_field_y')].in_units(\"uG\").value.T\n", - "Bz = model.MHD.grid[('gas','magnetic_field_z')].in_units(\"uG\").value.T" + "Temp = model.MHD.grid[(\"gas\", \"temperature\")].in_units(\"K\").value.T\n", + "nH = model.MHD.grid[(\"gas\", \"nH\")].in_units(\"cm**-3\").value.T\n", + "Bx = model.MHD.grid[(\"gas\", \"magnetic_field_x\")].in_units(\"uG\").value.T\n", + "By = model.MHD.grid[(\"gas\", \"magnetic_field_y\")].in_units(\"uG\").value.T\n", + "Bz = model.MHD.grid[(\"gas\", \"magnetic_field_z\")].in_units(\"uG\").value.T" ] }, { @@ -90,9 +92,9 @@ "metadata": {}, "outputs": [], "source": [ - "xcc = model.MHD.grid[(\"gas\",\"x\")][:,0,0].to('pc').value\n", - "ycc = model.MHD.grid[(\"gas\",\"y\")][0,:,0].to('pc').value\n", - "zcc = model.MHD.grid[(\"gas\",\"z\")][0,0,:].to('pc').value" + "xcc = model.MHD.grid[(\"gas\", \"x\")][:, 0, 0].to(\"pc\").value\n", + "ycc = model.MHD.grid[(\"gas\", \"y\")][0, :, 0].to(\"pc\").value\n", + "zcc = model.MHD.grid[(\"gas\", \"z\")][0, 0, :].to(\"pc\").value" ] }, { @@ -109,8 +111,8 @@ "metadata": {}, "outputs": [], "source": [ - "dx_pc = model.MHD.grid[(\"gas\",\"dx\")][0,0,0].to('pc').value\n", - "dx_cm = model.MHD.grid[(\"gas\",\"dx\")][0,0,0].to('cm').value" + "dx_pc = model.MHD.grid[(\"gas\", \"dx\")][0, 0, 0].to(\"pc\").value\n", + "dx_cm = model.MHD.grid[(\"gas\", \"dx\")][0, 0, 0].to(\"cm\").value" ] }, { @@ -128,7 +130,7 @@ "metadata": {}, "outputs": [], "source": [ - "I,Q,U = calc_IQU(nH,Bx,By,Bz,dx_pc,los='y')" + "I, Q, U = calc_IQU(nH, Bx, By, Bz, dx_pc, los=\"y\")" ] }, { @@ -156,24 +158,24 @@ } ], "source": [ - "fig, axes = plt.subplots(1,2, figsize=(12,5))\n", + "fig, axes = plt.subplots(1, 2, figsize=(12, 5))\n", "# integration along the y-axis (edge on view)\n", "plt.sca(axes[0])\n", - "NH = nH.sum(axis=1)*dx_cm\n", + "NH = nH.sum(axis=1) * dx_cm\n", "\n", - "plt.pcolormesh(xcc,zcc,NH,vmax=1.e22,shading='nearest')\n", - "plt.gca().set_aspect('equal')\n", - "plt.xlabel('x[pc]')\n", - "plt.ylabel('z[pc]')\n", - "cbar = plt.colorbar(label=r'$N_H\\,[{\\rm cm^{-2}}]$')\n", + "plt.pcolormesh(xcc, zcc, NH, vmax=1.0e22, shading=\"nearest\")\n", + "plt.gca().set_aspect(\"equal\")\n", + "plt.xlabel(\"x[pc]\")\n", + "plt.ylabel(\"z[pc]\")\n", + "cbar = plt.colorbar(label=r\"$N_H\\,[{\\rm cm^{-2}}]$\")\n", "\n", "plt.sca(axes[1])\n", "\n", - "plt.pcolormesh(xcc,zcc,I,vmax=5,shading='nearest')\n", - "plt.gca().set_aspect('equal')\n", - "plt.xlabel('x[pc]')\n", - "plt.ylabel('z[pc]')\n", - "cbar = plt.colorbar(label=r'$I$')" + "plt.pcolormesh(xcc, zcc, I, vmax=5, shading=\"nearest\")\n", + "plt.gca().set_aspect(\"equal\")\n", + "plt.xlabel(\"x[pc]\")\n", + "plt.ylabel(\"z[pc]\")\n", + "cbar = plt.colorbar(label=r\"$I$\")" ] }, { @@ -190,7 +192,7 @@ "metadata": {}, "outputs": [], "source": [ - "P = np.sqrt(Q**2+U**2)" + "P = np.sqrt(Q**2 + U**2)" ] }, { @@ -210,34 +212,34 @@ } ], "source": [ - "fig, axes = plt.subplots(2,2, figsize=(13,10))\n", + "fig, axes = plt.subplots(2, 2, figsize=(13, 10))\n", "axes = axes.flatten()\n", "# integration along the y-axis (edge on view)\n", "plt.sca(axes[0])\n", - "plt.pcolormesh(xcc,zcc,I,vmax=5,shading='nearest')\n", - "plt.gca().set_aspect('equal')\n", - "plt.xlabel('x[pc]')\n", - "plt.ylabel('z[pc]')\n", - "cbar = plt.colorbar(label=r'$I$')\n", + "plt.pcolormesh(xcc, zcc, I, vmax=5, shading=\"nearest\")\n", + "plt.gca().set_aspect(\"equal\")\n", + "plt.xlabel(\"x[pc]\")\n", + "plt.ylabel(\"z[pc]\")\n", + "cbar = plt.colorbar(label=r\"$I$\")\n", "plt.sca(axes[1])\n", - "plt.pcolormesh(xcc,zcc,P/I,vmax=0.2,shading='nearest')\n", - "plt.gca().set_aspect('equal')\n", - "plt.xlabel('x[pc]')\n", - "plt.ylabel('z[pc]')\n", - "cbar = plt.colorbar(label=r'$P/I$')\n", + "plt.pcolormesh(xcc, zcc, P / I, vmax=0.2, shading=\"nearest\")\n", + "plt.gca().set_aspect(\"equal\")\n", + "plt.xlabel(\"x[pc]\")\n", + "plt.ylabel(\"z[pc]\")\n", + "cbar = plt.colorbar(label=r\"$P/I$\")\n", "\n", "plt.sca(axes[2])\n", - "plt.pcolormesh(xcc,zcc,Q,vmin=-0.1,vmax=0.1,shading='nearest',cmap=plt.cm.RdBu)\n", - "plt.gca().set_aspect('equal')\n", - "plt.xlabel('x[pc]')\n", - "plt.ylabel('z[pc]')\n", - "cbar = plt.colorbar(label=r'$Q$')\n", + "plt.pcolormesh(xcc, zcc, Q, vmin=-0.1, vmax=0.1, shading=\"nearest\", cmap=plt.cm.RdBu)\n", + "plt.gca().set_aspect(\"equal\")\n", + "plt.xlabel(\"x[pc]\")\n", + "plt.ylabel(\"z[pc]\")\n", + "cbar = plt.colorbar(label=r\"$Q$\")\n", "plt.sca(axes[3])\n", - "plt.pcolormesh(xcc,zcc,U,vmin=-0.1,vmax=0.1,shading='nearest',cmap=plt.cm.RdBu)\n", - "plt.gca().set_aspect('equal')\n", - "plt.xlabel('x[pc]')\n", - "plt.ylabel('z[pc]')\n", - "cbar = plt.colorbar(label=r'$U$')" + "plt.pcolormesh(xcc, zcc, U, vmin=-0.1, vmax=0.1, shading=\"nearest\", cmap=plt.cm.RdBu)\n", + "plt.gca().set_aspect(\"equal\")\n", + "plt.xlabel(\"x[pc]\")\n", + "plt.ylabel(\"z[pc]\")\n", + "cbar = plt.colorbar(label=r\"$U$\")" ] }, {