ptypy.io.json_rw.jread#

ptypy.io.json_rw.jread(filename, *args, **kwargs)#

h5read(filename) h5read(filename, s1, s2, …) h5read(filename, (s1,s2, …))

Read variables from a JSON file created with jwrite and returns them as a dictionary.

The following features are meant to have an interface identical to h5read. Note however that no time of memory is saved by “loading” only a subset of variables or slices.

If specified, only variable named s1, s2, … are loaded.

Variable names support slicing and group access. For instance, provided that the file contains the appropriate objects, the following syntax is valid:

a = jread(‘file.h5’, ‘myarray[2:4]’) a = jread(‘file.h5’, ‘adict.thekeyIwant’)

Another way of slicing is with the slice keyword argument which will take the provided slice object and apply it on the last variable name:

a = jread(‘file.json’, ‘array1’, ‘array2’, slice=slice(1,2)) # Will read array2[1:2]

jread(filename_with_wildcard, … , doglob=True) Reads sequentially all globbed filenames.