Exemplo n.º 1
0
    def get_spotfinder(self, distl_params
                       ):  #following heuristics_base.register_frames() example
        #application-specific adjustments to parameters
        #XXX this should probably be a deep copy of parameters.
        if distl_params.distl.res.inner != None:
            distl_params.distl_lowres_limit = distl_params.distl.res.inner
        if distl_params.distl.res.outer != None:
            distl_params.force_method2_resolution_limit = distl_params.distl.res.outer
            distl_params.distl_highres_limit = distl_params.distl.res.outer

        distl_params.distl_force_binning = False
        distl_params.distl_permit_binning = False
        distl_params.wedgelimit = 1
        distl_params.spotfinder_header_tests = False

        #unusual location for min spot area tests...
        from iotbx.detectors.context.config_detector import beam_center_convention_from_image_object
        beam_center_convention_from_image_object(self, distl_params)
        # end special min spot area treatment

        from spotfinder.applications.practical_heuristics import heuristics_base
        from spotfinder.diffraction.imagefiles import file_names

        class empty:
            pass

        E = empty()
        E.argv = ["Empty", self.filename]
        names = file_names(E)
        this_frame = names.frames()[0]
        process_dictionary = dict(
            twotheta="%f" % self.twotheta,
            ybeam="%f" % self.beamy,
            xbeam="%f" % self.beamx,
            distance="%f" % self.distance,
            wavelength="%f" % self.wavelength,
            template=[
                item.template for item in names.FN if item.number == this_frame
            ][0],
        )
        Spotfinder = heuristics_base(process_dictionary, distl_params)
        Spotfinder.images[this_frame] = Spotfinder.oneImage(
            this_frame, Spotfinder.pd, self)
        Spotfinder.determine_maxcell(this_frame, Spotfinder.pd)
        Spotfinder.images[this_frame]['spotoutput']['relpath'] = self.filename
        from spotfinder.applications.stats_distl import pretty_image_stats
        pretty_image_stats(Spotfinder, this_frame)
        return Spotfinder, this_frame
Exemplo n.º 2
0
  def get_spotfinder(self,distl_params): #following heuristics_base.register_frames() example
    #application-specific adjustments to parameters
    #XXX this should probably be a deep copy of parameters.
    if distl_params.distl.res.inner!=None:
      distl_params.distl_lowres_limit = distl_params.distl.res.inner
    if distl_params.distl.res.outer!=None:
      distl_params.force_method2_resolution_limit = distl_params.distl.res.outer
      distl_params.distl_highres_limit = distl_params.distl.res.outer

    distl_params.distl_force_binning = False
    distl_params.distl_permit_binning = False
    distl_params.wedgelimit = 1
    distl_params.spotfinder_header_tests = False

    #unusual location for min spot area tests...
    from iotbx.detectors.context.config_detector import beam_center_convention_from_image_object
    beam_center_convention_from_image_object(self,distl_params)
    # end special min spot area treatment

    from spotfinder.applications.practical_heuristics import heuristics_base
    from spotfinder.diffraction.imagefiles import file_names
    class empty:pass
    E = empty()
    E.argv = ["Empty",self.filename]
    names = file_names(E)
    this_frame = names.frames()[0]
    process_dictionary = dict(twotheta = "%f"%self.twotheta,
       ybeam = "%f"%self.beamy,
       xbeam = "%f"%self.beamx,
       distance = "%f"%self.distance,
       wavelength = "%f"%self.wavelength,
       template = [item.template for item in names.FN if item.number==this_frame][0],
                              )
    Spotfinder = heuristics_base(process_dictionary,distl_params)
    Spotfinder.images[this_frame] = Spotfinder.oneImage(this_frame,
      Spotfinder.pd, self)
    Spotfinder.determine_maxcell(this_frame,Spotfinder.pd)
    Spotfinder.images[this_frame]['spotoutput']['relpath']=self.filename
    from spotfinder.applications.stats_distl import pretty_image_stats
    pretty_image_stats(Spotfinder,this_frame)
    return Spotfinder,this_frame
Exemplo n.º 3
0
    def do_POST(self):
        T = Timer("do_POST")
        parsed = urlparse(self.path)
        qs = parse_qs(parsed.query)

        expect = self.headers.getheaders("Expect")
        if len(expect) >= 1:
            if True in [item.find("100") >= 0 for item in expect]:
                self.send_response(
                    100)  # untested; has no apparent affect on libcurl

        # Get arguments by reading body of request.
        # We read this in chunks to avoid straining
        # socket.read(); around the 10 or 15Mb mark, some platforms
        # begin to have problems (bug #792570).
        max_chunk_size = 10 * 1024 * 1024
        size_remaining = int(self.headers["content-length"])
        L = []
        while size_remaining:
            chunk_size = min(size_remaining, max_chunk_size)
            L.append(self.rfile.read(chunk_size))
            size_remaining -= len(L[-1])
        data = ''.join(L)
        post_data = StringIO(data)

        # Parse the multipart/form-data
        contentTypeHeader = self.headers.getheaders('content-type').pop()

        # Extract the boundary parameter in the content-type header
        headerParameters = contentTypeHeader.split(";")
        boundary = headerParameters[1].split("=")
        boundary = boundary[1].strip()

        parts = cgi.parse_multipart(
            post_data, {
                "boundary":
                boundary,
                "content-disposition":
                self.headers.getheaders('content-disposition')
            })
        print("*****************************")
        for item in parts.keys():
            if len(parts[item][0]) < 1000:
                print(item, parts[item])
        print("*****************************")

        from iotbx.detectors.image_from_http_request import module_or_slice_from_http_request
        imgobj = module_or_slice_from_http_request(parts)
        imgobj.read()
        print("Final image object:")
        imgobj.show_header()

        from spotfinder.diffraction.imagefiles import image_files, file_names
        from spotfinder.diffraction.imagefiles import Spotspickle_argument_module

        from spotfinder.applications.overall_procedure import spotfinder_no_pickle

        class server_imagefiles(image_files):
            def __init__(self):
                pass

        Files = server_imagefiles()
        Files.filenames = file_names(
            Spotspickle_argument_module(imgobj.filename))
        Files.images = [imgobj]

        S = spotfinder_no_pickle(Files, s3_passthru="-s3 4", spot_convention=0)

        frames = Files.frames()

        logfile = StringIO()
        sys.stdout = logfile

        from spotfinder.applications.stats_distl import pretty_image_stats, notes
        for frame in frames:
            #pretty_image_stats(S,frame)
            #notes(S,frames[0])
            module_image_stats(S, frame)

        sys.stdout = sys.__stdout__
        log = logfile.getvalue()
        print(log)

        ctype = 'text/plain'
        self.send_response(200)
        self.send_header("Content-type", ctype)
        self.send_header("Content-length", len(log))
        self.end_headers()
        self.wfile.write(log)
        self.opt_logging()