Skip to content

Commit

Permalink
Automatic linting
Browse files Browse the repository at this point in the history
  • Loading branch information
convert-repo authored and cphyc committed Jul 26, 2021
1 parent a5cb16a commit 56c3f83
Show file tree
Hide file tree
Showing 22 changed files with 814 additions and 472 deletions.
50 changes: 37 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[\"all\", \"particle_index\"].astype(\"int\")\n",
"print (indices)"
"print(indices)"
]
},
{
Expand Down Expand Up @@ -117,8 +119,8 @@
},
"outputs": [],
"source": [
"print (trajs[\"all\", \"particle_position_x\"])\n",
"print (trajs[\"all\", \"particle_position_x\"].shape)"
"print(trajs[\"all\", \"particle_position_x\"])\n",
"print(trajs[\"all\", \"particle_position_x\"].shape)"
]
},
{
Expand Down Expand Up @@ -218,7 +220,13 @@
"outputs": [],
"source": [
"ds = yt.load(\"enzo_tiny_cosmology/DD0046/DD0046\")\n",
"slc = yt.SlicePlot(ds, \"x\", [(\"gas\", \"density\"), (\"gas\", \"dark_matter_density\")], center=\"max\", width=(3.0, \"Mpc\"))\n",
"slc = yt.SlicePlot(\n",
" ds,\n",
" \"x\",\n",
" [(\"gas\", \"density\"), (\"gas\", \"dark_matter_density\")],\n",
" center=\"max\",\n",
" width=(3.0, \"Mpc\"),\n",
")\n",
"slc.show()"
]
},
Expand Down Expand Up @@ -278,10 +286,22 @@
"outputs": [],
"source": [
"fig = plt.figure(figsize=(8.0, 8.0))\n",
"ax = fig.add_subplot(111, projection='3d')\n",
"ax.plot(trajs[\"all\", \"particle_position_x\"][100], trajs[\"all\", \"particle_position_y\"][100], trajs[\"all\", \"particle_position_z\"][100])\n",
"ax.plot(trajs[\"all\", \"particle_position_x\"][8], trajs[\"all\", \"particle_position_y\"][8], trajs[\"all\", \"particle_position_z\"][8])\n",
"ax.plot(trajs[\"all\", \"particle_position_x\"][25], trajs[\"all\", \"particle_position_y\"][25], trajs[\"all\", \"particle_position_z\"][25])"
"ax = fig.add_subplot(111, projection=\"3d\")\n",
"ax.plot(\n",
" trajs[\"all\", \"particle_position_x\"][100],\n",
" trajs[\"all\", \"particle_position_y\"][100],\n",
" trajs[\"all\", \"particle_position_z\"][100],\n",
")\n",
"ax.plot(\n",
" trajs[\"all\", \"particle_position_x\"][8],\n",
" trajs[\"all\", \"particle_position_y\"][8],\n",
" trajs[\"all\", \"particle_position_z\"][8],\n",
")\n",
"ax.plot(\n",
" trajs[\"all\", \"particle_position_x\"][25],\n",
" trajs[\"all\", \"particle_position_y\"][25],\n",
" trajs[\"all\", \"particle_position_z\"][25],\n",
")"
]
},
{
Expand All @@ -299,7 +319,7 @@
},
"outputs": [],
"source": [
"plt.figure(figsize=(6,6))\n",
"plt.figure(figsize=(6, 6))\n",
"plt.plot(trajs[\"all\", \"particle_time\"], trajs[\"all\", \"particle_position_x\"][100])\n",
"plt.plot(trajs[\"all\", \"particle_time\"], trajs[\"all\", \"particle_position_x\"][8])\n",
"plt.plot(trajs[\"all\", \"particle_time\"], trajs[\"all\", \"particle_position_x\"][25])"
Expand Down Expand Up @@ -338,7 +358,7 @@
},
"outputs": [],
"source": [
"plt.figure(figsize=(6,6))\n",
"plt.figure(figsize=(6, 6))\n",
"plt.plot(trajs[\"all\", \"particle_time\"], trajs[\"gas\", \"density\"][100])\n",
"plt.plot(trajs[\"all\", \"particle_time\"], trajs[\"gas\", \"density\"][8])\n",
"plt.plot(trajs[\"all\", \"particle_time\"], trajs[\"gas\", \"density\"][25])\n",
Expand All @@ -360,8 +380,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 +411,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
63 changes: 46 additions & 17 deletions doc/source/analyzing/domain_analysis/XrayEmissionFields.ipynb
Expand Up @@ -41,9 +41,13 @@
"source": [
"import yt\n",
"\n",
"ds = yt.load(\"GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150\", default_species_fields=\"ionized\")\n",
"ds = yt.load(\n",
" \"GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150\", default_species_fields=\"ionized\"\n",
")\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 +73,7 @@
"metadata": {},
"outputs": [],
"source": [
"print (xray_fields)"
"print(xray_fields)"
]
},
{
Expand All @@ -86,7 +90,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 +108,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 +139,17 @@
"source": [
"ds2 = yt.load(\"D9p_500/10MpcBox_HartGal_csf_a0.500.d\", default_species_fields=\"ionized\")\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 +165,7 @@
"metadata": {},
"outputs": [],
"source": [
"print (xray_fields2)"
"print(xray_fields2)"
]
},
{
Expand All @@ -166,8 +183,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 +215,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 +233,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
68 changes: 48 additions & 20 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,11 @@
"\n",
"# you can chain cut regions in two ways:\n",
"dense_and_cool_ad = dense_ad.cut_region(['obj[\"gas\", \"temperature\"] < 1e5'])\n",
"overpressure_and_fast_ad = ad.cut_region(['(obj[\"gas\", \"pressure\"] > 1e-14) & (obj[\"gas\", \"velocity_magnitude\"].in_units(\"km/s\") > 1e2)'])"
"overpressure_and_fast_ad = ad.cut_region(\n",
" [\n",
" '(obj[\"gas\", \"pressure\"] > 1e-14) & (obj[\"gas\", \"velocity_magnitude\"].in_units(\"km/s\") > 1e2)'\n",
" ]\n",
")"
]
},
{
Expand All @@ -61,7 +66,9 @@
"# These can be chained as well\n",
"dense_and_cool_ad = dense_ad.include_below((\"gas\", \"temperature\"), 1e5)\n",
"overpressure_and_fast_ad = ad.include_above((\"gas\", \"pressure\"), 1e-14)\n",
"overpressure_and_fast_ad = overpressure_and_fast_ad.include_above((\"gas\", \"velocity_magnitude\"), 1e2, 'km/s')"
"overpressure_and_fast_ad = overpressure_and_fast_ad.include_above(\n",
" (\"gas\", \"velocity_magnitude\"), 1e2, \"km/s\"\n",
")"
]
},
{
Expand All @@ -77,8 +84,13 @@
"metadata": {},
"outputs": [],
"source": [
"print (\"Temperature of all cells:\\n ad['temperature'] = \\n%s\\n\" % ad[\"gas\", \"temperature\"])\n",
"print (\"Temperatures of all \\\"hot\\\" cells:\\n hot_ad['temperature'] = \\n%s\" % hot_ad[\"gas\", \"temperature\"])"
"print(\n",
" \"Temperature of all cells:\\n ad['temperature'] = \\n%s\\n\" % ad[\"gas\", \"temperature\"]\n",
")\n",
"print(\n",
" \"Temperatures of all \\\"hot\\\" cells:\\n hot_ad['temperature'] = \\n%s\"\n",
" % hot_ad[\"gas\", \"temperature\"]\n",
")"
]
},
{
Expand All @@ -87,8 +99,14 @@
"metadata": {},
"outputs": [],
"source": [
"print (\"Density of dense, cool material:\\n dense_and_cool_ad['density'] = \\n%s\\n\" % dense_and_cool_ad[\"gas\", \"density\"])\n",
"print (\"Temperature of dense, cool material:\\n dense_and_cool_ad['temperature'] = \\n%s\" % dense_and_cool_ad[\"gas\", \"temperature\"])"
"print(\n",
" \"Density of dense, cool material:\\n dense_and_cool_ad['density'] = \\n%s\\n\"\n",
" % dense_and_cool_ad[\"gas\", \"density\"]\n",
")\n",
"print(\n",
" \"Temperature of dense, cool material:\\n dense_and_cool_ad['temperature'] = \\n%s\"\n",
" % dense_and_cool_ad[\"gas\", \"temperature\"]\n",
")"
]
},
{
Expand All @@ -106,13 +124,15 @@
"metadata": {},
"outputs": [],
"source": [
"proj1 = yt.ProjectionPlot(ds, 'x', (\"gas\", \"density\"), weight_field=(\"gas\", \"density\"))\n",
"proj1.annotate_title('No Cuts')\n",
"proj1 = yt.ProjectionPlot(ds, \"x\", (\"gas\", \"density\"), weight_field=(\"gas\", \"density\"))\n",
"proj1.annotate_title(\"No Cuts\")\n",
"proj1.set_figure_size(5)\n",
"proj1.show()\n",
"\n",
"proj2 = yt.ProjectionPlot(ds, 'x', (\"gas\", \"density\"), weight_field=(\"gas\", \"density\"), data_source=hot_ad)\n",
"proj2.annotate_title('Hot Gas')\n",
"proj2 = yt.ProjectionPlot(\n",
" ds, \"x\", (\"gas\", \"density\"), weight_field=(\"gas\", \"density\"), data_source=hot_ad\n",
")\n",
"proj2.annotate_title(\"Hot Gas\")\n",
"proj2.set_zlim((\"gas\", \"density\"), 3e-31, 3e-27)\n",
"proj2.set_figure_size(5)\n",
"proj2.show()"
Expand All @@ -136,15 +156,15 @@
"metadata": {},
"outputs": [],
"source": [
"slc1 = yt.SlicePlot(ds, 'x', (\"gas\", \"density\"), center='m')\n",
"slc1.set_zlim((\"gas\", 'density'), 3e-31, 3e-27)\n",
"slc1.annotate_title('No Cuts')\n",
"slc1 = yt.SlicePlot(ds, \"x\", (\"gas\", \"density\"), center=\"m\")\n",
"slc1.set_zlim((\"gas\", \"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', (\"gas\", \"density\"), center='m', data_source=dense_ad)\n",
"slc2.set_zlim((\"gas\", 'density'), 3e-31, 3e-27)\n",
"slc2.annotate_title('Dense Gas')\n",
"slc2 = yt.SlicePlot(ds, \"x\", (\"gas\", \"density\"), center=\"m\", data_source=dense_ad)\n",
"slc2.set_zlim((\"gas\", \"density\"), 3e-31, 3e-27)\n",
"slc2.annotate_title(\"Dense Gas\")\n",
"slc2.set_figure_size(5)\n",
"slc2.show()"
]
Expand All @@ -155,15 +175,23 @@
"metadata": {},
"outputs": [],
"source": [
"ph1 = yt.PhasePlot(ad, (\"gas\", \"density\"), (\"gas\", \"temperature\"), (\"gas\", \"mass\"), weight_field=None)\n",
"ph1 = yt.PhasePlot(\n",
" ad, (\"gas\", \"density\"), (\"gas\", \"temperature\"), (\"gas\", \"mass\"), weight_field=None\n",
")\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, (\"gas\", \"density\"), (\"gas\", \"temperature\"), (\"gas\", \"mass\"), weight_field=None)\n",
"ph1 = yt.PhasePlot(\n",
" dense_ad,\n",
" (\"gas\", \"density\"),\n",
" (\"gas\", \"temperature\"),\n",
" (\"gas\", \"mass\"),\n",
" weight_field=None,\n",
")\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 56c3f83

Please sign in to comment.