Skip to content

Commit

Permalink
Reformatting (ignoring E741)
Browse files Browse the repository at this point in the history
  • Loading branch information
changgoo committed Sep 18, 2024
1 parent c000df5 commit d6219ba
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[lint]
ignore = ["E741"]
100 changes: 51 additions & 49 deletions docs/example_2-synthetic-dustpol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand All @@ -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\")"
]
},
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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$\")"
]
},
{
Expand All @@ -190,7 +192,7 @@
"metadata": {},
"outputs": [],
"source": [
"P = np.sqrt(Q**2+U**2)"
"P = np.sqrt(Q**2 + U**2)"
]
},
{
Expand All @@ -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$\")"
]
},
{
Expand Down

0 comments on commit d6219ba

Please sign in to comment.