[yt-svn] commit/yt-3.0: xarthisius: [sunyaev_zeldovich/projection] API fix for pf.h.proj

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Oct 10 00:34:30 PDT 2013


1 new commit in yt-3.0:

https://bitbucket.org/yt_analysis/yt-3.0/commits/bbc172ce561b/
Changeset:   bbc172ce561b
Branch:      yt-3.0
User:        xarthisius
Date:        2013-10-10 09:33:24
Summary:     [sunyaev_zeldovich/projection] API fix for pf.h.proj
Affected #:  1 file

diff -r df014c2a539d29bccef80bbc25f49bec8d019c60 -r bbc172ce561bf6dc3f518a7a4af590b58bf8848e yt/analysis_modules/sunyaev_zeldovich/projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/projection.py
@@ -7,7 +7,7 @@
 For details on the computations involved please refer to the following references:
 
 Chluba, Nagai, Sazonov, Nelson, MNRAS, 2012, arXiv:1205.5778
-Chluba, Switzer, Nagai, Nelson, MNRAS, 2012, arXiv:1211.3206 
+Chluba, Switzer, Nagai, Nelson, MNRAS, 2012, arXiv:1211.3206
 """
 
 #-----------------------------------------------------------------------------
@@ -30,7 +30,7 @@
 import numpy as np
 
 I0 = 2*(kboltz*Tcmb)**3/((hcgs*clight)**2)*1.0e17
-        
+
 try:
     import SZpack
 except:
@@ -78,7 +78,7 @@
     >>> szprj = SZProjection(pf, freqs, high_order=True)
     """
     def __init__(self, pf, freqs, mue=1.143, high_order=False):
-            
+
         self.pf = pf
         self.num_freqs = len(freqs)
         self.high_order = high_order
@@ -99,7 +99,7 @@
         for f, field in zip(self.freqs, self.freq_fields):
             self.units[field] = r"$\mathrm{MJy\ sr^{-1}}$"
             self.display_names[field] = r"$\mathrm{\Delta{I}_{%d\ GHz}}$" % (int(f))
-            
+
     def on_axis(self, axis, center="c", width=(1, "unitary"), nx=800, source=None):
         r""" Make an on-axis projection of the SZ signal.
 
@@ -126,9 +126,9 @@
             axis = data.get_field_parameter("axis")
             vpar = data["Density"]*data["%s-velocity" % (vlist[axis])]
             return vpar/clight
-        add_field("BetaPar", function=_beta_par)    
+        add_field("BetaPar", function=_beta_par)
 
-        proj = self.pf.h.proj(axis, "Density", data_source=source)
+        proj = self.pf.h.proj("Density", axis, data_source=source)
         proj.set_field_parameter("axis", axis)
         frb = proj.to_frb(width, nx)
         dens = frb["Density"]
@@ -137,7 +137,7 @@
         omega1 = frb["TSquared"]/dens/(Te*Te) - 1.
         bperp2 = np.zeros((nx,nx))
         sigma1 = np.zeros((nx,nx))
-        kappa1 = np.zeros((nx,nx))                                    
+        kappa1 = np.zeros((nx,nx))
         if self.high_order:
             bperp2 = frb["BetaPerpSquared"]/dens
             sigma1 = frb["TBetaPar"]/dens/Te - bpar
@@ -149,16 +149,16 @@
         self.dx = (frb.bounds[1]-frb.bounds[0])/nx
         self.dy = (frb.bounds[3]-frb.bounds[2])/ny
         self.nx = nx
-        
+
         self._compute_intensity(tau, Te, bpar, omega1, sigma1, kappa1, bperp2)
-                                                                                                                
+
     def off_axis(self, L, center="c", width=(1, "unitary"), nx=800, source=None):
         r""" Make an off-axis projection of the SZ signal.
-        
+
         Parameters
         ----------
         L : array_like
