예제 #1
0
def run(search_dir, pf_logfiles=None):
    for img_template, min_frame, max_frame in dataset.find_data_sets(search_dir,skip_symlinks=False):

        print "Dataset found:"
        print " NAME_TEMPLATE_OF_DATA_FRAMES= %s" % img_template
        print " DATA_RNAGE= %d %d" % (min_frame, max_frame)

        pdir, ppath = os.path.split(img_template)
        if not os.path.exists(os.path.join(pdir, "xds")):
            os.mkdir(os.path.join(pdir, "xds"))
        else:
            assert os.path.isdir(os.path.join(pdir, "xds"))

        prefix = ppath[:ppath.index("?")]
        if not prefix.endswith("_"):
            prefix += "_"

        if pf_logfiles is None:
            wdir = os.path.join(pdir, "xds", "xds_%s%d-%d" % (prefix, min_frame, max_frame))
            if os.path.isfile(os.path.join(wdir, "XDS.INP")):
                print " Already exist:", os.path.join(wdir, "XDS.INP")
                continue

            os.mkdir(wdir)

            cmd = 'generate_XDS.INP "%s"' % os.path.relpath(img_template, wdir)
            print " launching", cmd
            call(cmd=cmd, wdir=wdir)
        else:
            for minf, maxf in split_runs_based_on_pf_logfiles(pf_logfiles):
                if maxf < min_frame or max_frame < minf:
                    continue
                if minf < min_frame:
                    minf = min_frame
                if maxf > max_frame:
                    maxf = max_frame

                wdir = os.path.join(pdir, "xds", "xds_%s%d-%d" % (prefix, minf, maxf))

                if os.path.isfile(os.path.join(wdir, "XDS.INP")):
                    print "Already exist:", os.path.isfile(os.path.join(wdir, "XDS.INP"))
                    continue

                os.mkdir(wdir)

                cmd = 'generate_XDS.INP "%s"' % os.path.relpath(img_template, wdir)
                print " launching", cmd
                call(cmd=cmd, wdir=wdir)
                # XXX dirty hacks..
                inp = open(os.path.join(wdir, "XDS.INP")).readlines()
                ofs = open(os.path.join(wdir, "XDS.INP"), "w")
                for l in inp:
                    if l.startswith("DATA_RANGE="):
                        l = "DATA_RANGE= %d %d\n" % (minf, maxf)
                    if l.startswith("SPOT_RANGE="):
                        l = "SPOT_RANGE= %d %d\n" % (minf, (maxf-minf)/2+minf)
                    ofs.write(l)
                ofs.close()
        print
예제 #2
0
def run(search_dir, pf_logfiles=None):
    for img_template, min_frame, max_frame in dataset.find_data_sets(
            search_dir, skip_symlinks=False):

        print "Dataset found:"
        print " NAME_TEMPLATE_OF_DATA_FRAMES= %s" % img_template
        print " DATA_RNAGE= %d %d" % (min_frame, max_frame)

        pdir, ppath = os.path.split(img_template)
        if not os.path.exists(os.path.join(pdir, "xds")):
            os.mkdir(os.path.join(pdir, "xds"))
        else:
            assert os.path.isdir(os.path.join(pdir, "xds"))

        prefix = ppath[:ppath.index("?")]
        if not prefix.endswith("_"):
            prefix += "_"

        if pf_logfiles is None:
            wdir = os.path.join(pdir, "xds",
                                "xds_%s%d-%d" % (prefix, min_frame, max_frame))
            if os.path.isfile(os.path.join(wdir, "XDS.INP")):
                print " Already exist:", os.path.join(wdir, "XDS.INP")
                continue

            os.mkdir(wdir)

            cmd = 'generate_XDS.INP "%s"' % os.path.relpath(img_template, wdir)
            print " launching", cmd
            call(cmd=cmd, wdir=wdir)
        else:
            for minf, maxf in split_runs_based_on_pf_logfiles(pf_logfiles):
                if maxf < min_frame or max_frame < minf:
                    continue
                if minf < min_frame:
                    minf = min_frame
                if maxf > max_frame:
                    maxf = max_frame

                wdir = os.path.join(pdir, "xds",
                                    "xds_%s%d-%d" % (prefix, minf, maxf))

                if os.path.isfile(os.path.join(wdir, "XDS.INP")):
                    print "Already exist:", os.path.isfile(
                        os.path.join(wdir, "XDS.INP"))
                    continue

                os.mkdir(wdir)

                cmd = 'generate_XDS.INP "%s"' % os.path.relpath(
                    img_template, wdir)
                print " launching", cmd
                call(cmd=cmd, wdir=wdir)
                # XXX dirty hacks..
                inp = open(os.path.join(wdir, "XDS.INP")).readlines()
                ofs = open(os.path.join(wdir, "XDS.INP"), "w")
                for l in inp:
                    if l.startswith("DATA_RANGE="):
                        l = "DATA_RANGE= %d %d\n" % (minf, maxf)
                    if l.startswith("SPOT_RANGE="):
                        l = "SPOT_RANGE= %d %d\n" % (minf,
                                                     (maxf - minf) / 2 + minf)
                    ofs.write(l)
                ofs.close()
        print
예제 #3
0
"""
from yamtbx.dataproc import XIO
from yamtbx.dataproc.dataset import template_to_filenames, find_data_sets

def timestamps(img_files):
    img_date = []

    for f in img_files:
        im = XIO.Image(f)
        img_date.append((f, im.header["DateSeconds"]))

    for i in xrange(len(img_files)):
        print img_files[i],
        if i == 0:
            print 0
        else:
            print img_date[i][1] - img_date[i-1][1]


if __name__ == "__main__":
    import sys

    if len(sys.argv) > 1:
        wdir = sys.argv[1]
    else:
        wdir = os.getcwd()

    for img_template, min_frame, max_frame in find_data_sets(wdir):
        img_files = template_to_filenames(img_template, min_frame, max_frame)
        timestamps(img_files)
예제 #4
0
from yamtbx.dataproc import XIO
from yamtbx.dataproc.dataset import template_to_filenames, find_data_sets


def timestamps(img_files):
    img_date = []

    for f in img_files:
        im = XIO.Image(f)
        img_date.append((f, im.header["DateSeconds"]))

    for i in xrange(len(img_files)):
        print img_files[i],
        if i == 0:
            print 0
        else:
            print img_date[i][1] - img_date[i - 1][1]


if __name__ == "__main__":
    import sys

    if len(sys.argv) > 1:
        wdir = sys.argv[1]
    else:
        wdir = os.getcwd()

    for img_template, min_frame, max_frame in find_data_sets(wdir):
        img_files = template_to_filenames(img_template, min_frame, max_frame)
        timestamps(img_files)