[yt-svn] commit/yt: MatthewTurk: Merged in galtay/yt/yt-3.0 (pull request #805)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Apr 9 09:48:59 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/9ad2fddff40f/
Changeset:   9ad2fddff40f
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-04-09 18:48:50
Summary:     Merged in galtay/yt/yt-3.0 (pull request #805)

fixed out of bounds index problem for very high or very low density
Affected #:  1 file

diff -r b7bc0683be9ad0e96cf6a0fa2b570c92b963d20c -r 9ad2fddff40fff447a86b92e211fb134366ba153 yt/frontends/sph/owls_ion_tables.py
--- a/yt/frontends/sph/owls_ion_tables.py
+++ b/yt/frontends/sph/owls_ion_tables.py
@@ -162,8 +162,7 @@
         T  = np.array( T )
 
         if nH.size != T.size:
-            print ' array size mismatch !!! '
-            sys.exit(1)
+            raise ValueError(' owls_ion_tables: array size mismatch !!! ')
         
         # field discovery will have nH.size == 1 and T.size == 1
         # in that case we simply return 1.0
@@ -175,38 +174,25 @@
 
         # find inH and fnH
         #-----------------------------------------------------
-        inH = np.int32( ( nH - self.nH[0] ) / self.DELTA_nH )
-        fnH = ( nH - self.nH[inH] ) / self.dnH[inH]
-
-        indx = np.where( inH < 0 )[0]
-        if len(indx) > 0:
-            inH[indx] = 0
-            fnH[indx] = 0.0
-
-        indx = np.where( inH >= len(nH) )[0]
-        if len(indx) > 0:
-            inH[indx] = len(nH)-2
-            fnH[indx] = 1.0
+        x_nH = ( nH - self.nH[0] ) / self.DELTA_nH
+        x_nH_clip = np.clip( x_nH, 0.0, self.nH.size-1.001 )
+        fnH,inH = np.modf( x_nH_clip )
+        inH = inH.astype( np.int32 )
 
 
         # find iT and fT
         #-----------------------------------------------------
-        iT = np.int32( ( T - self.T[0] ) / self.DELTA_T )
-        fT = ( T - self.T[iT] ) / self.dT[iT]
+        x_T = ( T - self.T[0] ) / self.DELTA_T
+        x_T_clip = np.clip( x_T, 0.0, self.T.size-1.001 )
+        fT,iT = np.modf( x_T_clip )
+        iT = iT.astype( np.int32 )
+        
 
-        indx = np.where( iT < 0 )[0]
-        if len(indx) > 0:
-            iT[indx] = 0
-            fT[indx] = 0.0
-
-        indx = np.where( iT >= len(T) )[0]
-        if len(indx) > 0:
-            iT[indx] = len(T)-2
-            fT[indx] = 1.0
-
-
+        # short names for previously calculated iz and fz
+        #-----------------------------------------------------
         iz = self.iz
         fz = self.fz
+
                    
         # calculate interpolated value
         # use tri-linear interpolation on the log values

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