[Yt-svn] commit/yt: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Jun 6 19:11:29 PDT 2011
3 new changesets in yt:
http://bitbucket.org/yt_analysis/yt/changeset/e1dfd9245f15/
changeset: e1dfd9245f15
branches:
user: brittonsmith
date: 2011-06-04 22:04:22
summary: Adding absorption spectrum generator.
affected #: 7 files (22.6 KB)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/analysis_modules/absorption_spectrum/__init__.py Sat Jun 04 14:04:22 2011 -0600
@@ -0,0 +1,25 @@
+"""
+Import stuff for light cone generator.
+
+Author: Britton Smith <brittons at origins.colorado.edu>
+Affiliation: CASA/University of CO, Boulder
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2008-2011 Britton Smith. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/analysis_modules/absorption_spectrum/absorption_line.py Sat Jun 04 14:04:22 2011 -0600
@@ -0,0 +1,210 @@
+"""
+Absorption line generating functions.
+
+Author: Britton Smith <brittonsmith at gmail.com>
+Affiliation: Michigan State University
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2008-2011 Britton Smith. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import numpy as na
+
+def voigt(a,u):
+ """
+ NAME:
+ VOIGT
+ PURPOSE:
+ Implementation of Voigt function
+ CATEGORY:
+ Math
+ CALLING SEQUENCE:
+ voigt=Voigt(a,u)
+ INPUTS:
+ A = Voigt "A" parameter.
+ U = Frequency in units of the Doppler frequency.
+
+ The line profile "Phi(v)", the doppler width
+ "Delv", the voigt parameter "a", and the frequency "u"
+ are given by:
+
+ Phi(v) = Voigt(a,u)/[ Delv * sqrt(pi) ]
+ Delv = Vo/c * sqrt[ 2kT/m ]
+ u = V - Vo / Delv
+ a = GAMMA / [ Delv * 4pi ]
+ Gamma = Gu + Gl + 2*Vcol
+ "Gu" and "Gl" are the widths of the upper and lower states
+ "Vcol" is the collisions per unit time
+ "Vo" is the line center frequency
+
+ OUTPUTS:
+ An array of the same type as u
+ RESTRICTIONS:
+ U must be an array, a should not be. Also this procedure is only valid
+ for the region a<1.0, u<4.0 or a<1.8(u+1), u>4, which should be most
+ astrophysical conditions (see the article below for further comments
+ PROCEDURE:
+ Follows procedure in Armstrong JQSRT 7, 85 (1967)
+ also the same as the intrinsic in the previous version of IDL
+ MODIFICATION HISTORY:
+ J. Murthy, Mar 1990 (adapted from the FORTRAN program of Armstrong)
+ Sep 1990 (better overflow checking)
+ """
+ x = na.asarray(u).astype(na.float64)
+ y = na.asarray(a).astype(na.float64)
+
+ w = na.array([0.462243670, 0.286675505, 0.109017206,
+ 0.0248105209, 0.00324377334, 0.000228338636,
+ 7.80255648e-6, 1.08606937e-7, 4.39934099e-10,
+ 2.22939365e-13])
+
+ t = na.array([0.245340708, 0.737473729, 1.23407622, 1.73853771,
+ 2.25497400, 2.78880606, 3.34785457, 3.94476404,
+ 4.60368245, 5.38748089])
+
+ # Hummer's Chebyshev Coefficients
+ c = ( 0.1999999999972224, -0.1840000000029998, 0.1558399999965025,
+ -0.1216640000043988, 0.0877081599940391, -0.0585141248086907,
+ 0.0362157301623914, -0.0208497654398036, 0.0111960116346270,
+ -0.56231896167109e-2, 0.26487634172265e-2, -0.11732670757704e-2,
+ 0.4899519978088e-3, -0.1933630801528e-3, 0.722877446788e-4,
+ -0.256555124979e-4, 0.86620736841e-5, -0.27876379719e-5,
+ 0.8566873627e-6, -0.2518433784e-6, 0.709360221e-7,
+ -0.191732257e-7, 0.49801256e-8, -0.12447734e-8,
+ 0.2997777e-9, -0.696450e-10, 0.156262e-10,
+ -0.33897e-11, 0.7116e-12, -0.1447e-12,
+ 0.285e-13, -0.55e-14, 0.10e-14,
+ -0.2e-15)
+
+ y2 = y * y
+
+ # limits are y<1., x<4 or y<1.8(x+1), x>4 (no checking performed)
+ u1 = na.exp(-x * x + y2) * na.cos(2. * x * y)
+
+ # Clenshaw's Algorithm
+ bno1 = na.zeros(x.shape)
+ bno2 = na.zeros(x.shape)
+ x1 = na.clip((x / 5.), -na.inf, 1.)
+ coef = 4. * x1 * x1 - 2.
+ for i in range(33, -1, -1):
+ bn = coef * bno1 - bno2 + c[i]
+ bno2 = na.copy(bno1)
+ bno1 = na.copy(bn)
+
+ f = x1 * (bn - bno2)
+ dno1 = 1. - 2. * x * f
+ dno2 = f
+
+ q = x > 5
+ if q.any():
+ x14 = na.power(na.clip(x[q], -na.inf, 500.), 14)
+ x12 = na.power(na.clip(x[q], -na.inf, 1000.), 12)
+ x10 = na.power(na.clip(x[q], -na.inf, 5000.), 10)
+ x8 = na.power(na.clip(x[q], -na.inf, 50000.), 8)
+ x6 = na.power(na.clip(x[q], -na.inf, 1.e6), 6)
+ x4 = na.power(na.clip(x[q], -na.inf, 1.e9), 4)
+ x2 = na.power(na.clip(x[q], -na.inf, 1.e18), 2)
+ dno1[q] = -(0.5 / x2 + 0.75 / x4 + 1.875 / x6 +
+ 6.5625 / x8 + 29.53125 / x10 +
+ 162.4218 / x12 + 1055.7421 / x14)
+ dno2[q] = (1. - dno1[q]) / (2. * x[q])
+
+ funct = y * dno1
+ if (y > 1.e-8).any():
+ q = 1.0
+ yn = y
+ for i in range(2, 51):
+ dn = (x * dno1 + dno2) * (-2. / i)
+ dno2 = dno1
+ dno1 = dn
+ if (i % 2) == 1:
+ q = -q
+ yn = yn * y2
+ g = dn.astype(na.float64) * yn
+ funct = funct + q * g
+ if na.max(na.abs(g / funct)) <= 1.e-8: break
+
+ k1 = u1 - 1.12837917 * funct
+ k1 = k1.astype(na.float64).clip(0)
+ return k1
+
+def tau_profile(lam0, fval, gamma, vkms, column_density,
+ deltav=None, delta_lambda=None,
+ lambda_bins=None, n_lambda=12000, dlambda=0.01):
+ """
+ Create an optical depth vs. wavelength profile for an
+ absorption line using a voigt profile.
+ :param lam0 (float): central wavelength (angstroms).
+ :param fval (float): f-value.
+ :param gamma (float): gamma value.
+ :param vkms (float): doppler b-parameter.
+ :param column_density (float): column density (cm^-2).
+ :param deltav (float): velocity offset from lam0 (km/s).
+ Default: None (no shift).
+ :param delta_lambda (float): wavelength offset in angstroms.
+ Default: None (no shift).
+ :param lambda_bins (array): array of wavelengths in angstroms.
+ Default: None
+ :param n_lambda (float): size of lambda bins to create
+ array if lambda_bins is None. Default: 12000
+ :param dlambda (float): lambda bin width if lambda_bins is
+ None. Default: 0.01
+ """
+
+ ## constants
+ me = 1.6726231e-24 / 1836. # grams mass electron
+ e = 4.8032e-10 # esu
+ c = 2.99792456e5 # km/s
+ ccgs = c * 1.e5 # cm/s
+
+ ## shift lam0 by deltav
+ if deltav is not None:
+ lam1 = lam0 * (1 + deltav / c)
+ elif delta_lambda is not None:
+ lam1 = lam0 + delta_lambda
+ else:
+ lam1 = lam0
+
+ ## conversions
+ vdop = vkms * 1.e5 # in cm/s
+ lam0cgs = lam0 / 1.e8 # rest wavelength in cm
+ lam1cgs = lam1 / 1.e8 # line wavelength in cm
+ nu1 = ccgs / lam1cgs # line freq in Hz
+ nudop = vdop / ccgs * nu1 # doppler width in Hz
+ lamdop = vdop / ccgs * lam1 # doppler width in Ang
+
+ ## create wavelength
+ if lambda_bins is None:
+ lambda_bins = lam1 + \
+ na.arange(n_lambda, dtype=na.float) * dlambda - \
+ n_lambda * dlambda / 2 # wavelength vector (angstroms)
+ nua = ccgs / (lambda_bins / 1.e8) # frequency vector (Hz)
+
+ ## tau_0
+ tau_X = na.sqrt(na.pi) * e**2 / (me * ccgs) * \
+ column_density * fval / vdop
+ tau1 = tau_X * lam1cgs
+ tau0 = tau_X * lam0cgs
+
+ # dimensionless frequency offset in units of doppler freq
+ x = (nua - nu1) / nudop
+ a = gamma / (4 * na.pi * nudop) # damping parameter
+ phi = voigt(a, x) # profile
+ tauphi = tau0 * phi # profile scaled with tau0
+
+ return (lambda_bins, tauphi)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/analysis_modules/absorption_spectrum/absorption_spectrum.py Sat Jun 04 14:04:22 2011 -0600
@@ -0,0 +1,285 @@
+"""
+AbsorptionSpectrum class and member functions.
+
+Author: Britton Smith <brittonsmith at gmail.com>
+Affiliation: Michigan State University
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2008-2011 Britton Smith. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import h5py
+import numpy as na
+
+from absorption_line import tau_profile
+
+from yt.funcs import get_pbar
+from yt.utilities.physical_constants import \
+ amu_cgs, boltzmann_constant_cgs, \
+ speed_of_light_cgs, km_per_cm
+
+speed_of_light_kms = speed_of_light_cgs * km_per_cm
+
+class AbsorptionSpectrum(object):
+ def __init__(self, lambda_min, lambda_max, n_lambda):
+ """
+ Create an absorption spectrum object.
+ :param lambda_min (float): lower wavelength bound in angstroms.
+ :param lambda_max (float): upper wavelength bound in angstroms.
+ :param n_lambda (float): number of wavelength bins.
+ """
+
+ self.n_lambda = n_lambda
+ self.tau_field = None
+ self.flux_field = None
+ self.spectrum_line_list = None
+ self.lambda_bins = na.linspace(lambda_min, lambda_max, n_lambda)
+ self.bin_width = (lambda_max - lambda_min) / float(n_lambda - 1)
+ self.line_list = []
+ self.continuum_list = []
+
+ def add_line(self, label, field_name, wavelength,
+ f_value, gamma, atomic_mass,
+ label_threshold=None):
+ """
+ Add an absorption line to the list of lines included in the spectrum.
+ :param label (string): label for the line.
+ :param field_name (string): field name from ray data for column densities.
+ :param wavelength (float): line rest wavelength in angstroms.
+ :param f_value (float): line f-value.
+ :param gamma (float): line gamme value.
+ :param atomic_mass (float): mass of atom in amu.
+ """
+
+ self.line_list.append({'label': label, 'field_name': field_name,
+ 'wavelength': wavelength, 'f_value': f_value,
+ 'gamma': gamma, 'atomic_mass': atomic_mass,
+ 'label_threshold': label_threshold})
+
+ def add_continuum(self, label, field_name, wavelength,
+ normalization, index):
+ """
+ Add a continuum feature that follows a power-law.
+ :param label (string): label for the feature.
+ :param field_name (string): field name from ray data for column densities.
+ :param wavelength (float): line rest wavelength in angstroms.
+ :param normalization (float): the column density normalization.
+ :param index (float): the power-law index for the wavelength dependence.
+ """
+
+ self.continuum_list.append({'label': label, 'field_name': field_name,
+ 'wavelength': wavelength,
+ 'normalization': normalization,
+ 'index': index})
+
+ def make_spectrum(self, input_file, output_file='spectrum.h5',
+ line_list_file='lines.txt',
+ use_peculiar_velocity=True):
+ """
+ Make spectrum from ray data using the line list.
+ :param input_file (string): path to input ray data.
+ :param output_file (string): path for output file.
+ File formats are chosen based on the filename extension.
+ - .h5: hdf5.
+ - .fits: fits.
+ - anything else: ascii.
+ :param use_peculiar_velocity (bool): if True, include line of sight
+ velocity for shifting lines.
+ """
+
+ input_fields = ['dl', 'redshift', 'Temperature']
+ field_data = {}
+ if use_peculiar_velocity: input_fields.append('los_velocity')
+ for feature in self.line_list + self.continuum_list:
+ if not feature['field_name'] in input_fields:
+ input_fields.append(feature['field_name'])
+
+ input = h5py.File(input_file, 'r')
+ for field in input_fields:
+ field_data[field] = input[field].value
+ input.close()
+
+ self.tau_field = na.zeros(self.lambda_bins.size)
+ self.spectrum_line_list = []
+
+ self._add_lines_to_spectrum(field_data, use_peculiar_velocity)
+ self._add_continua_to_spectrum(field_data, use_peculiar_velocity)
+
+ self.flux_field = na.exp(-self.tau_field)
+
+ if output_file.endswith('.h5'):
+ self._write_spectrum_hdf5(output_file)
+ elif output_file.endswith('.fits'):
+ self._write_spectrum_fits(output_file)
+ else:
+ self._write_spectrum_ascii(output_file)
+ self._write_spectrum_line_list(line_list_file)
+
+ del field_data
+ return (self.lambda_bins, self.flux_field)
+
+ def _add_continua_to_spectrum(self, field_data, use_peculiar_velocity):
+ """
+ Add continuum features to the spectrum.
+ """
+ # Only add continuum features down to tau of 1.e-4.
+ tau_min = 1.e-4
+
+ for continuum in self.continuum_list:
+ column_density = field_data[continuum['field_name']] * field_data['dl']
+ delta_lambda = continuum['wavelength'] * field_data['redshift']
+ if use_peculiar_velocity:
+ delta_lambda += continuum['wavelength'] * field_data['los_velocity'] / \
+ speed_of_light_cgs
+ this_wavelength = delta_lambda + continuum['wavelength']
+ right_index = na.digitize(this_wavelength, self.lambda_bins).clip(0, self.n_lambda)
+ left_index = na.digitize((this_wavelength *
+ na.power((tau_min * continuum['normalization'] /
+ column_density), (1. / continuum['index']))),
+ self.lambda_bins).clip(0, self.n_lambda)
+
+ valid_continuua = na.where(((column_density /
+ continuum['normalization']) > tau_min) &
+ (right_index - left_index > 1))[0]
+ pbar = get_pbar("Adding continuum feature - %s [%f A]: " % \
+ (continuum['label'], continuum['wavelength']),
+ valid_continuua.size)
+ for i, lixel in enumerate(valid_continuua):
+ line_tau = na.power((self.lambda_bins[left_index[lixel]:right_index[lixel]] /
+ this_wavelength[lixel]), continuum['index']) * \
+ column_density[lixel] / continuum['normalization']
+ self.tau_field[left_index[lixel]:right_index[lixel]] += line_tau
+ pbar.update(i)
+ pbar.finish()
+
+ def _add_lines_to_spectrum(self, field_data, use_peculiar_velocity):
+ """
+ Add the absorption lines to the spectrum.
+ """
+ # Only make voigt profile for slice of spectrum that is 10 times the line width.
+ spectrum_bin_ratio = 5
+
+ for line in self.line_list:
+ column_density = field_data[line['field_name']] * field_data['dl']
+ delta_lambda = line['wavelength'] * field_data['redshift']
+ if use_peculiar_velocity:
+ delta_lambda += line['wavelength'] * field_data['los_velocity'] / \
+ speed_of_light_cgs
+ thermal_b = km_per_cm * na.sqrt((2 * boltzmann_constant_cgs *
+ field_data['Temperature']) /
+ (amu_cgs * line['atomic_mass']))
+ center_bins = na.digitize((delta_lambda + line['wavelength']),
+ self.lambda_bins)
+
+ # ratio of line width to bin width
+ width_ratio = (line['wavelength'] + delta_lambda) * \
+ thermal_b / speed_of_light_kms / self.bin_width
+
+ # do voigt profiles for a subset of the full spectrum
+ left_index = (center_bins -
+ spectrum_bin_ratio * width_ratio).astype(int).clip(0, self.n_lambda)
+ right_index = (center_bins +
+ spectrum_bin_ratio * width_ratio).astype(int).clip(0, self.n_lambda)
+
+ # loop over all lines wider than the bin width
+ valid_lines = na.where((width_ratio >= 1.0) &
+ (right_index - left_index > 1))[0]
+ pbar = get_pbar("Adding line - %s [%f A]: " % (line['label'], line['wavelength']),
+ valid_lines.size)
+ for i, lixel in enumerate(valid_lines):
+ lambda_bins, line_tau = \
+ tau_profile(line['wavelength'], line['f_value'],
+ line['gamma'], thermal_b[lixel],
+ column_density[lixel],
+ delta_lambda=delta_lambda[lixel],
+ lambda_bins=self.lambda_bins[left_index[lixel]:right_index[lixel]])
+ self.tau_field[left_index[lixel]:right_index[lixel]] += line_tau
+ if line['label_threshold'] is not None and \
+ column_density[lixel] >= line['label_threshold']:
+ if use_peculiar_velocity:
+ peculiar_velocity = km_per_cm * field_data['los_velocity'][lixel]
+ else:
+ peculiar_velocity = 0.0
+ self.spectrum_line_list.append({'label': line['label'],
+ 'wavelength': (line['wavelength'] +
+ delta_lambda[lixel]),
+ 'column_density': column_density[lixel],
+ 'b_thermal': thermal_b[lixel],
+ 'redshift': field_data['redshift'][lixel],
+ 'v_pec': peculiar_velocity})
+ pbar.update(i)
+ pbar.finish()
+
+ del column_density, delta_lambda, thermal_b, \
+ center_bins, width_ratio, left_index, right_index
+
+ def _write_spectrum_line_list(self, filename):
+ """
+ Write out list of spectral lines.
+ """
+ print "Writing spectral line list: %s." % filename
+ self.spectrum_line_list.sort(key=lambda obj: obj['wavelength'])
+ f = open(filename, 'w')
+ f.write('#%-14s %-14s %-12s %-12s %-12s %-12s\n' %
+ ('Wavelength', 'Line', 'N [cm^-2]', 'b [km/s]', 'z', 'v_pec [km/s]'))
+ for line in self.spectrum_line_list:
+ f.write('%-14.6f %-14ls %e %e %e %e.\n' % (line['wavelength'], line['label'],
+ line['column_density'], line['b_thermal'],
+ line['redshift'], line['v_pec']))
+ f.close()
+
+ def _write_spectrum_ascii(self, filename):
+ """
+ Write spectrum to an ascii file.
+ """
+ print "Writing spectrum to ascii file: %s." % filename
+ f = open(filename, 'w')
+ f.write("# wavelength[A] tau flux\n")
+ for i in xrange(self.lambda_bins.size):
+ f.write("%e %e %e\n" % (self.lambda_bins[i],
+ self.tau_field[i], self.flux_field[i]))
+ f.close()
+
+ def _write_spectrum_fits(self, filename):
+ """
+ Write spectrum to a fits file.
+ """
+ try:
+ import pyfits
+ except:
+ print "Could not import the pyfits module. Please install pyfits."
+ return
+
+ print "Writing spectrum to fits file: %s." % filename
+ col1 = pyfits.Column(name='wavelength', format='E', array=self.lambda_bins)
+ col2 = pyfits.Column(name='flux', format='E', array=self.flux_field)
+ cols = pyfits.ColDefs([col1, col2])
+ tbhdu = pyfits.new_table(cols)
+ tbhdu.writeto(filename, clobber=True)
+
+ def _write_spectrum_hdf5(self, filename):
+ """
+ Write spectrum to an hdf5 file.
+
+ """
+ print "Writing spectrum to hdf5 file: %s." % filename
+ output = h5py.File(filename, 'w')
+ output.create_dataset('wavelength', data=self.lambda_bins)
+ output.create_dataset('tau', data=self.tau_field)
+ output.create_dataset('flux', data=self.flux_field)
+ output.close()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/analysis_modules/absorption_spectrum/api.py Sat Jun 04 14:04:22 2011 -0600
@@ -0,0 +1,32 @@
+"""
+API for absorption_spectrum
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: UCSD
+Author: J.S. Oishi <jsoishi at gmail.com>
+Affiliation: KIPAC/SLAC/Stanford
+Author: Britton Smith <brittonsmith at gmail.com>
+Affiliation: MSU
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2010-2011 Matthew Turk. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+
+from .absorption_spectrum import \
+ AbsorptionSpectrum
--- a/yt/analysis_modules/api.py Thu Jun 02 18:31:36 2011 -0600
+++ b/yt/analysis_modules/api.py Sat Jun 04 14:04:22 2011 -0600
@@ -28,6 +28,9 @@
"""
+from .absorption_spectrum.api import \
+ AbsorptionSpectrum
+
from .coordinate_transformation.api import \
spherical_regrid
--- a/yt/analysis_modules/setup.py Thu Jun 02 18:31:36 2011 -0600
+++ b/yt/analysis_modules/setup.py Sat Jun 04 14:04:22 2011 -0600
@@ -6,6 +6,7 @@
config = Configuration('analysis_modules',parent_package,top_path)
config.make_config_py() # installs __config__.py
config.make_svn_version_py()
+ config.add_subpackage("absorption_spectrum")
config.add_subpackage("coordinate_transformation")
config.add_subpackage("halo_finding")
config.add_subpackage("halo_mass_function")
--- a/yt/utilities/physical_constants.py Thu Jun 02 18:31:36 2011 -0600
+++ b/yt/utilities/physical_constants.py Sat Jun 04 14:04:22 2011 -0600
@@ -5,6 +5,7 @@
# Masses
mass_hydrogen_cgs = 1.67e-24 # g
mass_electron_cgs = 9.11e-28 # g
+amu_cgs = 1.66053886e-24 # g
# Velocities
speed_of_light_cgs = 2.99792458e10 # cm/s, exact
@@ -24,7 +25,7 @@
mass_mean_atomic_cosmology = 1.22
mass_mean_atomic_galactic = 2.3
-# Conversion Factors: X au * mpc_per_au = Y au
+# Conversion Factors: X au * mpc_per_au = Y mpc
# length
mpc_per_mpc = 1
mpc_per_kpc = 1e-3
http://bitbucket.org/yt_analysis/yt/changeset/d4efa8b66dd2/
changeset: d4efa8b66dd2
branches:
user: brittonsmith
date: 2011-06-07 04:10:28
summary: Updating docstring docs for light cone and light ray.
affected #: 2 files (4.9 KB)
--- a/yt/analysis_modules/light_cone/light_cone.py Sat Jun 04 14:04:22 2011 -0600
+++ b/yt/analysis_modules/light_cone/light_cone.py Mon Jun 06 22:10:28 2011 -0400
@@ -49,25 +49,29 @@
set_parameters=None, output_dir='LC', output_prefix='LightCone', **kwargs):
"""
Initialize a LightCone object.
- :param initial_redshift (float): the initial (highest) redshift for the light cone. Default: 1.0.
- :param final_redshift (float): the final (lowest) redshift for the light cone. Default: 0.0.
+ :param initial_redshift (float): the initial (highest) redshift for the light cone.
+ Default: 1.0.
+ :param final_redshift (float): the final (lowest) redshift for the light cone.
+ Default: 0.0.
:param observer_redshift (float): the redshift of the observer. Default: 0.0.
- :param field_of_view_in_arcminutes (float): the field of view of the image in units of arcminutes.
- Default: 600.0.
- :param image_resolution_in_arcseconds (float): the size of each image pixel in units of arcseconds.
- Default: 60.0.
- :param use_minimum_datasets (bool): if True, the minimum number of datasets is used to connect the
- initial and final redshift. If false, the light cone solution will contain as many entries
- as possible within the redshift interval. Default: True.
- :param deltaz_min (float): specifies the minimum :math:`\Delta z` between consecutive datasets in
- the returned list. Default: 0.0.
- :param minimum_coherent_box_fraction (float): used with use_minimum_datasets set to False, this
- parameter specifies the fraction of the total box size to be traversed before rerandomizing
- the projection axis and center. This was invented to allow light cones with thin slices to
- sample coherent large scale structure, but in practice does not work so well. Try setting
- this parameter to 1 and see what happens. Default: 0.0.
- :param set_parameters (dict): dictionary of parameters to attach to pf.parameters. Default: None.
- :param output_dir (str): the directory in which images and data files will be written. Default: 'LC'.
+ :param field_of_view_in_arcminutes (float): the field of view of the image in units of
+ arcminutes. Default: 600.0.
+ :param image_resolution_in_arcseconds (float): the size of each image pixel in units of
+ arcseconds. Default: 60.0.
+ :param use_minimum_datasets (bool): if True, the minimum number of datasets is used to
+ connect the initial and final redshift. If false, the light cone solution will contain
+ as many entries as possible within the redshift interval. Default: True.
+ :param deltaz_min (float): specifies the minimum :math:`\Delta z` between consecutive
+ datasets in the returned list. Default: 0.0.
+ :param minimum_coherent_box_fraction (float): used with use_minimum_datasets set to
+ False, this parameter specifies the fraction of the total box size to be traversed before
+ rerandomizing the projection axis and center. This was invented to allow light cones with
+ thin slices to sample coherent large scale structure, but in practice does not work so
+ well. Try setting this parameter to 1 and see what happens. Default: 0.0.
+ :param set_parameters (dict): dictionary of parameters to attach to pf.parameters.
+ Default: None.
+ :param output_dir (str): the directory in which images and data files will be written.
+ Default: 'LC'.
:param output_prefix (str): the prefix of all images and data files. Default: 'LightCone'.
"""
--- a/yt/analysis_modules/light_ray/light_ray.py Sat Jun 04 14:04:22 2011 -0600
+++ b/yt/analysis_modules/light_ray/light_ray.py Mon Jun 06 22:10:28 2011 -0400
@@ -46,13 +46,39 @@
from yt.convenience import load
class LightRay(EnzoSimulation):
- def __init__(self, EnzoParameterFile, FinalRedshift, InitialRedshift,
+ def __init__(self, enzo_parameter_file, final_redshift, initial_redshift,
deltaz_min=0.0, use_minimum_datasets=True,
minimum_coherent_box_fraction=0.0, **kwargs):
+ """
+ Create a LightRay object. A light ray is much like a light cone, in that
+ it stacks together multiple datasets in order to extend a redshift interval.
+ Unlike a light cone, which does randomly oriented projections for each dataset,
+ a light ray consists of randomly oriented single rays. The purpose of these
+ is to create synthetic QSO lines of sight.
- EnzoSimulation.__init__(self, EnzoParameterFile,
- initial_redshift=InitialRedshift,
- final_redshift=FinalRedshift, links=True,
+ Once the LightRay object is set up, use LightRay.make_light_ray to begin making
+ rays. Different randomizations can be created with a single object by providing
+ different random seeds to make_light_ray.
+
+ :param enzo_parameter_file (string): path to simulation parameter file.
+ :param final_redshift (float): lower bound of the ray redshift interval.
+ :param initial_redshift (float): upper bound of the ray redshift interval.
+ :param deltaz_min (float): minimum delta z between consecutive datasets.
+ Default: 0.0.
+ :param use_minimum_datasets (bool): if True, the minimum number of datasets is
+ used to connect the initial and final redshift. If false, the light ray
+ solution will contain as many entries as possible within the redshift interval.
+ Default: True.
+ minimum_coherent_box_fraction (float): used with use_minimum_datasets set to False,
+ this parameter specifies the fraction of the total box size to be traversed before
+ rerandomizing the projection axis and center. This was invented to allow light cones
+ with thin slices to sample coherent large scale structure, but in practice does not
+ work so well. It is not very clear what this will do to a light ray. Default: 0.0.
+ """
+
+ EnzoSimulation.__init__(self, enzo_parameter_file,
+ initial_redshift=initial_redshift,
+ final_redshift=final_redshift, links=True,
enzo_parameters={'CosmologyComovingBoxSize':float},
**kwargs)
@@ -85,7 +111,7 @@
for q in range(len(self.light_ray_solution)):
if (q == len(self.light_ray_solution) - 1):
- z_next = self.FinalRedshift
+ z_next = self.final_redshift
else:
z_next = self.light_ray_solution[q+1]['redshift']
@@ -130,16 +156,62 @@
boxFractionUsed += self.light_ray_solution[q]['TraversalBoxFraction']
if filename is not None:
- self._write_light_ray_solution(filename, \
- extra_info={'EnzoParameterFile':self.EnzoParameterFile,
- 'RandomSeed':seed,
- 'InitialRedshift':self.InitialRedshift,
- 'FinalRedshift':self.FinalRedshift})
+ self._write_light_ray_solution(filename,
+ extra_info={'enzo_parameter_file':self.enzo_parameter_file,
+ 'RandomSeed':seed,
+ 'initial_redshift':self.initial_redshift,
+ 'final_redshift':self.final_redshift})
def make_light_ray(self, seed=None, fields=None,
solution_filename=None, data_filename=None,
get_nearest_galaxy=False, get_los_velocity=False, **kwargs):
- "Create a light ray and get field values for each lixel."
+ """
+ Create a light ray and get field values for each lixel. A light ray consists of
+ a list of field values for cells intersected by the ray and the path length of
+ the ray through those cells. Light ray data can be written out to an hdf5 file.
+
+ :param seed (int): seed for the random number generator. Default: None.
+ :param fields (list): a list of fields for which to get data. Default: None.
+ :param solution_filename (string): path to a text file where the trajectories of each
+ subray is written out. Default: None.
+ :param data_filename (string): path to output file for ray data. Default: None.
+ :param get_nearest_galaxy (bool): if True, the HaloProfiler will be used to calculate
+ the distance and mass of the nearest halo for each point in the ray. This option
+ requires additional information to be included. See below for an example.
+ Default: False.
+ :param get_los_velocity (bool): if True, the line of sight velocity is calculated for
+ each point in the ray. Default: False.
+
+ GETTING THE NEAREST GALAXIES
+ The light ray tool will use the HaloProfiler to calculate the distance and mass
+ of the nearest halo to that pixel. In order to do this, three additional keyword
+ arguments must be supplied to tell the HaloProfiler what to do.
+
+ :param halo_profiler_kwargs (dict): a dictionary of standard HaloProfiler keyword
+ arguments and values to be given to the HaloProfiler.
+ EXAMPLE: halo_profiler_kwargs = {'halo_list_format': {'id':0,
+ 'center':[4, 5, 6]},
+ 'TotalMassMsun':1},
+ 'halo_list_file': 'HopAnalysis.out'}
+
+ :param halo_profiler_actions (list): a list of actions to be performed by the
+ HaloProfiler. Each item in the list should be a dictionary with the following
+ entries: "function", "args", and "kwargs", for the function to be performed,
+ the arguments supplied to that function, and the keyword arguments.
+ EXAMPLE: halo_profiler_actions = [{'function': make_profiles,
+ 'args': None,
+ 'kwargs': {'filename': 'VirializedHalos.out'}},
+ {'function': add_halo_filter,
+ 'args': VirialFilter,
+ 'kwargs': {'overdensity_field': 'ActualOverdensity',
+ 'virial_overdensity': 200,
+ 'virial_filters': [['TotalMassMsun','>=','1e14']],
+ 'virial_quantities': ['TotalMassMsun','RadiusMpc']}}]
+
+ :param halo_list (string): 'all' to use the full halo list, or 'filtered' to use
+ the filtered halo list created after calling make_profiles.
+ EXAMPLE: halo_list = 'filtered'
+ """
# Calculate solution.
self._calculate_light_ray_solution(seed=seed, filename=solution_filename)
@@ -163,7 +235,7 @@
mylog.info("Proc %04d: creating ray segment at z = %f." %
(my_rank, segment['redshift']))
if segment['next'] is None:
- next_redshift = self.FinalRedshift
+ next_redshift = self.final_redshift
else:
next_redshift = segment['next']['redshift']
http://bitbucket.org/yt_analysis/yt/changeset/9b135b7e9376/
changeset: 9b135b7e9376
branches:
user: brittonsmith
date: 2011-06-07 04:10:38
summary: Merged.
affected #: 9 files (5.9 KB)
--- a/yt/data_objects/data_containers.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/data_objects/data_containers.py Mon Jun 06 22:10:38 2011 -0400
@@ -1421,7 +1421,7 @@
class AMRQuadTreeProjBase(AMR2DData):
_top_node = "/Projections"
_key_fields = AMR2DData._key_fields + ['weight_field']
- _type_name = "quad_proj"
+ _type_name = "proj"
_con_args = ('axis', 'field', 'weight_field')
def __init__(self, axis, field, weight_field = None,
max_level = None, center = None, pf = None,
@@ -1705,7 +1705,7 @@
class AMRProjBase(AMR2DData):
_top_node = "/Projections"
_key_fields = AMR2DData._key_fields + ['weight_field']
- _type_name = "proj"
+ _type_name = "overlap_proj"
_con_args = ('axis', 'field', 'weight_field')
def __init__(self, axis, field, weight_field = None,
max_level = None, center = None, pf = None,
--- a/yt/data_objects/derived_quantities.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/data_objects/derived_quantities.py Mon Jun 06 22:10:38 2011 -0400
@@ -109,7 +109,10 @@
rv = []
for my_list in self.retvals:
data = na.array(my_list).transpose()
- rv.append(self._mpi_catarray(data).transpose())
+ old_shape = data.shape
+ data = self._mpi_catarray(data).transpose()
+ if len(data.shape) != old_shape: data = data.squeeze()
+ rv.append(data)
self.retvals = rv
def _call_func_unlazy(self, args, kwargs):
--- a/yt/frontends/flash/data_structures.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/frontends/flash/data_structures.py Mon Jun 06 22:10:38 2011 -0400
@@ -294,6 +294,21 @@
[self._find_parameter("real", "%smin" % ax) for ax in 'xyz'])
self.domain_right_edge = na.array(
[self._find_parameter("real", "%smax" % ax) for ax in 'xyz'])
+
+ # Determine domain dimensions
+ try:
+ nxb = self._find_parameter("integer", "nxb", handle = self._handle)
+ nyb = self._find_parameter("integer", "nyb", handle = self._handle)
+ nzb = self._find_parameter("integer", "nzb", handle = self._handle)
+ except KeyError:
+ nxb, nyb, nzb = [int(self._handle["/simulation parameters"]['n%sb' % ax])
+ for ax in 'xyz']
+ nblockx = self._find_parameter("integer", "nblockx", handle = self._handle)
+ nblocky = self._find_parameter("integer", "nblockx", handle = self._handle)
+ nblockz = self._find_parameter("integer", "nblockx", handle = self._handle)
+ self.domain_dimensions = \
+ na.array([nblockx*nxb,nblocky*nyb,nblockz*nzb])
+
if self._flash_version == 7:
self.current_time = float(
self._handle["simulation parameters"][:]["time"])
--- a/yt/gui/reason/bottle_mods.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/gui/reason/bottle_mods.py Mon Jun 06 22:10:38 2011 -0400
@@ -152,6 +152,9 @@
print "WARNING: %s has no _route_prefix attribute. Not notifying."
continue
w._route_prefix = token
+ repl.activate()
+ while not repl.execution_thread.queue.empty():
+ time.sleep(1)
print
print
print "============================================================================="
@@ -195,7 +198,7 @@
import yt.utilities.rocket as rocket
server_type = YTRocketServer
log = logging.getLogger('Rocket')
- log.setLevel(logging.INFO)
+ log.setLevel(logging.WARNING)
kwargs = {'timeout': 600, 'max_threads': 2}
if repl is not None:
repl.server = YTRocketServer.server_info
--- a/yt/gui/reason/extdirect_repl.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py Mon Jun 06 22:10:38 2011 -0400
@@ -106,24 +106,24 @@
def run(self):
while 1:
- print "Checking for a queue ..."
+ #print "Checking for a queue ..."
try:
task = self.queue.get(True, 10)
except (Queue.Full, Queue.Empty):
if self.repl.stopped: return
continue
- print "Received the task", task
+ #print "Received the task", task
if task['type'] == 'code':
self.execute_one(task['code'], task['hide'])
self.queue.task_done()
elif task['type'] == 'add_widget':
- print "Adding new widget"
+ #print "Adding new widget"
self.queue.task_done()
new_code = self.repl._add_widget(
task['name'], task['widget_data_name'])
- print "Got this command:", new_code
+ #print "Got this command:", new_code
self.repl.execute(new_code, hide=True)
- print "Executed!"
+ #print "Executed!"
def execute_one(self, code, hide):
self.repl.executed_cell_texts.append(code)
@@ -237,13 +237,13 @@
self.execute("data_objects = []", hide = True)
self.locals['load_script'] = ext_load_script
self.locals['deliver_image'] = deliver_image
+
+ def activate(self):
self._setup_logging_handlers()
-
# Setup our heartbeat
self.last_heartbeat = time.time()
self._check_heartbeat()
self.execution_thread.start()
- if self.debug: time.sleep(3)
def exception_handler(self, exc):
result = {'type': 'cell_results',
--- a/yt/utilities/_amr_utils/QuadTree.pyx Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/utilities/_amr_utils/QuadTree.pyx Mon Jun 06 22:10:38 2011 -0400
@@ -147,6 +147,8 @@
total += self.count_total_cells(root.children[i][j])
return total + 1
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
cdef int fill_buffer(self, QuadTreeNode *root, int curpos,
np.ndarray[np.int32_t, ndim=1] refined,
np.ndarray[np.float64_t, ndim=2] values,
@@ -164,6 +166,8 @@
refined, values, wval)
return curpos
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
cdef int unfill_buffer(self, QuadTreeNode *root, int curpos,
np.ndarray[np.int32_t, ndim=1] refined,
np.ndarray[np.float64_t, ndim=2] values,
@@ -186,6 +190,8 @@
return curpos
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
def frombuffer(self, np.ndarray[np.int32_t, ndim=1] refined,
np.ndarray[np.float64_t, ndim=2] values,
np.ndarray[np.float64_t, ndim=1] wval):
@@ -197,6 +203,8 @@
curpos = self.unfill_buffer(self.root_nodes[i][j], curpos,
refined, values, wval)
+ @cython.boundscheck(False)
+ @cython.wraparound(False)
def tobuffer(self):
cdef int total = 0
for i in range(self.top_grid_dims[0]):
@@ -226,7 +234,7 @@
int level, np.int64_t pos[2],
np.float64_t *val,
np.float64_t weight_val):
- cdef int i, j
+ cdef int i, j, L
cdef QuadTreeNode *node
node = self.find_on_root_level(pos, level)
cdef np.int64_t fac
@@ -240,6 +248,7 @@
node = node.children[i][j]
QTN_add_value(node, val, weight_val)
+ @cython.cdivision(True)
cdef QuadTreeNode *find_on_root_level(self, np.int64_t pos[2], int level):
# We need this because the root level won't just have four children
# So we find on the root level, then we traverse the tree.
@@ -266,6 +275,7 @@
pos[0] = pxs[p]
pos[1] = pys[p]
self.add_to_position(level, pos, vals, pweight_vals[p])
+ return
def add_grid_to_tree(self, int level,
np.ndarray[np.int64_t, ndim=1] start_index,
--- a/yt/utilities/command_line.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/utilities/command_line.py Mon Jun 06 22:10:38 2011 -0400
@@ -26,7 +26,8 @@
from yt.mods import *
from yt.funcs import *
import cmdln as cmdln
-import optparse, os, os.path, math, sys, time, subprocess
+import optparse, os, os.path, math, sys, time, subprocess, getpass, tempfile
+import urllib, urllib2, base64
def _fix_pf(arg):
if os.path.isdir("%s" % arg) and \
@@ -88,9 +89,9 @@
help="Desired units"),
center = dict(short="-c", long="--center",
action="store", type="float",
- dest="center", default=[0.5, 0.5, 0.5],
+ dest="center", default=None,
nargs=3,
- help="Center (-1,-1,-1 for max)"),
+ help="Center, command separated (-1 -1 -1 for max)"),
bn = dict(short="-b", long="--basename",
action="store", type="string",
dest="basename", default=None,
@@ -277,6 +278,22 @@
version = _get_hg_version(path)[:12]
return version
+# This code snippet is modified from Georg Brandl
+def bb_apicall(endpoint, data, use_pass = True):
+ uri = 'https://api.bitbucket.org/1.0/%s/' % endpoint
+ # since bitbucket doesn't return the required WWW-Authenticate header when
+ # making a request without Authorization, we cannot use the standard urllib2
+ # auth handlers; we have to add the requisite header from the start
+ if data is not None:
+ data = urllib.urlencode(data)
+ req = urllib2.Request(uri, data)
+ if use_pass:
+ username = raw_input("Bitbucket Username? ")
+ password = getpass.getpass()
+ upw = '%s:%s' % (username, password)
+ req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
+ return urllib2.urlopen(req).read()
+
class YTCommands(cmdln.Cmdln):
name="yt"
@@ -461,6 +478,8 @@
if opts.center == (-1,-1,-1):
mylog.info("No center fed in; seeking.")
v, center = pf.h.find_max("Density")
+ elif opts.center is None:
+ center = 0.5*(pf.domain_left_edge + pf.domain_right_edge)
center = na.array(center)
pc=PlotCollection(pf, center=center)
if opts.axis == 4:
@@ -609,7 +628,7 @@
help="Description for this pasteboard entry")
def do_pasteboard(self, subcmd, opts, arg):
"""
- Place a file into the user's pasteboard
+ Place a file into your pasteboard.
"""
if opts.desc is None: raise RuntimeError
from yt.utilities.pasteboard import PostInventory
@@ -620,9 +639,103 @@
default = None, dest="output_fn",
help="File to output to; else, print.")
def do_pastegrab(self, subcmd, opts, username, paste_id):
+ """
+ Download from your or another user's pasteboard.
+ """
from yt.utilities.pasteboard import retrieve_pastefile
retrieve_pastefile(username, paste_id, opts.output_fn)
+ def do_bugreport(self, subcmd, opts):
+ """
+ Report a bug in yt
+ """
+ print "==============================================================="
+ print
+ print "Hi there! Welcome to the yt bugreport taker."
+ print
+ print "==============================================================="
+ print
+ print "At any time in advance of the upload of the bug, you"
+ print "should feel free to ctrl-C out and submit the bug "
+ print "report manually by going here:"
+ print " http://hg.enzotools.org/yt/issues/new"
+ print
+ print "First off, how about a nice, pithy summary of the bug?"
+ print
+ try:
+ current_version = get_yt_version()
+ except:
+ current_version = "Unavailable"
+ summary = raw_input("Summary? ")
+ bugtype = "bug"
+ data = dict(title = summary, type=bugtype)
+ print "Okay, now let's get a bit more information."
+ print
+ print "Remember that if you want to submit a traceback, you can run"
+ print "any script with --paste or --detailed-paste to submit it to"
+ print "the pastebin."
+ if "EDITOR" in os.environ:
+ print
+ print "Press enter to spawn your editor, %s" % os.environ["EDITOR"]
+ loki = raw_input()
+ tf = tempfile.NamedTemporaryFile(delete=False)
+ fn = tf.name
+ tf.close()
+ popen = subprocess.call("$EDITOR %s" % fn, shell = True)
+ content = open(fn).read()
+ try:
+ os.unlink(fn)
+ except:
+ pass
+ else:
+ print
+ print "Couldn't find an $EDITOR variable. So, let's just take"
+ print "take input here. Type up your summary until you're ready"
+ print "to be done, and to signal you're done, type --- by itself"
+ print "on a line to signal your completion."
+ print
+ print "(okay, type now)"
+ print
+ lines = []
+ while 1:
+ line = raw_input()
+ if line.strip() == "---": break
+ lines.append(line)
+ content = "\n".join(lines)
+ content = "Reporting Version: %s\n\n%s" % (current_version, content)
+ endpoint = "repositories/yt_analysis/yt/issues"
+ data['content'] = content
+ print
+ print "==============================================================="
+ print
+ print "Okay, we're going to submit with this:"
+ print
+ print "Summary: %s" % (data['title'])
+ print
+ print "---"
+ print content
+ print "---"
+ print
+ print "==============================================================="
+ print
+ print "Is that okay? If not, hit ctrl-c. Otherwise, enter means"
+ print "'submit'. Next we'll ask for your Bitbucket Username."
+ print "If you don't have one, run the 'yt bootstrap_dev' command."
+ print
+ loki = raw_input()
+ retval = bb_apicall(endpoint, data, use_pass=True)
+ import json
+ retval = json.loads(retval)
+ url = "http://hg.enzotools.org/yt/issue/%s" % retval['local_id']
+ print
+ print "==============================================================="
+ print
+ print "Thanks for your bug report! You can view it here:"
+ print " %s" % url
+ print
+ print "Keep in touch!"
+ print
+
def do_bootstrap_dev(self, subcmd, opts):
"""
Bootstrap a yt development environment
@@ -1009,6 +1122,7 @@
bottle.debug()
uuid_serve_functions(open_browser=opts.open_browser,
port=int(opts.port), repl=hr)
+
def do_remote(self, subcmd, opts):
import getpass, sys, socket, time, webbrowser
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py Mon Jun 06 22:10:38 2011 -0400
@@ -1293,13 +1293,13 @@
while mask < size:
if (mask & rank) != 0:
target = (rank & ~mask) % size
- print "SENDING FROM %02i to %02i" % (rank, target)
+ #print "SENDING FROM %02i to %02i" % (rank, target)
self._send_quadtree(target, qt, tgd, args)
#qt = self._recv_quadtree(target, tgd, args)
else:
target = (rank | mask)
if target < size:
- print "RECEIVING FROM %02i on %02i" % (target, rank)
+ #print "RECEIVING FROM %02i on %02i" % (target, rank)
qto = self._recv_quadtree(target, tgd, args)
merge_quadtrees(qt, qto)
del qto
--- a/yt/visualization/profile_plotter.py Mon Jun 06 22:10:28 2011 -0400
+++ b/yt/visualization/profile_plotter.py Mon Jun 06 22:10:38 2011 -0400
@@ -37,7 +37,7 @@
BinnedProfile1D, \
BinnedProfile2D
from .plot_types import ProfilePlot, PhasePlot
-from .tick_locators import LogLocator
+from .tick_locators import LogLocator, LinearLocator
from yt.utilities.logger import ytLogger as mylog
def invalidate_plot(f):
@@ -57,6 +57,8 @@
def calculate_ticks(self):
if self.scale == 'log':
locator = LogLocator()
+ elif self.scale == 'linear':
+ locator = LinearLocator()
else:
raise NotImplementedError
self.ticks = locator(*self.bounds)
@@ -86,10 +88,12 @@
if self.x_spec.scale == 'log' and \
self.y_spec.scale == 'log':
func = axes.loglog
- elif self.x_spec == 'log':
+ elif self.x_spec.scale == 'log':
func = axes.semilogx
- elif self.y_spec == 'log':
+ elif self.y_spec.scale == 'log':
func = axes.semilogy
+ else:
+ func = axes.plot
if self.plot_spec is None:
kwargs = {}
else:
@@ -277,7 +281,7 @@
self._current_field = field_z
self.profile = profile
self.scale = {True:'log', False:'linear'}.get(
- data_source.pf.field_info[field_z], "log")
+ data_source.pf.field_info[field_z].take_log, "log")
self._setup_plot()
def _setup_plot(self):
@@ -404,7 +408,7 @@
self._current_field = field_y
self.profile = profile
self.scale = {True:'log', False:'linear'}.get(
- data_source.pf.field_info[field_y], "log")
+ data_source.pf.field_info[field_y].take_log, "log")
self._setup_plot()
def _setup_plot(self):
@@ -421,7 +425,7 @@
ny = (self.profile[self._current_field] > 0)
mi = self.profile[self._current_field][ny].min()
else:
- mi = self.profile[self._current_field][ny].min()
+ mi = self.profile[self._current_field].min()
ma = self.profile[self._current_field].max()
yax.bounds = (mi, ma)
yax.scale = self.scale
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