[Yt-svn] yt: 3 new changesets

hg at spacepope.org hg at spacepope.org
Fri Apr 23 15:22:01 PDT 2010


hg Repository: yt
details:   yt/rev/e75f8fec5312
changeset: 1593:e75f8fec5312
user:      Matthew Turk <matthewturk at gmail.com>
date:
Fri Apr 23 15:21:08 2010 -0700
description:
Changing the ordering of the field from 3 to 6 improves render time
considerably.  We are now time-competitive with the old renderer.

hg Repository: yt
details:   yt/rev/4bb05833cdf1
changeset: 1594:4bb05833cdf1
user:      Matthew Turk <matthewturk at gmail.com>
date:
Fri Apr 23 15:21:46 2010 -0700
description:
Merging the vr-multivariate branch in

hg Repository: yt
details:   yt/rev/5b4d30e9c4fd
changeset: 1595:5b4d30e9c4fd
user:      Matthew Turk <matthewturk at gmail.com>
date:
Fri Apr 23 15:21:55 2010 -0700
description:
Re-cythonizing

diffstat:

 yt/_amr_utils/VolumeIntegrator.pyx                 |    23 +-
 yt/_amr_utils/fortran_reader.pyx                   |    70 +
 yt/amr_utils.c                                     |  2803 +++++++++++++++++--------
 yt/amr_utils.pyx                                   |     1 +
 yt/config.py                                       |     1 +
 yt/extensions/volume_rendering/software_sampler.py |     4 +-
 yt/funcs.py                                        |     9 +-
 yt/lagos/BaseDataTypes.py                          |    20 +-
 yt/lagos/BaseGridType.py                           |    24 +
 yt/lagos/DataReadingFuncs.py                       |    26 +
 yt/lagos/FieldInfoContainer.py                     |     9 +
 yt/lagos/HierarchyType.py                          |    76 +
 yt/lagos/OutputTypes.py                            |    77 +-
 yt/logger.py                                       |    26 +
 yt/mods.py                                         |     2 +-
 15 files changed, 2246 insertions(+), 925 deletions(-)

diffs (truncated from 6825 to 300 lines):

diff -r 2ed9f1c5a4d6 -r 5b4d30e9c4fd yt/_amr_utils/VolumeIntegrator.pyx
--- a/yt/_amr_utils/VolumeIntegrator.pyx	Wed Apr 21 09:52:41 2010 -0700
+++ b/yt/_amr_utils/VolumeIntegrator.pyx	Fri Apr 23 15:21:55 2010 -0700
@@ -215,7 +215,7 @@
             # measure of emissivity.
             ta = fmax((1.0 - dt*trgba[i+3]), 0.0)
             rgba[i  ] = dt*trgba[i  ] + ta * rgba[i  ]
-            rgba[i+3] = dt*trgba[i+3] + ta * rgba[i+3]
+            #rgba[i+3] = dt*trgba[i+3] + ta * rgba[i+3]
             # This is the old way:
             #rgba[i  ] += trgba[i] * (1.0 - rgba[i+3])*dt*trgba[i+3]
             #rgba[i+3] += trgba[i] * (1.0 - rgba[i+3])*dt*trgba[i+3]
@@ -225,6 +225,8 @@
     cdef np.float64_t *vp_pos, *vp_dir, *center, *image,
     cdef np.float64_t pdx, pdy, bounds[4]
     cdef int nv[2]
+    cdef int vp_strides[3]
+    cdef int im_strides[3]
     cdef public object ax_vec, ay_vec
     cdef np.float64_t *x_vec, *y_vec
 
@@ -254,6 +256,9 @@
         for i in range(4): self.bounds[i] = bounds[i]
         self.pdx = (self.bounds[1] - self.bounds[0])/self.nv[0]
         self.pdy = (self.bounds[3] - self.bounds[2])/self.nv[1]
+        for i in range(3):
+            self.vp_strides[i] = vp_pos.strides[i] / 8
+            self.im_strides[i] = image.strides[i] / 8
 
     @cython.boundscheck(False)
     @cython.wraparound(False)
@@ -271,18 +276,20 @@
         rv[3] = rv[2] + lrint((ex[3] - ex[2])/self.pdy)
 
     cdef inline void copy_into(self, np.float64_t *fv, np.float64_t *tv,
-                        int i, int j, int nk):
+                        int i, int j, int nk, int strides[3]):
         # We know the first two dimensions of our from-vector, and our
         # to-vector is flat and 'ni' long
         cdef int k
+        cdef int offset = strides[0] * i + strides[1] * j
         for k in range(nk):
