[yt-svn] commit/yt: 3 new changesets

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


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/1dcb3c06ee19/
Changeset:   1dcb3c06ee19
Branch:      yt-3.0
User:        galtay
Date:        2014-04-07 23:28:01
Summary:     fixed out of bounds index problem for very high or very low density
particles.
Affected #:  1 file

diff -r 1234d06b45b315e6ab9142ac781e9db3a2816621 -r 1dcb3c06ee195f43edeb7ddcb74e6094439deef9 yt/frontends/sph/owls_ion_tables.py
--- a/yt/frontends/sph/owls_ion_tables.py
+++ b/yt/frontends/sph/owls_ion_tables.py
@@ -176,32 +176,42 @@
         # find inH and fnH
         #-----------------------------------------------------
         inH = np.int32( ( nH - self.nH[0] ) / self.DELTA_nH )
+
+        indx = np.where( inH < 0 )[0]
+        if len(indx) > 0:
+            inH[indx] = 0
+        indx = np.where( inH >= self.nH.size-1 )[0]
+        if len(indx) > 0:
+            inH[indx] = self.nH.size-2
+
         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]
+        indx = np.where( inH >= self.nH.size-1 )[0]
         if len(indx) > 0:
-            inH[indx] = len(nH)-2
             fnH[indx] = 1.0
 
 
         # find iT and fT
         #-----------------------------------------------------
         iT = np.int32( ( T - self.T[0] ) / self.DELTA_T )
+
+        indx = np.where( iT < 0 )[0]
+        if len(indx) > 0:
+            iT[indx] = 0
+        indx = np.where( iT >= self.T.size-1 )[0]
+        if len(indx) > 0:
+            iT[indx] = self.T.size-2
+
         fT = ( T - self.T[iT] ) / self.dT[iT]
 
         indx = np.where( iT < 0 )[0]
         if len(indx) > 0:
-            iT[indx] = 0
             fT[indx] = 0.0
-
-        indx = np.where( iT >= len(T) )[0]
+        indx = np.where( iT >= self.T.size-1 )[0]
         if len(indx) > 0:
-            iT[indx] = len(T)-2
             fT[indx] = 1.0
 
 


https://bitbucket.org/yt_analysis/yt/commits/a927f3d2ea08/
Changeset:   a927f3d2ea08
Branch:      yt-3.0
User:        galtay
Date:        2014-04-08 18:06:29
Summary:     cleaned up index selection using np.clip and np.modf
Affected #:  1 file

diff -r 1dcb3c06ee195f43edeb7ddcb74e6094439deef9 -r a927f3d2ea08f4a1d661bf77c835e31443aed103 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,48 +174,25 @@
 
         # find inH and fnH
         #-----------------------------------------------------
-        inH = np.int32( ( nH - self.nH[0] ) / self.DELTA_nH )
-
-        indx = np.where( inH < 0 )[0]
-        if len(indx) > 0:
-            inH[indx] = 0
-        indx = np.where( inH >= self.nH.size-1 )[0]
-        if len(indx) > 0:
-            inH[indx] = self.nH.size-2
-
-        fnH = ( nH - self.nH[inH] ) / self.dnH[inH]
-
-        indx = np.where( inH < 0 )[0]
-        if len(indx) > 0:
-            fnH[indx] = 0.0
-        indx = np.where( inH >= self.nH.size-1 )[0]
-        if len(indx) > 0:
-            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 )
+        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
-        indx = np.where( iT >= self.T.size-1 )[0]
-        if len(indx) > 0:
-            iT[indx] = self.T.size-2
-
-        fT = ( T - self.T[iT] ) / self.dT[iT]
-
-        indx = np.where( iT < 0 )[0]
-        if len(indx) > 0:
-            fT[indx] = 0.0
-        indx = np.where( iT >= self.T.size-1 )[0]
-        if len(indx) > 0:
-            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


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