Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 7, 2021
1 parent 48127bc commit 087e3d4
Show file tree
Hide file tree
Showing 22 changed files with 803 additions and 479 deletions.
46 changes: 33 additions & 13 deletions doc/source/analyzing/Particle_Trajectories.ipynb
Expand Up @@ -18,8 +18,10 @@
"%matplotlib inline\n",
"import glob\n",
"from os.path import join\n",
"\n",
"import yt\n",
"from yt.config import ytcfg\n",
"\n",
"path = ytcfg.get(\"yt\", \"test_data_dir\")\n",
"import matplotlib.pyplot as plt"
]
Expand Down Expand Up @@ -79,7 +81,7 @@
"ds = yt.load(my_fns[0])\n",
"dd = ds.all_data()\n",
"indices = dd[\"particle_index\"].astype(\"int\")\n",
"print (indices)"
"print(indices)"
]
},
{
Expand Down Expand Up @@ -117,8 +119,8 @@
},
"outputs": [],
"source": [
"print (trajs[\"particle_position_x\"])\n",
"print (trajs[\"particle_position_x\"].shape)"
"print(trajs[\"particle_position_x\"])\n",
"print(trajs[\"particle_position_x\"].shape)"
]
},
{
Expand Down Expand Up @@ -218,7 +220,9 @@
"outputs": [],
"source": [
"ds = yt.load(\"enzo_tiny_cosmology/DD0046/DD0046\")\n",
"slc = yt.SlicePlot(ds, \"x\", [\"density\",\"dark_matter_density\"], center=\"max\", width=(3.0, \"Mpc\"))\n",
"slc = yt.SlicePlot(\n",
" ds, \"x\", [\"density\", \"dark_matter_density\"], center=\"max\", width=(3.0, \"Mpc\")\n",
")\n",
"slc.show()"
]
},
Expand Down Expand Up @@ -278,10 +282,22 @@
"outputs": [],
"source": [
"fig = plt.figure(figsize=(8.0, 8.0))\n",
"ax = fig.add_subplot(111, projection='3d')\n",
"ax.plot(trajs[\"particle_position_x\"][100], trajs[\"particle_position_y\"][100], trajs[\"particle_position_z\"][100])\n",
"ax.plot(trajs[\"particle_position_x\"][8], trajs[\"particle_position_y\"][8], trajs[\"particle_position_z\"][8])\n",
"ax.plot(trajs[\"particle_position_x\"][25], trajs[\"particle_position_y\"][25], trajs[\"particle_position_z\"][25])"
"ax = fig.add_subplot(111, projection=\"3d\")\n",
"ax.plot(\n",
" trajs[\"particle_position_x\"][100],\n",
" trajs[\"particle_position_y\"][100],\n",
" trajs[\"particle_position_z\"][100],\n",
")\n",
"ax.plot(\n",
" trajs[\"particle_position_x\"][8],\n",
" trajs[\"particle_position_y\"][8],\n",
" trajs[\"particle_position_z\"][8],\n",
")\n",
"ax.plot(\n",
" trajs[\"particle_position_x\"][25],\n",
" trajs[\"particle_position_y\"][25],\n",
" trajs[\"particle_position_z\"][25],\n",
")"
]
},
{
Expand All @@ -299,7 +315,7 @@
},
"outputs": [],
"source": [
"plt.figure(figsize=(6,6))\n",
"plt.figure(figsize=(6, 6))\n",
"plt.plot(trajs[\"particle_time\"], trajs[\"particle_position_x\"][100])\n",
"plt.plot(trajs[\"particle_time\"], trajs[\"particle_position_x\"][8])\n",
"plt.plot(trajs[\"particle_time\"], trajs[\"particle_position_x\"][25])"
Expand Down Expand Up @@ -338,7 +354,7 @@
},
"outputs": [],
"source": [
"plt.figure(figsize=(6,6))\n",
"plt.figure(figsize=(6, 6))\n",
"plt.plot(trajs[\"particle_time\"], trajs[\"density\"][100])\n",
"plt.plot(trajs[\"particle_time\"], trajs[\"density\"][8])\n",
"plt.plot(trajs[\"particle_time\"], trajs[\"density\"][25])\n",
Expand All @@ -360,8 +376,12 @@
},
"outputs": [],
"source": [
"trajs.write_out(\"halo_trajectories\") # This will write a separate file for each trajectory\n",
"trajs.write_out_h5(\"halo_trajectories.h5\") # This will write all trajectories to a single file"
"trajs.write_out(\n",
" \"halo_trajectories\"\n",
") # This will write a separate file for each trajectory\n",
"trajs.write_out_h5(\n",
" \"halo_trajectories.h5\"\n",
") # This will write all trajectories to a single file"
]
}
],
Expand All @@ -387,4 +407,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
59 changes: 43 additions & 16 deletions doc/source/analyzing/domain_analysis/XrayEmissionFields.ipynb
Expand Up @@ -43,7 +43,9 @@
"\n",
"ds = yt.load(\"GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150\")\n",
"\n",
"xray_fields = yt.add_xray_emissivity_field(ds, 0.5, 7.0, table_type='apec', metallicity=0.3)"
"xray_fields = yt.add_xray_emissivity_field(\n",
" ds, 0.5, 7.0, table_type=\"apec\", metallicity=0.3\n",
")"
]
},
{
Expand All @@ -69,7 +71,7 @@
"metadata": {},
"outputs": [],
"source": [
"print (xray_fields)"
"print(xray_fields)"
]
},
{
Expand All @@ -86,7 +88,7 @@
"outputs": [],
"source": [
"sp = ds.sphere(\"c\", (2.0, \"Mpc\"))\n",
"print (sp.quantities.total_quantity((\"gas\",\"xray_luminosity_0.5_7.0_keV\")))"
"print(sp.quantities.total_quantity((\"gas\", \"xray_luminosity_0.5_7.0_keV\")))"
]
},
{
Expand All @@ -104,9 +106,15 @@
},
"outputs": [],
"source": [
"slc = yt.SlicePlot(ds, 'z', [('gas', 'xray_emissivity_0.5_7.0_keV'),\n",
" ('gas', 'xray_photon_emissivity_0.5_7.0_keV')],\n",
" width=(0.75, \"Mpc\"))\n",
"slc = yt.SlicePlot(\n",
" ds,\n",
" \"z\",\n",
" [\n",
" (\"gas\", \"xray_emissivity_0.5_7.0_keV\"),\n",
" (\"gas\", \"xray_photon_emissivity_0.5_7.0_keV\"),\n",
" ],\n",
" width=(0.75, \"Mpc\"),\n",
")\n",
"slc.show()"
]
},
Expand All @@ -129,10 +137,17 @@
"source": [
"ds2 = yt.load(\"D9p_500/10MpcBox_HartGal_csf_a0.500.d\")\n",
"\n",
"# In this case, use the redshift and cosmology from the dataset, \n",
"# In this case, use the redshift and cosmology from the dataset,\n",
"# but in theory you could put in something different\n",
"xray_fields2 = yt.add_xray_emissivity_field(ds2, 0.5, 2.0, redshift=ds2.current_redshift, cosmology=ds2.cosmology,\n",
" metallicity=(\"gas\", \"metallicity\"), table_type='cloudy')"
"xray_fields2 = yt.add_xray_emissivity_field(\n",
" ds2,\n",
" 0.5,\n",
" 2.0,\n",
" redshift=ds2.current_redshift,\n",
" cosmology=ds2.cosmology,\n",
" metallicity=(\"gas\", \"metallicity\"),\n",
" table_type=\"cloudy\",\n",
")"
]
},
{
Expand All @@ -148,7 +163,7 @@
"metadata": {},
"outputs": [],
"source": [
"print (xray_fields2)"
"print(xray_fields2)"
]
},
{
Expand All @@ -166,8 +181,9 @@
},
"outputs": [],
"source": [
"prj = yt.ProjectionPlot(ds2, \"x\", (\"gas\",\"xray_intensity_0.5_2.0_keV\"),\n",
" center=\"max\", width=(40, \"kpc\"))\n",
"prj = yt.ProjectionPlot(\n",
" ds2, \"x\", (\"gas\", \"xray_intensity_0.5_2.0_keV\"), center=\"max\", width=(40, \"kpc\")\n",
")\n",
"prj.set_zlim(\"xray_intensity_0.5_2.0_keV\", 1.0e-32, 5.0e-24)\n",
"prj.show()"
]
Expand Down Expand Up @@ -197,8 +213,14 @@
"metadata": {},
"outputs": [],
"source": [
"xray_fields3 = yt.add_xray_emissivity_field(ds2, 0.5, 2.0, dist=(1.0,\"Mpc\"), metallicity=(\"gas\", \"metallicity\"), \n",
" table_type='cloudy')"
"xray_fields3 = yt.add_xray_emissivity_field(\n",
" ds2,\n",
" 0.5,\n",
" 2.0,\n",
" dist=(1.0, \"Mpc\"),\n",
" metallicity=(\"gas\", \"metallicity\"),\n",
" table_type=\"cloudy\",\n",
")"
]
},
{
Expand All @@ -209,8 +231,13 @@
},
"outputs": [],
"source": [
"prj = yt.ProjectionPlot(ds2, \"x\", (\"gas\", \"xray_photon_intensity_0.5_2.0_keV\"),\n",
" center=\"max\", width=(40, \"kpc\"))\n",
"prj = yt.ProjectionPlot(\n",
" ds2,\n",
" \"x\",\n",
" (\"gas\", \"xray_photon_intensity_0.5_2.0_keV\"),\n",
" center=\"max\",\n",
" width=(40, \"kpc\"),\n",
")\n",
"prj.set_zlim(\"xray_photon_intensity_0.5_2.0_keV\", 1.0e-24, 5.0e-16)\n",
"prj.show()"
]
Expand Down
64 changes: 40 additions & 24 deletions doc/source/analyzing/mesh_filter.ipynb
Expand Up @@ -14,6 +14,7 @@
"outputs": [],
"source": [
"import yt\n",
"\n",
"ds = yt.load(\"Enzo_64/DD0042/data0042\")"
]
},
Expand All @@ -38,7 +39,9 @@
"\n",
"# you can chain cut regions in two ways:\n",
"dense_and_cool_ad = dense_ad.cut_region([\"obj['temperature'] < 1e5\"])\n",
"overpressure_and_fast_ad = ad.cut_region(['(obj[\"pressure\"] > 1e-14) & (obj[\"velocity_magnitude\"].in_units(\"km/s\") > 1e2)'])"
"overpressure_and_fast_ad = ad.cut_region(\n",
" ['(obj[\"pressure\"] > 1e-14) & (obj[\"velocity_magnitude\"].in_units(\"km/s\") > 1e2)']\n",
")"
]
},
{
Expand All @@ -55,13 +58,15 @@
"outputs": [],
"source": [
"ad = ds.all_data()\n",
"hot_ad = ad.include_above('temperature', 1e6)\n",
"dense_ad = ad.include_above('density', 5e-30)\n",
"hot_ad = ad.include_above(\"temperature\", 1e6)\n",
"dense_ad = ad.include_above(\"density\", 5e-30)\n",
"\n",
"# These can be chained as well\n",
"dense_and_cool_ad = dense_ad.include_below('temperature', 1e5)\n",
"overpressure_and_fast_ad = ad.include_above('pressure', 1e-14)\n",
"overpressure_and_fast_ad = overpressure_and_fast_ad.include_above('velocity_magnitude', 1e2, 'km/s')"
"dense_and_cool_ad = dense_ad.include_below(\"temperature\", 1e5)\n",
"overpressure_and_fast_ad = ad.include_above(\"pressure\", 1e-14)\n",
"overpressure_and_fast_ad = overpressure_and_fast_ad.include_above(\n",
" \"velocity_magnitude\", 1e2, \"km/s\"\n",
")"
]
},
{
Expand All @@ -77,8 +82,11 @@
"metadata": {},
"outputs": [],
"source": [
"print (\"Temperature of all cells:\\n ad['temperature'] = \\n%s\\n\" % ad[\"temperature\"])\n",
"print (\"Temperatures of all \\\"hot\\\" cells:\\n hot_ad['temperature'] = \\n%s\" % hot_ad['temperature'])"
"print(\"Temperature of all cells:\\n ad['temperature'] = \\n%s\\n\" % ad[\"temperature\"])\n",
"print(\n",
" \"Temperatures of all \\\"hot\\\" cells:\\n hot_ad['temperature'] = \\n%s\"\n",
" % hot_ad[\"temperature\"]\n",
")"
]
},
{
Expand All @@ -87,8 +95,14 @@
"metadata": {},
"outputs": [],
"source": [
"print (\"Density of dense, cool material:\\n dense_and_cool_ad['density'] = \\n%s\\n\" % dense_and_cool_ad['density'])\n",
"print (\"Temperature of dense, cool material:\\n dense_and_cool_ad['temperature'] = \\n%s\" % dense_and_cool_ad['temperature'])"
"print(\n",
" \"Density of dense, cool material:\\n dense_and_cool_ad['density'] = \\n%s\\n\"\n",
" % dense_and_cool_ad[\"density\"]\n",
")\n",
"print(\n",
" \"Temperature of dense, cool material:\\n dense_and_cool_ad['temperature'] = \\n%s\"\n",
" % dense_and_cool_ad[\"temperature\"]\n",
")"
]
},
{
Expand All @@ -106,13 +120,15 @@
"metadata": {},
"outputs": [],
"source": [
"proj1 = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\")\n",
"proj1.annotate_title('No Cuts')\n",
"proj1 = yt.ProjectionPlot(ds, \"x\", \"density\", weight_field=\"density\")\n",
"proj1.annotate_title(\"No Cuts\")\n",
"proj1.set_figure_size(5)\n",
"proj1.show()\n",
"\n",
"proj2 = yt.ProjectionPlot(ds, 'x', \"density\", weight_field=\"density\", data_source=hot_ad)\n",
"proj2.annotate_title('Hot Gas')\n",
"proj2 = yt.ProjectionPlot(\n",
" ds, \"x\", \"density\", weight_field=\"density\", data_source=hot_ad\n",
")\n",
"proj2.annotate_title(\"Hot Gas\")\n",
"proj2.set_zlim(\"density\", 3e-31, 3e-27)\n",
"proj2.set_figure_size(5)\n",
"proj2.show()"
Expand All @@ -136,15 +152,15 @@
"metadata": {},
"outputs": [],
"source": [
"slc1 = yt.SlicePlot(ds, 'x', \"density\", center='m')\n",
"slc1.set_zlim('density', 3e-31, 3e-27)\n",
"slc1.annotate_title('No Cuts')\n",
"slc1 = yt.SlicePlot(ds, \"x\", \"density\", center=\"m\")\n",
"slc1.set_zlim(\"density\", 3e-31, 3e-27)\n",
"slc1.annotate_title(\"No Cuts\")\n",
"slc1.set_figure_size(5)\n",
"slc1.show()\n",
"\n",
"slc2 = yt.SlicePlot(ds, 'x', \"density\", center='m', data_source=dense_ad)\n",
"slc2.set_zlim('density', 3e-31, 3e-27)\n",
"slc2.annotate_title('Dense Gas')\n",
"slc2 = yt.SlicePlot(ds, \"x\", \"density\", center=\"m\", data_source=dense_ad)\n",
"slc2.set_zlim(\"density\", 3e-31, 3e-27)\n",
"slc2.annotate_title(\"Dense Gas\")\n",
"slc2.set_figure_size(5)\n",
"slc2.show()"
]
Expand All @@ -155,15 +171,15 @@
"metadata": {},
"outputs": [],
"source": [
"ph1 = yt.PhasePlot(ad, 'density', 'temperature', 'mass', weight_field=None)\n",
"ph1 = yt.PhasePlot(ad, \"density\", \"temperature\", \"mass\", weight_field=None)\n",
"ph1.set_xlim(3e-31, 3e-27)\n",
"ph1.annotate_title('No Cuts')\n",
"ph1.annotate_title(\"No Cuts\")\n",
"ph1.set_figure_size(5)\n",
"ph1.show()\n",
"\n",
"ph1 = yt.PhasePlot(dense_ad, 'density', 'temperature', 'mass', weight_field=None)\n",
"ph1 = yt.PhasePlot(dense_ad, \"density\", \"temperature\", \"mass\", weight_field=None)\n",
"ph1.set_xlim(3e-31, 3e-27)\n",
"ph1.annotate_title('Dense Gas')\n",
"ph1.annotate_title(\"Dense Gas\")\n",
"ph1.set_figure_size(5)\n",
"ph1.show()"
]
Expand Down

0 comments on commit 087e3d4

Please sign in to comment.