def parse_pv(header):
    """
    Parses the PV array from an astropy FITS header.

    Args:
      header: astropy.io.fits.header.Header
        The header containing the PV values.

    Returns:
      cd: 2d array (list(list(float))
        [[PV1_0, PV1_1, ... PV1_N], [PV2_0, PV2_1, ... PV2_N]]
        Note that N depends on the order of the fit.  For example, an
        order 3 fit goes up to PV?_10.
    """
    order_fit = parse_order_fit(header)

    def parse_with_base(i):
        key_base = "PV%d_" % i

        pvi_x = [header[key_base + "0"]]

        def parse_range(lower, upper):
            for j in range(lower, upper + 1):
                pvi_x.append(header[key_base + str(j)])

        if order_fit >= 1:
            parse_range(1, 3)

        if order_fit >= 2:
            parse_range(4, 6)

        if order_fit >= 3:
            parse_range(7, 10)

        return pvi_x

    return [parse_with_base(1), parse_with_base(2)]
Parses the PV array from an astropy FITS header.

    Args:
      header: astropy.io.fits.header.Header
        The header containing the PV values.

    Returns:
      cd: 2d array (list(list(float))
        [[PV1_0, PV1_1, ... PV1_N], [PV2_0, PV2_1, ... PV2_N]]
        Note that N depends on the order of the fit.  For example, an
        order 3 fit goes up to PV?_10.