def read_field_h5(xdmf_file, fieldname, snapshot, header=None):
if header is None:<EOL><INDENT>header, xdmf_root = read_geom_h5(xdmf_file, snapshot)<EOL><DEDENT>else:<EOL><INDENT>xdmf_root = xmlET.parse(str(xdmf_file)).getroot()<EOL><DEDENT>npc = header['<STR_LIT>'] // header['<STR_LIT>']  <EOL>flds = np.zeros(_flds_shape(fieldname, header))<EOL>data_found = False<EOL>for elt_subdomain in xdmf_root[<NUM_LIT:0>][<NUM_LIT:0>][snapshot].findall('<STR_LIT>'):<EOL><INDENT>ibk = int(elt_subdomain.get('<STR_LIT:Name>').startswith('<STR_LIT>'))<EOL>for data_attr in elt_subdomain.findall('<STR_LIT>'):<EOL><INDENT>if data_attr.get('<STR_LIT:Name>') != fieldname:<EOL><INDENT>continue<EOL><DEDENT>icore, fld = _get_field(xdmf_file, data_attr.find('<STR_LIT>'))<EOL>fld = fld.T<EOL>shp = fld.shape<EOL>if shp[-<NUM_LIT:1>] == <NUM_LIT:1> and header['<STR_LIT>'][<NUM_LIT:0>] == <NUM_LIT:1>:  <EOL><INDENT>fld = fld.reshape((shp[<NUM_LIT:0>], <NUM_LIT:1>, shp[<NUM_LIT:1>], shp[<NUM_LIT:2>]))<EOL>if header['<STR_LIT>'] < <NUM_LIT:0>:<EOL><INDENT>fld = fld[(<NUM_LIT:2>, <NUM_LIT:0>, <NUM_LIT:1>), ...]<EOL><DEDENT><DEDENT>elif shp[-<NUM_LIT:1>] == <NUM_LIT:1>:  <EOL><INDENT>fld = fld.reshape((shp[<NUM_LIT:0>], shp[<NUM_LIT:1>], <NUM_LIT:1>, shp[<NUM_LIT:2>]))<EOL>if header['<STR_LIT>'] < <NUM_LIT:0>:<EOL><INDENT>fld = fld[(<NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:1>), ...]<EOL><DEDENT><DEDENT>elif header['<STR_LIT>'][<NUM_LIT:1>] == <NUM_LIT:1>:  <EOL><INDENT>fld = fld.reshape((<NUM_LIT:1>, shp[<NUM_LIT:0>], <NUM_LIT:1>, shp[<NUM_LIT:1>]))<EOL><DEDENT>ifs = [icore // np.prod(header['<STR_LIT>'][:i]) % header['<STR_LIT>'][i] *<EOL>npc[i] for i in range(<NUM_LIT:3>)]<EOL>if header['<STR_LIT>']:  <EOL><INDENT>fld = fld[:, :, :, :-<NUM_LIT:1>]<EOL><DEDENT>flds[:,<EOL>ifs[<NUM_LIT:0>]:ifs[<NUM_LIT:0>] + npc[<NUM_LIT:0>] + header['<STR_LIT>'],<EOL>ifs[<NUM_LIT:1>]:ifs[<NUM_LIT:1>] + npc[<NUM_LIT:1>] + header['<STR_LIT>'],<EOL>ifs[<NUM_LIT:2>]:ifs[<NUM_LIT:2>] + npc[<NUM_LIT:2>],<EOL>ibk] = fld<EOL>data_found = True<EOL><DEDENT><DEDENT>flds = _post_read_flds(flds, header)<EOL>return (header, flds) if data_found else None<EOL>
Extract field data from hdf5 files.

    Args:
        xdmf_file (:class:`pathlib.Path`): path of the xdmf file.
        fieldname (str): name of field to extract.
        snapshot (int): snapshot number.
        header (dict): geometry information.
    Returns:
        (dict, numpy.array): geometry information and field data. None
            is returned if data is unavailable.