def wcs_update(self, wcs_text, fb=None):
        """
        parses the wcs_text and populates the fields
        of a coord_tran instance.
        we start from the coord_tran of the input
        frame buffer, if any
        """
        if (fb):
            ct = fb.ct
        else:
            ct = coord_tran()
        if (not ct.valid):
            ct.zt = W_UNITARY

            # read wcs_text
            data = string.split(wcs_text, '\n')
            ct.imtitle = data[0]
            # we are expecting 8 floats and 1 int
            try:
                (ct.a, ct.b, ct.c, ct.d,
                 ct.tx, ct.ty, ct.z1, ct.z2,
                 ct.zt) = string.split(data[1])
                ct.a = float(ct.a)
                ct.b = float(ct.b)
                ct.c = float(ct.c)
                ct.d = float(ct.d)
                ct.tx = float(ct.tx)
                ct.ty = float(ct.ty)
                ct.z1 = float(ct.z1)
                ct.z2 = float(ct.z2)
                ct.zt = int(ct.zt)
            except Exception:
                ct.imtitle = "[NO WCS]"
                ct.a = 1
                ct.d = 1
                ct.b = 0
                ct.c = 0
                ct.tx = 0
                ct.ty = 0
                ct.zt = W_UNITARY
            ct.valid += 1

            # determine the best format for WCS output
            if (ct.valid and ct.zt == W_LINEAR):
                z1 = ct.z1
                z2 = ct.z2
                zrange = abs(z1 - z2)
                zavg = (abs(z1) + abs(z2)) / 2.0
                if (zrange < 100.0 and zavg < 200.0):
                    ct.format = " %7.2f %7.2f %7.3f%c"
                elif (zrange > 99999.0 or zavg > 99999.0):
                    ct.format = " %7.2f %7.2f %7.3g%c"
                else:
                    ct.format = W_DEFFORMAT
            else:
                ct.format = " %7.2f %7.2f %7.0f%c"

            # add_mapping, if we can
            if (len(data) < 4):
                return(ct)

            # we are expecting 1 string, 2 floats, and 6 int
            try:
                print("updating WCS: %s" % str(data[2]))
                (ct.region, ct.sx, ct.sy, ct.snx,
                 ct.sny, ct.dx, ct.dy, ct.dnx,
                 ct.dny) = string.split(data[2])
                ct.sx = float(ct.sx)
                ct.sy = float(ct.sy)
                ct.snx = int(ct.snx)
                ct.sny = int(ct.sny)
                # dx, dy: offset into frame where actual data starts
                ct.dx = int(ct.dx)
                ct.dy = int(ct.dy)
                # dnx, dny: length of actual data in frame from offsets
                ct.dnx = int(ct.dnx)
                ct.dny = int(ct.dny)
                ct.ref = string.strip(data[3])
                # if this works, we also have the real size of the image
                fb.img_width = ct.dnx + 1  # for some reason, the width is always 1 pixel smaller...
                fb.img_height = ct.dny
            except Exception:
                ct.region = 'none'
                ct.sx = 1.0
                ct.sy = 1.0
                ct.snx = fb.width
                ct.sny = fb.height
                ct.dx = 1
                ct.dy = 1
                ct.dnx = fb.width
                ct.dny = fb.height
                ct.ref = 'none'
        return (ct)
parses the wcs_text and populates the fields
        of a coord_tran instance.
        we start from the coord_tran of the input
        frame buffer, if any