h5md-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [h5md-user] Minor revisions before H5MD v1.0


From: Peter Colberg
Subject: Re: [h5md-user] Minor revisions before H5MD v1.0
Date: Mon, 6 May 2013 11:29:46 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, May 06, 2013 at 04:02:52PM +0200, Felix Höfling wrote:
> 1) either make /observables/box mandatory if /observables is present,

Let's make it mandatory. If a "trajectory" subgroup is present, it has
to contain "box". If an "observables" group is present, it has to
contain "box".

> 2) or permit the interpretation of flucutations only if the optional group
> /observables/box is present (otherwise the reader considers the H5MD file
> as incomplete for the desired purpose and fails)
> 
> In both cases, there appears the same issue with a fluctuating box as for
> the trajectory: the sampling intervals of the box and the various
> observables may differ, rendering the box information essentially useless
> for these observables. The solution would be to attach the box (possibly
> via hard link) to each data group in /observables. But this appears to be
> a pretty weird, I admit.
> 
> The pragmatic and maybe best solution would be variant 2) with the
> constraint that the sampling times of the box and the observable shall
> coincide.

Could we leave it up to the user at which times to sample box or the
observables? Before reading any "value" dataset, I seek [1] in its
related "step" dataset to find the corresponding index. Regardless of
whether a group of datasets shares the same "step" dataset or not.

[1] http://en.wikipedia.org/wiki/Binary_search_algorithm

This is my seeking routine (LuaJIT):

  local function find_step(group, step)
    local dset = group:open_dataset("step")
    local filespace = dset:get_space()
    local dims = filespace:get_simple_extent_dims()
    local data = ffi.new("uint32_t[1]")
    local memspace = hdf5.create_simple_space({1})
    filespace:select_hyperslab("set", {0}, nil, {1})
    local min, max = 0, dims[1] - 1
    while min <= max do
      local mid = min + bit.rshift(max - min, 1)
      filespace:offset_simple({mid})
      dset:read("native_uint32", memspace, filespace, nil, data)
      if data[0] == step then return mid end
      if data[0] < step then min = mid + 1 else max = mid - 1 end
    end
  end

If the data is unavailable at a given step, the reader throws an error.

Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]