-            tv[k] = fv[(((k*self.nv[1])+j)*self.nv[0]+i)]
+            tv[k] = fv[offset + k]
 
     cdef inline void copy_back(self, np.float64_t *fv, np.float64_t *tv,
-                        int i, int j, int nk):
+                        int i, int j, int nk, int strides[3]):
         cdef int k
+        cdef int offset = strides[0] * i + strides[1] * j
         for k in range(nk):
-            tv[(((k*self.nv[1])+j)*self.nv[0]+i)] = fv[k]
+            tv[offset + k] = fv[k]
 
 cdef class PartitionedGrid:
     cdef public object my_data
@@ -341,10 +348,10 @@
         hit = 0
         for vi in range(iter[0], iter[1]):
             for vj in range(iter[2], iter[3]):
-                vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3)
-                vp.copy_into(vp.image, rgba, vi, vj, 6)
+                vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
+                vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
                 self.integrate_ray(v_pos, vp.vp_dir, rgba, tf)
-                vp.copy_back(rgba, vp.image, vi, vj, 6)
+                vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)
         return hit
 
     @cython.boundscheck(False)
diff -r 2ed9f1c5a4d6 -r 5b4d30e9c4fd yt/_amr_utils/fortran_reader.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/_amr_utils/fortran_reader.pyx	Fri Apr 23 15:21:55 2010 -0700
@@ -0,0 +1,70 @@
+"""
+Simple readers for fortran unformatted data, specifically for the Tiger code.
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: UCSD
+Homepage: http://yt.enzotools.org/
+License:
+  Copyright (C) 2010 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/>.
+"""
+
+import numpy as np
+cimport numpy as np
+cimport cython
+
+from stdio cimport fopen, fclose, FILE
+
+cdef extern from "stdio.h":
+    cdef int SEEK_SET
+    cdef int SEEK_CUR
+    cdef int SEEK_END
+    int fseek(FILE *stream, long offset, int whence)
+    size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
+    long ftell(FILE *stream)
+
+ at cython.boundscheck(False)
+ at cython.wraparound(False)
+def read_tiger_section(
+                     char *fn,
+                     np.ndarray[np.int64_t, ndim=1] slab_start,
+                     np.ndarray[np.int64_t, ndim=1] slab_size,
+                     np.ndarray[np.int64_t, ndim=1] root_size,
+                     int offset = 36):
+    cdef int strides[3]
+    strides[0] = 1
+    strides[1] = root_size[0] * strides[0]
+    strides[2] = strides[1] * root_size[1] + 2
+    cdef np.int64_t i, j, k
+    cdef np.ndarray buffer = np.zeros(slab_size, dtype='float32', order='F')
+    cdef FILE *f = fopen(fn, "rb")
+    #for i in range(3): offset += strides[i] * slab_start[i]
+    cdef np.int64_t pos = 0
+    cdef np.int64_t moff = 0
+    cdef float *data = <float *> buffer.data
+    fseek(f, offset, 0)
+    # If anybody wants to convert this loop to a SEEK_CUR, that'd be great.
+    for i in range(slab_size[2]):
+        for j in range(slab_size[1]):
+            moff = (slab_start[0]    ) * strides[0] \
+                 + (slab_start[1] + j) * strides[1] \
+                 + (slab_start[2] + i) * strides[2]
+            #print offset + 4 * moff, pos
+            fseek(f, offset + 4 * moff, SEEK_SET)
+            fread(<void *> (data + pos), 4, slab_size[0], f)
+            pos += slab_size[0]
+    return buffer
diff -r 2ed9f1c5a4d6 -r 5b4d30e9c4fd yt/amr_utils.c
--- a/yt/amr_utils.c	Wed Apr 21 09:52:41 2010 -0700
+++ b/yt/amr_utils.c	Fri Apr 23 15:21:55 2010 -0700
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.12.1 on Thu Apr  1 00:44:35 2010 */
+/* Generated by Cython 0.12.1 on Fri Apr 23 15:21:52 2010 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -159,6 +159,7 @@
 #include "numpy/ufuncobject.h"
 #include "math.h"
 #include "FixedInterpolator.h"
+#include "png.h"
 
 #ifndef CYTHON_INLINE
   #if defined(__GNUC__)
@@ -392,23 +393,27 @@
   __pyx_t_5numpy_float64_t idbin;
   int field_id;
   int weight_field_id;
+  int weight_table_id;
   int nbins;
-};
-
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":87
- *     int nbins
+  int pass_through;
+};
+
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":89
+ *     int pass_through
  * 
  * cdef void FIT_initialize_table(FieldInterpolationTable *fit, int nbins,             # <<<<<<<<<<<<<<
  *               np.float64_t *values, np.float64_t bounds1, np.float64_t bounds2,
- *               int field_id, int weight_field_id = -1):
+ *               int field_id, int weight_field_id = -1, int weight_table_id = -1,
  */
 
 struct __pyx_opt_args_2yt_9amr_utils_FIT_initialize_table {
   int __pyx_n;
   int weight_field_id;
-};
-
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":112
+  int weight_table_id;
+  int pass_through;
+};
+
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":118
  *     return (bv + dd*dy*fit.idbin)
  * 
  * cdef class TransferFunctionProxy:             # <<<<<<<<<<<<<<