-            The normal vector of the projection. 
+            The normal vector of the projection.
         center : array_like or string, optional
             The center of the projection.
         width : float or tuple
@@ -168,7 +168,7 @@
         source : yt.data_objects.api.AMRData, optional
             If specified, this will be the data source used for selecting regions to project.
             Currently unsupported in yt 2.x.
-                    
+
         Examples
         --------
         >>> L = np.array([0.5, 1.0, 0.75])
@@ -188,7 +188,7 @@
         if source is not None:
             mylog.error("Source argument is not currently supported for off-axis S-Z projections.")
             raise NotImplementedError
-                
+
         def _beta_par(field, data):
             vpar = data["Density"]*(data["x-velocity"]*L[0]+
                                     data["y-velocity"]*L[1]+
@@ -225,18 +225,18 @@
         # Bad hack, but we get NaNs if we don't do something like this
         small_beta = np.abs(bpar) < 1.0e-20
         bpar[small_beta] = 1.0e-20
-                                                                   
+
         comm = communication_system.communicators[-1]
 
         nx, ny = self.nx,self.nx
         signal = np.zeros((self.num_freqs,nx,ny))
         xo = np.zeros((self.num_freqs))
-        
+
         k = int(0)
 
         start_i = comm.rank*nx/comm.size
         end_i = (comm.rank+1)*nx/comm.size
-                        
+
         pbar = get_pbar("Computing SZ signal.", nx*nx)
 
         for i in xrange(start_i, end_i):
@@ -250,9 +250,9 @@
                 k += 1
 
         signal = comm.mpi_allreduce(signal)
-        
+
         pbar.finish()
-                
+
         for i, field in enumerate(self.freq_fields):
             self.data[field] = ImageArray(I0*self.xinit[i]**3*signal[i,:,:])
         self.data["Tau"] = ImageArray(tau)
@@ -262,15 +262,15 @@
     def write_fits(self, filename_prefix, clobber=True):
         r""" Export images to a FITS file. Writes the SZ distortion in all
         specified frequencies as well as the mass-weighted temperature and the
-        optical depth. Distance units are in kpc.  
-        
+        optical depth. Distance units are in kpc.
+
         Parameters
         ----------
         filename_prefix : string
             The prefix of the FITS filename.
         clobber : boolean, optional
             If the file already exists, do we overwrite?
-                    
+
         Examples
         --------
         >>> szprj.write_fits("SZbullet", clobber=False)
@@ -289,17 +289,17 @@
     def write_png(self, filename_prefix):
         r""" Export images to PNG files. Writes the SZ distortion in all
         specified frequencies as well as the mass-weighted temperature and the
-        optical depth. Distance units are in kpc. 
-        
+        optical depth. Distance units are in kpc.
+
         Parameters
         ----------
         filename_prefix : string
             The prefix of the image filenames.
-                
+
         Examples
         --------
         >>> szprj.write_png("SZsloshing")
-        """     
+        """
         extent = tuple([bound*self.pf.units["kpc"] for bound in self.bounds])
         for field, image in self.items():
             filename=filename_prefix+"_"+field+".png"
@@ -313,22 +313,22 @@
     @parallel_root_only
     def write_hdf5(self, filename):
         r"""Export the set of S-Z fields to a set of HDF5 datasets.
-        
+
         Parameters
         ----------
         filename : string
             This file will be opened in "write" mode.
-        
+
         Examples
         --------
-        >>> szprj.write_hdf5("SZsloshing.h5")                        
+        >>> szprj.write_hdf5("SZsloshing.h5")
         """
         import h5py
         f = h5py.File(filename, "w")
         for field, data in self.items():
             f.create_dataset(field,data=data)
         f.close()
-   
+
     def keys(self):
         return self.data.keys()
 
@@ -337,7 +337,7 @@
 
     def values(self):
         return self.data.values()
-    
+
     def has_key(self, key):
         return key in self.data.keys()

Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/

--

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