[Yt-svn] yt: Merging changes from yt into vr-multivariate
hg at spacepope.org
hg at spacepope.org
Thu Apr 15 08:03:10 PDT 2010
hg Repository: yt
details: yt/rev/269219744a61
changeset: 1565:269219744a61
user: Matthew Turk <matthewturk at gmail.com>
date:
Thu Apr 15 11:02:57 2010 -0400
description:
Merging changes from yt into vr-multivariate
diffstat:
doc/install_script.sh | 24 +-
doc/install_script_osx.sh | 1 +
doc/install_script_osx106.sh | 1 +
scripts/yt_lodgeit.py | 1 +
yt/_amr_utils/png_writer.pyx | 147 +++++++++
yt/amr_utils.pyx | 1 +
yt/extensions/image_panner/pan_and_scan_widget.py | 1 -
yt/extensions/kdtree/fKD.f90 | 27 +
yt/extensions/kdtree/fKD.v | 2 +
yt/extensions/setup.py | 1 +
yt/extensions/volume_rendering/__init__.py | 2 +-
yt/extensions/volume_rendering/software_sampler.py | 10 +
yt/lagos/BaseDataTypes.py | 4 +-
yt/lagos/DerivedQuantities.py | 26 +-
yt/lagos/EnzoFields.py | 2 +
yt/lagos/HaloFinding.py | 5 +-
yt/lagos/StructureFunctionGenerator.py | 425 ++++++++++++++------------
yt/lagos/setup.py | 53 ++-
yt/raven/PlotCollection.py | 32 +-
yt/raven/PlotTypes.py | 27 +-
yt/setup.py | 57 +++-
21 files changed, 614 insertions(+), 235 deletions(-)
diffs (truncated from 1374 to 300 lines):
diff -r 4825a94c4d27 -r 269219744a61 doc/install_script.sh
--- a/doc/install_script.sh Thu Apr 15 10:41:32 2010 -0400
+++ b/doc/install_script.sh Thu Apr 15 11:02:57 2010 -0400
@@ -28,11 +28,12 @@
# If you absolutely can't get the fortran to work, try this:
#NUMPY_ARGS="--fcompiler=fake"
-INST_WXPYTHON=1 # If you 't want to install wxPython, set this to 1
+INST_WXPYTHON=0 # If you want to install wxPython, set this to 1
INST_ZLIB=1 # On some systems (Kraken) matplotlib has issues with
# the system zlib, which is compiled statically.
# If need be, you can turn this off.
-INST_TRAITS=1 # Experimental TraitsUI installation
+INST_PNG=0 # Install a local libpng? Same things apply as with zlib.
+INST_TRAITS=0 # Experimental TraitsUI installation
INST_HG=1 # Install Mercurial or not?
# If you've got YT some other place, set this to point to it.
@@ -229,6 +230,7 @@
fi
[ $INST_ZLIB -eq 1 ] && get_enzotools zlib-1.2.3.tar.bz2
+[ $INST_PNG -eq 1 ] && get_enzotools libpng-1.2.43.tar.gz
[ $INST_WXPYTHON -eq 1 ] && get_enzotools wxPython-src-2.8.10.1.tar.bz2
get_enzotools Python-2.6.3.tgz
get_enzotools numpy-1.3.0.tar.gz
@@ -272,6 +274,23 @@
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ZLIB_DIR}/lib/"
fi
+if [ $INST_PNG -eq 1 ]
+then
+ if [ ! -e libpng-1.2.43/done ]
+ then
+ [ ! -e libpng-1.2.43 ] && tar xfz libpng-1.2.43.tar.gz
+ echo "Installing PNG"
+ cd libpng-1.2.43
+ ( ./configure --prefix=${DEST_DIR}/ 2>&1 ) 1>> ${LOG_FILE} || do_exit
+ ( make install 2>&1 ) 1>> ${LOG_FILE} || do_exit
+ touch done
+ cd ..
+ fi
+ PNG_DIR=${DEST_DIR}
+ export LDFLAGS="${LDFLAGS} -L${PNG_DIR}/lib/ -L${PNG_DIR}/lib64/"
+ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${PNG_DIR}/lib/"
+fi
+
if [ -z "$HDF5_DIR" ]
then
if [ ! -e hdf5-1.6.9/done ]
@@ -350,6 +369,7 @@
echo "Installing yt"
echo $HDF5_DIR > hdf5.cfg
+[ $INST_PNG -eq 1 ] && echo $PNG_DIR > png.cfg
( ${DEST_DIR}/bin/python2.6 setup.py develop 2>&1 ) 1>> ${LOG_FILE} || do_exit
touch done
cd $MY_PWD
diff -r 4825a94c4d27 -r 269219744a61 doc/install_script_osx.sh
--- a/doc/install_script_osx.sh Thu Apr 15 10:41:32 2010 -0400
+++ b/doc/install_script_osx.sh Thu Apr 15 11:02:57 2010 -0400
@@ -203,6 +203,7 @@
echo "Installing yt (may need sudo)"
echo $HDF5_DIR > hdf5.cfg
+echo /usr/X11 > png.cfg # I think this should work everywhere
( ${PY_DIR}/bin/python2.5 setup.py build_ext -i 2>&1 ) 1>> ${LOG_FILE} || do_exit
( sudo ${PY_DIR}/bin/python2.5 setup.py develop 2>&1 ) 1>> ${LOG_FILE} || do_exit
touch done
diff -r 4825a94c4d27 -r 269219744a61 doc/install_script_osx106.sh
--- a/doc/install_script_osx106.sh Thu Apr 15 10:41:32 2010 -0400
+++ b/doc/install_script_osx106.sh Thu Apr 15 11:02:57 2010 -0400
@@ -204,6 +204,7 @@
echo "Installing yt (may need sudo)"
echo $HDF5_DIR > hdf5.cfg
+echo /usr/X11 > png.cfg # I think this should work everywhere
( ${PY_DIR}/bin/python2.6 setup.py build_ext -i 2>&1 ) 1>> ${LOG_FILE} || do_exit
( sudo ${PY_DIR}/bin/python2.6 setup.py develop 2>&1 ) 1>> ${LOG_FILE} || do_exit
touch done
diff -r 4825a94c4d27 -r 269219744a61 scripts/yt_lodgeit.py
--- a/scripts/yt_lodgeit.py Thu Apr 15 10:41:32 2010 -0400
+++ b/scripts/yt_lodgeit.py Thu Apr 15 11:02:57 2010 -0400
@@ -222,6 +222,7 @@
data = read_file(sys.stdin)
if not langopt:
mime = get_mimetype(data, '') or ''
+ fname = ""
elif len(filenames) == 1:
fname = filenames[0]
data = read_file(open(filenames[0], 'rb'))
diff -r 4825a94c4d27 -r 269219744a61 yt/_amr_utils/png_writer.pyx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/_amr_utils/png_writer.pyx Thu Apr 15 11:02:57 2010 -0400
@@ -0,0 +1,147 @@
+"""
+A light interface to libpng
+
+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 "stdlib.h":
+ # NOTE that size_t might not be int
+ void *alloca(int)
+
+cdef extern from "png.h":
+ ctypedef unsigned long png_uint_32
+ ctypedef long png_int_32
+ ctypedef unsigned short png_uint_16
+ ctypedef short png_int_16
+ ctypedef unsigned char png_byte
+ ctypedef void *png_voidp
+ ctypedef png_byte *png_bytep
+ ctypedef png_uint_32 *png_uint_32p
+ ctypedef png_int_32 *png_int_32p
+ ctypedef png_uint_16 *png_uint_16p
+ ctypedef png_int_16 *png_int_16p
+ ctypedef char *png_charp
+ ctypedef char *png_const_charp
+ ctypedef FILE *png_FILE_p
+
+ ctypedef struct png_struct:
+ pass
+ ctypedef png_struct *png_structp
+
+ ctypedef struct png_info:
+ pass
+ ctypedef png_info *png_infop
+
+ ctypedef struct png_color_8:
+ png_byte red
+ png_byte green
+ png_byte blue
+ png_byte gray
+ png_byte alpha
+ ctypedef png_color_8 *png_color_8p
+
+ cdef png_const_charp PNG_LIBPNG_VER_STRING
+
+ # Note that we don't support error or warning functions
+ png_structp png_create_write_struct(
+ png_const_charp user_png_ver, png_voidp error_ptr,
+ void *error_fn, void *warn_fn)
+
+ png_infop png_create_info_struct(png_structp png_ptr)
+
+ void png_init_io(png_structp png_ptr, png_FILE_p fp)
+
+ void png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
+ png_uint_32 width, png_uint_32 height, int bit_depth,
+ int color_type, int interlace_method, int compression_method,
+ int filter_method)
+
+ cdef int PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE
+ cdef int PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE
+
+ void png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
+ png_uint_32 res_x, png_uint_32 res_y, int unit_type)
+
+ cdef int PNG_RESOLUTION_METER
+
+ void png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
+ png_color_8p sig_bit)
+
+ void png_write_info(png_structp png_ptr, png_infop info_ptr)
+ void png_write_image(png_structp png_ptr, png_bytep *image)
+ void png_write_end(png_structp png_ptr, png_infop info_ptr)
+
+ void png_destroy_write_struct(
+ png_structp *png_ptr_ptr, png_infop *info_ptr_ptr)
+
+def write_png(np.ndarray[np.uint8_t, ndim=3] buffer,
+ char *filename, int dpi=100):
+
+ # This is something of a translation of the matplotlib _png module
+ cdef png_byte *pix_buffer = <png_byte *> buffer.data
+ cdef int width = buffer.shape[0]
+ cdef int height = buffer.shape[1]
+
+ cdef FILE* fileobj = fopen(filename, "wb")
+ cdef png_bytep *row_pointers
+ cdef png_structp png_ptr
+ cdef png_infop info_ptr
+
+ cdef png_color_8 sig_bit
+ cdef png_uint_32 row
+
+ row_pointers = <png_bytep *> alloca(sizeof(png_bytep) * height)
+
+ for row in range(height):
+ row_pointers[row] = pix_buffer + row * width * 4
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)
+ info_ptr = png_create_info_struct(png_ptr)
+
+ # Um we are ignoring setjmp sorry guys
+
+ png_init_io(png_ptr, fileobj)
+
+ png_set_IHDR(png_ptr, info_ptr, width, height, 8,
+ PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE)
+
+ cdef size_t dots_per_meter = <size_t> (dpi / (2.54 / 100.0))
+ png_set_pHYs(png_ptr, info_ptr, dots_per_meter, dots_per_meter,
+ PNG_RESOLUTION_METER)
+
+ sig_bit.gray = 0
+ sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 8
+
+ png_set_sBIT(png_ptr, info_ptr, &sig_bit)
+
+ png_write_info(png_ptr, info_ptr)
+ png_write_image(png_ptr, row_pointers)
+ png_write_end(png_ptr, info_ptr)
+
+ fclose(fileobj)
+ png_destroy_write_struct(&png_ptr, &info_ptr)
diff -r 4825a94c4d27 -r 269219744a61 yt/amr_utils.pyx
--- a/yt/amr_utils.pyx Thu Apr 15 10:41:32 2010 -0400
+++ b/yt/amr_utils.pyx Thu Apr 15 11:02:57 2010 -0400
@@ -42,3 +42,4 @@
include "_amr_utils/VolumeIntegrator.pyx"
include "_amr_utils/CICDeposit.pyx"
include "_amr_utils/ContourFinding.pyx"
+include "_amr_utils/png_writer.pyx"
diff -r 4825a94c4d27 -r 269219744a61 yt/extensions/image_panner/pan_and_scan_widget.py
--- a/yt/extensions/image_panner/pan_and_scan_widget.py Thu Apr 15 10:41:32 2010 -0400
+++ b/yt/extensions/image_panner/pan_and_scan_widget.py Thu Apr 15 11:02:57 2010 -0400
@@ -37,7 +37,6 @@
CMapImagePlot, OverlayPlotContainer
from enthought.chaco.tools.api import PanTool, ZoomTool, RangeSelection, \
RangeSelectionOverlay, RangeSelection
-from zoom_overlay import ZoomOverlay
from enthought.chaco.tools.image_inspector_tool import ImageInspectorTool, \
ImageInspectorOverlay
diff -r 4825a94c4d27 -r 269219744a61 yt/extensions/kdtree/fKD.f90
--- a/yt/extensions/kdtree/fKD.f90 Thu Apr 15 10:41:32 2010 -0400
+++ b/yt/extensions/kdtree/fKD.f90 Thu Apr 15 11:02:57 2010 -0400
@@ -43,6 +43,33 @@
end subroutine find_nn_nearest_neighbors
+subroutine find_many_nn_nearest_neighbors()
+ ! Given an input array of query vectors (qv_many), find their
+ ! nearest neighbors.
+ use kdtree2_module
+ use fKD_module
+ use kdtree2module
+ use tree_nodemodule
+ use intervalmodule
+
+ integer :: k, number
+ type(kdtree2_result),allocatable :: results(:)
+
+ allocate(results(nn))
+
+ number = size(qv_many,2)
+
+ do k=1, number
+ qv(:) = qv_many(:,k)
+ call kdtree2_n_nearest(tp=tree2,qv=qv,nn=nn,results=results)
+ nn_tags(:, k) = results%idx
+ end do
+
+ deallocate(results)
+ return
+
+end subroutine find_many_nn_nearest_neighbors
+
subroutine find_all_nn_nearest_neighbors()
! for all particles in pos, find their nearest neighbors and return the
! indexes and distances as big arrays
diff -r 4825a94c4d27 -r 269219744a61 yt/extensions/kdtree/fKD.v
--- a/yt/extensions/kdtree/fKD.v Thu Apr 15 10:41:32 2010 -0400
More information about the yt-svn
mailing list