[Yt-svn] yt: Ramses works with coalesced patches and IO
hg at spacepope.org
hg at spacepope.org
Tue Aug 10 15:41:50 PDT 2010
hg Repository: yt
details: yt/rev/f4ac807130c6
changeset: 1932:f4ac807130c6
user: Matthew Turk <matthewturk at gmail.com>
date:
Tue Aug 10 15:41:46 2010 -0700
description:
Ramses works with coalesced patches and IO
diffstat:
yt/lagos/DataReadingFuncs.py | 18 +-
yt/lagos/HierarchyType.py | 2 +-
yt/lagos/OutputTypes.py | 3 +
yt/lagos/RAMSESFields.py | 14 +
yt/ramses_reader.cpp | 1663 +++++++++++++++++++++++++++++++++++++++-------
yt/ramses_reader.pyx | 67 +-
6 files changed, 1488 insertions(+), 279 deletions(-)
diffs (truncated from 3284 to 300 lines):
diff -r 20bae0b4b687 -r f4ac807130c6 yt/lagos/DataReadingFuncs.py
--- a/yt/lagos/DataReadingFuncs.py Tue Aug 10 14:13:28 2010 -0700
+++ b/yt/lagos/DataReadingFuncs.py Tue Aug 10 15:41:46 2010 -0700
@@ -544,9 +544,21 @@
BaseIOHandler.__init__(self, *args, **kwargs)
def _read_data_set(self, grid, field):
- d = self.ramses_tree.read_grid(field, grid.Level, grid.domain,
- grid.grid_offset)
- return d
+ tr = na.zeros(grid.ActiveDimensions, dtype='float64')
+ filled = na.zeros(grid.ActiveDimensions, dtype='int32')
+ to_fill = grid.ActiveDimensions.prod()
+ grids = [grid]
+ l_delta = 0
+ while to_fill > 0 and len(grids) > 0:
+ next_grids = []
+ for g in grids:
+ to_fill -= self.ramses_tree.read_grid(field,
+ grid.get_global_startindex(), grid.ActiveDimensions,
+ tr, filled, g.Level, 2**l_delta, g.locations)
+ next_grids += g.Parent
+ grids = next_grids
+ l_delta += 1
+ return tr
def _read_data_slice(self, grid, field, axis, coord):
sl = [slice(None), slice(None), slice(None)]
diff -r 20bae0b4b687 -r f4ac807130c6 yt/lagos/HierarchyType.py
--- a/yt/lagos/HierarchyType.py Tue Aug 10 14:13:28 2010 -0700
+++ b/yt/lagos/HierarchyType.py Tue Aug 10 15:41:46 2010 -0700
@@ -1659,7 +1659,7 @@
ogrid_left_edge = na.zeros((num_ogrids,3), dtype='float64')
ogrid_right_edge = na.zeros((num_ogrids,3), dtype='float64')
ogrid_levels = na.zeros((num_ogrids,1), dtype='int32')
- ogrid_file_locations = na.zeros((num_ogrids,3), dtype='int64')
+ ogrid_file_locations = na.zeros((num_ogrids,6), dtype='int64')
ochild_masks = na.zeros((num_ogrids, 8), dtype='int32')
self.tree_proxy.fill_hierarchy_arrays(
ogrid_left_edge, ogrid_right_edge,
diff -r 20bae0b4b687 -r f4ac807130c6 yt/lagos/OutputTypes.py
--- a/yt/lagos/OutputTypes.py Tue Aug 10 14:13:28 2010 -0700
+++ b/yt/lagos/OutputTypes.py Tue Aug 10 15:41:46 2010 -0700
@@ -935,6 +935,9 @@
self.parameters["RefineBy"] = 2
self.parameters["HydroMethod"] = 'ramses'
self.parameters["Time"] = 1. # default unit is 1...
+
+ def __repr__(self):
+ return self.basename.rsplit(".", 1)[0]
def _set_units(self):
"""
diff -r 20bae0b4b687 -r f4ac807130c6 yt/lagos/RAMSESFields.py
--- a/yt/lagos/RAMSESFields.py Tue Aug 10 14:13:28 2010 -0700
+++ b/yt/lagos/RAMSESFields.py Tue Aug 10 15:41:46 2010 -0700
@@ -31,3 +31,17 @@
add_ramses_field = RAMSESFieldInfo.add_field
add_field = add_ramses_field
+
+translation_dict = {"Density":"density",
+ }
+
+def _generate_translation(mine, theirs):
+ add_field(theirs, function=lambda a, b: b[mine], take_log=True)
+
+for f,v in translation_dict.items():
+ if v not in RAMSESFieldInfo:
+ add_field(v, function=lambda a,b: None, take_log=False,
+ validators = [ValidateDataField(v)])
+ #print "Setting up translator from %s to %s" % (v, f)
+ _generate_translation(v, f)
+
diff -r 20bae0b4b687 -r f4ac807130c6 yt/ramses_reader.cpp
--- a/yt/ramses_reader.cpp Tue Aug 10 14:13:28 2010 -0700
+++ b/yt/ramses_reader.cpp Tue Aug 10 15:41:46 2010 -0700
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.13.beta0 on Tue Aug 10 14:12:47 2010 */
+/* Generated by Cython 0.13.beta0 on Tue Aug 10 15:34:03 2010 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -390,8 +390,8 @@
int nfields;
};
-/* "/Users/matthewturk/yt/yt/yt/ramses_reader.pyx":599
- * return tr
+/* "/Users/matthewturk/yt/yt/yt/ramses_reader.pyx":659
+ * return to_fill
*
* cdef class ProtoSubgrid: # <<<<<<<<<<<<<<
* cdef np.int64_t *signature[3]
@@ -621,6 +621,11 @@
static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
+static CYTHON_INLINE int __Pyx_div_int(int, int); /* proto */
+
+#define UNARY_NEG_WOULD_OVERFLOW(x) (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
+#define __Pyx_BufPtrStrided3d(type, buf, i0, s0, i1, s1, i2, s2) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2)
+
static CYTHON_INLINE __pyx_t_5numpy_int64_t __Pyx_div___pyx_t_5numpy_int64_t(__pyx_t_5numpy_int64_t, __pyx_t_5numpy_int64_t); /* proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
@@ -891,6 +896,7 @@
static char __pyx_k__boxlen[] = "boxlen";
static char __pyx_k__domain[] = "domain";
static char __pyx_k__fields[] = "fields";
+static char __pyx_k__filled[] = "filled";
static char __pyx_k__format[] = "format";
static char __pyx_k__loaded[] = "loaded";
static char __pyx_k__unit_d[] = "unit_d";
@@ -919,6 +925,7 @@
static char __pyx_k__type_num[] = "type_num";
static char __pyx_k__byteorder[] = "byteorder";
static char __pyx_k__field_ind[] = "field_ind";
+static char __pyx_k__grid_dims[] = "grid_dims";
static char __pyx_k__is_finest[] = "is_finest";
static char __pyx_k__left_edge[] = "left_edge";
static char __pyx_k__signature[] = "signature";
@@ -931,6 +938,7 @@
static char __pyx_k__left_index[] = "left_index";
static char __pyx_k__m_maxlevel[] = "m_maxlevel";
static char __pyx_k__m_varnames[] = "m_varnames";
+static char __pyx_k__ref_factor[] = "ref_factor";
static char __pyx_k__right_edge[] = "right_edge";
static char __pyx_k__suboffsets[] = "suboffsets";
static char __pyx_k__field_names[] = "field_names";
@@ -938,6 +946,7 @@
static char __pyx_k__hydro_datas[] = "hydro_datas";
static char __pyx_k__m_var_array[] = "m_var_array";
static char __pyx_k__right_edges[] = "right_edges";
+static char __pyx_k__start_index[] = "start_index";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__domain_index[] = "domain_index";
static char __pyx_k__m_AMR_levels[] = "m_AMR_levels";
@@ -946,6 +955,7 @@
static char __pyx_k__snapshot_name[] = "snapshot_name";
static char __pyx_k__grid_dimensions[] = "grid_dimensions";
static char __pyx_k__grid_pos_double[] = "grid_pos_double";
+static char __pyx_k__component_grid_info[] = "component_grid_info";
static char __pyx_k__grid_file_locations[] = "grid_file_locations";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_n_s_2;
@@ -970,6 +980,7 @@
static PyObject *__pyx_n_s__byteorder;
static PyObject *__pyx_n_s__c_str;
static PyObject *__pyx_n_s__child_mask;
+static PyObject *__pyx_n_s__component_grid_info;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__dd;
static PyObject *__pyx_n_s__descr;
@@ -985,11 +996,13 @@
static PyObject *__pyx_n_s__field_ind;
static PyObject *__pyx_n_s__field_names;
static PyObject *__pyx_n_s__fields;
+static PyObject *__pyx_n_s__filled;
static PyObject *__pyx_n_s__float64;
static PyObject *__pyx_n_s__fn;
static PyObject *__pyx_n_s__format;
static PyObject *__pyx_n_s__get_parent;
static PyObject *__pyx_n_s__grid_dimensions;
+static PyObject *__pyx_n_s__grid_dims;
static PyObject *__pyx_n_s__grid_file_locations;
static PyObject *__pyx_n_s__grid_id;
static PyObject *__pyx_n_s__grid_levels;
@@ -1031,6 +1044,7 @@
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__readonly;
+static PyObject *__pyx_n_s__ref_factor;
static PyObject *__pyx_n_s__right_edge;
static PyObject *__pyx_n_s__right_edges;
static PyObject *__pyx_n_s__rsnap;
@@ -1039,6 +1053,7 @@
static PyObject *__pyx_n_s__sigs;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__snapshot_name;
+static PyObject *__pyx_n_s__start_index;
static PyObject *__pyx_n_s__strides;
static PyObject *__pyx_n_s__suboffsets;
static PyObject *__pyx_n_s__time;
@@ -2994,7 +3009,7 @@
* grid_levels[grid_ind, 0] = ilevel
* # Now the harder part
* father_it = grid_it.get_parent() # <<<<<<<<<<<<<<
- * grid_file_locations[grid_ind, 0] = idomain
+ * grid_file_locations[grid_ind, 0] = <np.int64_t> idomain
* grid_file_locations[grid_ind, 1] = grid_ind - level_cell_counts[ilevel]
*/
__pyx_v_father_it = __pyx_v_grid_it.get_parent();
@@ -3002,7 +3017,7 @@
/* "/Users/matthewturk/yt/yt/yt/ramses_reader.pyx":557
* # Now the harder part
* father_it = grid_it.get_parent()
- * grid_file_locations[grid_ind, 0] = idomain # <<<<<<<<<<<<<<
+ * grid_file_locations[grid_ind, 0] = <np.int64_t> idomain # <<<<<<<<<<<<<<
* grid_file_locations[grid_ind, 1] = grid_ind - level_cell_counts[ilevel]
* parent_ind = father_it.get_absolute_position()
*/
@@ -3021,11 +3036,11 @@
__Pyx_RaiseBufferIndexError(__pyx_t_23);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_grid_file_locations.buf, __pyx_t_21, __pyx_bstride_0_grid_file_locations, __pyx_t_22, __pyx_bstride_1_grid_file_locations) = __pyx_v_idomain;
+ *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_grid_file_locations.buf, __pyx_t_21, __pyx_bstride_0_grid_file_locations, __pyx_t_22, __pyx_bstride_1_grid_file_locations) = ((__pyx_t_5numpy_int64_t)__pyx_v_idomain);
/* "/Users/matthewturk/yt/yt/yt/ramses_reader.pyx":558
* father_it = grid_it.get_parent()
- * grid_file_locations[grid_ind, 0] = idomain
+ * grid_file_locations[grid_ind, 0] = <np.int64_t> idomain
* grid_file_locations[grid_ind, 1] = grid_ind - level_cell_counts[ilevel] # <<<<<<<<<<<<<<
* parent_ind = father_it.get_absolute_position()
* if ilevel > 0:
@@ -3058,7 +3073,7 @@
*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_grid_file_locations.buf, __pyx_t_23, __pyx_bstride_0_grid_file_locations, __pyx_t_27, __pyx_bstride_1_grid_file_locations) = __pyx_t_26;
/* "/Users/matthewturk/yt/yt/yt/ramses_reader.pyx":559
- * grid_file_locations[grid_ind, 0] = idomain
+ * grid_file_locations[grid_ind, 0] = <np.int64_t> idomain
* grid_file_locations[grid_ind, 1] = grid_ind - level_cell_counts[ilevel]
* parent_ind = father_it.get_absolute_position() # <<<<<<<<<<<<<<
* if ilevel > 0:
@@ -3217,7 +3232,7 @@
* grid_it.next()
* del local_tree, local_hydro_data # <<<<<<<<<<<<<<
*
- * def read_grid(self, char *field, int level, int domain, int grid_id):
+ * def read_oct_grid(self, char *field, int level, int domain, int grid_id):
*/
delete __pyx_v_local_tree;
delete __pyx_v_local_hydro_data;
@@ -3257,13 +3272,13 @@
/* "/Users/matthewturk/yt/yt/yt/ramses_reader.pyx":573
* del local_tree, local_hydro_data
*
- * def read_grid(self, char *field, int level, int domain, int grid_id): # <<<<<<<<<<<<<<
+ * def read_oct_grid(self, char *field, int level, int domain, int grid_id): # <<<<<<<<<<<<<<
*
* self.ensure_loaded(field, domain - 1)
*/
-static PyObject *__pyx_pf_2yt_13ramses_reader_17RAMSES_tree_proxy_read_grid(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pf_2yt_13ramses_reader_17RAMSES_tree_proxy_read_grid(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_2yt_13ramses_reader_17RAMSES_tree_proxy_read_oct_grid(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_2yt_13ramses_reader_17RAMSES_tree_proxy_read_oct_grid(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
char *__pyx_v_field;
int __pyx_v_level;
int __pyx_v_domain;
@@ -3289,7 +3304,7 @@
int __pyx_t_5;
PyArrayObject *__pyx_t_6 = NULL;
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__field,&__pyx_n_s__level,&__pyx_n_s__domain,&__pyx_n_s__grid_id,0};
- __Pyx_RefNannySetupContext("read_grid");
+ __Pyx_RefNannySetupContext("read_oct_grid");
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
PyObject* values[4] = {0,0,0,0};
@@ -3310,23 +3325,23 @@
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__level);
if (likely(values[1])) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("read_grid", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("read_oct_grid", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__domain);
if (likely(values[2])) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("read_grid", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("read_oct_grid", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 3:
values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_id);
if (likely(values[3])) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("read_grid", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("read_oct_grid", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "read_grid") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "read_oct_grid") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
__pyx_v_field = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_field) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_v_level = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
@@ -3342,16 +3357,16 @@
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("read_grid", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("read_oct_grid", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
- __Pyx_AddTraceback("yt.ramses_reader.RAMSES_tree_proxy.read_grid");
+ __Pyx_AddTraceback("yt.ramses_reader.RAMSES_tree_proxy.read_oct_grid");
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
More information about the yt-svn
mailing list