Skip to content

The best way to resize record component? #658

@KseniaBastrakova

Description

@KseniaBastrakova

According to openPMD-api, to write record component, one needs to first create a record component structure and after assign values to the record component.

Python:

mpiDims = [4]
x_particle_values_first_part = np.arange(2, dtype=np.float32)
x_particle_values_second_part = np.arange(2, dtype=np.float32)
d = Dataset(partial_particlePos.dtype, extent=mpiDims)
electrons["position"]["x"].reset_dataset(d)
electrons["position"]["x"][0:2] = x_particle_values_first_part
electrons["position"]["x"][2:4] = x_particle_values_second_part 

I am currently modifying my particle_reduction from directly using hdf5 to openPMD-api. I got the following problem: I process and write values of every patch separately, and in the process I don't know the resulting size of the full particles' dataset before finishing the last patch.

When I used h5py, I did this like

self.hdf_file[node_name].resize(new_size).

What is the best way to do it in openPMD-api? As a note, I do know an upper bound size of my output data, so perhaps something like preallocating this size and then scaling down to the actual resulting size can work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions