[yt-svn] commit/yt: 14 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Jul 2 23:57:37 PDT 2014
14 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/e4eaec1e1557/
Changeset: e4eaec1e1557
Branch: yt-3.0
User: jzuhone
Date: 2014-06-19 15:32:12
Summary: Fixing some PEP-8 in photon_simulator.
Affected #: 1 file
diff -r e17556a9d270d158341c7fb5ca07507eedc9c624 -r e4eaec1e155751b78c79fe164af30d6bd20e3188 yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -181,7 +181,7 @@
Examples
--------
>>> apec_model = TableApecModel("/Users/jzuhone/Data/atomdb_v2.0.2/", 0.05, 50.0,
- 1000, thermal_broad=True)
+ ... 1000, thermal_broad=True)
"""
def __init__(self, apec_root, emin, emax, nchan,
apec_vers="2.0.2", thermal_broad=False):
@@ -226,7 +226,7 @@
tmpspec = np.zeros((self.nchan))
- i = np.where((self.line_handle[tindex].data.field('element')==element) &
+ i = np.where((self.line_handle[tindex].data.field('element') == element) &
(self.line_handle[tindex].data.field('lambda') > self.minlam) &
(self.line_handle[tindex].data.field('lambda') < self.maxlam))[0]
@@ -242,24 +242,24 @@
vec += np.diff(cdf)*a
else:
ie = np.searchsorted(ebins, E0, side='right')-1
- for i,a in zip(ie,amp): vec[i] += a
+ for i, a in zip(ie, amp): vec[i] += a
tmpspec += vec
- ind = np.where((self.coco_handle[tindex].data.field('Z')==element) &
- (self.coco_handle[tindex].data.field('rmJ')==0))[0]
- if len(ind)==0:
+ ind = np.where((self.coco_handle[tindex].data.field('Z') == element) &
+ (self.coco_handle[tindex].data.field('rmJ') == 0))[0]
+ if len(ind) == 0:
return tmpspec
else:
- ind=ind[0]
+ ind = ind[0]
- n_cont=self.coco_handle[tindex].data.field('N_Cont')[ind]
- e_cont=self.coco_handle[tindex].data.field('E_Cont')[ind][:n_cont]
+ n_cont = self.coco_handle[tindex].data.field('N_Cont')[ind]
+ e_cont = self.coco_handle[tindex].data.field('E_Cont')[ind][:n_cont]
continuum = self.coco_handle[tindex].data.field('Continuum')[ind][:n_cont]
tmpspec += np.interp(self.emid.ndarray_view(), e_cont, continuum)*self.de.ndarray_view()
- n_pseudo=self.coco_handle[tindex].data.field('N_Pseudo')[ind]
- e_pseudo=self.coco_handle[tindex].data.field('E_Pseudo')[ind][:n_pseudo]
+ n_pseudo = self.coco_handle[tindex].data.field('N_Pseudo')[ind]
+ e_pseudo = self.coco_handle[tindex].data.field('E_Pseudo')[ind][:n_pseudo]
pseudo = self.coco_handle[tindex].data.field('Pseudo')[ind][:n_pseudo]
tmpspec += np.interp(self.emid.ndarray_view(), e_pseudo, pseudo)*self.de.ndarray_view()
https://bitbucket.org/yt_analysis/yt/commits/e8f37410cdc4/
Changeset: e8f37410cdc4
Branch: yt-3.0
User: jzuhone
Date: 2014-06-19 15:32:47
Summary: Add photons unit.
Affected #: 1 file
diff -r e4eaec1e155751b78c79fe164af30d6bd20e3188 -r e8f37410cdc48844cc1d37389350be56dad62611 yt/units/unit_lookup_table.py
--- a/yt/units/unit_lookup_table.py
+++ b/yt/units/unit_lookup_table.py
@@ -89,6 +89,7 @@
"angstrom": (cm_per_ang, dimensions.length),
"Jy": (jansky_cgs, dimensions.specific_flux),
"counts": (1.0, dimensions.dimensionless),
+ "photons": (1.0, dimensions.dimensionless),
# for AstroPy compatibility
"solMass": (mass_sun_grams, dimensions.mass),
https://bitbucket.org/yt_analysis/yt/commits/07054af995f5/
Changeset: 07054af995f5
Branch: yt-3.0
User: jzuhone
Date: 2014-06-19 15:33:23
Summary: spectral_integrator refactor, for 3.0.
Affected #: 2 files
diff -r e8f37410cdc48844cc1d37389350be56dad62611 -r 07054af995f55b27a18440b9275304173d3a33e8 yt/analysis_modules/spectral_integrator/api.py
--- a/yt/analysis_modules/spectral_integrator/api.py
+++ b/yt/analysis_modules/spectral_integrator/api.py
@@ -15,6 +15,4 @@
from .spectral_frequency_integrator import \
EmissivityIntegrator, \
- add_xray_emissivity_field, \
- add_xray_luminosity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
\ No newline at end of file
diff -r e8f37410cdc48844cc1d37389350be56dad62611 -r 07054af995f55b27a18440b9275304173d3a33e8 yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
--- a/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
+++ b/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
@@ -23,14 +23,15 @@
mylog, \
only_on_root
-from yt.fields.local_fields import add_field
+from yt.utilities.exceptions import YTFieldNotFound
from yt.utilities.exceptions import YTException
from yt.utilities.linear_interpolators import \
BilinearFieldInterpolator
from yt.utilities.physical_constants import \
- erg_per_eV, hcgs
-from yt.units import keV, Hz
-keV_per_Hz = keV/Hz/hcgs
+ hcgs, mp
+from yt.units.yt_array import YTArray, YTQuantity
+from yt.utilities.physical_ratios import \
+ primordial_H_mass_fraction, erg_per_keV
xray_data_version = 1
@@ -62,7 +63,8 @@
class ObsoleteDataException(YTException):
def __str__(self):
- return "X-ray emissivity data is out of data.\nDownload the latest data from http://yt-project.org/data/xray_emissivity.h5 and move it to %s." % \
+ return "X-ray emissivity data is out of date.\n" + \
+ "Download the latest data from http://yt-project.org/data/xray_emissivity.h5 and move it to %s." % \
os.path.join(os.environ["YT_DEST"], "data", "xray_emissivity.h5")
class EmissivityIntegrator(object):
@@ -108,35 +110,26 @@
E_diff = np.diff(self.log_E)
self.E_bins = \
- np.power(10, np.concatenate([self.log_E[:-1] - 0.5 * E_diff,
- [self.log_E[-1] - 0.5 * E_diff[-1],
- self.log_E[-1] + 0.5 * E_diff[-1]]]))
- self.dnu = keV_per_Hz * np.diff(self.E_bins)
+ YTArray(np.power(10, np.concatenate([self.log_E[:-1] - 0.5 * E_diff,
+ [self.log_E[-1] - 0.5 * E_diff[-1],
+ self.log_E[-1] + 0.5 * E_diff[-1]]])),
+ "keV")
+ self.dnu = (np.diff(self.E_bins)/hcgs).in_units("Hz")
- def _get_interpolator(self, data, e_min, e_max):
- r"""Create an interpolator for total emissivity in a
- given energy range.
-
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
-
- """
+ def get_interpolator(self, data, e_min, e_max):
+ e_min = YTQuantity(e_min, "keV")
+ e_max = YTQuantity(e_max, "keV")
if (e_min - self.E_bins[0]) / e_min < -1e-3 or \
(e_max - self.E_bins[-1]) / e_max > 1e-3:
- raise EnergyBoundsException(np.power(10, self.E_bins[0]),
- np.power(10, self.E_bins[-1]))
+ raise EnergyBoundsException(self.E_bins[0], self.E_bins[-1])
e_is, e_ie = np.digitize([e_min, e_max], self.E_bins)
e_is = np.clip(e_is - 1, 0, self.E_bins.size - 1)
e_ie = np.clip(e_ie, 0, self.E_bins.size - 1)
- my_dnu = np.copy(self.dnu[e_is: e_ie])
+ my_dnu = self.dnu[e_is: e_ie].copy()
# clip edge bins if the requested range is smaller
- my_dnu[0] -= e_min - self.E_bins[e_is]
- my_dnu[-1] -= self.E_bins[e_ie] - e_max
+ my_dnu[0] -= ((e_min - self.E_bins[e_is])/hcgs).in_units("Hz")
+ my_dnu[-1] -= ((self.E_bins[e_ie] - e_max)/hcgs).in_units("Hz")
interp_data = (data[..., e_is:e_ie] * my_dnu).sum(axis=-1)
return BilinearFieldInterpolator(np.log10(interp_data),
@@ -144,10 +137,11 @@
self.log_T[0], self.log_T[-1]],
["log_nH", "log_T"], truncate=True)
-def add_xray_emissivity_field(e_min, e_max, filename=None,
+def add_xray_emissivity_field(ds, e_min, e_max,
+ filename=None,
with_metals=True,
constant_metallicity=None):
- r"""Create an X-ray emissivity field for a given energy range.
+ r"""Create X-ray emissivity fields for a given energy range.
Parameters
----------
@@ -155,197 +149,115 @@
the minimum energy in keV for the energy band.
e_min: float
the maximum energy in keV for the energy band.
-
- Other Parameters
- ----------------
- filename: string
+ filename: string, optional
Path to data file containing emissivity values. If None,
a file called xray_emissivity.h5 is used. This file contains
emissivity tables for primordial elements and for metals at
solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
- with_metals: bool
+ with_metals: bool, optional
If True, use the metallicity field to add the contribution from
metals. If False, only the emission from H/He is considered.
Default: True.
- constant_metallicity: float
+ constant_metallicity: float, optional
If specified, assume a constant metallicity for the emission
from metals. The *with_metals* keyword must be set to False
to use this.
Default: None.
- This will create a field named "Xray_Emissivity_{e_min}_{e_max}keV".
- The units of the field are erg s^-1 cm^-3.
+ This will create three fields:
+
+ "xray_emissivity_{e_min}_{e_max}_keV" (erg s^-1 cm^-3)
+ "xray_luminosity_{e_min}_{e_max}_keV" (erg s^-1)
+ "xray_photon_emissivity_{e_min}_{e_max}_keV" (photons s^-1 cm^-3)
Examples
--------
>>> from yt.mods import *
>>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_emissivity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> p = ProjectionPlot(pf, 'x', "Xray_Emissivity_0.5_2keV")
+ >>> ds = load(dataset)
+ >>> add_xray_emissivity_field(ds, 0.5, 2)
+ >>> p = ProjectionPlot(ds, 'x', "xray_emissivity_0.5_2_keV")
>>> p.save()
"""
+ if with_metals:
+ try:
+ ds._get_field_info("metal_density")
+ except YTFieldNotFound:
+ raise RuntimeError("Your dataset does not have a \"metal_density\" field! " +
+ "Perhaps you should specify a constant metallicity?")
+
my_si = EmissivityIntegrator(filename=filename)
- em_0 = my_si._get_interpolator(my_si.emissivity_primordial, e_min, e_max)
+ em_0 = my_si.get_interpolator(my_si.emissivity_primordial, e_min, e_max)
em_Z = None
if with_metals or constant_metallicity is not None:
- em_Z = my_si._get_interpolator(my_si.emissivity_metals, e_min, e_max)
+ em_Z = my_si.get_interpolator(my_si.emissivity_metals, e_min, e_max)
+
+ energy_erg = np.power(10, my_si.log_E) * erg_per_keV
+ emp_0 = my_si.get_interpolator((my_si.emissivity_primordial[..., :] / energy_erg),
+ e_min, e_max)
+ emp_Z = None
+ if with_metals or constant_metallicity is not None:
+ emp_Z = my_si.get_interpolator((my_si.emissivity_metals[..., :] / energy_erg),
+ e_min, e_max)
+
+ try:
+ ds._get_field_info("H_number_density")
+ except YTFieldNotFound:
+ mylog.warning("Could not find a field for \"H_number_density\". Assuming primordial H " +
+ "mass fraction.")
+ def _nh(field, data):
+ return primordial_H_mass_fraction*data["gas","density"]/mp
+ ds.add_field(("gas","H_number_density"), function=_nh, units="cm**-3")
def _emissivity_field(field, data):
- dd = {"log_nH" : np.log10(data["H_NumberDensity"]),
- "log_T" : np.log10(data["Temperature"])}
+ dd = {"log_nH" : np.log10(data["gas","H_number_density"]),
+ "log_T" : np.log10(data["gas","temperature"])}
my_emissivity = np.power(10, em_0(dd))
if em_Z is not None:
if with_metals:
- my_Z = data["Metallicity"]
+ my_Z = data["gas","metallicity"]
elif constant_metallicity is not None:
my_Z = constant_metallicity
my_emissivity += my_Z * np.power(10, em_Z(dd))
- return data["H_NumberDensity"]**2 * my_emissivity
+ return data["gas","H_number_density"]**2 * YTArray(my_emissivity, "erg*cm**3/s")
- field_name = "Xray_Emissivity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_emissivity_field,
- projection_conversion="cm",
- display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{erg}\/\rm{cm}^{-3}\/\rm{s}^{-1}")
- return field_name
-
-def add_xray_luminosity_field(e_min, e_max, filename=None,
- with_metals=True,
- constant_metallicity=None):
- r"""Create an X-ray luminosity field for a given energy range.
-
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
-
- Other Parameters
- ----------------
- filename: string
- Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
- Default: None.
- with_metals: bool
- If True, use the metallicity field to add the contribution from
- metals. If False, only the emission from H/He is considered.
- Default: True.
- constant_metallicity: float
- If specified, assume a constant metallicity for the emission
- from metals. The *with_metals* keyword must be set to False
- to use this.
- Default: None.
-
- This will create a field named "Xray_Luminosity_{e_min}_{e_max}keV".
- The units of the field are erg s^-1.
-
- Examples
- --------
-
- >>> from yt.mods import *
- >>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_luminosity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> sp = pf.sphere('max', (2., 'mpc'))
- >>> print sp.quantities['TotalQuantity']('Xray_Luminosity_0.5_2keV')
-
- """
-
- em_field = add_xray_emissivity_field(e_min, e_max, filename=filename,
- with_metals=with_metals,
- constant_metallicity=constant_metallicity)
+ emiss_name = "xray_emissivity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(emiss_name, function=_emissivity_field,
+ display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="erg/cm**3/s")
def _luminosity_field(field, data):
- return data[em_field] * data["CellVolume"]
- field_name = "Xray_Luminosity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_luminosity_field,
- display_name=r"\rm{L}_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{erg}\/\rm{s}^{-1}")
- return field_name
+ return data[emiss_name] * data["cell_volume"]
-def add_xray_photon_emissivity_field(e_min, e_max, filename=None,
- with_metals=True,
- constant_metallicity=None):
- r"""Create an X-ray photon emissivity field for a given energy range.
+ lum_name = "xray_luminosity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(lum_name, function=_luminosity_field,
+ display_name=r"\rm{L}_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="erg/s")
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
+ def _photon_emissivity_field(field, data):
+ dd = {"log_nH" : np.log10(data["gas","H_number_density"]),
+ "log_T" : np.log10(data["gas","temperature"])}
- Other Parameters
- ----------------
- filename: string
- Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
- Default: None.
- with_metals: bool
- If True, use the metallicity field to add the contribution from
- metals. If False, only the emission from H/He is considered.
- Default: True.
- constant_metallicity: float
- If specified, assume a constant metallicity for the emission
- from metals. The *with_metals* keyword must be set to False
- to use this.
- Default: None.
-
- This will create a field named "Xray_Photon_Emissivity_{e_min}_{e_max}keV".
- The units of the field are photons s^-1 cm^-3.
-
- Examples
- --------
-
- >>> from yt.mods import *
- >>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_emissivity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> p = ProjectionPlot(pf, 'x', "Xray_Emissivity_0.5_2keV")
- >>> p.save()
-
- """
-
- my_si = EmissivityIntegrator(filename=filename)
- energy_erg = np.power(10, my_si.log_E) * erg_per_eV
-
- em_0 = my_si._get_interpolator((my_si.emissivity_primordial[..., :] / energy_erg),
- e_min, e_max)
- em_Z = None
- if with_metals or constant_metallicity is not None:
- em_Z = my_si._get_interpolator((my_si.emissivity_metals[..., :] / energy_erg),
- e_min, e_max)
-
- def _emissivity_field(field, data):
- dd = {"log_nH" : np.log10(data["H_NumberDensity"]),
- "log_T" : np.log10(data["Temperature"])}
-
- my_emissivity = np.power(10, em_0(dd))
- if em_Z is not None:
+ my_emissivity = np.power(10, emp_0(dd))
+ if emp_Z is not None:
if with_metals:
- my_Z = data["Metallicity"]
+ my_Z = data["gas","metallicity"]
elif constant_metallicity is not None:
my_Z = constant_metallicity
- my_emissivity += my_Z * np.power(10, em_Z(dd))
+ my_emissivity += my_Z * np.power(10, emp_Z(dd))
- return data["H_NumberDensity"]**2 * my_emissivity
+ return data["gas","H_number_density"]**2 * YTArray(my_emissivity, "photons*cm**3/s")
- field_name = "Xray_Photon_Emissivity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_emissivity_field,
- projection_conversion="cm",
- display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{photons}\/\rm{cm}^{-3}\/\rm{s}^{-1}")
- return field_name
+ phot_name = "xray_photon_emissivity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(phot_name, function=_photon_emissivity_field,
+ display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="photons/cm**3/s")
+
+ return emiss_name, lum_name, phot_name
\ No newline at end of file
https://bitbucket.org/yt_analysis/yt/commits/7c34fc6776ff/
Changeset: 7c34fc6776ff
Branch: yt-3.0
User: jzuhone
Date: 2014-06-25 20:46:32
Summary: Adding ability to use an APEC file instead for a collisionally ionized plasma.
Affected #: 1 file
diff -r 07054af995f55b27a18440b9275304173d3a33e8 -r 7c34fc6776ff729b570eb5090b67e89cf6b58fb2 yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
--- a/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
+++ b/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
@@ -1,6 +1,6 @@
"""
Integrator classes to deal with interpolation and integration of input spectral
-bins. Currently only supports Cloudy-style data.
+bins. Currently only supports Cloudy and APEC-style data.
@@ -26,7 +26,7 @@
from yt.utilities.exceptions import YTFieldNotFound
from yt.utilities.exceptions import YTException
from yt.utilities.linear_interpolators import \
- BilinearFieldInterpolator
+ UnilinearFieldInterpolator, BilinearFieldInterpolator
from yt.utilities.physical_constants import \
hcgs, mp
from yt.units.yt_array import YTArray, YTQuantity
@@ -36,7 +36,7 @@
xray_data_version = 1
def _get_data_file():
- data_file = "xray_emissivity.h5"
+ data_file = "cloudy_emissivity.h5"
data_url = "http://yt-project.org/data"
if "YT_DEST" in os.environ and \
os.path.isdir(os.path.join(os.environ["YT_DEST"], "data")):
@@ -77,7 +77,7 @@
----------
filename: string, default None
Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
+ a file called "cloudy_emissivity.h5" is used. This file contains
emissivity tables for primordial elements and for metals at
solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
@@ -105,7 +105,8 @@
for field in ["emissivity_primordial", "emissivity_metals",
"log_nH", "log_T", "log_E"]:
- setattr(self, field, in_file[field][:])
+ if field in in_file:
+ setattr(self, field, in_file[field][:])
in_file.close()
E_diff = np.diff(self.log_E)
@@ -132,10 +133,17 @@
my_dnu[-1] -= ((self.E_bins[e_ie] - e_max)/hcgs).in_units("Hz")
interp_data = (data[..., e_is:e_ie] * my_dnu).sum(axis=-1)
- return BilinearFieldInterpolator(np.log10(interp_data),
- [self.log_nH[0], self.log_nH[-1],
- self.log_T[0], self.log_T[-1]],
- ["log_nH", "log_T"], truncate=True)
+ if len(data.shape) == 2:
+ emiss = UnilinearFieldInterpolator(np.log10(interp_data),
+ [self.log_T[0], self.log_T[-1]],
+ "log_T", truncate=True)
+ else:
+ emiss = BilinearFieldInterpolator(np.log10(interp_data),
+ [self.log_nH[0], self.log_nH[-1],
+ self.log_T[0], self.log_T[-1]],
+ ["log_nH", "log_T"], truncate=True)
+
+ return emiss
def add_xray_emissivity_field(ds, e_min, e_max,
filename=None,
https://bitbucket.org/yt_analysis/yt/commits/a71a9abbdd65/
Changeset: a71a9abbdd65
Branch: yt-3.0
User: jzuhone
Date: 2014-06-26 01:31:37
Summary: Updated docs
Affected #: 1 file
diff -r 7c34fc6776ff729b570eb5090b67e89cf6b58fb2 -r a71a9abbdd65c9f092cbaeaaed3b5c24f522bf34 doc/source/analyzing/analysis_modules/xray_emission_fields.rst
--- a/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
+++ b/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
@@ -2,39 +2,42 @@
X-ray Emission Fields
=====================
-.. sectionauthor:: Britton Smith <brittonsmith at gmail.com>
+.. sectionauthor:: Britton Smith <brittonsmith at gmail.com>, John ZuHone <jzuhone at gmail.com>
+
+.. note::
+
+ If you came here trying to figure out how to create simulated X-ray photons and observations,
+ you should go `here <photon_simulator.html>`_ instead.
This functionality provides the ability to create metallicity-dependent
-X-ray luminosity, emissivity, and photo emissivity fields for a given
+X-ray luminosity, emissivity, and photon emissivity fields for a given
photon energy range. This works by interpolating from emission tables
-created with the photoionization code, `Cloudy <http://nublado.org/>`_.
-If you installed yt with the install script, the data should be located in
-the *data* directory inside the installation directory. Emission fields can
-be made for any interval between 0.1 keV and 100 keV.
+created from the photoionization code `Cloudy <http://nublado.org/>`_ or
+the collisional ionization database `AtomDB <http://www.atomdb.org>`_. If
+you installed yt with the install script, the data should be located in
+the *data* directory inside the installation directory, or can be downloaded
+from `<http://yt-project.org/data>`_. Emission fields can be made for any
+interval between 0.1 keV and 100 keV.
Adding Emission Fields
----------------------
-Fields can be created for luminosity (erg/s), emissivity (erg/s/cm^3),
-and photon emissivity (photons/s/cm^3). The only required arguments are
-the minimum and maximum energies.
+Fields will be created for luminosity (erg/s), emissivity (erg/s/cm**3),
+and photon emissivity (photons/s/cm**3). The only required arguments are
+the dataset object, and the minimum and maximum energies of the band.
.. code-block:: python
- from yt.mods import *
+ import yt
from yt.analysis_modules.spectral_integrator.api import \
- add_xray_luminosity_field, \
- add_xray_emissivity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
- add_xray_luminosity_field(0.5, 7)
- add_xray_emissivity_field(0.5, 7)
- add_xray_photon_emissivity_field(0.5, 7)
+ xray_fields = add_xray_emissivity_field(0.5, 7.0)
Additional keyword arguments are:
- * **filename** (*string*): Path to data file containing emissivity
- values. If None, a file called xray_emissivity.h5 is used. This file
+ * **filename** (*string*): Path to data file containing emissivity
+ values. If None, a file called cloudy_emissivity.h5 is used. This file
contains emissivity tables for primordial elements and for metals at
solar metallicity for the energy range 0.1 to 100 keV. Default: None.
@@ -46,24 +49,27 @@
metallicity for the emission from metals. The *with_metals* keyword
must be set to False to use this. Default: None.
-The resulting fields can be used like all normal fields.
+The resulting fields can be used like all normal fields. The function will return the names of
+the created fields in a Python list.
.. python-script::
- from yt.mods import *
+ import yt
from yt.analysis_modules.spectral_integrator.api import \
- add_xray_luminosity_field, \
- add_xray_emissivity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
- add_xray_luminosity_field(0.5, 7)
- add_xray_emissivity_field(0.5, 7)
- add_xray_photon_emissivity_field(0.5, 7)
+ xray_fields = add_xray_emissivity_field(0.5, 7.0)
- pf = load("enzo_tiny_cosmology/DD0046/DD0046")
- plot = SlicePlot(pf, 'x', 'Xray_Luminosity_0.5_7keV')
+ ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+ plot = yt.SlicePlot(ds, 'x', 'xray_luminosity_0.5_7.0_keV')
plot.save()
- plot = ProjectionPlot(pf, 'x', 'Xray_Emissivity_0.5_7keV')
+ plot = yt.ProjectionPlot(ds, 'x', 'xray_emissivity_0.5_7.0_keV')
plot.save()
- plot = ProjectionPlot(pf, 'x', 'Xray_Photon_Emissivity_0.5_7keV')
+ plot = yt.ProjectionPlot(ds, 'x', 'xray_photon_emissivity_0.5_7.0_keV')
plot.save()
+
+.. warning::
+
+ The X-ray fields depend on the number density of hydrogen atoms, in the yt field
+ ``H_number_density``. If this field is not defined (either in the dataset or by the user),
+ the primordial hydrogen mass fraction (X = 0.76) will be used to construct it.
\ No newline at end of file
https://bitbucket.org/yt_analysis/yt/commits/a9cbfcd8868e/
Changeset: a9cbfcd8868e
Branch: yt-3.0
User: jzuhone
Date: 2014-06-28 06:13:00
Summary: Bug fixes
Affected #: 1 file
diff -r a71a9abbdd65c9f092cbaeaaed3b5c24f522bf34 -r a9cbfcd8868e3c25bfddbe0bd24fc7ceefe1853a yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -956,7 +956,7 @@
if isinstance(self.parameters["Area"], basestring):
mylog.error("Writing SIMPUT files is only supported if you didn't convolve with an ARF.")
- raise TypeError
+ raise TypeError("Writing SIMPUT files is only supported if you didn't convolve with an ARF.")
if emin is None:
emin = self.events["eobs"].min().value*0.95
@@ -1032,7 +1032,10 @@
f = h5py.File(h5file, "w")
f.create_dataset("/exp_time", data=float(self.parameters["ExposureTime"]))
- f.create_dataset("/area", data=float(self.parameters["Area"]))
+ area = self.parameters["Area"]
+ if not isinstance(area, basestring):
+ area = float(area)
+ f.create_dataset("/area", data=area)
f.create_dataset("/redshift", data=self.parameters["Redshift"])
f.create_dataset("/d_a", data=float(self.parameters["AngularDiameterDistance"]))
if "ARF" in self.parameters:
https://bitbucket.org/yt_analysis/yt/commits/34de820981ba/
Changeset: 34de820981ba
Branch: yt-3.0
User: jzuhone
Date: 2014-06-28 06:32:58
Summary: Fixing up docs
Affected #: 2 files
diff -r a9cbfcd8868e3c25bfddbe0bd24fc7ceefe1853a -r 34de820981ba190e500e0804521a13a0d27a75b5 doc/source/analyzing/analysis_modules/photon_simulator.rst
--- a/doc/source/analyzing/analysis_modules/photon_simulator.rst
+++ b/doc/source/analyzing/analysis_modules/photon_simulator.rst
@@ -1,6 +1,11 @@
Constructing Mock X-ray Observations
------------------------------------
+.. note::
+
+ If you just want to create derived fields for X-ray emission,
+ you should go `here <xray_emission_fields.html>`_ instead.
+
The ``photon_simulator`` analysis module enables the creation of
simulated X-ray photon lists of events from datasets that ``yt`` is able
to read. The simulated events then can be exported to X-ray telescope
diff -r a9cbfcd8868e3c25bfddbe0bd24fc7ceefe1853a -r 34de820981ba190e500e0804521a13a0d27a75b5 doc/source/analyzing/analysis_modules/xray_emission_fields.rst
--- a/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
+++ b/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
@@ -22,9 +22,9 @@
Adding Emission Fields
----------------------
-Fields will be created for luminosity (erg/s), emissivity (erg/s/cm**3),
-and photon emissivity (photons/s/cm**3). The only required arguments are
-the dataset object, and the minimum and maximum energies of the band.
+Fields will be created for luminosity :math:`{\rm (erg~s^{-1})}`, emissivity :math:`{\rm (erg~s^{-1}~cm^{-3})}`,
+and photon emissivity :math:`{\rm (photons~s^{-1}~cm^{-3})}`. The only required arguments are the
+dataset object, and the minimum and maximum energies of the energy band.
.. code-block:: python
@@ -52,7 +52,7 @@
The resulting fields can be used like all normal fields. The function will return the names of
the created fields in a Python list.
-.. python-script::
+.. code-block:: python
import yt
from yt.analysis_modules.spectral_integrator.api import \
https://bitbucket.org/yt_analysis/yt/commits/2fad8a4dbdd7/
Changeset: 2fad8a4dbdd7
Branch: yt-3.0
User: jzuhone
Date: 2014-06-28 18:10:02
Summary: Changing name of file
Affected #: 1 file
diff -r 34de820981ba190e500e0804521a13a0d27a75b5 -r 2fad8a4dbdd7f4d309398c26a2dac4b8407da393 doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -567,8 +567,8 @@
mkdir -p ${DEST_DIR}/data
cd ${DEST_DIR}/data
-echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 xray_emissivity.h5' > xray_emissivity.h5.sha512
-get_ytdata xray_emissivity.h5
+echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 xray_emissivity.h5' > cloudy_emissivity.h5.sha512
+get_ytdata cloudy_emissivity.h5
# Set paths to what they should be when yt is activated.
export PATH=${DEST_DIR}/bin:$PATH
https://bitbucket.org/yt_analysis/yt/commits/a75dfa57a6ff/
Changeset: a75dfa57a6ff
Branch: yt-3.0
User: jzuhone
Date: 2014-06-28 18:35:04
Summary: Adding apec_emissivity.h5 to the install script
Affected #: 2 files
diff -r 2fad8a4dbdd7f4d309398c26a2dac4b8407da393 -r a75dfa57a6ff01658829294adad8bbd18c4f7486 doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -567,8 +567,10 @@
mkdir -p ${DEST_DIR}/data
cd ${DEST_DIR}/data
-echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 xray_emissivity.h5' > cloudy_emissivity.h5.sha512
+echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 cloudy_emissivity.h5' > cloudy_emissivity.h5.sha512
get_ytdata cloudy_emissivity.h5
+echo '0f714ae2eace0141b1381abf1160dc8f8a521335e886f99919caf3beb31df1fe271d67c7b2a804b1467949eb16b0ef87a3d53abad0e8160fccac1e90d8d9e85f apec_emissivity.h5' > apec_emissivity.h5.sha512
+get_ytdata apec_emissivity.h5
# Set paths to what they should be when yt is activated.
export PATH=${DEST_DIR}/bin:$PATH
diff -r 2fad8a4dbdd7f4d309398c26a2dac4b8407da393 -r a75dfa57a6ff01658829294adad8bbd18c4f7486 doc/source/analyzing/analysis_modules/photon_simulator.rst
--- a/doc/source/analyzing/analysis_modules/photon_simulator.rst
+++ b/doc/source/analyzing/analysis_modules/photon_simulator.rst
@@ -3,7 +3,7 @@
.. note::
- If you just want to create derived fields for X-ray emission,
+ If you just want to create derived fields for X-ray emission,
you should go `here <xray_emission_fields.html>`_ instead.
The ``photon_simulator`` analysis module enables the creation of
https://bitbucket.org/yt_analysis/yt/commits/6dae3842fe6c/
Changeset: 6dae3842fe6c
Branch: yt-3.0
User: jzuhone
Date: 2014-06-28 18:38:05
Summary: Merge
Affected #: 119 files
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -568,9 +568,9 @@
mkdir -p ${DEST_DIR}/data
cd ${DEST_DIR}/data
echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 cloudy_emissivity.h5' > cloudy_emissivity.h5.sha512
-get_ytdata cloudy_emissivity.h5
+[ ! -e cloudy_emissivity.h5 ] && get_ytdata cloudy_emissivity.h5
echo '0f714ae2eace0141b1381abf1160dc8f8a521335e886f99919caf3beb31df1fe271d67c7b2a804b1467949eb16b0ef87a3d53abad0e8160fccac1e90d8d9e85f apec_emissivity.h5' > apec_emissivity.h5.sha512
-get_ytdata apec_emissivity.h5
+[ ! -e apec_emissivity.h5 ] && get_ytdata apec_emissivity.h5
# Set paths to what they should be when yt is activated.
export PATH=${DEST_DIR}/bin:$PATH
@@ -610,7 +610,6 @@
echo '3f53d0b474bfd79fea2536d0a9197eaef6c0927e95f2f9fd52dbd6c1d46409d0e649c21ac418d8f7767a9f10fe6114b516e06f2be4b06aec3ab5bdebc8768220 Forthon-0.8.11.tar.gz' > Forthon-0.8.11.tar.gz.sha512
echo '4941f5aa21aff3743546495fb073c10d2657ff42b2aff401903498638093d0e31e344cce778980f28a7170c6d29eab72ac074277b9d4088376e8692dc71e55c1 PyX-0.12.1.tar.gz' > PyX-0.12.1.tar.gz.sha512
echo '3df0ba4b1cfef5f02fb27925de4c2ca414eca9000af6a3d475d39063720afe987287c3d51377e0a36b88015573ef699f700782e1749c7a357b8390971d858a79 Python-2.7.6.tgz' > Python-2.7.6.tgz.sha512
-echo '172f2bc671145ebb0add2669c117863db35851fb3bdb192006cd710d4d038e0037497eb39a6d01091cb923f71a7e8982a77b6e80bf71d6275d5d83a363c8d7e5 rockstar-0.99.6.tar.gz' > rockstar-0.99.6.tar.gz.sha512
echo '276bd9c061ec9a27d478b33078a86f93164ee2da72210e12e2c9da71dcffeb64767e4460b93f257302b09328eda8655e93c4b9ae85e74472869afbeae35ca71e blas.tar.gz' > blas.tar.gz.sha512
echo '00ace5438cfa0c577e5f578d8a808613187eff5217c35164ffe044fbafdfec9e98f4192c02a7d67e01e5a5ccced630583ad1003c37697219b0f147343a3fdd12 bzip2-1.0.6.tar.gz' > bzip2-1.0.6.tar.gz.sha512
echo 'a296dfcaef7e853e58eed4e24b37c4fa29cfc6ac688def048480f4bb384b9e37ca447faf96eec7b378fd764ba291713f03ac464581d62275e28eb2ec99110ab6 reason-js-20120623.zip' > reason-js-20120623.zip.sha512
@@ -626,7 +625,6 @@
echo 'd58177f3971b6d07baf6f81a2088ba371c7e43ea64ee7ada261da97c6d725b4bd4927122ac373c55383254e4e31691939276dab08a79a238bfa55172a3eff684 numpy-1.7.1.tar.gz' > numpy-1.7.1.tar.gz.sha512
echo '9c0a61299779aff613131aaabbc255c8648f0fa7ab1806af53f19fbdcece0c8a68ddca7880d25b926d67ff1b9201954b207919fb09f6a290acb078e8bbed7b68 python-hglib-1.0.tar.gz' > python-hglib-1.0.tar.gz.sha512
echo 'c65013293dd4049af5db009fdf7b6890a3c6b1e12dd588b58fb5f5a5fef7286935851fb7a530e03ea16f28de48b964e50f48bbf87d34545fd23b80dd4380476b pyzmq-13.1.0.tar.gz' > pyzmq-13.1.0.tar.gz.sha512
-echo '172f2bc671145ebb0add2669c117863db35851fb3bdb192006cd710d4d038e0037497eb39a6d01091cb923f71a7e8982a77b6e80bf71d6275d5d83a363c8d7e5 rockstar-0.99.6.tar.gz' > rockstar-0.99.6.tar.gz.sha512
echo '80c8e137c3ccba86575d4263e144ba2c4684b94b5cd620e200f094c92d4e118ea6a631d27bdb259b0869771dfaeeae68c0fdd37fdd740b9027ee185026e921d4 scipy-0.12.0.tar.gz' > scipy-0.12.0.tar.gz.sha512
echo '96f3e51b46741450bc6b63779c10ebb4a7066860fe544385d64d1eda52592e376a589ef282ace2e1df73df61c10eab1a0d793abbdaf770e60289494d4bf3bcb4 sqlite-autoconf-3071700.tar.gz' > sqlite-autoconf-3071700.tar.gz.sha512
echo '2992baa3edfb4e1842fb642abf0bf0fc0bf56fc183aab8fed6b3c42fbea928fa110ede7fdddea2d63fc5953e8d304b04da433dc811134fadefb1eecc326121b8 sympy-0.7.3.tar.gz' > sympy-0.7.3.tar.gz.sha512
@@ -659,7 +657,6 @@
get_ytproject $NOSE.tar.gz
get_ytproject $PYTHON_HGLIB.tar.gz
get_ytproject $SYMPY.tar.gz
-get_ytproject $ROCKSTAR.tar.gz
if [ $INST_BZLIB -eq 1 ]
then
if [ ! -e $BZLIB/done ]
@@ -818,6 +815,7 @@
YT_DIR=`dirname $ORIG_PWD`
elif [ ! -e yt-hg ]
then
+ echo "Cloning yt"
YT_DIR="$PWD/yt-hg/"
( ${HG_EXEC} --debug clone https://bitbucket.org/yt_analysis/yt-supplemental/ 2>&1 ) 1>> ${LOG_FILE}
# Recently the hg server has had some issues with timeouts. In lieu of
@@ -826,9 +824,9 @@
( ${HG_EXEC} --debug clone https://bitbucket.org/yt_analysis/yt/ ./yt-hg 2>&1 ) 1>> ${LOG_FILE}
# Now we update to the branch we're interested in.
( ${HG_EXEC} -R ${YT_DIR} up -C ${BRANCH} 2>&1 ) 1>> ${LOG_FILE}
- elif [ -e yt-3.0-hg ]
+ elif [ -e yt-hg ]
then
- YT_DIR="$PWD/yt-3.0-hg/"
+ YT_DIR="$PWD/yt-hg/"
fi
echo Setting YT_DIR=${YT_DIR}
fi
@@ -945,14 +943,19 @@
# Now we build Rockstar and set its environment variable.
if [ $INST_ROCKSTAR -eq 1 ]
then
- if [ ! -e Rockstar/done ]
+ if [ ! -e rockstar/done ]
then
- [ ! -e Rockstar ] && tar xfz $ROCKSTAR.tar.gz
echo "Building Rockstar"
- cd Rockstar
+ if [ ! -e rockstar ]
+ then
+ ( hg clone http://bitbucket.org/MatthewTurk/rockstar 2>&1 ) 1>> ${LOG_FILE}
+ fi
+ cd rockstar
+ ( hg pull 2>&1 ) 1>> ${LOG_FILE}
+ ( hg up -C tip 2>&1 ) 1>> ${LOG_FILE}
( make lib 2>&1 ) 1>> ${LOG_FILE} || do_exit
cp librockstar.so ${DEST_DIR}/lib
- ROCKSTAR_DIR=${DEST_DIR}/src/Rockstar
+ ROCKSTAR_DIR=${DEST_DIR}/src/rockstar
echo $ROCKSTAR_DIR > ${YT_DIR}/rockstar.cfg
touch done
cd ..
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/bootcamp/1)_Introduction.ipynb
--- a/doc/source/bootcamp/1)_Introduction.ipynb
+++ b/doc/source/bootcamp/1)_Introduction.ipynb
@@ -1,6 +1,7 @@
{
"metadata": {
- "name": ""
+ "name": "",
+ "signature": "sha256:39620670ce7751b23f30d2123fd3598de1c7843331f65de13e29f4ae9f759e0f"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -32,9 +33,40 @@
"5. Derived Fields and Profiles (IsolatedGalaxy dataset)\n",
"6. Volume Rendering (IsolatedGalaxy dataset)"
]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The following code will download the data needed for this tutorial automatically using `curl`. It may take some time so please wait when the kernel is busy. You will need to set `download_datasets` to True before using it."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "download_datasets = False\n",
+ "if download_datasets:\n",
+ " !curl -sSO http://yt-project.org/data/enzo_tiny_cosmology.tar\n",
+ " print \"Got enzo_tiny_cosmology\"\n",
+ " !tar xf enzo_tiny_cosmology.tar\n",
+ " \n",
+ " !curl -sSO http://yt-project.org/data/Enzo_64.tar\n",
+ " print \"Got Enzo_64\"\n",
+ " !tar xf Enzo_64.tar\n",
+ " \n",
+ " !curl -sSO http://yt-project.org/data/IsolatedGalaxy.tar\n",
+ " print \"Got IsolatedGalaxy\"\n",
+ " !tar xf IsolatedGalaxy.tar\n",
+ " \n",
+ " print \"All done!\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
}
],
"metadata": {}
}
]
-}
+}
\ No newline at end of file
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/bootcamp/2)_Data_Inspection.ipynb
--- a/doc/source/bootcamp/2)_Data_Inspection.ipynb
+++ b/doc/source/bootcamp/2)_Data_Inspection.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:15cdc35ddb8b1b938967237e17534149f734f4e7a61ebd37d74b675f8059da20"
+ "signature": "sha256:9d67e9e4ca5ce92dcd0658025dbfbd28be47b47ca8d4531fdac16cc2c2fa038b"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -21,7 +21,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "from yt.mods import *"
+ "import yt"
],
"language": "python",
"metadata": {},
@@ -38,7 +38,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "ds = load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")"
+ "ds = yt.load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")"
],
"language": "python",
"metadata": {},
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/bootcamp/3)_Simple_Visualization.ipynb
--- a/doc/source/bootcamp/3)_Simple_Visualization.ipynb
+++ b/doc/source/bootcamp/3)_Simple_Visualization.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:eb5fbf5eb55a9c8997c687f072c8c6030e74bef0048a72b4f74a06893c11b80a"
+ "signature": "sha256:c00ba7fdbbd9ea957d06060ad70f06f629b1fd4ebf5379c1fdad2697ab0a4cd6"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -21,7 +21,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "from yt.mods import *"
+ "import yt"
],
"language": "python",
"metadata": {},
@@ -38,7 +38,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "ds = load(\"enzo_tiny_cosmology/DD0046/DD0046\")\n",
+ "ds = yt.load(\"enzo_tiny_cosmology/DD0046/DD0046\")\n",
"print \"Redshift =\", ds.current_redshift"
],
"language": "python",
@@ -58,7 +58,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "p = ProjectionPlot(ds, \"y\", \"density\")\n",
+ "p = yt.ProjectionPlot(ds, \"y\", \"density\")\n",
"p.show()"
],
"language": "python",
@@ -135,7 +135,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "p = ProjectionPlot(ds, \"z\", [\"density\", \"temperature\"], weight_field=\"density\")\n",
+ "p = yt.ProjectionPlot(ds, \"z\", [\"density\", \"temperature\"], weight_field=\"density\")\n",
"p.show()"
],
"language": "python",
@@ -189,8 +189,8 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "ds = load(\"Enzo_64/DD0043/data0043\")\n",
- "s = SlicePlot(ds, \"z\", [\"density\", \"velocity_magnitude\"], center=\"max\")\n",
+ "ds = yt.load(\"Enzo_64/DD0043/data0043\")\n",
+ "s = yt.SlicePlot(ds, \"z\", [\"density\", \"velocity_magnitude\"], center=\"max\")\n",
"s.set_cmap(\"velocity_magnitude\", \"kamae\")\n",
"s.zoom(10.0)"
],
@@ -243,7 +243,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "s = SlicePlot(ds, \"x\", [\"density\"], center=\"max\")\n",
+ "s = yt.SlicePlot(ds, \"x\", [\"density\"], center=\"max\")\n",
"s.annotate_contour(\"temperature\")\n",
"s.zoom(2.5)"
],
@@ -272,4 +272,4 @@
"metadata": {}
}
]
-}
+}
\ No newline at end of file
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/bootcamp/4)_Data_Objects_and_Time_Series.ipynb
--- a/doc/source/bootcamp/4)_Data_Objects_and_Time_Series.ipynb
+++ b/doc/source/bootcamp/4)_Data_Objects_and_Time_Series.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:41293a66cd6fd5eae6da2d0343549144dc53d72e83286999faab3cf21d801f51"
+ "signature": "sha256:a46e1baa90d32045c2b524100f28bad41b3665249612c9a275ee0375a6f4be20"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -22,7 +22,8 @@
"collapsed": false,
"input": [
"%matplotlib inline\n",
- "from yt.mods import *\n",
+ "import yt\n",
+ "import numpy as np\n",
"from matplotlib import pylab\n",
"from yt.analysis_modules.halo_finding.api import HaloFinder"
],
@@ -45,7 +46,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "ts = DatasetSeries(\"enzo_tiny_cosmology/*/*.hierarchy\")"
+ "ts = yt.DatasetSeries(\"enzo_tiny_cosmology/*/*.hierarchy\")"
],
"language": "python",
"metadata": {},
@@ -87,8 +88,13 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "pylab.semilogy(times, rho_ex[:,0], '-xk')\n",
- "pylab.semilogy(times, rho_ex[:,1], '-xr')"
+ "pylab.semilogy(times, rho_ex[:,0], '-xk', label='Minimum')\n",
+ "pylab.semilogy(times, rho_ex[:,1], '-xr', label='Maximum')\n",
+ "pylab.ylabel(\"Density ($g/cm^3$)\")\n",
+ "pylab.xlabel(\"Time (Gyr)\")\n",
+ "pylab.legend()\n",
+ "pylab.ylim(1e-32, 1e-21)\n",
+ "pylab.show()"
],
"language": "python",
"metadata": {},
@@ -109,13 +115,15 @@
"cell_type": "code",
"collapsed": false,
"input": [
+ "from yt.units import Msun\n",
+ "\n",
"mass = []\n",
"zs = []\n",
"for ds in ts:\n",
" halos = HaloFinder(ds)\n",
" dd = ds.all_data()\n",
" total_mass = dd.quantities.total_quantity(\"cell_mass\").in_units(\"Msun\")\n",
- " total_in_baryons = 0.0\n",
+ " total_in_baryons = 0.0*Msun\n",
" for halo in halos:\n",
" sp = halo.get_sphere()\n",
" total_in_baryons += sp.quantities.total_quantity(\"cell_mass\").in_units(\"Msun\")\n",
@@ -137,7 +145,11 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "pylab.loglog(zs, mass, '-xb')"
+ "pylab.semilogx(zs, mass, '-xb')\n",
+ "pylab.xlabel(\"Redshift\")\n",
+ "pylab.ylabel(\"Mass in halos / Total mass\")\n",
+ "pylab.xlim(max(zs), min(zs))\n",
+ "pylab.ylim(-0.01, .18)"
],
"language": "python",
"metadata": {},
@@ -155,7 +167,9 @@
"\n",
"yt provides the ability to examine rays, or lines, through the domain. Note that these are not periodic, unlike most other data objects. We create a ray object and can then examine quantities of it. Rays have the special fields `t` and `dts`, which correspond to the time the ray enters a given cell and the distance it travels through that cell.\n",
"\n",
- "To create a ray, we specify the start and end points."
+ "To create a ray, we specify the start and end points.\n",
+ "\n",
+ "Note that we need to convert these arrays to numpy arrays due to a bug in matplotlib 1.3.1."
]
},
{
@@ -163,7 +177,7 @@
"collapsed": false,
"input": [
"ray = ds.ray([0.1, 0.2, 0.3], [0.9, 0.8, 0.7])\n",
- "pylab.semilogy(ray[\"t\"], ray[\"density\"])"
+ "pylab.semilogy(np.array(ray[\"t\"]), np.array(ray[\"density\"]))"
],
"language": "python",
"metadata": {},
@@ -212,10 +226,12 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "ds = load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")\n",
+ "ds = yt.load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")\n",
"v, c = ds.find_max(\"density\")\n",
"sl = ds.slice(0, c[0])\n",
- "print sl[\"index\", \"x\"], sl[\"index\", \"z\"], sl[\"pdx\"]\n",
+ "print sl[\"index\", \"x\"]\n",
+ "print sl[\"index\", \"z\"]\n",
+ "print sl[\"pdx\"]\n",
"print sl[\"gas\", \"density\"].shape"
],
"language": "python",
@@ -251,8 +267,8 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "write_image(np.log10(frb[\"gas\", \"density\"]), \"temp.png\")\n",
- "from IPython.core.display import Image\n",
+ "yt.write_image(np.log10(frb[\"gas\", \"density\"]), \"temp.png\")\n",
+ "from IPython.display import Image\n",
"Image(filename = \"temp.png\")"
],
"language": "python",
@@ -275,7 +291,7 @@
"collapsed": false,
"input": [
"cp = ds.cutting([0.2, 0.3, 0.5], \"max\")\n",
- "pw = cp.to_pw(fields = [\"density\"])"
+ "pw = cp.to_pw(fields = [(\"gas\", \"density\")])"
],
"language": "python",
"metadata": {},
@@ -310,7 +326,8 @@
"collapsed": false,
"input": [
"pws = sl.to_pw(fields=[\"density\"])\n",
- "pws.show()"
+ "#pws.show()\n",
+ "print pws.plots.keys()"
],
"language": "python",
"metadata": {},
@@ -362,4 +379,4 @@
"metadata": {}
}
]
-}
+}
\ No newline at end of file
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/bootcamp/5)_Derived_Fields_and_Profiles.ipynb
--- a/doc/source/bootcamp/5)_Derived_Fields_and_Profiles.ipynb
+++ b/doc/source/bootcamp/5)_Derived_Fields_and_Profiles.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:a19d451f3b4dcfeed448caa22c2cac35c46958e0646c19c226b1e467b76d0718"
+ "signature": "sha256:eca573e749829cacda0a8c07c6d5d11d07a5de657563a44b8c4ffff8f735caed"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -22,7 +22,9 @@
"collapsed": false,
"input": [
"%matplotlib inline\n",
- "from yt.mods import *\n",
+ "import yt\n",
+ "import numpy as np\n",
+ "from yt import derived_field\n",
"from matplotlib import pylab"
],
"language": "python",
@@ -61,7 +63,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "ds = load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")\n",
+ "ds = yt.load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")\n",
"dd = ds.all_data()\n",
"print dd.quantities.keys()"
],
@@ -120,7 +122,9 @@
"bv = sp.quantities.bulk_velocity()\n",
"L = sp.quantities.angular_momentum_vector()\n",
"rho_min, rho_max = sp.quantities.extrema(\"density\")\n",
- "print bv, L, rho_min, rho_max"
+ "print bv\n",
+ "print L\n",
+ "print rho_min, rho_max"
],
"language": "python",
"metadata": {},
@@ -143,9 +147,11 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "prof = Profile1D(sp, \"density\", 32, rho_min, rho_max, True, weight_field=\"cell_mass\")\n",
+ "prof = yt.Profile1D(sp, \"density\", 32, rho_min, rho_max, True, weight_field=\"cell_mass\")\n",
"prof.add_fields([\"temperature\",\"dinosaurs\"])\n",
- "pylab.loglog(np.array(prof.x), np.array(prof[\"temperature\"]), \"-x\")"
+ "pylab.loglog(np.array(prof.x), np.array(prof[\"temperature\"]), \"-x\")\n",
+ "pylab.xlabel('Density $(g/cm^3)$')\n",
+ "pylab.ylabel('Temperature $(K)$')"
],
"language": "python",
"metadata": {},
@@ -162,7 +168,9 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "pylab.loglog(np.array(prof.x), np.array(prof[\"dinosaurs\"]), '-x')"
+ "pylab.loglog(np.array(prof.x), np.array(prof[\"dinosaurs\"]), '-x')\n",
+ "pylab.xlabel('Density $(g/cm^3)$')\n",
+ "pylab.ylabel('Dinosaurs $(K cm / s)$')"
],
"language": "python",
"metadata": {},
@@ -179,9 +187,30 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "prof = Profile1D(sp, \"density\", 32, rho_min, rho_max, True, weight_field=None)\n",
+ "prof = yt.Profile1D(sp, \"density\", 32, rho_min, rho_max, True, weight_field=None)\n",
"prof.add_fields([\"cell_mass\"])\n",
- "pylab.loglog(np.array(prof.x), np.array(prof[\"cell_mass\"].in_units(\"Msun\")), '-x')"
+ "pylab.loglog(np.array(prof.x), np.array(prof[\"cell_mass\"].in_units(\"Msun\")), '-x')\n",
+ "pylab.xlabel('Density $(g/cm^3)$')\n",
+ "pylab.ylabel('Cell mass $(M_\\odot)$')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "In addition to the low-level `ProfileND` interface, it's also quite straightforward to quickly create plots of profiles using the `ProfilePlot` class. Let's redo the last plot using `ProfilePlot`"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "prof = yt.ProfilePlot(sp, 'density', 'cell_mass', weight_field=None)\n",
+ "prof.set_unit('cell_mass', 'Msun')\n",
+ "prof.show()"
],
"language": "python",
"metadata": {},
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/bootcamp/6)_Volume_Rendering.ipynb
--- a/doc/source/bootcamp/6)_Volume_Rendering.ipynb
+++ b/doc/source/bootcamp/6)_Volume_Rendering.ipynb
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
- "signature": "sha256:2929940fc3977b495aa124dee851f7602d61e073ed65407dd95e7cf597684b35"
+ "signature": "sha256:2a24bbe82955f9d948b39cbd1b1302968ff57f62f73afb2c7a5c4953393d00ae"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -21,8 +21,8 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "from yt.mods import *\n",
- "ds = load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")"
+ "import yt\n",
+ "ds = yt.load(\"IsolatedGalaxy/galaxy0030/galaxy0030\")"
],
"language": "python",
"metadata": {},
@@ -43,7 +43,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "tf = ColorTransferFunction((-28, -24))\n",
+ "tf = yt.ColorTransferFunction((-28, -24))\n",
"tf.add_layers(4, w=0.01)\n",
"cam = ds.camera([0.5, 0.5, 0.5], [1.0, 1.0, 1.0], (20, 'kpc'), 512, tf, fields=[\"density\"])\n",
"cam.show()"
@@ -80,7 +80,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "tf = ColorTransferFunction((-28, -25))\n",
+ "tf = yt.ColorTransferFunction((-28, -25))\n",
"tf.add_layers(4, w=0.03)\n",
"cam = ds.camera([0.5, 0.5, 0.5], [1.0, 1.0, 1.0], (20.0, 'kpc'), 512, tf, no_ghost=False)\n",
"cam.show(clip_ratio=4.0)"
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/aligned_cutting_plane.py
--- a/doc/source/cookbook/aligned_cutting_plane.py
+++ b/doc/source/cookbook/aligned_cutting_plane.py
@@ -1,18 +1,20 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
import yt
# Load the dataset.
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
-# Create a 1 kpc radius sphere, centered on the maximum gas density. Note
-# that this sphere is very small compared to the size of our final plot,
-# and it has a non-axially aligned L vector.
-sp = ds.sphere("m", (1.0, "kpc"))
+# Create a 15 kpc radius sphere, centered on the center of the sim volume
+sp = ds.sphere("center", (15.0, "kpc"))
# Get the angular momentum vector for the sphere.
L = sp.quantities.angular_momentum_vector()
print "Angular momentum vector: {0}".format(L)
-# Create an OffAxisSlicePlot on the object with the L vector as its normal
-p = yt.OffAxisSlicePlot(ds, L, "density", sp.center, (15, "kpc"))
+# Create an OffAxisSlicePlot of density centered on the object with the L
+# vector as its normal and a width of 25 kpc on a side
+p = yt.OffAxisSlicePlot(ds, L, "density", sp.center, (25, "kpc"))
p.save()
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/amrkdtree_downsampling.py
--- a/doc/source/cookbook/amrkdtree_downsampling.py
+++ b/doc/source/cookbook/amrkdtree_downsampling.py
@@ -1,3 +1,6 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
# Using AMRKDTree Homogenized Volumes to examine large datasets
# at lower resolution.
@@ -10,17 +13,17 @@
import yt
from yt.utilities.amr_kdtree.api import AMRKDTree
-# Load up a data and print out the maximum refinement level
+# Load up a dataset
ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
kd = AMRKDTree(ds)
-# Print out the total volume of all the bricks
-print kd.count_volume()
-# Print out the number of cells
-print kd.count_cells()
+
+# Print out specifics of KD Tree
+print "Total volume of all bricks = %i" % kd.count_volume()
+print "Total number of cells = %i" % kd.count_cells()
tf = yt.ColorTransferFunction((-30, -22))
-cam = ds.h.camera([0.5, 0.5, 0.5], [0.2, 0.3, 0.4], 0.10, 256,
+cam = ds.camera([0.5, 0.5, 0.5], [0.2, 0.3, 0.4], 0.10, 256,
tf, volume=kd)
tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5], colormap='RdBu_r')
cam.snapshot("v1.png", clip_ratio=6.0)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/average_value.py
--- a/doc/source/cookbook/average_value.py
+++ b/doc/source/cookbook/average_value.py
@@ -5,9 +5,10 @@
field = "temperature" # The field to average
weight = "cell_mass" # The weight for the average
-dd = ds.h.all_data() # This is a region describing the entire box,
- # but note it doesn't read anything in yet!
+ad = ds.all_data() # This is a region describing the entire box,
+ # but note it doesn't read anything in yet!
+
# We now use our 'quantities' call to get the average quantity
-average_value = dd.quantities["WeightedAverageQuantity"](field, weight)
+average_value = ad.quantities.weighted_average_quantity(field, weight)
-print "Average %s (weighted by %s) is %0.5e" % (field, weight, average_value)
+print "Average %s (weighted by %s) is %0.3e %s" % (field, weight, average_value, average_value.units)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/boolean_data_objects.py
--- a/doc/source/cookbook/boolean_data_objects.py
+++ b/doc/source/cookbook/boolean_data_objects.py
@@ -1,23 +1,32 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
import yt
ds = yt.load("Enzo_64/DD0043/data0043") # load data
-# Make a few data ojbects to start.
+# Make a few data ojbects to start. Two boxes and two spheres.
re1 = ds.region([0.5, 0.5, 0.5], [0.4, 0.4, 0.4], [0.6, 0.6, 0.6])
re2 = ds.region([0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [0.6, 0.6, 0.6])
sp1 = ds.sphere([0.5, 0.5, 0.5], 0.05)
sp2 = ds.sphere([0.1, 0.2, 0.3], 0.1)
+
# The "AND" operator. This will make a region identical to re2.
bool1 = ds.boolean([re1, "AND", re2])
xp = bool1["particle_position_x"]
+
# The "OR" operator. This will make a region identical to re1.
bool2 = ds.boolean([re1, "OR", re2])
+
# The "NOT" operator. This will make a region like re1, but with the corner
# that re2 covers cut out.
bool3 = ds.boolean([re1, "NOT", re2])
+
# Disjoint regions can be combined with the "OR" operator.
bool4 = ds.boolean([sp1, "OR", sp2])
+
# Find oddly-shaped overlapping regions.
bool5 = ds.boolean([re2, "AND", sp1])
+
# Nested logic with parentheses.
# This is re1 with the oddly-shaped region cut out.
bool6 = ds.boolean([re1, "NOT", "(", re1, "AND", sp1, ")"])
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/camera_movement.py
--- a/doc/source/cookbook/camera_movement.py
+++ b/doc/source/cookbook/camera_movement.py
@@ -1,11 +1,13 @@
-import numpy as np
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
import yt
+import numpy as np
# Follow the simple_volume_rendering cookbook for the first part of this.
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") # load data
-dd = ds.all_data()
-mi, ma = dd.quantities["Extrema"]("density")
+ad = ds.all_data()
+mi, ma = ad.quantities.extrema("density")
# Set up transfer function
tf = yt.ColorTransferFunction((np.log10(mi), np.log10(ma)))
@@ -40,4 +42,4 @@
# Zoom in by a factor of 10 over 5 frames
for i, snapshot in enumerate(cam.zoomin(10.0, 5, clip_ratio=8.0)):
snapshot.write_png('camera_movement_%04i.png' % frame)
- frame += 1
\ No newline at end of file
+ frame += 1
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/contours_on_slice.py
--- a/doc/source/cookbook/contours_on_slice.py
+++ b/doc/source/cookbook/contours_on_slice.py
@@ -1,13 +1,12 @@
import yt
# first add density contours on a density slice
-pf = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") # load data
-p = yt.SlicePlot(pf, "x", "density")
+ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
+p = yt.SlicePlot(ds, "x", "density")
p.annotate_contour("density")
p.save()
-# then add temperature contours on the same densty slice
-pf = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") # load data
-p = yt.SlicePlot(pf, "x", "density")
+# then add temperature contours on the same density slice
+p = yt.SlicePlot(ds, "x", "density")
p.annotate_contour("temperature")
-p.save(str(pf)+'_T_contour')
+p.save(str(ds)+'_T_contour')
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/extract_fixed_resolution_data.py
--- a/doc/source/cookbook/extract_fixed_resolution_data.py
+++ b/doc/source/cookbook/extract_fixed_resolution_data.py
@@ -8,21 +8,26 @@
level = 2
dims = ds.domain_dimensions * ds.refine_by**level
-# Now, we construct an object that describes the data region and structure we
-# want
-cube = ds.covering_grid(2, # The level we are willing to extract to; higher
- # levels than this will not contribute to the data!
+# We construct an object that describes the data region and structure we want
+# In this case, we want all data up to the maximum "level" of refinement
+# across the entire simulation volume. Higher levels than this will not
+# contribute to our covering grid.
+cube = ds.covering_grid(level,
left_edge=[0.0, 0.0, 0.0],
+ dims=dims,
# And any fields to preload (this is optional!)
- dims=dims,
fields=["density"])
# Now we open our output file using h5py
-# Note that we open with 'w' which will overwrite existing files!
+# Note that we open with 'w' (write), which will overwrite existing files!
f = h5py.File("my_data.h5", "w")
-# We create a dataset at the root note, calling it density...
+# We create a dataset at the root, calling it "density"
f.create_dataset("/density", data=cube["density"])
# We close our file
f.close()
+
+# If we want to then access this datacube in the h5 file, we can now...
+f = h5py.File("my_data.h5", "r")
+print f["density"].value
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/find_clumps.py
--- a/doc/source/cookbook/find_clumps.py
+++ b/doc/source/cookbook/find_clumps.py
@@ -1,3 +1,6 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
import numpy as np
import yt
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/fit_spectrum.py
--- a/doc/source/cookbook/fit_spectrum.py
+++ b/doc/source/cookbook/fit_spectrum.py
@@ -1,22 +1,21 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
import yt
from yt.analysis_modules.cosmological_observation.light_ray.api import LightRay
-from yt.analysis_modules.api import AbsorptionSpectrum
+from yt.analysis_modules.absorption_spectrum.api import AbsorptionSpectrum
from yt.analysis_modules.absorption_spectrum.api import generate_total_fit
# Define and add a field to simulate OVI based on a constant relationship to HI
-def _OVI_NumberDensity(field, data):
- return data['HI_NumberDensity']
+# Do *NOT* use this for science, because this is not how OVI actually behaves;
+# it is just an example.
+ at yt.derived_field(name='OVI_number_density', units='cm**-3')
+def _OVI_number_density(field, data):
+ return data['HI_NumberDensity']*2.0
-def _convertOVI(data):
- return 4.9E-4*.2
-yt.add_field('my_OVI_NumberDensity',
- function=_OVI_NumberDensity,
- convert_function=_convertOVI)
-
-
-# Define species andi associated parameters to add to continuum
+# Define species and associated parameters to add to continuum
# Parameters used for both adding the transition to the spectrum
# and for fitting
# Note that for single species that produce multiple lines
@@ -37,7 +36,7 @@
'init_N': 1E14}
OVI_parameters = {'name': 'OVI',
- 'field': 'my_OVI_NumberDensity',
+ 'field': 'OVI_number_density',
'f': [.1325, .06580],
'Gamma': [4.148E8, 4.076E8],
'wavelength': [1031.9261, 1037.6167],
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/free_free_field.py
--- a/doc/source/cookbook/free_free_field.py
+++ b/doc/source/cookbook/free_free_field.py
@@ -1,3 +1,6 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
import numpy as np
import yt
# Need to grab the proton mass from the constants database
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/global_phase_plots.py
--- a/doc/source/cookbook/global_phase_plots.py
+++ b/doc/source/cookbook/global_phase_plots.py
@@ -4,10 +4,10 @@
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
# This is an object that describes the entire box
-ad = ds.h.all_data()
+ad = ds.all_data()
-# We plot the average VelocityMagnitude (mass-weighted) in our object
-# as a function of Density and temperature
+# We plot the average velocity magnitude (mass-weighted) in our object
+# as a function of density and temperature
plot = yt.PhasePlot(ad, "density", "temperature", "velocity_magnitude")
# save the plot
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/halo_merger_tree.py
--- a/doc/source/cookbook/halo_merger_tree.py
+++ b/doc/source/cookbook/halo_merger_tree.py
@@ -1,3 +1,6 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
# This script demonstrates some of the halo merger tracking infrastructure,
# for tracking halos across multiple datadumps in a time series.
# Ultimately, it outputs an HDF5 file with the important quantities for the
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/halo_plotting.py
--- a/doc/source/cookbook/halo_plotting.py
+++ b/doc/source/cookbook/halo_plotting.py
@@ -1,16 +1,20 @@
-"""
-This is a mechanism for plotting circles representing identified particle halos
-on an image. For more information, see :ref:`halo_finding`.
-"""
-from yt.mods import * # set up our namespace
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
-data_pf = load("Enzo_64/RD0006/RedshiftOutput0006")
+import yt
+from yt.analysis_modules.halo_analysis.halo_catalog import HaloCatalog
-halo_pf = load('rockstar_halos/halos_0.0.bin')
+# Load the dataset
+ds = yt.load("Enzo_64/RD0006/RedshiftOutput0006")
-hc - HaloCatalog(halos_pf = halo_pf)
+# Load the halo list from a rockstar output for this dataset
+halos = yt.load('rockstar_halos/halos_0.0.bin')
+
+# Create the halo catalog from this halo list
+hc = HaloCatalog(halos_pf = halos)
hc.load()
-p = ProjectionPlot(pf, "x", "density")
+# Create a projection with the halos overplot on top
+p = yt.ProjectionPlot(ds, "x", "density")
p.annotate_halos(hc)
p.save()
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/halo_profiler.py
--- a/doc/source/cookbook/halo_profiler.py
+++ b/doc/source/cookbook/halo_profiler.py
@@ -1,3 +1,6 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
from yt.mods import *
from yt.analysis_modules.halo_profiler.api import *
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/hse_field.py
--- a/doc/source/cookbook/hse_field.py
+++ b/doc/source/cookbook/hse_field.py
@@ -1,11 +1,14 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
import numpy as np
import yt
# Define the components of the gravitational acceleration vector field by
# taking the gradient of the gravitational potential
-
-def _Grav_Accel_x(field, data):
+ at yt.derived_field(name='grav_accel_x', units='cm/s**2', take_log=False)
+def grav_accel_x(field, data):
# We need to set up stencils
@@ -19,13 +22,14 @@
gx -= data["gravitational_potential"][sl_left, 1:-1, 1:-1]/dx
new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')
+ dtype='float64')*gx.unit_array
new_field[1:-1, 1:-1, 1:-1] = -gx
return new_field
-def _Grav_Accel_y(field, data):
+ at yt.derived_field(name='grav_accel_y', units='cm/s**2', take_log=False)
+def grav_accel_y(field, data):
# We need to set up stencils
@@ -39,13 +43,14 @@
gy -= data["gravitational_potential"][1:-1, sl_left, 1:-1]/dy
new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')
+ dtype='float64')*gx.unit_array
new_field[1:-1, 1:-1, 1:-1] = -gy
return new_field
-def _Grav_Accel_z(field, data):
+ at yt.derived_field(name='grav_accel_z', units='cm/s**2', take_log=False)
+def grav_accel_z(field, data):
# We need to set up stencils
@@ -59,7 +64,7 @@
gz -= data["gravitational_potential"][1:-1, 1:-1, sl_left]/dz
new_field = np.zeros(data["gravitational_potential"].shape,
- dtype='float64')
+ dtype='float64')*gx.unit_array
new_field[1:-1, 1:-1, 1:-1] = -gz
return new_field
@@ -68,7 +73,8 @@
# Define the components of the pressure gradient field
-def _Grad_Pressure_x(field, data):
+ at yt.derived_field(name='grad_pressure_x', units='g/(cm*s)**2', take_log=False)
+def grad_pressure_x(field, data):
# We need to set up stencils
@@ -81,13 +87,14 @@
px = data["pressure"][sl_right, 1:-1, 1:-1]/dx
px -= data["pressure"][sl_left, 1:-1, 1:-1]/dx
- new_field = np.zeros(data["pressure"].shape, dtype='float64')
+ new_field = np.zeros(data["pressure"].shape, dtype='float64')*px.unit_array
new_field[1:-1, 1:-1, 1:-1] = px
return new_field
-def _Grad_Pressure_y(field, data):
+ at yt.derived_field(name='grad_pressure_y', units='g/(cm*s)**2', take_log=False)
+def grad_pressure_y(field, data):
# We need to set up stencils
@@ -100,13 +107,14 @@
py = data["pressure"][1:-1, sl_right, 1:-1]/dy
py -= data["pressure"][1:-1, sl_left, 1:-1]/dy
- new_field = np.zeros(data["pressure"].shape, dtype='float64')
+ new_field = np.zeros(data["pressure"].shape, dtype='float64')*px.unit_array
new_field[1:-1, 1:-1, 1:-1] = py
return new_field
-def _Grad_Pressure_z(field, data):
+ at yt.derived_field(name='grad_pressure_z', units='g/(cm*s)**2', take_log=False)
+def grad_pressure_z(field, data):
# We need to set up stencils
@@ -119,7 +127,7 @@
pz = data["pressure"][1:-1, 1:-1, sl_right]/dz
pz -= data["pressure"][1:-1, 1:-1, sl_left]/dz
- new_field = np.zeros(data["pressure"].shape, dtype='float64')
+ new_field = np.zeros(data["pressure"].shape, dtype='float64')*px.unit_array
new_field[1:-1, 1:-1, 1:-1] = pz
return new_field
@@ -127,8 +135,8 @@
# Define the "degree of hydrostatic equilibrium" field
-
-def _HSE(field, data):
+ at yt.derived_field(name='HSE', units=None, take_log=False)
+def HSE(field, data):
gx = data["density"]*data["Grav_Accel_x"]
gy = data["density"]*data["Grav_Accel_y"]
@@ -138,31 +146,10 @@
hy = data["Grad_Pressure_y"] - gy
hz = data["Grad_Pressure_z"] - gz
- h = np.sqrt((hx*hx+hy*hy+hz*hz)/(gx*gx+gy*gy+gz*gz))
+ h = np.sqrt((hx*hx+hy*hy+hz*hz)/(gx*gx+gy*gy+gz*gz))*gx.unit_array
return h
-# Now add the fields to the database
-
-yt.add_field("Grav_Accel_x", function=_Grav_Accel_x, take_log=False,
- validators=[yt.ValidateSpatial(1, ["gravitational_potential"])])
-
-yt.add_field("Grav_Accel_y", function=_Grav_Accel_y, take_log=False,
- validators=[yt.ValidateSpatial(1, ["gravitational_potential"])])
-
-yt.add_field("Grav_Accel_z", function=_Grav_Accel_z, take_log=False,
- validators=[yt.ValidateSpatial(1, ["gravitational_potential"])])
-
-yt.add_field("Grad_Pressure_x", function=_Grad_Pressure_x, take_log=False,
- validators=[yt.ValidateSpatial(1, ["pressure"])])
-
-yt.add_field("Grad_Pressure_y", function=_Grad_Pressure_y, take_log=False,
- validators=[yt.ValidateSpatial(1, ["pressure"])])
-
-yt.add_field("Grad_Pressure_z", function=_Grad_Pressure_z, take_log=False,
- validators=[yt.ValidateSpatial(1, ["pressure"])])
-
-yt.add_field("HSE", function=_HSE, take_log=False)
# Open two files, one at the beginning and the other at a later time when
# there's a lot of sloshing going on.
@@ -173,8 +160,8 @@
# Sphere objects centered at the cluster potential minimum with a radius
# of 200 kpc
-sphere_i = dsi.h.sphere(dsi.domain_center, (200, "kpc"))
-sphere_f = dsf.h.sphere(dsf.domain_center, (200, "kpc"))
+sphere_i = dsi.sphere(dsi.domain_center, (200, "kpc"))
+sphere_f = dsf.sphere(dsf.domain_center, (200, "kpc"))
# Average "degree of hydrostatic equilibrium" in these spheres
@@ -188,9 +175,9 @@
# of the two files
slc_i = yt.SlicePlot(dsi, 2, ["density", "HSE"], center=dsi.domain_center,
- width=(1.0, "mpc"))
+ width=(1.0, "Mpc"))
slc_f = yt.SlicePlot(dsf, 2, ["density", "HSE"], center=dsf.domain_center,
- width=(1.0, "mpc"))
+ width=(1.0, "Mpc"))
slc_i.save("initial")
slc_f.save("final")
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/image_background_colors.py
--- a/doc/source/cookbook/image_background_colors.py
+++ b/doc/source/cookbook/image_background_colors.py
@@ -1,21 +1,24 @@
-from yt.mods import *
-
# This shows how to save ImageArray objects, such as those returned from
# volume renderings, to pngs with varying backgrounds.
+import yt
+import numpy as np
+
# Lets make a fake "rendering" that has 4 channels and looks like a linear
# gradient from the bottom to top.
+
im = np.zeros([64,128,4])
for i in xrange(im.shape[0]):
for k in xrange(im.shape[2]):
im[i,:,k] = np.linspace(0.,10.*k, im.shape[1])
-im_arr = ImageArray(im)
+im_arr = yt.ImageArray(im)
# in this case you would have gotten im_arr from something like:
# im_arr = cam.snapshot()
# To save it with the default settings, we can just use write_png, where it
# rescales the image and uses a black background.
+
im_arr.write_png('standard.png')
# write_png accepts a background keyword argument that defaults to 'black'.
@@ -24,12 +27,8 @@
# white (1.,1.,1.,1.)
# None (0.,0.,0.,0.) <-- Transparent!
# any rgba list/array: [r,g,b,a], bounded by 0..1
+
im_arr.write_png('black_bg.png', background='black')
im_arr.write_png('white_bg.png', background='white')
im_arr.write_png('green_bg.png', background=[0.,1.,0.,1.])
im_arr.write_png('transparent_bg.png', background=None)
-
-
-
-
-
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/index.rst
--- a/doc/source/cookbook/index.rst
+++ b/doc/source/cookbook/index.rst
@@ -18,9 +18,6 @@
`here <http://yt-project.org/data/>`_, where you will find links to download
individual datasets.
-If you want to take a look at more complex recipes, or submit your own,
-check out the `yt Hub <http://hub.yt-project.org>`_.
-
.. note:: To contribute your own recipes, please follow the instructions
on how to contribute documentation code: :ref:`writing_documentation`.
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/light_cone_projection.py
--- a/doc/source/cookbook/light_cone_projection.py
+++ b/doc/source/cookbook/light_cone_projection.py
@@ -1,9 +1,13 @@
-from yt.mods import *
-from yt.analysis_modules.api import LightCone
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
+import yt
+from yt.analysis_modules.cosmological_observation.light_cone.light_cone import LightCone
# Create a LightCone object extending from z = 0 to z = 0.1
# with a 600 arcminute field of view and a resolution of
# 60 arcseconds.
+
# We have already set up the redshift dumps to be
# used for this, so we will not use any of the time
# data dumps.
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/light_cone_with_halo_mask.py
--- a/doc/source/cookbook/light_cone_with_halo_mask.py
+++ b/doc/source/cookbook/light_cone_with_halo_mask.py
@@ -1,7 +1,10 @@
-from yt.mods import *
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
-from yt.analysis_modules.api import LightCone
-from yt.analysis_modules.halo_profiler.api import *
+import yt
+
+from yt.analysis_modules.cosmological_observation.light_cone.light_cone import LightCone
+from yt.analysis_modules.halo_profiler.api import HaloProfiler
# Instantiate a light cone object as usual.
lc = LightCone('enzo_tiny_cosmology/32Mpc_32.enzo',
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/make_light_ray.py
--- a/doc/source/cookbook/make_light_ray.py
+++ b/doc/source/cookbook/make_light_ray.py
@@ -1,13 +1,16 @@
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
import os
import sys
-
-from yt.mods import *
-
-from yt.analysis_modules.halo_profiler.api import *
-from yt.analysis_modules.cosmological_observation.light_ray.api import \
+import yt
+from yt.analysis_modules.halo_profiler.api import HaloProfiler
+from yt.analysis_modules.cosmological_observation.light_ray.light_ray import \
LightRay
-if not os.path.isdir("LR"): os.mkdir('LR')
+# Create a directory for the light rays
+if not os.path.isdir("LR"):
+ os.mkdir('LR')
# Create a LightRay object extending from z = 0 to z = 0.1
# and use only the redshift dumps.
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/multi_plot_3x2_FRB.py
--- a/doc/source/cookbook/multi_plot_3x2_FRB.py
+++ b/doc/source/cookbook/multi_plot_3x2_FRB.py
@@ -1,12 +1,14 @@
-from yt.mods import * # set up our namespace
+import yt
+import numpy as np
+from yt.visualization.api import get_multi_plot
import matplotlib.colorbar as cb
from matplotlib.colors import LogNorm
fn = "Enzo_64/RD0006/RedshiftOutput0006" # parameter file to load
-
-pf = load(fn) # load data
-v, c = pf.h.find_max("density")
+# load data and get center value and center location as maximum density location
+ds = yt.load(fn)
+v, c = ds.find_max("density")
# set up our Fixed Resolution Buffer parameters: a width, resolution, and center
width = (1.0, 'unitary')
@@ -28,7 +30,7 @@
# over the columns, which will become axes of slicing.
plots = []
for ax in range(3):
- sli = pf.slice(ax, c[ax])
+ sli = ds.slice(ax, c[ax])
frb = sli.to_frb(width, res)
den_axis = axes[ax][0]
temp_axis = axes[ax][1]
@@ -39,11 +41,16 @@
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
- plots.append(den_axis.imshow(frb['density'], norm=LogNorm()))
+ # converting our fixed resolution buffers to NDarray so matplotlib can
+ # render them
+ dens = np.array(frb['density'])
+ temp = np.array(frb['temperature'])
+
+ plots.append(den_axis.imshow(dens, norm=LogNorm()))
plots[-1].set_clim((5e-32, 1e-29))
plots[-1].set_cmap("bds_highcontrast")
- plots.append(temp_axis.imshow(frb['temperature'], norm=LogNorm()))
+ plots.append(temp_axis.imshow(temp, norm=LogNorm()))
plots[-1].set_clim((1e3, 1e8))
plots[-1].set_cmap("hot")
@@ -60,4 +67,4 @@
cbar.set_label(t)
# And now we're done!
-fig.savefig("%s_3x2.png" % pf)
+fig.savefig("%s_3x2.png" % ds)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/multi_plot_slice_and_proj.py
--- a/doc/source/cookbook/multi_plot_slice_and_proj.py
+++ b/doc/source/cookbook/multi_plot_slice_and_proj.py
@@ -1,4 +1,5 @@
-from yt.mods import * # set up our namespace
+import yt
+import numpy as np
from yt.visualization.base_plot_types import get_multi_plot
import matplotlib.colorbar as cb
from matplotlib.colors import LogNorm
@@ -6,7 +7,7 @@
fn = "GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150" # parameter file to load
orient = 'horizontal'
-pf = load(fn) # load data
+ds = yt.load(fn) # load data
# There's a lot in here:
# From this we get a containing figure, a list-of-lists of axes into which we
@@ -17,12 +18,11 @@
# bw is the base-width in inches, but 4 is about right for most cases.
fig, axes, colorbars = get_multi_plot(3, 2, colorbar=orient, bw = 4)
-slc = pf.slice(2, 0.0, fields=["density","temperature","velocity_magnitude"],
- center=pf.domain_center)
-proj = pf.proj("density", 2, weight_field="density", center=pf.domain_center)
+slc = yt.SlicePlot(ds, 'z', fields=["density","temperature","velocity_magnitude"])
+proj = yt.ProjectionPlot(ds, 'z', "density", weight_field="density")
-slc_frb = slc.to_frb((1.0, "mpc"), 512)
-proj_frb = proj.to_frb((1.0, "mpc"), 512)
+slc_frb = slc.data_source.to_frb((1.0, "Mpc"), 512)
+proj_frb = proj.data_source.to_frb((1.0, "Mpc"), 512)
dens_axes = [axes[0][0], axes[1][0]]
temp_axes = [axes[0][1], axes[1][1]]
@@ -37,12 +37,22 @@
vax.xaxis.set_visible(False)
vax.yaxis.set_visible(False)
-plots = [dens_axes[0].imshow(slc_frb["density"], origin='lower', norm=LogNorm()),
- dens_axes[1].imshow(proj_frb["density"], origin='lower', norm=LogNorm()),
- temp_axes[0].imshow(slc_frb["temperature"], origin='lower'),
- temp_axes[1].imshow(proj_frb["temperature"], origin='lower'),
- vels_axes[0].imshow(slc_frb["velocity_magnitude"], origin='lower', norm=LogNorm()),
- vels_axes[1].imshow(proj_frb["velocity_magnitude"], origin='lower', norm=LogNorm())]
+# Converting our Fixed Resolution Buffers to numpy arrays so that matplotlib
+# can render them
+
+slc_dens = np.array(slc_frb['density'])
+proj_dens = np.array(proj_frb['density'])
+slc_temp = np.array(slc_frb['temperature'])
+proj_temp = np.array(proj_frb['temperature'])
+slc_vel = np.array(slc_frb['velocity_magnitude'])
+proj_vel = np.array(proj_frb['velocity_magnitude'])
+
+plots = [dens_axes[0].imshow(slc_dens, origin='lower', norm=LogNorm()),
+ dens_axes[1].imshow(proj_dens, origin='lower', norm=LogNorm()),
+ temp_axes[0].imshow(slc_temp, origin='lower'),
+ temp_axes[1].imshow(proj_temp, origin='lower'),
+ vels_axes[0].imshow(slc_vel, origin='lower', norm=LogNorm()),
+ vels_axes[1].imshow(proj_vel, origin='lower', norm=LogNorm())]
plots[0].set_clim((1.0e-27,1.0e-25))
plots[0].set_cmap("bds_highcontrast")
@@ -58,12 +68,12 @@
plots[5].set_cmap("gist_rainbow")
titles=[r'$\mathrm{Density}\ (\mathrm{g\ cm^{-3}})$',
- r'$\mathrm{temperature}\ (\mathrm{K})$',
- r'$\mathrm{VelocityMagnitude}\ (\mathrm{cm\ s^{-1}})$']
+ r'$\mathrm{Temperature}\ (\mathrm{K})$',
+ r'$\mathrm{Velocity Magnitude}\ (\mathrm{cm\ s^{-1}})$']
for p, cax, t in zip(plots[0:6:2], colorbars, titles):
cbar = fig.colorbar(p, cax=cax, orientation=orient)
cbar.set_label(t)
# And now we're done!
-fig.savefig("%s_3x2" % pf)
+fig.savefig("%s_3x2" % ds)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/multi_width_image.py
--- a/doc/source/cookbook/multi_width_image.py
+++ b/doc/source/cookbook/multi_width_image.py
@@ -1,15 +1,16 @@
-from yt.mods import *
+import yt
# Load the dataset.
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
# Create a slice plot for the dataset. With no additional arguments,
# the width will be the size of the domain and the center will be the
# center of the simulation box
-slc = SlicePlot(pf,2,'density')
+slc = yt.SlicePlot(ds, 'z', 'density')
-# Create a list of a couple of widths and units.
-widths = [(1, 'mpc'),
+# Create a list of a couple of widths and units.
+# (N.B. Mpc (megaparsec) != mpc (milliparsec)
+widths = [(1, 'Mpc'),
(15, 'kpc')]
# Loop through the list of widths and units.
@@ -19,12 +20,12 @@
slc.set_width(width, unit)
# Write out the image with a unique name.
- slc.save("%s_%010d_%s" % (pf, width, unit))
+ slc.save("%s_%010d_%s" % (ds, width, unit))
zoomFactors = [2,4,5]
# recreate the original slice
-slc = SlicePlot(pf,2,'density')
+slc = yt.SlicePlot(ds, 'z', 'density')
for zoomFactor in zoomFactors:
@@ -32,4 +33,4 @@
slc.zoom(zoomFactor)
# Write out the image with a unique name.
- slc.save("%s_%i" % (pf, zoomFactor))
+ slc.save("%s_%i" % (ds, zoomFactor))
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/multiplot_2x2.py
--- a/doc/source/cookbook/multiplot_2x2.py
+++ b/doc/source/cookbook/multiplot_2x2.py
@@ -1,9 +1,9 @@
-from yt.mods import *
+import yt
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import AxesGrid
fn = "IsolatedGalaxy/galaxy0030/galaxy0030"
-pf = load(fn) # load data
+ds = yt.load(fn) # load data
fig = plt.figure()
@@ -22,11 +22,16 @@
cbar_size="3%",
cbar_pad="0%")
-fields = ['density', 'velocity_x', 'velocity_y', 'VelocityMagnitude']
+fields = ['density', 'velocity_x', 'velocity_y', 'velocity_magnitude']
# Create the plot. Since SlicePlot accepts a list of fields, we need only
# do this once.
-p = SlicePlot(pf, 'z', fields)
+p = yt.SlicePlot(ds, 'z', fields)
+
+# Velocity is going to be both positive and negative, so let's make these
+# slices linear
+p.set_log('velocity_x', False)
+p.set_log('velocity_y', False)
p.zoom(2)
# For each plotted field, force the SlicePlot to redraw itself onto the AxesGrid
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/multiplot_2x2_coordaxes_slice.py
--- a/doc/source/cookbook/multiplot_2x2_coordaxes_slice.py
+++ b/doc/source/cookbook/multiplot_2x2_coordaxes_slice.py
@@ -1,9 +1,9 @@
-from yt.mods import *
+import yt
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import AxesGrid
fn = "IsolatedGalaxy/galaxy0030/galaxy0030"
-pf = load(fn) # load data
+ds = yt.load(fn) # load data
fig = plt.figure()
@@ -27,7 +27,7 @@
for i, (direction, field) in enumerate(zip(cuts, fields)):
# Load the data and create a single plot
- p = SlicePlot(pf, direction, field)
+ p = yt.SlicePlot(ds, direction, field)
p.zoom(40)
# This forces the ProjectionPlot to redraw itself on the AxesGrid axes.
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/multiplot_2x2_time_series.py
--- a/doc/source/cookbook/multiplot_2x2_time_series.py
+++ b/doc/source/cookbook/multiplot_2x2_time_series.py
@@ -1,4 +1,4 @@
-from yt.mods import *
+import yt
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import AxesGrid
@@ -23,8 +23,8 @@
for i, fn in enumerate(fns):
# Load the data and create a single plot
- pf = load(fn) # load data
- p = ProjectionPlot(pf, 'z', 'density', width=(55, 'Mpccm'))
+ ds = yt.load(fn) # load data
+ p = yt.ProjectionPlot(ds, 'z', 'density', width=(55, 'Mpccm'))
# Ensure the colorbar limits match for all plots
p.set_zlim('density', 1e-4, 1e-2)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/offaxis_projection.py
--- a/doc/source/cookbook/offaxis_projection.py
+++ b/doc/source/cookbook/offaxis_projection.py
@@ -1,7 +1,8 @@
-from yt.mods import *
+import yt
+import numpy as np
# Load the dataset.
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
# Choose a center for the render.
c = [0.5, 0.5, 0.5]
@@ -25,10 +26,10 @@
# Create the off axis projection.
# Setting no_ghost to False speeds up the process, but makes a
# slighly lower quality image.
-image = off_axis_projection(pf, c, L, W, Npixels, "density", no_ghost=False)
+image = yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)
# Write out the final image and give it a name
# relating to what our dataset is called.
# We save the log of the values so that the colors do not span
# many orders of magnitude. Try it without and see what happens.
-write_image(np.log10(image), "%s_offaxis_projection.png" % pf)
+yt.write_image(np.log10(image), "%s_offaxis_projection.png" % ds)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/offaxis_projection_colorbar.py
--- a/doc/source/cookbook/offaxis_projection_colorbar.py
+++ b/doc/source/cookbook/offaxis_projection_colorbar.py
@@ -1,8 +1,9 @@
-from yt.mods import * # set up our namespace
+import yt
+import numpy as np
fn = "IsolatedGalaxy/galaxy0030/galaxy0030" # parameter file to load
-pf = load(fn) # load data
+ds = yt.load(fn) # load data
# Now we need a center of our volume to render. Here we'll just use
# 0.5,0.5,0.5, because volume renderings are not periodic.
@@ -31,9 +32,9 @@
# Also note that we set the field which we want to project as "density", but
# really we could use any arbitrary field like "temperature", "metallicity"
# or whatever.
-image = off_axis_projection(pf, c, L, W, Npixels, "density", no_ghost=False)
+image = yt.off_axis_projection(ds, c, L, W, Npixels, "density", no_ghost=False)
# Image is now an NxN array representing the intensities of the various pixels.
# And now, we call our direct image saver. We save the log of the result.
-write_projection(image, "offaxis_projection_colorbar.png",
- colorbar_label="Column Density (cm$^{-2}$)")
+yt.write_projection(image, "offaxis_projection_colorbar.png",
+ colorbar_label="Column Density (cm$^{-2}$)")
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/opaque_rendering.py
--- a/doc/source/cookbook/opaque_rendering.py
+++ b/doc/source/cookbook/opaque_rendering.py
@@ -1,20 +1,15 @@
-## Opaque Volume Rendering
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
-# The new version of yt also features opaque rendering, using grey opacity.
-# For example, this makes blues opaque to red and green. In this example we
-# will explore how the opacity model you choose changes the appearance of the
-# rendering.
+import yt
+import numpy as np
-# Here we start by loading up a dataset, in this case galaxy0030.
-
-from yt.mods import *
-
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
# We start by building a transfer function, and initializing a camera.
-tf = ColorTransferFunction((-30, -22))
-cam = pf.h.camera([0.5, 0.5, 0.5], [0.2, 0.3, 0.4], 0.10, 256, tf)
+tf = yt.ColorTransferFunction((-30, -22))
+cam = ds.camera([0.5, 0.5, 0.5], [0.2, 0.3, 0.4], 0.10, 256, tf)
# Now let's add some isocontours, and take a snapshot.
@@ -66,5 +61,3 @@
# That looks pretty different, but the main thing is that you can see that the
# inner contours are somewhat visible again.
-
-
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/overplot_grids.py
--- a/doc/source/cookbook/overplot_grids.py
+++ b/doc/source/cookbook/overplot_grids.py
@@ -1,10 +1,10 @@
-from yt.mods import *
+import yt
# Load the dataset.
-pf = load("Enzo_64/DD0043/data0043")
+ds = yt.load("Enzo_64/DD0043/data0043")
# Make a density projection.
-p = ProjectionPlot(pf, "y", "density")
+p = yt.ProjectionPlot(ds, "y", "density")
# Modify the projection
# The argument specifies the region along the line of sight
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/overplot_particles.py
--- a/doc/source/cookbook/overplot_particles.py
+++ b/doc/source/cookbook/overplot_particles.py
@@ -1,10 +1,10 @@
-from yt.mods import *
+import yt
# Load the dataset.
-pf = load("Enzo_64/DD0043/data0043")
+ds = yt.load("Enzo_64/DD0043/data0043")
# Make a density projection.
-p = ProjectionPlot(pf, "y", "density")
+p = yt.ProjectionPlot(ds, "y", "density")
# Modify the projection
# The argument specifies the region along the line of sight
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/profile_with_variance.py
--- a/doc/source/cookbook/profile_with_variance.py
+++ b/doc/source/cookbook/profile_with_variance.py
@@ -1,30 +1,34 @@
-from matplotlib import pyplot
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
-from yt.mods import *
+import matplotlib.pyplot as plt
+import yt
# Load the dataset.
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
-# Create a sphere of radius 1000 kpc centered on the max density.
-sphere = pf.sphere("max", (1000, "kpc"))
+# Create a sphere of radius 1 Mpc centered on the max density location.
+sp = ds.sphere("max", (1, "Mpc"))
# Calculate and store the bulk velocity for the sphere.
-bulk_velocity = sphere.quantities['BulkVelocity']()
-sphere.set_field_parameter('bulk_velocity', bulk_velocity)
+bulk_velocity = sp.quantities['BulkVelocity']()
+sp.set_field_parameter('bulk_velocity', bulk_velocity)
# Create a 1D profile object for profiles over radius
# and add a velocity profile.
-profile = BinnedProfile1D(sphere, 100, "Radiuskpc", 0.1, 1000.)
-profile.add_fields('VelocityMagnitude')
+prof = yt.ProfilePlot(sp, 'radius', 'velocity_magnitude',
+ weight_field='cell_mass')
+prof.set_unit('radius', 'kpc')
+prof.set_xlim(0.1, 1000)
# Plot the average velocity magnitude.
-pyplot.loglog(profile['Radiuskpc'], profile['VelocityMagnitude'],
- label='mean')
+plt.loglog(prof['radius'], prof['velocity_magnitude'],
+ label='Mean')
# Plot the variance of the velocity madnitude.
-pyplot.loglog(profile['Radiuskpc'], profile['VelocityMagnitude_std'],
- label='std')
-pyplot.xlabel('r [kpc]')
-pyplot.ylabel('v [cm/s]')
-pyplot.legend()
+plt.loglog(prof['radius'], prof['velocity_magnitude_std'],
+ label='Standard Deviation')
+plt.xlabel('r [kpc]')
+plt.ylabel('v [cm/s]')
+plt.legend()
-pyplot.savefig('velocity_profiles.png')
+plt.savefig('velocity_profiles.png')
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/rad_velocity.py
--- a/doc/source/cookbook/rad_velocity.py
+++ b/doc/source/cookbook/rad_velocity.py
@@ -1,32 +1,38 @@
-from yt.mods import *
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
+import yt
import matplotlib.pyplot as plt
-pf = load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
+ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
# Get the first sphere
-
-sphere0 = pf.sphere(pf.domain_center, (500., "kpc"))
+sp0 = ds.sphere(ds.domain_center, (500., "kpc"))
# Compute the bulk velocity from the cells in this sphere
+bulk_vel = sp0.quantities["BulkVelocity"]()
-bulk_vel = sphere0.quantities["BulkVelocity"]()
# Get the second sphere
-
-sphere1 = pf.sphere(pf.domain_center, (500., "kpc"))
+sp1 = ds.sphere(ds.domain_center, (500., "kpc"))
# Set the bulk velocity field parameter
-sphere1.set_field_parameter("bulk_velocity", bulk_vel)
+sp1.set_field_parameter("bulk_velocity", bulk_vel)
# Radial profile without correction
-rad_profile0 = BinnedProfile1D(sphere0, 100, "Radiuskpc", 0.0, 500., log_space=False)
-rad_profile0.add_fields("RadialVelocity")
+rp0 = yt.ProfilePlot(sp0, 'radius', 'radial_velocity')
+rp0.set_unit('radius', 'kpc')
+rp0.set_log('radius', False)
# Radial profile with correction for bulk velocity
-rad_profile1 = BinnedProfile1D(sphere1, 100, "Radiuskpc", 0.0, 500., log_space=False)
-rad_profile1.add_fields("RadialVelocity")
+rp1 = yt.ProfilePlot(sp1, 'radius', 'radial_velocity')
+rp1.set_unit('radius', 'kpc')
+rp1.set_log('radius', False)
+
+#rp0.save('radial_velocity_profile_uncorrected.png')
+#rp1.save('radial_velocity_profile_corrected.png')
# Make a plot using matplotlib
@@ -41,4 +47,4 @@
ax.set_ylabel(r"$\mathrm{v_r\ (km/s)}$")
ax.legend(["Without Correction", "With Correction"])
-fig.savefig("%s_profiles.png" % pf)
\ No newline at end of file
+fig.savefig("%s_profiles.png" % ds)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/radial_profile_styles.py
--- a/doc/source/cookbook/radial_profile_styles.py
+++ b/doc/source/cookbook/radial_profile_styles.py
@@ -1,16 +1,22 @@
-from yt.mods import *
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
+import yt
import matplotlib.pyplot as plt
-pf = load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
+ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
# Get a sphere object
-sphere = pf.sphere(pf.domain_center, (500., "kpc"))
+sp = ds.sphere(ds.domain_center, (500., "kpc"))
# Bin up the data from the sphere into a radial profile
-rad_profile = BinnedProfile1D(sphere, 100, "Radiuskpc", 0.0, 500., log_space=False)
-rad_profile.add_fields("density","temperature")
+#rp = BinnedProfile1D(sphere, 100, "Radiuskpc", 0.0, 500., log_space=False)
+#rp.add_fields("density","temperature")
+rp = yt.ProfilePlot(sp, 'radius', ['density', 'temperature'])
+rp.set_unit('radius', 'kpc')
+rp.set_log('radius', False)
# Make plots using matplotlib
@@ -18,7 +24,7 @@
ax = fig.add_subplot(111)
# Plot the density as a log-log plot using the default settings
-dens_plot = ax.loglog(rad_profile["Radiuskpc"], rad_profile["density"])
+dens_plot = ax.loglog(rp["Radiuskpc"], rp["density"])
# Here we set the labels of the plot axes
@@ -27,7 +33,7 @@
# Save the default plot
-fig.savefig("density_profile_default.png" % pf)
+fig.savefig("density_profile_default.png" % ds)
# The "dens_plot" object is a list of plot objects. In our case we only have one,
# so we index the list by '0' to get it.
@@ -51,10 +57,10 @@
ax.lines = []
-# Since the rad_profile object also includes the standard deviation in each bin,
+# Since the radial profile object also includes the standard deviation in each bin,
# we'll use these as errorbars. We have to make a new plot for this:
-dens_err_plot = ax.errorbar(rad_profile["Radiuskpc"], rad_profile["density"],
- yerr=rad_profile["Density_std"])
+dens_err_plot = ax.errorbar(pr["Radiuskpc"], rp["density"],
+ yerr=rp["Density_std"])
-fig.savefig("density_profile_with_errorbars.png")
\ No newline at end of file
+fig.savefig("density_profile_with_errorbars.png")
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/rendering_with_box_and_grids.py
--- a/doc/source/cookbook/rendering_with_box_and_grids.py
+++ b/doc/source/cookbook/rendering_with_box_and_grids.py
@@ -1,18 +1,22 @@
-from yt.mods import *
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
+import yt
+import numpy as np
# Load the dataset.
-pf = load("Enzo_64/DD0043/data0043")
+ds = yt.load("Enzo_64/DD0043/data0043")
# Create a data container (like a sphere or region) that
# represents the entire domain.
-dd = pf.h.all_data()
+ad = ds.all_data()
# Get the minimum and maximum densities.
-mi, ma = dd.quantities["Extrema"]("density")[0]
+mi, ma = ad.quantities.extrema("density")
# Create a transfer function to map field values to colors.
# We bump up our minimum to cut out some of the background fluid
-tf = ColorTransferFunction((np.log10(mi)+2.0, np.log10(ma)))
+tf = yt.ColorTransferFunction((np.log10(mi)+2.0, np.log10(ma)))
# Add three guassians, evenly spaced between the min and
# max specified above with widths of 0.02 and using the
@@ -37,25 +41,24 @@
# Create a camera object.
# This object creates the images and
# can be moved and rotated.
-cam = pf.h.camera(c, L, W, Npixels, tf)
+cam = ds.camera(c, L, W, Npixels, tf)
# Create a snapshot.
# The return value of this function could also be accepted, modified (or saved
# for later manipulation) and then put written out using write_bitmap.
# clip_ratio applies a maximum to the function, which is set to that value
# times the .std() of the array.
-im = cam.snapshot("%s_volume_rendered.png" % pf, clip_ratio=8.0)
+im = cam.snapshot("%s_volume_rendered.png" % ds, clip_ratio=8.0)
# Add the domain edges, with an alpha blending of 0.3:
nim = cam.draw_domain(im, alpha=0.3)
-nim.write_png('%s_vr_domain.png' % pf)
+nim.write_png('%s_vr_domain.png' % ds)
# Add the grids, colored by the grid level with the algae colormap
nim = cam.draw_grids(im, alpha=0.3, cmap='algae')
-nim.write_png('%s_vr_grids.png' % pf)
+nim.write_png('%s_vr_grids.png' % ds)
# Here we can draw the coordinate vectors on top of the image by processing
# it through the camera. Then save it out.
cam.draw_coordinate_vectors(nim)
-nim.write_png("%s_vr_vectors.png" % pf)
-
+nim.write_png("%s_vr_vectors.png" % ds)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/save_profiles.py
--- a/doc/source/cookbook/save_profiles.py
+++ b/doc/source/cookbook/save_profiles.py
@@ -1,28 +1,31 @@
-from yt.mods import *
+### THIS RECIPE IS CURRENTLY BROKEN IN YT-3.0
+### DO NOT TRUST THIS RECIPE UNTIL THIS LINE IS REMOVED
+
+import yt
import matplotlib.pyplot as plt
-import h5py
+import h5py as h5
-pf = load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
+ds = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
# Get a sphere
-sp = pf.sphere(pf.domain_center, (500., "kpc"))
+sp = ds.sphere(ds.domain_center, (500., "kpc"))
# Radial profile from the sphere
-rad_profile = BinnedProfile1D(sp, 100, "Radiuskpc", 0.0, 500., log_space=False)
-
-# Adding density and temperature fields to the profile
-
-rad_profile.add_fields(["density","temperature"])
+prof = yt.BinnedProfile1D(sp, 100, "Radiuskpc", 0.0, 500., log_space=False)
+prof = yt.ProfilePlot(sp, 'radius', ['density', 'temperature'], weight_field="cell_mass")
+prof.set_unit('radius', 'kpc')
+prof.set_log('radius', False)
+prof.set_xlim(0, 500)
# Write profiles to ASCII file
-rad_profile.write_out("%s_profile.dat" % pf, bin_style="center")
+prof.write_out("%s_profile.dat" % ds, bin_style="center")
# Write profiles to HDF5 file
-rad_profile.write_out_h5("%s_profile.h5" % pf, bin_style="center")
+prof.write_out_h5("%s_profile.h5" % ds, bin_style="center")
# Now we will show how using NumPy, h5py, and Matplotlib the data in these
# files may be plotted.
@@ -42,13 +45,13 @@
ax.set_xlabel(r"$\mathrm{r\ (kpc)}$")
ax.set_ylabel(r"$\mathrm{\rho\ (g\ cm^{-3})}$")
ax.set_title("Density vs. Radius")
-fig1.savefig("%s_dens.png" % pf)
+fig1.savefig("%s_dens.png" % ds)
# Plot temperature from HDF5 file
# Get the file handle
-f = h5py.File("%s_profile.h5" % pf, "r")
+f = h5py.File("%s_profile.h5" % ds, "r")
# Get the radius and temperature arrays from the file handle
@@ -66,4 +69,4 @@
ax.set_xlabel(r"$\mathrm{r\ (kpc)}$")
ax.set_ylabel(r"$\mathrm{T\ (K)}$")
ax.set_title("temperature vs. Radius")
-fig2.savefig("%s_temp.png" % pf)
+fig2.savefig("%s_temp.png" % ds)
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/show_hide_axes_colorbar.py
--- a/doc/source/cookbook/show_hide_axes_colorbar.py
+++ b/doc/source/cookbook/show_hide_axes_colorbar.py
@@ -1,8 +1,8 @@
-from yt.mods import *
+import yt
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
-slc = SlicePlot(pf, "x", "density")
+slc = yt.SlicePlot(ds, "x", "density")
slc.save("default_sliceplot.png")
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/simple_contour_in_slice.py
--- a/doc/source/cookbook/simple_contour_in_slice.py
+++ b/doc/source/cookbook/simple_contour_in_slice.py
@@ -1,10 +1,10 @@
-from yt.mods import *
+import yt
# Load the data file.
-pf = load("Sedov_3d/sedov_hdf5_chk_0002")
+ds = yt.load("Sedov_3d/sedov_hdf5_chk_0002")
# Make a traditional slice plot.
-sp = SlicePlot(pf,"x","density")
+sp = yt.SlicePlot(ds, "x", "density")
# Overlay the slice plot with thick red contours of density.
sp.annotate_contour("density", ncont=3, clim=(1e-2,1e-1), label=True,
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/simple_off_axis_projection.py
--- a/doc/source/cookbook/simple_off_axis_projection.py
+++ b/doc/source/cookbook/simple_off_axis_projection.py
@@ -1,12 +1,12 @@
-from yt.mods import *
+import yt
# Load the dataset.
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
# Create a 1 kpc radius sphere, centered on the max density. Note that this
# sphere is very small compared to the size of our final plot, and it has a
# non-axially aligned L vector.
-sp = pf.sphere("center", (15.0, "kpc"))
+sp = ds.sphere("center", (15.0, "kpc"))
# Get the angular momentum vector for the sphere.
L = sp.quantities["AngularMomentumVector"]()
@@ -14,5 +14,5 @@
print "Angular momentum vector: {0}".format(L)
# Create an OffAxisSlicePlot on the object with the L vector as its normal
-p = OffAxisProjectionPlot(pf, L, "density", sp.center, (25, "kpc"))
+p = yt.OffAxisProjectionPlot(ds, L, "density", sp.center, (25, "kpc"))
p.save()
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/simple_pdf.py
--- a/doc/source/cookbook/simple_pdf.py
+++ b/doc/source/cookbook/simple_pdf.py
@@ -1,14 +1,14 @@
-from yt.mods import *
+import yt
# Load the dataset.
-pf = load("GalaxyClusterMerger/fiducial_1to3_b0.273d_hdf5_plt_cnt_0175")
+ds = yt.load("GalaxyClusterMerger/fiducial_1to3_b0.273d_hdf5_plt_cnt_0175")
# Create a data object that represents the whole box.
-ad = pf.h.all_data()
+ad = ds.h.all_data()
# This is identical to the simple phase plot, except we supply
# the fractional=True keyword to divide the profile data by the sum.
-plot = PhasePlot(ad, "density", "temperature", "cell_mass",
+plot = yt.PhasePlot(ad, "density", "temperature", "cell_mass",
weight_field=None, fractional=True)
# Set a new title for the colorbar since it is now fractional.
diff -r a75dfa57a6ff01658829294adad8bbd18c4f7486 -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f doc/source/cookbook/simple_phase.py
--- a/doc/source/cookbook/simple_phase.py
+++ b/doc/source/cookbook/simple_phase.py
@@ -1,18 +1,21 @@
-from yt.mods import *
+import yt
# Load the dataset.
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
# Create a sphere of radius 100 kpc in the center of the domain.
-my_sphere = pf.sphere("c", (100.0, "kpc"))
+my_sphere = ds.sphere("c", (100.0, "kpc"))
# Create a PhasePlot object.
# Setting weight to None will calculate a sum.
# Setting weight to a field will calculate an average
# weighted by that field.
-plot = PhasePlot(my_sphere, "density", "temperature", "cell_mass",
+plot = yt.PhasePlot(my_sphere, "density", "temperature", "cell_mass",
weight_field=None)
+# Set the units of mass to be in solar masses (not the default in cgs)
+plot.set_unit('cell_mass', 'Msun')
+
# Save the image.
# Optionally, give a string as an argument
# to name files with a keyword.
This diff is so big that we needed to truncate the remainder.
https://bitbucket.org/yt_analysis/yt/commits/396514e3e394/
Changeset: 396514e3e394
Branch: yt-3.0
User: jzuhone
Date: 2014-06-29 16:05:27
Summary: Allow for more flexibility in the definition of the data file.
Affected #: 1 file
diff -r 6dae3842fe6cb1adb96acd5c6fecd5a18711396f -r 396514e3e394194fbf749fb1540d87c5e7ce2cad yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
--- a/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
+++ b/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
@@ -35,8 +35,9 @@
xray_data_version = 1
-def _get_data_file():
- data_file = "cloudy_emissivity.h5"
+def _get_data_file(data_file=None):
+ if data_file is None:
+ data_file = "cloudy_emissivity.h5"
data_url = "http://yt-project.org/data"
if "YT_DEST" in os.environ and \
os.path.isdir(os.path.join(os.environ["YT_DEST"], "data")):
@@ -64,8 +65,8 @@
class ObsoleteDataException(YTException):
def __str__(self):
return "X-ray emissivity data is out of date.\n" + \
- "Download the latest data from http://yt-project.org/data/xray_emissivity.h5 and move it to %s." % \
- os.path.join(os.environ["YT_DEST"], "data", "xray_emissivity.h5")
+ "Download the latest data from http://yt-project.org/data/cloudy_emissivity.h5 and move it to %s." % \
+ os.path.join(os.environ["YT_DEST"], "data", "cloudy_emissivity.h5")
class EmissivityIntegrator(object):
r"""Class for making X-ray emissivity fields with hdf5 data tables
@@ -91,7 +92,8 @@
default_filename = True
if not os.path.exists(filename):
- raise IOError("File does not exist: %s." % filename)
+ mylog.warning("File %s does not exist, will attempt to find it." % filename)
+ filename = _get_data_file(data_file=filename)
only_on_root(mylog.info, "Loading emissivity data from %s." % filename)
in_file = h5py.File(filename, "r")
if "info" in in_file.attrs:
https://bitbucket.org/yt_analysis/yt/commits/30d6fa6640b5/
Changeset: 30d6fa6640b5
Branch: yt-3.0
User: jzuhone
Date: 2014-06-30 19:06:58
Summary: Merge
Affected #: 10 files
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -567,8 +567,10 @@
mkdir -p ${DEST_DIR}/data
cd ${DEST_DIR}/data
-echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 xray_emissivity.h5' > xray_emissivity.h5.sha512
-[ ! -e xray_emissivity.h5 ] && get_ytdata xray_emissivity.h5
+echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 cloudy_emissivity.h5' > cloudy_emissivity.h5.sha512
+[ ! -e cloudy_emissivity.h5 ] && get_ytdata cloudy_emissivity.h5
+echo '0f714ae2eace0141b1381abf1160dc8f8a521335e886f99919caf3beb31df1fe271d67c7b2a804b1467949eb16b0ef87a3d53abad0e8160fccac1e90d8d9e85f apec_emissivity.h5' > apec_emissivity.h5.sha512
+[ ! -e apec_emissivity.h5 ] && get_ytdata apec_emissivity.h5
# Set paths to what they should be when yt is activated.
export PATH=${DEST_DIR}/bin:$PATH
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a doc/source/analyzing/analysis_modules/photon_simulator.rst
--- a/doc/source/analyzing/analysis_modules/photon_simulator.rst
+++ b/doc/source/analyzing/analysis_modules/photon_simulator.rst
@@ -1,6 +1,11 @@
Constructing Mock X-ray Observations
------------------------------------
+.. note::
+
+ If you just want to create derived fields for X-ray emission,
+ you should go `here <xray_emission_fields.html>`_ instead.
+
The ``photon_simulator`` analysis module enables the creation of
simulated X-ray photon lists of events from datasets that ``yt`` is able
to read. The simulated events then can be exported to X-ray telescope
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a doc/source/analyzing/analysis_modules/xray_emission_fields.rst
--- a/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
+++ b/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
@@ -2,39 +2,42 @@
X-ray Emission Fields
=====================
-.. sectionauthor:: Britton Smith <brittonsmith at gmail.com>
+.. sectionauthor:: Britton Smith <brittonsmith at gmail.com>, John ZuHone <jzuhone at gmail.com>
+
+.. note::
+
+ If you came here trying to figure out how to create simulated X-ray photons and observations,
+ you should go `here <photon_simulator.html>`_ instead.
This functionality provides the ability to create metallicity-dependent
-X-ray luminosity, emissivity, and photo emissivity fields for a given
+X-ray luminosity, emissivity, and photon emissivity fields for a given
photon energy range. This works by interpolating from emission tables
-created with the photoionization code, `Cloudy <http://nublado.org/>`_.
-If you installed yt with the install script, the data should be located in
-the *data* directory inside the installation directory. Emission fields can
-be made for any interval between 0.1 keV and 100 keV.
+created from the photoionization code `Cloudy <http://nublado.org/>`_ or
+the collisional ionization database `AtomDB <http://www.atomdb.org>`_. If
+you installed yt with the install script, the data should be located in
+the *data* directory inside the installation directory, or can be downloaded
+from `<http://yt-project.org/data>`_. Emission fields can be made for any
+interval between 0.1 keV and 100 keV.
Adding Emission Fields
----------------------
-Fields can be created for luminosity (erg/s), emissivity (erg/s/cm^3),
-and photon emissivity (photons/s/cm^3). The only required arguments are
-the minimum and maximum energies.
+Fields will be created for luminosity :math:`{\rm (erg~s^{-1})}`, emissivity :math:`{\rm (erg~s^{-1}~cm^{-3})}`,
+and photon emissivity :math:`{\rm (photons~s^{-1}~cm^{-3})}`. The only required arguments are the
+dataset object, and the minimum and maximum energies of the energy band.
.. code-block:: python
- from yt.mods import *
+ import yt
from yt.analysis_modules.spectral_integrator.api import \
- add_xray_luminosity_field, \
- add_xray_emissivity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
- add_xray_luminosity_field(0.5, 7)
- add_xray_emissivity_field(0.5, 7)
- add_xray_photon_emissivity_field(0.5, 7)
+ xray_fields = add_xray_emissivity_field(0.5, 7.0)
Additional keyword arguments are:
- * **filename** (*string*): Path to data file containing emissivity
- values. If None, a file called xray_emissivity.h5 is used. This file
+ * **filename** (*string*): Path to data file containing emissivity
+ values. If None, a file called cloudy_emissivity.h5 is used. This file
contains emissivity tables for primordial elements and for metals at
solar metallicity for the energy range 0.1 to 100 keV. Default: None.
@@ -46,24 +49,27 @@
metallicity for the emission from metals. The *with_metals* keyword
must be set to False to use this. Default: None.
-The resulting fields can be used like all normal fields.
+The resulting fields can be used like all normal fields. The function will return the names of
+the created fields in a Python list.
-.. python-script::
+.. code-block:: python
- from yt.mods import *
+ import yt
from yt.analysis_modules.spectral_integrator.api import \
- add_xray_luminosity_field, \
- add_xray_emissivity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
- add_xray_luminosity_field(0.5, 7)
- add_xray_emissivity_field(0.5, 7)
- add_xray_photon_emissivity_field(0.5, 7)
+ xray_fields = add_xray_emissivity_field(0.5, 7.0)
- pf = load("enzo_tiny_cosmology/DD0046/DD0046")
- plot = SlicePlot(pf, 'x', 'Xray_Luminosity_0.5_7keV')
+ ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+ plot = yt.SlicePlot(ds, 'x', 'xray_luminosity_0.5_7.0_keV')
plot.save()
- plot = ProjectionPlot(pf, 'x', 'Xray_Emissivity_0.5_7keV')
+ plot = yt.ProjectionPlot(ds, 'x', 'xray_emissivity_0.5_7.0_keV')
plot.save()
- plot = ProjectionPlot(pf, 'x', 'Xray_Photon_Emissivity_0.5_7keV')
+ plot = yt.ProjectionPlot(ds, 'x', 'xray_photon_emissivity_0.5_7.0_keV')
plot.save()
+
+.. warning::
+
+ The X-ray fields depend on the number density of hydrogen atoms, in the yt field
+ ``H_number_density``. If this field is not defined (either in the dataset or by the user),
+ the primordial hydrogen mass fraction (X = 0.76) will be used to construct it.
\ No newline at end of file
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -956,7 +956,7 @@
if isinstance(self.parameters["Area"], basestring):
mylog.error("Writing SIMPUT files is only supported if you didn't convolve with an ARF.")
- raise TypeError
+ raise TypeError("Writing SIMPUT files is only supported if you didn't convolve with an ARF.")
if emin is None:
emin = self.events["eobs"].min().value*0.95
@@ -1032,7 +1032,10 @@
f = h5py.File(h5file, "w")
f.create_dataset("/exp_time", data=float(self.parameters["ExposureTime"]))
- f.create_dataset("/area", data=float(self.parameters["Area"]))
+ area = self.parameters["Area"]
+ if not isinstance(area, basestring):
+ area = float(area)
+ f.create_dataset("/area", data=area)
f.create_dataset("/redshift", data=self.parameters["Redshift"])
f.create_dataset("/d_a", data=float(self.parameters["AngularDiameterDistance"]))
if "ARF" in self.parameters:
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -181,7 +181,7 @@
Examples
--------
>>> apec_model = TableApecModel("/Users/jzuhone/Data/atomdb_v2.0.2/", 0.05, 50.0,
- 1000, thermal_broad=True)
+ ... 1000, thermal_broad=True)
"""
def __init__(self, apec_root, emin, emax, nchan,
apec_vers="2.0.2", thermal_broad=False):
@@ -226,7 +226,7 @@
tmpspec = np.zeros((self.nchan))
- i = np.where((self.line_handle[tindex].data.field('element')==element) &
+ i = np.where((self.line_handle[tindex].data.field('element') == element) &
(self.line_handle[tindex].data.field('lambda') > self.minlam) &
(self.line_handle[tindex].data.field('lambda') < self.maxlam))[0]
@@ -242,24 +242,24 @@
vec += np.diff(cdf)*a
else:
ie = np.searchsorted(ebins, E0, side='right')-1
- for i,a in zip(ie,amp): vec[i] += a
+ for i, a in zip(ie, amp): vec[i] += a
tmpspec += vec
- ind = np.where((self.coco_handle[tindex].data.field('Z')==element) &
- (self.coco_handle[tindex].data.field('rmJ')==0))[0]
- if len(ind)==0:
+ ind = np.where((self.coco_handle[tindex].data.field('Z') == element) &
+ (self.coco_handle[tindex].data.field('rmJ') == 0))[0]
+ if len(ind) == 0:
return tmpspec
else:
- ind=ind[0]
+ ind = ind[0]
- n_cont=self.coco_handle[tindex].data.field('N_Cont')[ind]
- e_cont=self.coco_handle[tindex].data.field('E_Cont')[ind][:n_cont]
+ n_cont = self.coco_handle[tindex].data.field('N_Cont')[ind]
+ e_cont = self.coco_handle[tindex].data.field('E_Cont')[ind][:n_cont]
continuum = self.coco_handle[tindex].data.field('Continuum')[ind][:n_cont]
tmpspec += np.interp(self.emid.ndarray_view(), e_cont, continuum)*self.de.ndarray_view()
- n_pseudo=self.coco_handle[tindex].data.field('N_Pseudo')[ind]
- e_pseudo=self.coco_handle[tindex].data.field('E_Pseudo')[ind][:n_pseudo]
+ n_pseudo = self.coco_handle[tindex].data.field('N_Pseudo')[ind]
+ e_pseudo = self.coco_handle[tindex].data.field('E_Pseudo')[ind][:n_pseudo]
pseudo = self.coco_handle[tindex].data.field('Pseudo')[ind][:n_pseudo]
tmpspec += np.interp(self.emid.ndarray_view(), e_pseudo, pseudo)*self.de.ndarray_view()
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a yt/analysis_modules/spectral_integrator/api.py
--- a/yt/analysis_modules/spectral_integrator/api.py
+++ b/yt/analysis_modules/spectral_integrator/api.py
@@ -15,6 +15,4 @@
from .spectral_frequency_integrator import \
EmissivityIntegrator, \
- add_xray_emissivity_field, \
- add_xray_luminosity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
\ No newline at end of file
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
--- a/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
+++ b/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
@@ -1,6 +1,6 @@
"""
Integrator classes to deal with interpolation and integration of input spectral
-bins. Currently only supports Cloudy-style data.
+bins. Currently only supports Cloudy and APEC-style data.
@@ -23,19 +23,21 @@
mylog, \
only_on_root
-from yt.fields.local_fields import add_field
+from yt.utilities.exceptions import YTFieldNotFound
from yt.utilities.exceptions import YTException
from yt.utilities.linear_interpolators import \
- BilinearFieldInterpolator
+ UnilinearFieldInterpolator, BilinearFieldInterpolator
from yt.utilities.physical_constants import \
- erg_per_eV, hcgs
-from yt.units import keV, Hz
-keV_per_Hz = keV/Hz/hcgs
+ hcgs, mp
+from yt.units.yt_array import YTArray, YTQuantity
+from yt.utilities.physical_ratios import \
+ primordial_H_mass_fraction, erg_per_keV
xray_data_version = 1
-def _get_data_file():
- data_file = "xray_emissivity.h5"
+def _get_data_file(data_file=None):
+ if data_file is None:
+ data_file = "cloudy_emissivity.h5"
data_url = "http://yt-project.org/data"
if "YT_DEST" in os.environ and \
os.path.isdir(os.path.join(os.environ["YT_DEST"], "data")):
@@ -62,8 +64,9 @@
class ObsoleteDataException(YTException):
def __str__(self):
- return "X-ray emissivity data is out of data.\nDownload the latest data from http://yt-project.org/data/xray_emissivity.h5 and move it to %s." % \
- os.path.join(os.environ["YT_DEST"], "data", "xray_emissivity.h5")
+ return "X-ray emissivity data is out of date.\n" + \
+ "Download the latest data from http://yt-project.org/data/cloudy_emissivity.h5 and move it to %s." % \
+ os.path.join(os.environ["YT_DEST"], "data", "cloudy_emissivity.h5")
class EmissivityIntegrator(object):
r"""Class for making X-ray emissivity fields with hdf5 data tables
@@ -75,7 +78,7 @@
----------
filename: string, default None
Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
+ a file called "cloudy_emissivity.h5" is used. This file contains
emissivity tables for primordial elements and for metals at
solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
@@ -89,7 +92,8 @@
default_filename = True
if not os.path.exists(filename):
- raise IOError("File does not exist: %s." % filename)
+ mylog.warning("File %s does not exist, will attempt to find it." % filename)
+ filename = _get_data_file(data_file=filename)
only_on_root(mylog.info, "Loading emissivity data from %s." % filename)
in_file = h5py.File(filename, "r")
if "info" in in_file.attrs:
@@ -103,51 +107,51 @@
for field in ["emissivity_primordial", "emissivity_metals",
"log_nH", "log_T", "log_E"]:
- setattr(self, field, in_file[field][:])
+ if field in in_file:
+ setattr(self, field, in_file[field][:])
in_file.close()
E_diff = np.diff(self.log_E)
self.E_bins = \
- np.power(10, np.concatenate([self.log_E[:-1] - 0.5 * E_diff,
- [self.log_E[-1] - 0.5 * E_diff[-1],
- self.log_E[-1] + 0.5 * E_diff[-1]]]))
- self.dnu = keV_per_Hz * np.diff(self.E_bins)
+ YTArray(np.power(10, np.concatenate([self.log_E[:-1] - 0.5 * E_diff,
+ [self.log_E[-1] - 0.5 * E_diff[-1],
+ self.log_E[-1] + 0.5 * E_diff[-1]]])),
+ "keV")
+ self.dnu = (np.diff(self.E_bins)/hcgs).in_units("Hz")
- def _get_interpolator(self, data, e_min, e_max):
- r"""Create an interpolator for total emissivity in a
- given energy range.
-
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
-
- """
+ def get_interpolator(self, data, e_min, e_max):
+ e_min = YTQuantity(e_min, "keV")
+ e_max = YTQuantity(e_max, "keV")
if (e_min - self.E_bins[0]) / e_min < -1e-3 or \
(e_max - self.E_bins[-1]) / e_max > 1e-3:
- raise EnergyBoundsException(np.power(10, self.E_bins[0]),
- np.power(10, self.E_bins[-1]))
+ raise EnergyBoundsException(self.E_bins[0], self.E_bins[-1])
e_is, e_ie = np.digitize([e_min, e_max], self.E_bins)
e_is = np.clip(e_is - 1, 0, self.E_bins.size - 1)
e_ie = np.clip(e_ie, 0, self.E_bins.size - 1)
- my_dnu = np.copy(self.dnu[e_is: e_ie])
+ my_dnu = self.dnu[e_is: e_ie].copy()
# clip edge bins if the requested range is smaller
- my_dnu[0] -= e_min - self.E_bins[e_is]
- my_dnu[-1] -= self.E_bins[e_ie] - e_max
+ my_dnu[0] -= ((e_min - self.E_bins[e_is])/hcgs).in_units("Hz")
+ my_dnu[-1] -= ((self.E_bins[e_ie] - e_max)/hcgs).in_units("Hz")
interp_data = (data[..., e_is:e_ie] * my_dnu).sum(axis=-1)
- return BilinearFieldInterpolator(np.log10(interp_data),
- [self.log_nH[0], self.log_nH[-1],
- self.log_T[0], self.log_T[-1]],
- ["log_nH", "log_T"], truncate=True)
+ if len(data.shape) == 2:
+ emiss = UnilinearFieldInterpolator(np.log10(interp_data),
+ [self.log_T[0], self.log_T[-1]],
+ "log_T", truncate=True)
+ else:
+ emiss = BilinearFieldInterpolator(np.log10(interp_data),
+ [self.log_nH[0], self.log_nH[-1],
+ self.log_T[0], self.log_T[-1]],
+ ["log_nH", "log_T"], truncate=True)
-def add_xray_emissivity_field(e_min, e_max, filename=None,
+ return emiss
+
+def add_xray_emissivity_field(ds, e_min, e_max,
+ filename=None,
with_metals=True,
constant_metallicity=None):
- r"""Create an X-ray emissivity field for a given energy range.
+ r"""Create X-ray emissivity fields for a given energy range.
Parameters
----------
@@ -155,197 +159,115 @@
the minimum energy in keV for the energy band.
e_min: float
the maximum energy in keV for the energy band.
-
- Other Parameters
- ----------------
- filename: string
+ filename: string, optional
Path to data file containing emissivity values. If None,
a file called xray_emissivity.h5 is used. This file contains
emissivity tables for primordial elements and for metals at
solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
- with_metals: bool
+ with_metals: bool, optional
If True, use the metallicity field to add the contribution from
metals. If False, only the emission from H/He is considered.
Default: True.
- constant_metallicity: float
+ constant_metallicity: float, optional
If specified, assume a constant metallicity for the emission
from metals. The *with_metals* keyword must be set to False
to use this.
Default: None.
- This will create a field named "Xray_Emissivity_{e_min}_{e_max}keV".
- The units of the field are erg s^-1 cm^-3.
+ This will create three fields:
+
+ "xray_emissivity_{e_min}_{e_max}_keV" (erg s^-1 cm^-3)
+ "xray_luminosity_{e_min}_{e_max}_keV" (erg s^-1)
+ "xray_photon_emissivity_{e_min}_{e_max}_keV" (photons s^-1 cm^-3)
Examples
--------
>>> from yt.mods import *
>>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_emissivity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> p = ProjectionPlot(pf, 'x', "Xray_Emissivity_0.5_2keV")
+ >>> ds = load(dataset)
+ >>> add_xray_emissivity_field(ds, 0.5, 2)
+ >>> p = ProjectionPlot(ds, 'x', "xray_emissivity_0.5_2_keV")
>>> p.save()
"""
+ if with_metals:
+ try:
+ ds._get_field_info("metal_density")
+ except YTFieldNotFound:
+ raise RuntimeError("Your dataset does not have a \"metal_density\" field! " +
+ "Perhaps you should specify a constant metallicity?")
+
my_si = EmissivityIntegrator(filename=filename)
- em_0 = my_si._get_interpolator(my_si.emissivity_primordial, e_min, e_max)
+ em_0 = my_si.get_interpolator(my_si.emissivity_primordial, e_min, e_max)
em_Z = None
if with_metals or constant_metallicity is not None:
- em_Z = my_si._get_interpolator(my_si.emissivity_metals, e_min, e_max)
+ em_Z = my_si.get_interpolator(my_si.emissivity_metals, e_min, e_max)
+
+ energy_erg = np.power(10, my_si.log_E) * erg_per_keV
+ emp_0 = my_si.get_interpolator((my_si.emissivity_primordial[..., :] / energy_erg),
+ e_min, e_max)
+ emp_Z = None
+ if with_metals or constant_metallicity is not None:
+ emp_Z = my_si.get_interpolator((my_si.emissivity_metals[..., :] / energy_erg),
+ e_min, e_max)
+
+ try:
+ ds._get_field_info("H_number_density")
+ except YTFieldNotFound:
+ mylog.warning("Could not find a field for \"H_number_density\". Assuming primordial H " +
+ "mass fraction.")
+ def _nh(field, data):
+ return primordial_H_mass_fraction*data["gas","density"]/mp
+ ds.add_field(("gas","H_number_density"), function=_nh, units="cm**-3")
def _emissivity_field(field, data):
- dd = {"log_nH" : np.log10(data["H_NumberDensity"]),
- "log_T" : np.log10(data["Temperature"])}
+ dd = {"log_nH" : np.log10(data["gas","H_number_density"]),
+ "log_T" : np.log10(data["gas","temperature"])}
my_emissivity = np.power(10, em_0(dd))
if em_Z is not None:
if with_metals:
- my_Z = data["Metallicity"]
+ my_Z = data["gas","metallicity"]
elif constant_metallicity is not None:
my_Z = constant_metallicity
my_emissivity += my_Z * np.power(10, em_Z(dd))
- return data["H_NumberDensity"]**2 * my_emissivity
+ return data["gas","H_number_density"]**2 * YTArray(my_emissivity, "erg*cm**3/s")
- field_name = "Xray_Emissivity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_emissivity_field,
- projection_conversion="cm",
- display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{erg}\/\rm{cm}^{-3}\/\rm{s}^{-1}")
- return field_name
-
-def add_xray_luminosity_field(e_min, e_max, filename=None,
- with_metals=True,
- constant_metallicity=None):
- r"""Create an X-ray luminosity field for a given energy range.
-
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
-
- Other Parameters
- ----------------
- filename: string
- Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
- Default: None.
- with_metals: bool
- If True, use the metallicity field to add the contribution from
- metals. If False, only the emission from H/He is considered.
- Default: True.
- constant_metallicity: float
- If specified, assume a constant metallicity for the emission
- from metals. The *with_metals* keyword must be set to False
- to use this.
- Default: None.
-
- This will create a field named "Xray_Luminosity_{e_min}_{e_max}keV".
- The units of the field are erg s^-1.
-
- Examples
- --------
-
- >>> from yt.mods import *
- >>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_luminosity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> sp = pf.sphere('max', (2., 'mpc'))
- >>> print sp.quantities['TotalQuantity']('Xray_Luminosity_0.5_2keV')
-
- """
-
- em_field = add_xray_emissivity_field(e_min, e_max, filename=filename,
- with_metals=with_metals,
- constant_metallicity=constant_metallicity)
+ emiss_name = "xray_emissivity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(emiss_name, function=_emissivity_field,
+ display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="erg/cm**3/s")
def _luminosity_field(field, data):
- return data[em_field] * data["CellVolume"]
- field_name = "Xray_Luminosity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_luminosity_field,
- display_name=r"\rm{L}_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{erg}\/\rm{s}^{-1}")
- return field_name
+ return data[emiss_name] * data["cell_volume"]
-def add_xray_photon_emissivity_field(e_min, e_max, filename=None,
- with_metals=True,
- constant_metallicity=None):
- r"""Create an X-ray photon emissivity field for a given energy range.
+ lum_name = "xray_luminosity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(lum_name, function=_luminosity_field,
+ display_name=r"\rm{L}_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="erg/s")
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
+ def _photon_emissivity_field(field, data):
+ dd = {"log_nH" : np.log10(data["gas","H_number_density"]),
+ "log_T" : np.log10(data["gas","temperature"])}
- Other Parameters
- ----------------
- filename: string
- Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
- Default: None.
- with_metals: bool
- If True, use the metallicity field to add the contribution from
- metals. If False, only the emission from H/He is considered.
- Default: True.
- constant_metallicity: float
- If specified, assume a constant metallicity for the emission
- from metals. The *with_metals* keyword must be set to False
- to use this.
- Default: None.
-
- This will create a field named "Xray_Photon_Emissivity_{e_min}_{e_max}keV".
- The units of the field are photons s^-1 cm^-3.
-
- Examples
- --------
-
- >>> from yt.mods import *
- >>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_emissivity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> p = ProjectionPlot(pf, 'x', "Xray_Emissivity_0.5_2keV")
- >>> p.save()
-
- """
-
- my_si = EmissivityIntegrator(filename=filename)
- energy_erg = np.power(10, my_si.log_E) * erg_per_eV
-
- em_0 = my_si._get_interpolator((my_si.emissivity_primordial[..., :] / energy_erg),
- e_min, e_max)
- em_Z = None
- if with_metals or constant_metallicity is not None:
- em_Z = my_si._get_interpolator((my_si.emissivity_metals[..., :] / energy_erg),
- e_min, e_max)
-
- def _emissivity_field(field, data):
- dd = {"log_nH" : np.log10(data["H_NumberDensity"]),
- "log_T" : np.log10(data["Temperature"])}
-
- my_emissivity = np.power(10, em_0(dd))
- if em_Z is not None:
+ my_emissivity = np.power(10, emp_0(dd))
+ if emp_Z is not None:
if with_metals:
- my_Z = data["Metallicity"]
+ my_Z = data["gas","metallicity"]
elif constant_metallicity is not None:
my_Z = constant_metallicity
- my_emissivity += my_Z * np.power(10, em_Z(dd))
+ my_emissivity += my_Z * np.power(10, emp_Z(dd))
- return data["H_NumberDensity"]**2 * my_emissivity
+ return data["gas","H_number_density"]**2 * YTArray(my_emissivity, "photons*cm**3/s")
- field_name = "Xray_Photon_Emissivity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_emissivity_field,
- projection_conversion="cm",
- display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{photons}\/\rm{cm}^{-3}\/\rm{s}^{-1}")
- return field_name
+ phot_name = "xray_photon_emissivity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(phot_name, function=_photon_emissivity_field,
+ display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="photons/cm**3/s")
+
+ return emiss_name, lum_name, phot_name
\ No newline at end of file
diff -r 103131490fefcf01b2a7288ad246869fe853dd47 -r 30d6fa6640b545777b6f211f3309e7a293795d8a yt/units/unit_lookup_table.py
--- a/yt/units/unit_lookup_table.py
+++ b/yt/units/unit_lookup_table.py
@@ -89,6 +89,7 @@
"angstrom": (cm_per_ang, dimensions.length),
"Jy": (jansky_cgs, dimensions.specific_flux),
"counts": (1.0, dimensions.dimensionless),
+ "photons": (1.0, dimensions.dimensionless),
# for AstroPy compatibility
"solMass": (mass_sun_grams, dimensions.mass),
https://bitbucket.org/yt_analysis/yt/commits/7582ac6f8ecd/
Changeset: 7582ac6f8ecd
Branch: yt-3.0
User: jzuhone
Date: 2014-07-03 01:26:48
Summary: Adding more documentation regarding the file options.
Affected #: 2 files
diff -r 30d6fa6640b545777b6f211f3309e7a293795d8a -r 7582ac6f8ecd9fd0e0d33ae6b6ca5966183e448b doc/source/analyzing/analysis_modules/xray_emission_fields.rst
--- a/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
+++ b/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
@@ -14,7 +14,7 @@
photon energy range. This works by interpolating from emission tables
created from the photoionization code `Cloudy <http://nublado.org/>`_ or
the collisional ionization database `AtomDB <http://www.atomdb.org>`_. If
-you installed yt with the install script, the data should be located in
+you installed yt with the install script, these data files should be located in
the *data* directory inside the installation directory, or can be downloaded
from `<http://yt-project.org/data>`_. Emission fields can be made for any
interval between 0.1 keV and 100 keV.
@@ -36,10 +36,12 @@
Additional keyword arguments are:
- * **filename** (*string*): Path to data file containing emissivity
- values. If None, a file called cloudy_emissivity.h5 is used. This file
- contains emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV. Default: None.
+ * **filename** (*string*): Path to data file containing emissivity values. If None,
+ a file called "cloudy_emissivity.h5" is used, for photoionized plasmas. A second
+ option, for collisionally ionized plasmas, is in the file "apec_emissivity.h5",
+ available at http://yt-project.org/data. These files contain emissivity tables
+ for primordial elements and for metals at solar metallicity for the energy range
+ 0.1 to 100 keV. Default: None.
* **with_metals** (*bool*): If True, use the metallicity field to add the
contribution from metals. If False, only the emission from H/He is
@@ -58,7 +60,7 @@
from yt.analysis_modules.spectral_integrator.api import \
add_xray_emissivity_field
- xray_fields = add_xray_emissivity_field(0.5, 7.0)
+ xray_fields = add_xray_emissivity_field(0.5, 7.0, filename="apec_emissivity.h5")
ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
plot = yt.SlicePlot(ds, 'x', 'xray_luminosity_0.5_7.0_keV')
diff -r 30d6fa6640b545777b6f211f3309e7a293795d8a -r 7582ac6f8ecd9fd0e0d33ae6b6ca5966183e448b yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
--- a/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
+++ b/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
@@ -78,9 +78,11 @@
----------
filename: string, default None
Path to data file containing emissivity values. If None,
- a file called "cloudy_emissivity.h5" is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
+ a file called "cloudy_emissivity.h5" is used, for photoionized
+ plasmas. A second option, for collisionally ionized plasmas, is
+ in the file "apec_emissivity.h5", available at http://yt-project.org/data.
+ These files contain emissivity tables for primordial elements and
+ for metals at solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
"""
@@ -161,9 +163,11 @@
the maximum energy in keV for the energy band.
filename: string, optional
Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
+ a file called "cloudy_emissivity.h5" is used, for photoionized
+ plasmas. A second option, for collisionally ionized plasmas, is
+ in the file "apec_emissivity.h5", available at http://yt-project.org/data.
+ These files contain emissivity tables for primordial elements and
+ for metals at solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
with_metals: bool, optional
If True, use the metallicity field to add the contribution from
https://bitbucket.org/yt_analysis/yt/commits/c3d17397f8c1/
Changeset: c3d17397f8c1
Branch: yt-3.0
User: brittonsmith
Date: 2014-07-03 08:57:30
Summary: Merged in jzuhone/yt-3.x/yt-3.0 (pull request #963)
Porting spectral integrator to 3.0
Affected #: 10 files
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -567,8 +567,10 @@
mkdir -p ${DEST_DIR}/data
cd ${DEST_DIR}/data
-echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 xray_emissivity.h5' > xray_emissivity.h5.sha512
-[ ! -e xray_emissivity.h5 ] && get_ytdata xray_emissivity.h5
+echo 'de6d8c6ea849f0206d219303329a0276b3cce7c051eec34377d42aacbe0a4f47ac5145eb08966a338ecddd2b83c8f787ca9956508ad5c39ee2088ad875166410 cloudy_emissivity.h5' > cloudy_emissivity.h5.sha512
+[ ! -e cloudy_emissivity.h5 ] && get_ytdata cloudy_emissivity.h5
+echo '0f714ae2eace0141b1381abf1160dc8f8a521335e886f99919caf3beb31df1fe271d67c7b2a804b1467949eb16b0ef87a3d53abad0e8160fccac1e90d8d9e85f apec_emissivity.h5' > apec_emissivity.h5.sha512
+[ ! -e apec_emissivity.h5 ] && get_ytdata apec_emissivity.h5
# Set paths to what they should be when yt is activated.
export PATH=${DEST_DIR}/bin:$PATH
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d doc/source/analyzing/analysis_modules/photon_simulator.rst
--- a/doc/source/analyzing/analysis_modules/photon_simulator.rst
+++ b/doc/source/analyzing/analysis_modules/photon_simulator.rst
@@ -1,6 +1,11 @@
Constructing Mock X-ray Observations
------------------------------------
+.. note::
+
+ If you just want to create derived fields for X-ray emission,
+ you should go `here <xray_emission_fields.html>`_ instead.
+
The ``photon_simulator`` analysis module enables the creation of
simulated X-ray photon lists of events from datasets that ``yt`` is able
to read. The simulated events then can be exported to X-ray telescope
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d doc/source/analyzing/analysis_modules/xray_emission_fields.rst
--- a/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
+++ b/doc/source/analyzing/analysis_modules/xray_emission_fields.rst
@@ -2,41 +2,46 @@
X-ray Emission Fields
=====================
-.. sectionauthor:: Britton Smith <brittonsmith at gmail.com>
+.. sectionauthor:: Britton Smith <brittonsmith at gmail.com>, John ZuHone <jzuhone at gmail.com>
+
+.. note::
+
+ If you came here trying to figure out how to create simulated X-ray photons and observations,
+ you should go `here <photon_simulator.html>`_ instead.
This functionality provides the ability to create metallicity-dependent
-X-ray luminosity, emissivity, and photo emissivity fields for a given
+X-ray luminosity, emissivity, and photon emissivity fields for a given
photon energy range. This works by interpolating from emission tables
-created with the photoionization code, `Cloudy <http://nublado.org/>`_.
-If you installed yt with the install script, the data should be located in
-the *data* directory inside the installation directory. Emission fields can
-be made for any interval between 0.1 keV and 100 keV.
+created from the photoionization code `Cloudy <http://nublado.org/>`_ or
+the collisional ionization database `AtomDB <http://www.atomdb.org>`_. If
+you installed yt with the install script, these data files should be located in
+the *data* directory inside the installation directory, or can be downloaded
+from `<http://yt-project.org/data>`_. Emission fields can be made for any
+interval between 0.1 keV and 100 keV.
Adding Emission Fields
----------------------
-Fields can be created for luminosity (erg/s), emissivity (erg/s/cm^3),
-and photon emissivity (photons/s/cm^3). The only required arguments are
-the minimum and maximum energies.
+Fields will be created for luminosity :math:`{\rm (erg~s^{-1})}`, emissivity :math:`{\rm (erg~s^{-1}~cm^{-3})}`,
+and photon emissivity :math:`{\rm (photons~s^{-1}~cm^{-3})}`. The only required arguments are the
+dataset object, and the minimum and maximum energies of the energy band.
.. code-block:: python
- from yt.mods import *
+ import yt
from yt.analysis_modules.spectral_integrator.api import \
- add_xray_luminosity_field, \
- add_xray_emissivity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
- add_xray_luminosity_field(0.5, 7)
- add_xray_emissivity_field(0.5, 7)
- add_xray_photon_emissivity_field(0.5, 7)
+ xray_fields = add_xray_emissivity_field(0.5, 7.0)
Additional keyword arguments are:
- * **filename** (*string*): Path to data file containing emissivity
- values. If None, a file called xray_emissivity.h5 is used. This file
- contains emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV. Default: None.
+ * **filename** (*string*): Path to data file containing emissivity values. If None,
+ a file called "cloudy_emissivity.h5" is used, for photoionized plasmas. A second
+ option, for collisionally ionized plasmas, is in the file "apec_emissivity.h5",
+ available at http://yt-project.org/data. These files contain emissivity tables
+ for primordial elements and for metals at solar metallicity for the energy range
+ 0.1 to 100 keV. Default: None.
* **with_metals** (*bool*): If True, use the metallicity field to add the
contribution from metals. If False, only the emission from H/He is
@@ -46,24 +51,27 @@
metallicity for the emission from metals. The *with_metals* keyword
must be set to False to use this. Default: None.
-The resulting fields can be used like all normal fields.
+The resulting fields can be used like all normal fields. The function will return the names of
+the created fields in a Python list.
-.. python-script::
+.. code-block:: python
- from yt.mods import *
+ import yt
from yt.analysis_modules.spectral_integrator.api import \
- add_xray_luminosity_field, \
- add_xray_emissivity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
- add_xray_luminosity_field(0.5, 7)
- add_xray_emissivity_field(0.5, 7)
- add_xray_photon_emissivity_field(0.5, 7)
+ xray_fields = add_xray_emissivity_field(0.5, 7.0, filename="apec_emissivity.h5")
- pf = load("enzo_tiny_cosmology/DD0046/DD0046")
- plot = SlicePlot(pf, 'x', 'Xray_Luminosity_0.5_7keV')
+ ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+ plot = yt.SlicePlot(ds, 'x', 'xray_luminosity_0.5_7.0_keV')
plot.save()
- plot = ProjectionPlot(pf, 'x', 'Xray_Emissivity_0.5_7keV')
+ plot = yt.ProjectionPlot(ds, 'x', 'xray_emissivity_0.5_7.0_keV')
plot.save()
- plot = ProjectionPlot(pf, 'x', 'Xray_Photon_Emissivity_0.5_7keV')
+ plot = yt.ProjectionPlot(ds, 'x', 'xray_photon_emissivity_0.5_7.0_keV')
plot.save()
+
+.. warning::
+
+ The X-ray fields depend on the number density of hydrogen atoms, in the yt field
+ ``H_number_density``. If this field is not defined (either in the dataset or by the user),
+ the primordial hydrogen mass fraction (X = 0.76) will be used to construct it.
\ No newline at end of file
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -956,7 +956,7 @@
if isinstance(self.parameters["Area"], basestring):
mylog.error("Writing SIMPUT files is only supported if you didn't convolve with an ARF.")
- raise TypeError
+ raise TypeError("Writing SIMPUT files is only supported if you didn't convolve with an ARF.")
if emin is None:
emin = self.events["eobs"].min().value*0.95
@@ -1032,7 +1032,10 @@
f = h5py.File(h5file, "w")
f.create_dataset("/exp_time", data=float(self.parameters["ExposureTime"]))
- f.create_dataset("/area", data=float(self.parameters["Area"]))
+ area = self.parameters["Area"]
+ if not isinstance(area, basestring):
+ area = float(area)
+ f.create_dataset("/area", data=area)
f.create_dataset("/redshift", data=self.parameters["Redshift"])
f.create_dataset("/d_a", data=float(self.parameters["AngularDiameterDistance"]))
if "ARF" in self.parameters:
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d yt/analysis_modules/photon_simulator/spectral_models.py
--- a/yt/analysis_modules/photon_simulator/spectral_models.py
+++ b/yt/analysis_modules/photon_simulator/spectral_models.py
@@ -181,7 +181,7 @@
Examples
--------
>>> apec_model = TableApecModel("/Users/jzuhone/Data/atomdb_v2.0.2/", 0.05, 50.0,
- 1000, thermal_broad=True)
+ ... 1000, thermal_broad=True)
"""
def __init__(self, apec_root, emin, emax, nchan,
apec_vers="2.0.2", thermal_broad=False):
@@ -226,7 +226,7 @@
tmpspec = np.zeros((self.nchan))
- i = np.where((self.line_handle[tindex].data.field('element')==element) &
+ i = np.where((self.line_handle[tindex].data.field('element') == element) &
(self.line_handle[tindex].data.field('lambda') > self.minlam) &
(self.line_handle[tindex].data.field('lambda') < self.maxlam))[0]
@@ -242,24 +242,24 @@
vec += np.diff(cdf)*a
else:
ie = np.searchsorted(ebins, E0, side='right')-1
- for i,a in zip(ie,amp): vec[i] += a
+ for i, a in zip(ie, amp): vec[i] += a
tmpspec += vec
- ind = np.where((self.coco_handle[tindex].data.field('Z')==element) &
- (self.coco_handle[tindex].data.field('rmJ')==0))[0]
- if len(ind)==0:
+ ind = np.where((self.coco_handle[tindex].data.field('Z') == element) &
+ (self.coco_handle[tindex].data.field('rmJ') == 0))[0]
+ if len(ind) == 0:
return tmpspec
else:
- ind=ind[0]
+ ind = ind[0]
- n_cont=self.coco_handle[tindex].data.field('N_Cont')[ind]
- e_cont=self.coco_handle[tindex].data.field('E_Cont')[ind][:n_cont]
+ n_cont = self.coco_handle[tindex].data.field('N_Cont')[ind]
+ e_cont = self.coco_handle[tindex].data.field('E_Cont')[ind][:n_cont]
continuum = self.coco_handle[tindex].data.field('Continuum')[ind][:n_cont]
tmpspec += np.interp(self.emid.ndarray_view(), e_cont, continuum)*self.de.ndarray_view()
- n_pseudo=self.coco_handle[tindex].data.field('N_Pseudo')[ind]
- e_pseudo=self.coco_handle[tindex].data.field('E_Pseudo')[ind][:n_pseudo]
+ n_pseudo = self.coco_handle[tindex].data.field('N_Pseudo')[ind]
+ e_pseudo = self.coco_handle[tindex].data.field('E_Pseudo')[ind][:n_pseudo]
pseudo = self.coco_handle[tindex].data.field('Pseudo')[ind][:n_pseudo]
tmpspec += np.interp(self.emid.ndarray_view(), e_pseudo, pseudo)*self.de.ndarray_view()
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d yt/analysis_modules/spectral_integrator/api.py
--- a/yt/analysis_modules/spectral_integrator/api.py
+++ b/yt/analysis_modules/spectral_integrator/api.py
@@ -15,6 +15,4 @@
from .spectral_frequency_integrator import \
EmissivityIntegrator, \
- add_xray_emissivity_field, \
- add_xray_luminosity_field, \
- add_xray_photon_emissivity_field
+ add_xray_emissivity_field
\ No newline at end of file
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
--- a/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
+++ b/yt/analysis_modules/spectral_integrator/spectral_frequency_integrator.py
@@ -1,6 +1,6 @@
"""
Integrator classes to deal with interpolation and integration of input spectral
-bins. Currently only supports Cloudy-style data.
+bins. Currently only supports Cloudy and APEC-style data.
@@ -23,19 +23,21 @@
mylog, \
only_on_root
-from yt.fields.local_fields import add_field
+from yt.utilities.exceptions import YTFieldNotFound
from yt.utilities.exceptions import YTException
from yt.utilities.linear_interpolators import \
- BilinearFieldInterpolator
+ UnilinearFieldInterpolator, BilinearFieldInterpolator
from yt.utilities.physical_constants import \
- erg_per_eV, hcgs
-from yt.units import keV, Hz
-keV_per_Hz = keV/Hz/hcgs
+ hcgs, mp
+from yt.units.yt_array import YTArray, YTQuantity
+from yt.utilities.physical_ratios import \
+ primordial_H_mass_fraction, erg_per_keV
xray_data_version = 1
-def _get_data_file():
- data_file = "xray_emissivity.h5"
+def _get_data_file(data_file=None):
+ if data_file is None:
+ data_file = "cloudy_emissivity.h5"
data_url = "http://yt-project.org/data"
if "YT_DEST" in os.environ and \
os.path.isdir(os.path.join(os.environ["YT_DEST"], "data")):
@@ -62,8 +64,9 @@
class ObsoleteDataException(YTException):
def __str__(self):
- return "X-ray emissivity data is out of data.\nDownload the latest data from http://yt-project.org/data/xray_emissivity.h5 and move it to %s." % \
- os.path.join(os.environ["YT_DEST"], "data", "xray_emissivity.h5")
+ return "X-ray emissivity data is out of date.\n" + \
+ "Download the latest data from http://yt-project.org/data/cloudy_emissivity.h5 and move it to %s." % \
+ os.path.join(os.environ["YT_DEST"], "data", "cloudy_emissivity.h5")
class EmissivityIntegrator(object):
r"""Class for making X-ray emissivity fields with hdf5 data tables
@@ -75,9 +78,11 @@
----------
filename: string, default None
Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
+ a file called "cloudy_emissivity.h5" is used, for photoionized
+ plasmas. A second option, for collisionally ionized plasmas, is
+ in the file "apec_emissivity.h5", available at http://yt-project.org/data.
+ These files contain emissivity tables for primordial elements and
+ for metals at solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
"""
@@ -89,7 +94,8 @@
default_filename = True
if not os.path.exists(filename):
- raise IOError("File does not exist: %s." % filename)
+ mylog.warning("File %s does not exist, will attempt to find it." % filename)
+ filename = _get_data_file(data_file=filename)
only_on_root(mylog.info, "Loading emissivity data from %s." % filename)
in_file = h5py.File(filename, "r")
if "info" in in_file.attrs:
@@ -103,51 +109,51 @@
for field in ["emissivity_primordial", "emissivity_metals",
"log_nH", "log_T", "log_E"]:
- setattr(self, field, in_file[field][:])
+ if field in in_file:
+ setattr(self, field, in_file[field][:])
in_file.close()
E_diff = np.diff(self.log_E)
self.E_bins = \
- np.power(10, np.concatenate([self.log_E[:-1] - 0.5 * E_diff,
- [self.log_E[-1] - 0.5 * E_diff[-1],
- self.log_E[-1] + 0.5 * E_diff[-1]]]))
- self.dnu = keV_per_Hz * np.diff(self.E_bins)
+ YTArray(np.power(10, np.concatenate([self.log_E[:-1] - 0.5 * E_diff,
+ [self.log_E[-1] - 0.5 * E_diff[-1],
+ self.log_E[-1] + 0.5 * E_diff[-1]]])),
+ "keV")
+ self.dnu = (np.diff(self.E_bins)/hcgs).in_units("Hz")
- def _get_interpolator(self, data, e_min, e_max):
- r"""Create an interpolator for total emissivity in a
- given energy range.
-
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
-
- """
+ def get_interpolator(self, data, e_min, e_max):
+ e_min = YTQuantity(e_min, "keV")
+ e_max = YTQuantity(e_max, "keV")
if (e_min - self.E_bins[0]) / e_min < -1e-3 or \
(e_max - self.E_bins[-1]) / e_max > 1e-3:
- raise EnergyBoundsException(np.power(10, self.E_bins[0]),
- np.power(10, self.E_bins[-1]))
+ raise EnergyBoundsException(self.E_bins[0], self.E_bins[-1])
e_is, e_ie = np.digitize([e_min, e_max], self.E_bins)
e_is = np.clip(e_is - 1, 0, self.E_bins.size - 1)
e_ie = np.clip(e_ie, 0, self.E_bins.size - 1)
- my_dnu = np.copy(self.dnu[e_is: e_ie])
+ my_dnu = self.dnu[e_is: e_ie].copy()
# clip edge bins if the requested range is smaller
- my_dnu[0] -= e_min - self.E_bins[e_is]
- my_dnu[-1] -= self.E_bins[e_ie] - e_max
+ my_dnu[0] -= ((e_min - self.E_bins[e_is])/hcgs).in_units("Hz")
+ my_dnu[-1] -= ((self.E_bins[e_ie] - e_max)/hcgs).in_units("Hz")
interp_data = (data[..., e_is:e_ie] * my_dnu).sum(axis=-1)
- return BilinearFieldInterpolator(np.log10(interp_data),
- [self.log_nH[0], self.log_nH[-1],
- self.log_T[0], self.log_T[-1]],
- ["log_nH", "log_T"], truncate=True)
+ if len(data.shape) == 2:
+ emiss = UnilinearFieldInterpolator(np.log10(interp_data),
+ [self.log_T[0], self.log_T[-1]],
+ "log_T", truncate=True)
+ else:
+ emiss = BilinearFieldInterpolator(np.log10(interp_data),
+ [self.log_nH[0], self.log_nH[-1],
+ self.log_T[0], self.log_T[-1]],
+ ["log_nH", "log_T"], truncate=True)
-def add_xray_emissivity_field(e_min, e_max, filename=None,
+ return emiss
+
+def add_xray_emissivity_field(ds, e_min, e_max,
+ filename=None,
with_metals=True,
constant_metallicity=None):
- r"""Create an X-ray emissivity field for a given energy range.
+ r"""Create X-ray emissivity fields for a given energy range.
Parameters
----------
@@ -155,197 +161,117 @@
the minimum energy in keV for the energy band.
e_min: float
the maximum energy in keV for the energy band.
-
- Other Parameters
- ----------------
- filename: string
+ filename: string, optional
Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
+ a file called "cloudy_emissivity.h5" is used, for photoionized
+ plasmas. A second option, for collisionally ionized plasmas, is
+ in the file "apec_emissivity.h5", available at http://yt-project.org/data.
+ These files contain emissivity tables for primordial elements and
+ for metals at solar metallicity for the energy range 0.1 to 100 keV.
Default: None.
- with_metals: bool
+ with_metals: bool, optional
If True, use the metallicity field to add the contribution from
metals. If False, only the emission from H/He is considered.
Default: True.
- constant_metallicity: float
+ constant_metallicity: float, optional
If specified, assume a constant metallicity for the emission
from metals. The *with_metals* keyword must be set to False
to use this.
Default: None.
- This will create a field named "Xray_Emissivity_{e_min}_{e_max}keV".
- The units of the field are erg s^-1 cm^-3.
+ This will create three fields:
+
+ "xray_emissivity_{e_min}_{e_max}_keV" (erg s^-1 cm^-3)
+ "xray_luminosity_{e_min}_{e_max}_keV" (erg s^-1)
+ "xray_photon_emissivity_{e_min}_{e_max}_keV" (photons s^-1 cm^-3)
Examples
--------
>>> from yt.mods import *
>>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_emissivity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> p = ProjectionPlot(pf, 'x', "Xray_Emissivity_0.5_2keV")
+ >>> ds = load(dataset)
+ >>> add_xray_emissivity_field(ds, 0.5, 2)
+ >>> p = ProjectionPlot(ds, 'x', "xray_emissivity_0.5_2_keV")
>>> p.save()
"""
+ if with_metals:
+ try:
+ ds._get_field_info("metal_density")
+ except YTFieldNotFound:
+ raise RuntimeError("Your dataset does not have a \"metal_density\" field! " +
+ "Perhaps you should specify a constant metallicity?")
+
my_si = EmissivityIntegrator(filename=filename)
- em_0 = my_si._get_interpolator(my_si.emissivity_primordial, e_min, e_max)
+ em_0 = my_si.get_interpolator(my_si.emissivity_primordial, e_min, e_max)
em_Z = None
if with_metals or constant_metallicity is not None:
- em_Z = my_si._get_interpolator(my_si.emissivity_metals, e_min, e_max)
+ em_Z = my_si.get_interpolator(my_si.emissivity_metals, e_min, e_max)
+
+ energy_erg = np.power(10, my_si.log_E) * erg_per_keV
+ emp_0 = my_si.get_interpolator((my_si.emissivity_primordial[..., :] / energy_erg),
+ e_min, e_max)
+ emp_Z = None
+ if with_metals or constant_metallicity is not None:
+ emp_Z = my_si.get_interpolator((my_si.emissivity_metals[..., :] / energy_erg),
+ e_min, e_max)
+
+ try:
+ ds._get_field_info("H_number_density")
+ except YTFieldNotFound:
+ mylog.warning("Could not find a field for \"H_number_density\". Assuming primordial H " +
+ "mass fraction.")
+ def _nh(field, data):
+ return primordial_H_mass_fraction*data["gas","density"]/mp
+ ds.add_field(("gas","H_number_density"), function=_nh, units="cm**-3")
def _emissivity_field(field, data):
- dd = {"log_nH" : np.log10(data["H_NumberDensity"]),
- "log_T" : np.log10(data["Temperature"])}
+ dd = {"log_nH" : np.log10(data["gas","H_number_density"]),
+ "log_T" : np.log10(data["gas","temperature"])}
my_emissivity = np.power(10, em_0(dd))
if em_Z is not None:
if with_metals:
- my_Z = data["Metallicity"]
+ my_Z = data["gas","metallicity"]
elif constant_metallicity is not None:
my_Z = constant_metallicity
my_emissivity += my_Z * np.power(10, em_Z(dd))
- return data["H_NumberDensity"]**2 * my_emissivity
+ return data["gas","H_number_density"]**2 * YTArray(my_emissivity, "erg*cm**3/s")
- field_name = "Xray_Emissivity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_emissivity_field,
- projection_conversion="cm",
- display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{erg}\/\rm{cm}^{-3}\/\rm{s}^{-1}")
- return field_name
-
-def add_xray_luminosity_field(e_min, e_max, filename=None,
- with_metals=True,
- constant_metallicity=None):
- r"""Create an X-ray luminosity field for a given energy range.
-
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
-
- Other Parameters
- ----------------
- filename: string
- Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
- Default: None.
- with_metals: bool
- If True, use the metallicity field to add the contribution from
- metals. If False, only the emission from H/He is considered.
- Default: True.
- constant_metallicity: float
- If specified, assume a constant metallicity for the emission
- from metals. The *with_metals* keyword must be set to False
- to use this.
- Default: None.
-
- This will create a field named "Xray_Luminosity_{e_min}_{e_max}keV".
- The units of the field are erg s^-1.
-
- Examples
- --------
-
- >>> from yt.mods import *
- >>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_luminosity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> sp = pf.sphere('max', (2., 'mpc'))
- >>> print sp.quantities['TotalQuantity']('Xray_Luminosity_0.5_2keV')
-
- """
-
- em_field = add_xray_emissivity_field(e_min, e_max, filename=filename,
- with_metals=with_metals,
- constant_metallicity=constant_metallicity)
+ emiss_name = "xray_emissivity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(emiss_name, function=_emissivity_field,
+ display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="erg/cm**3/s")
def _luminosity_field(field, data):
- return data[em_field] * data["CellVolume"]
- field_name = "Xray_Luminosity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_luminosity_field,
- display_name=r"\rm{L}_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{erg}\/\rm{s}^{-1}")
- return field_name
+ return data[emiss_name] * data["cell_volume"]
-def add_xray_photon_emissivity_field(e_min, e_max, filename=None,
- with_metals=True,
- constant_metallicity=None):
- r"""Create an X-ray photon emissivity field for a given energy range.
+ lum_name = "xray_luminosity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(lum_name, function=_luminosity_field,
+ display_name=r"\rm{L}_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="erg/s")
- Parameters
- ----------
- e_min: float
- the minimum energy in keV for the energy band.
- e_min: float
- the maximum energy in keV for the energy band.
+ def _photon_emissivity_field(field, data):
+ dd = {"log_nH" : np.log10(data["gas","H_number_density"]),
+ "log_T" : np.log10(data["gas","temperature"])}
- Other Parameters
- ----------------
- filename: string
- Path to data file containing emissivity values. If None,
- a file called xray_emissivity.h5 is used. This file contains
- emissivity tables for primordial elements and for metals at
- solar metallicity for the energy range 0.1 to 100 keV.
- Default: None.
- with_metals: bool
- If True, use the metallicity field to add the contribution from
- metals. If False, only the emission from H/He is considered.
- Default: True.
- constant_metallicity: float
- If specified, assume a constant metallicity for the emission
- from metals. The *with_metals* keyword must be set to False
- to use this.
- Default: None.
-
- This will create a field named "Xray_Photon_Emissivity_{e_min}_{e_max}keV".
- The units of the field are photons s^-1 cm^-3.
-
- Examples
- --------
-
- >>> from yt.mods import *
- >>> from yt.analysis_modules.spectral_integrator.api import *
- >>> add_xray_emissivity_field(0.5, 2)
- >>> pf = load(dataset)
- >>> p = ProjectionPlot(pf, 'x', "Xray_Emissivity_0.5_2keV")
- >>> p.save()
-
- """
-
- my_si = EmissivityIntegrator(filename=filename)
- energy_erg = np.power(10, my_si.log_E) * erg_per_eV
-
- em_0 = my_si._get_interpolator((my_si.emissivity_primordial[..., :] / energy_erg),
- e_min, e_max)
- em_Z = None
- if with_metals or constant_metallicity is not None:
- em_Z = my_si._get_interpolator((my_si.emissivity_metals[..., :] / energy_erg),
- e_min, e_max)
-
- def _emissivity_field(field, data):
- dd = {"log_nH" : np.log10(data["H_NumberDensity"]),
- "log_T" : np.log10(data["Temperature"])}
-
- my_emissivity = np.power(10, em_0(dd))
- if em_Z is not None:
+ my_emissivity = np.power(10, emp_0(dd))
+ if emp_Z is not None:
if with_metals:
- my_Z = data["Metallicity"]
+ my_Z = data["gas","metallicity"]
elif constant_metallicity is not None:
my_Z = constant_metallicity
- my_emissivity += my_Z * np.power(10, em_Z(dd))
+ my_emissivity += my_Z * np.power(10, emp_Z(dd))
- return data["H_NumberDensity"]**2 * my_emissivity
+ return data["gas","H_number_density"]**2 * YTArray(my_emissivity, "photons*cm**3/s")
- field_name = "Xray_Photon_Emissivity_%s_%skeV" % (e_min, e_max)
- add_field(field_name, function=_emissivity_field,
- projection_conversion="cm",
- display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
- units=r"\rm{photons}\/\rm{cm}^{-3}\/\rm{s}^{-1}")
- return field_name
+ phot_name = "xray_photon_emissivity_%s_%s_keV" % (e_min, e_max)
+ ds.add_field(phot_name, function=_photon_emissivity_field,
+ display_name=r"\epsilon_{X}\/(%s-%s\/keV)" % (e_min, e_max),
+ units="photons/cm**3/s")
+
+ return emiss_name, lum_name, phot_name
\ No newline at end of file
diff -r 57ecc4cbdf24f36a5d522c983612468861ffde35 -r c3d17397f8c1f1f82df9d7d255e3e8f8964df57d yt/units/unit_lookup_table.py
--- a/yt/units/unit_lookup_table.py
+++ b/yt/units/unit_lookup_table.py
@@ -89,6 +89,7 @@
"angstrom": (cm_per_ang, dimensions.length),
"Jy": (jansky_cgs, dimensions.specific_flux),
"counts": (1.0, dimensions.dimensionless),
+ "photons": (1.0, dimensions.dimensionless),
# for AstroPy compatibility
"solMass": (mass_sun_grams, dimensions.mass),
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list