Exemple #1
0
    def rqwn(self, qwn, irec):
        """
        :param qwn: X,Y,Z,W,T,A,B,C or R  
        :param irec: step index 0,1,...
        :return binx, aval, bval, labels

        ::

            bi,a,b,l = cf.rqwn("T",4)

        """
        a = self.a
        b = self.b
        lval = "%s[%s]" % (qwn.lower(), irec)
        labels = ["Op : %s" % lval, "G4 : %s" % lval]

        if qwn == "R":
            apost = a.rpost_(irec)
            bpost = b.rpost_(irec)
            aval = vnorm(apost[:, :2])
            bval = vnorm(bpost[:, :2])
            cbins = a.pbins()
        elif qwn == "W":
            aval = a.recwavelength(irec)
            bval = b.recwavelength(irec)
            cbins = a.wbins()
        elif qwn in Evt.RPOST:
            q = Evt.RPOST[qwn]
            aval = a.rpost_(irec)[:, q]
            bval = b.rpost_(irec)[:, q]
            if qwn == "T":
                cbins = a.tbins()
            else:
                cbins = a.pbins()
            pass
        elif qwn in Evt.RPOL:
            q = Evt.RPOL[qwn]
            aval = a.rpol_(irec)[:, q]
            bval = b.rpol_(irec)[:, q]
            cbins = a.rpol_bins()
        else:
            assert 0, "qwn %s unknown " % qwn
        pass

        binscale = Evt.RQWN_BINSCALE[qwn]
        bins = cbins[::binscale]

        # hmm should arrange scaling to retain extreme bins to avoid clipping perhaps ??
        # formerly tried clever binning, but certainty of simple binning turns out easier to interpret
        #    bins = decompression_bins(cbins, [aval, bval], label=lval, binscale=binscale )
        #

        if len(bins) == 0:
            raise Exception("no bins")

        return bins, aval, bval, labels
Exemple #2
0
    def dump_ranges(self, i):
        log.info("%s : dump_ranges %s " % (repr(self), i))

        a = self.a
        b = self.b

        ap = a.rpost_(i)
        ar = vnorm(ap[:, :2])
        if len(ar) > 0:
            print " ".join(map(lambda _: "%6.3f" % _, (ar.min(), ar.max())))

        bp = b.rpost_(0)
        br = vnorm(bp[:, :2])
        if len(br) > 0:
            print " ".join(map(lambda _: "%6.3f" % _, (br.min(), br.max())))
Exemple #3
0
    def check_radius(self):
        """
        Asymmetric wider distribution than expected, from ~99 to 101.4 until
        fixed sphere positioning, when get expected symmetry

        ::

            In [50]: r.min()
            Out[50]: 99.96880356309731

            In [51]: r.max()
            Out[51]: 100.03083354506256

            In [53]: np.average(r)
            Out[53]: 100.00002525999686


        """
        #r = np.linalg.norm(self.p1, 2, 1)
        r = vnorm(self.p1)
        log.info("r min/max %s %s " % (r.min(), r, max()))

        plt.hist(r, bins=100)

        return r
Exemple #4
0
def theta(xyz):
    """
    :param xyz: array of cartesian coordinates
    :return: array of Spherical Coordinare polar angle, theta in degrees

    First subtract off any needed translations to align
    the coordinate system with focal points.

    Spherical Coordinates (where theta is polar angle 0:pi, phi is azimuthal 0:2pi)

     x = r sin(th) cos(ph)  = r st cp   
     y = r sin(th) sin(ph)  = r st sp  
     z = r cos(th)          = r ct     


     sqrt(x*x + y*y) = r sin(th)
                  z  = r cos(th)

     atan( sqrt(x*x+y*y) / z ) = th 

    """
    #r = np.linalg.norm(xyz, ord=2, axis=1)
    r = vnorm(xyz)
    z = xyz[:, 2]
    th = np.arccos(z / r) * 180. / np.pi
    return th
Exemple #5
0
    def rz_(self, i):
        v = self.vertices_(i)
        #r = np.linalg.norm(v[:,:2], 2, 1)
        r = vnorm(v[:, :2])

        rz = np.zeros((len(v), 2), dtype=np.float32)
        rz[:, 0] = r * np.sign(v[:, 0])
        rz[:, 1] = v[:, 2]
        return rz
Exemple #6
0
    def check_surface_normal(self):
        """

        In [187]: nnrm = np.linalg.norm(nrm, 2, 1)

        In [188]: nnrm[sr.msk].min()
        Out[188]: 0.99999999999999667

        In [189]: nnrm[sr.msk].max()
        Out[189]: 1.0000000000000033

        """
        sr = self
        p1c, nrm, msk = sr.intersection()
        #nnrm = np.linalg.norm(nrm, 2, 1)
        nnrm = vnorm(nrm)
Exemple #7
0
Jump into interactive::

    ipython -i $(which so.py) -- --det tboolean-sphere --tag 1 --src torch 

"""
import logging, sys
log = logging.getLogger(__name__)

from opticks.ana.base import opticks_main
from opticks.ana.nload import A
from opticks.ana.nbase import vnorm

if __name__ == '__main__':
    args = opticks_main(src="torch", tag="1", det="tboolean-sphere")

    try:
        so = A.load_("so", args.src, args.tag, args.det)
    except IOError as err:
        log.fatal(err)
        sys.exit(args.mrc)

    log.info("loaded so %s %s shape %s " % (so.path, so.stamp, repr(so.shape)))

    print so

    v = so[:, 0, :3]

    print "v", v
    print "vnorm(v)", vnorm(v)
Exemple #8
0
                det=args.det,
                seqs=seqs,
                args=args)
    except IOError as err:
        log.fatal(err)
        #sys.exit(args.mrc)  this causes a sysrap-t test fail from lack of a tmp file
        sys.exit(0)

    log.info(" a : %s " % a.brief)
    log.info(" b : %s " % b.brief)

if 0:
    if a.valid:
        a0 = a.rpost_(0)
        #a0r = np.linalg.norm(a0[:,:2],2,1)
        a0r = vnorm(a0[:, :2])
        if len(a0r) > 0:
            print(" ".join(map(lambda _: "%6.3f" % _, (a0r.min(), a0r.max()))))

    if b.valid:
        b0 = b.rpost_(0)
        #b0r = np.linalg.norm(b0[:,:2],2,1)
        b0r = vnorm(b0[:, :2])
        if len(b0r) > 0:
            print(" ".join(map(lambda _: "%6.3f" % _, (b0r.min(), b0r.max()))))

if 1:

    c2max = args.c2max
    c2max = None