@@ -460,7 +465,7 @@
   PyObject *grids;
 };
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":521
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":547
  *         return 1
  * 
  * cdef class ProtoPrism:             # <<<<<<<<<<<<<<
@@ -493,7 +498,7 @@
   int refined_pos;
 };
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":489
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":515
  *             tf.eval_transfer(dt, self.dvs, rgba, grad)
  * 
  * cdef class GridFace:             # <<<<<<<<<<<<<<
@@ -533,14 +538,16 @@
   __pyx_t_5numpy_float64_t pdy;
   __pyx_t_5numpy_float64_t bounds[4];
   int nv[2];
+  int vp_strides[3];
+  int im_strides[3];
   PyObject *ax_vec;
   PyObject *ay_vec;
   __pyx_t_5numpy_float64_t *x_vec;
   __pyx_t_5numpy_float64_t *y_vec;
 };
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":268
- *             tv[(((k*self.nv[1])+j)*self.nv[0]+i)] = fv[k]
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":294
+ *             tv[offset + k] = fv[k]
  * 
  * cdef class PartitionedGrid:             # <<<<<<<<<<<<<<
  *     cdef public object my_data
@@ -565,7 +572,7 @@
 };
 
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":521
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":547
  *         return 1
  * 
  * cdef class ProtoPrism:             # <<<<<<<<<<<<<<
@@ -579,7 +586,7 @@
 static struct __pyx_vtabstruct_2yt_9amr_utils_ProtoPrism *__pyx_vtabptr_2yt_9amr_utils_ProtoPrism;
 
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":204
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":223
  *             #rgba[i+3] += trgba[i] * (1.0 - rgba[i+3])*dt*trgba[i+3]
  * 
  * cdef class VectorPlane:             # <<<<<<<<<<<<<<
@@ -589,14 +596,14 @@
 
 struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane {
   void (*get_start_stop)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, int *);
-  void (*copy_into)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int);
-  void (*copy_back)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int);
+  void (*copy_into)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int, int *);
+  void (*copy_back)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int, int *);
 };
 static struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *__pyx_vtabptr_2yt_9amr_utils_VectorPlane;
 
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":268
- *             tv[(((k*self.nv[1])+j)*self.nv[0]+i)] = fv[k]
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":294
+ *             tv[offset + k] = fv[k]
  * 
  * cdef class PartitionedGrid:             # <<<<<<<<<<<<<<
  *     cdef public object my_data
@@ -611,7 +618,7 @@
 static struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *__pyx_vtabptr_2yt_9amr_utils_PartitionedGrid;
 
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":489
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":515
  *             tf.eval_transfer(dt, self.dvs, rgba, grad)
  * 
  * cdef class GridFace:             # <<<<<<<<<<<<<<
@@ -625,7 +632,7 @@
 static struct __pyx_vtabstruct_2yt_9amr_utils_GridFace *__pyx_vtabptr_2yt_9amr_utils_GridFace;
 
 
-/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":112
+/* "/Users/matthewturk/yt/yt/yt/_amr_utils/VolumeIntegrator.pyx":118
  *     return (bv + dd*dy*fit.idbin)
  * 
  * cdef class TransferFunctionProxy:             # <<<<<<<<<<<<<<
@@ -985,6 +992,8 @@
 
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int64(npy_int64);
 
+static CYTHON_INLINE png_uint_32 __Pyx_PyInt_from_py_png_uint_32(PyObject *);
+
 #if CYTHON_CCOMPLEX
   #ifdef __cplusplus
     #define __Pyx_CREAL(z) ((z).real())
@@ -1164,6 +1173,7 @@
 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float_t = { "numpy.float_t", NULL, sizeof(__pyx_t_5numpy_float_t), 'R' };



More information about the yt-svn mailing list