def extract_ref(scihdu, refhdu):
same_size, rx, ry, x0, y0 = find_line(scihdu, refhdu)<EOL>if same_size:<EOL><INDENT>return refhdu.data<EOL><DEDENT>if rx != <NUM_LIT:1> or ry != <NUM_LIT:1>:<EOL><INDENT>raise NotImplementedError(<EOL>'<STR_LIT>')<EOL><DEDENT>ny, nx = scihdu.data.shape<EOL>refdata = refhdu.data[y0:y0+ny, x0:x0+nx]<EOL>if refdata.shape != (ny, nx):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(refdata.shape, (ny, nx)))<EOL><DEDENT>return refdata<EOL>
Extract section of the reference image that
    corresponds to the given science image.

    This only returns a view, not a copy of the
    reference image's array.

    Parameters
    ----------
    scihdu, refhdu : obj
        Extension HDU's of the science and reference image,
        respectively.

    Returns
    -------
    refdata : array-like
        Section of the relevant reference image.

    Raises
    ------
    NotImplementedError
        Either science or reference data are binned.

    ValueError
        Extracted section size mismatch.