Ejemplo n.º 1
0
def diff2jpeg(diffimageName,JPEGfilename=None,reqID=None):
  imageJpegData = {}
  imageJpegHeader = {}
  imageJpegData["dataFilePath"]=diffimageName
  payload = {"fileName":diffimageName,"sizeX":500,"sizeY":500,"gray":100,"percentX":0.5,"percentY":0.5,"userName":"******","sessionId":"E","zoom":1.0}
  img_url = "http://"+imgsrv_host+":"+imgsrv_port+"/getImage" 
  r = requests.get(img_url,params=payload)
  data = r.content
  imageJpegData["data"] = data
  img_url = "http://"+imgsrv_host+":"+imgsrv_port+"/getThumbnail"
  r = requests.get(img_url,params=payload)
  thumbData = r.content
  imageJpegData["thumbData"] = thumbData
  payload = {"fileName":diffimageName,"userName":"******","sessionId":"E"}
  img_url = "http://"+imgsrv_host+":"+imgsrv_port+"/getHeader"
  r = requests.get(img_url,params=payload)
  imageJpegData["header"] = r
  headerData = r.text
  lines = headerData.split("\n")
  for i in range (0,len(lines)):
    line = lines[i]
    print line
    tokens = line.split()
    if (len(tokens) > 1):
      if (tokens[0] == "OSC_START"):
        print "Omega start = " + tokens[1]
        imageJpegHeader["oscStart"] = float(tokens[1])
      elif (tokens[0] == "OSC_RANGE"):
        print "Omega range = " + tokens[1] 
        imageJpegHeader["oscRange"] = float(tokens[1])
      elif (tokens[0] == "EXPOSURE"):
        print "Exposure Time = " + tokens[2]
        imageJpegHeader["exptime"] = float(tokens[2])
      elif (tokens[0] == "DISTANCE"):
        print "Distance = " + str(float(tokens[1])/1000.0)
        imageJpegHeader["detDist"] = float(tokens[1])
      elif (tokens[0] == "WAVELENGTH"):
        print "Wavelength = " + tokens[1] 
        imageJpegHeader["wave"] = float(tokens[1])
  imageJpegData["header"] = imageJpegHeader
  if (reqID != None): #this means I'll dump into mongo as a result
    resultObj = {}
    imgRef = db_lib.addFile(data)
    resultObj["data"] = imgRef
    imgRef = db_lib.addFile(thumbData)
    resultObj["thumbData"] = imgRef
    resultObj["dataFilePath"] = diffimageName
    resultObj["header"] = imageJpegHeader
    db_lib.addResultforRequest("diffImageJpeg",reqID,resultObj)
  return imageJpegData
Ejemplo n.º 2
0
def diff2jpegLYNX(diffimageName,JPEGfilename=None,reqID=None):
  imageJpegData = {}
  imageJpegHeader = {}
  imageJpegData["dataFilePath"]=diffimageName
  img_url = "http://"+imgsrv_host+":"+imgsrv_port+"/getImage\?fileName="+ diffimageName+"\&sizeX=500\&sizeY=500\&gray=100\&zoom=1.0\&percentX=0.5\&percentY=0.5\&userName=me\&sessionId=E"
#  comm_s = "lynx -source %s >%s" % (img_url,JPEGfilename) 
  comm_s = "lynx -source %s" % (img_url) 
  print comm_s
  data = os.popen(comm_s).read()
  imageJpegData["data"] = data
#  os.system(comm_s)
  img_url = "http://"+imgsrv_host+":"+imgsrv_port+"/getThumbnail\?fileName="+ diffimageName+"\&sizeX=500\&sizeY=500\&gray=100\&zoom=1.0\&percentX=0.5\&percentY=0.5\&userName=me\&sessionId=E"
  comm_s = "lynx -source %s" % (img_url) 
  thumbData = os.popen(comm_s).read()
  imageJpegData["thumbData"] = thumbData
#  comm_s = "lynx -source %s >%s" % (img_url,"thumb_"+JPEGfilename) 
  print comm_s
#  os.system(comm_s)
  img_url = "http://"+imgsrv_host+":"+imgsrv_port+"/getHeader\?fileName="+ diffimageName+"\&userName=me\&sessionId=E"
  comm_s = "lynx -source " + img_url
  for outputline in os.popen(comm_s).readlines():    
    print outputline
    tokens = string.split(outputline)      
    if (tokens[0] == "OSC_START"):
      print "Omega start = " + tokens[1]
      imageJpegHeader["oscStart"] = float(tokens[1])
    elif (tokens[0] == "OSC_RANGE"):
      print "Omega range = " + tokens[1] 
      imageJpegHeader["oscRange"] = float(tokens[1])
    elif (tokens[0] == "EXPOSURE"):
      print "Exposure Time = " + tokens[2]
      imageJpegHeader["exptime"] = float(tokens[2])
    elif (tokens[0] == "DISTANCE"):
      print "Distance = " + str(float(tokens[1])/1000.0)
      imageJpegHeader["detDist"] = float(tokens[1])
    elif (tokens[0] == "WAVELENGTH"):
      print "Wavelength = " + tokens[1] 
      imageJpegHeader["wave"] = float(tokens[1])
  if (reqID != None):
    resultObj = {}
    imgRef = db_lib.addFile(data)
    resultObj["data"] = imgRef
    imgRef = db_lib.addFile(thumbData)
    resultObj["thumbData"] = imgRef
    resultObj["dataFilePath"] = diffimageName
    resultObj["header"] = imageJpegHeader
    db_lib.addResultforRequest("diffImageJpeg",reqID,resultObj)
  return imageJpegData
Ejemplo n.º 3
0
def logMxRequestParams(currentRequest):
  global currentIspybDCID
  reqObj = currentRequest["request_obj"]
  transmissionReadback = beamline_support.getPvValFromDescriptor("transmissionRBV")
  flux = beamline_support.getPvValFromDescriptor("flux")
  resultObj = {"requestObj":reqObj,"transmissionReadback":transmissionReadback,"flux":flux}  
  resultID = db_lib.addResultforRequest("mxExpParams",currentRequest["uid"],owner=daq_utils.owner,result_obj=resultObj,proposalID=daq_utils.getProposalID(),beamline=daq_utils.beamline)
  newResult = db_lib.getResult(resultID)
  db_lib.beamlineInfo(daq_utils.beamline, 'currentSampleID', info_dict={'sampleID':currentRequest["sample"]})
  db_lib.beamlineInfo(daq_utils.beamline, 'currentRequestID', info_dict={'requestID':currentRequest["uid"]})
  logfile = open("dataColLog.txt","a+")
  try:
    logfile.write("\n\ntimestamp: " + time.ctime(currentRequest["time"])+"\n")
  except KeyError:    
    print("caught key error in logging")
    print(currentRequest)
  logfile.write("protocol: " + reqObj["protocol"] +"\n")  
  logfile.write("data prefix: " + reqObj["file_prefix"] +"\n")
  logfile.write("flux: " + str(flux) +"\n")
  logfile.write("transimission percent: " + str(transmissionReadback) +"\n")
  logfile.write("total current (BCU): " + str(beamline_support.getPvValFromDescriptor("totalCurrentBCU")) +"\n")    
  logfile.write("omega start: " + str(reqObj["sweep_start"]) +"\n")
  logfile.write("omega end: " + str(reqObj["sweep_end"]) +"\n")
  logfile.write("image width: " + str(reqObj["img_width"]) +"\n")
  logfile.write("exposure time per image (s): " + str(reqObj["exposure_time"]) +"\n")
  logfile.write("detector distance: " + str(reqObj["detDist"]) +"\n")
  logfile.write("wavelength: " + str(reqObj["wavelength"]) +"\n")
  logfile.close()
  visitName = daq_utils.getVisitName()
  try: #I'm worried about unforseen ispyb db errors
    currentIspybDCID = ispybLib.insertResult(newResult,"mxExpParams",currentRequest,visitName)
  except:
    currentIspybDCID = 999999
    print("ispyb error")
Ejemplo n.º 4
0
def runDials(imgPath,reqID=None):
  comm_s = "dials.find_spots_client " + imgPath
  print comm_s
  dialsResultObj = xmltodict.parse("<data>\n"+os.popen(comm_s).read()+"</data>\n")
  print "done parsing dials output"
  print dialsResultObj
  currentRequestID = db_lib.beamlineInfo(beamline, 'currentRequestID')["requestID"]
  dialsResult = db_lib.addResultforRequest("dials",currentRequestID, dialsResultObj)
Ejemplo n.º 5
0
def runDialsObsolete(imgPath,reqID=None):
  comm_s = "dials.find_spots_client " + imgPath
  print(comm_s)
  dialsResultObj = xmltodict.parse("<data>\n"+os.popen(comm_s).read()+"</data>\n")
  print("done parsing dials output")
  print(dialsResultObj)
  currentRequestID = db_lib.getBeamlineConfigParam(beamline,'currentRequestID')
  dialsResult = db_lib.addResultforRequest("dials",currentRequestID, owner=owner,result_obj=dialsResultObj)
Ejemplo n.º 6
0
def logMxRequestParams(currentRequest, wait=True):
    global currentIspybDCID
    reqObj = currentRequest["request_obj"]
    transmissionReadback = getPvDesc("transmissionRBV")
    flux = getPvDesc("flux")
    resultObj = {
        "requestObj": reqObj,
        "transmissionReadback": transmissionReadback,
        "flux": flux
    }
    resultID = db_lib.addResultforRequest("mxExpParams",
                                          currentRequest["uid"],
                                          owner=daq_utils.owner,
                                          result_obj=resultObj,
                                          proposalID=daq_utils.getProposalID(),
                                          beamline=daq_utils.beamline)
    newResult = db_lib.getResult(resultID)
    newResult['result_obj']['requestObj']['xbeam'] = reqObj['xbeam']
    newResult['result_obj']['requestObj']['ybeam'] = reqObj['ybeam']
    db_lib.beamlineInfo(daq_utils.beamline,
                        'currentSampleID',
                        info_dict={'sampleID': currentRequest["sample"]})
    db_lib.beamlineInfo(daq_utils.beamline,
                        'currentRequestID',
                        info_dict={'requestID': currentRequest["uid"]})
    logfile = open("dataColLog.txt", "a+")
    try:
        logfile.write("\n\ntimestamp: " + time.ctime(currentRequest["time"]) +
                      "\n")
    except KeyError:
        logger.error("caught key error in logging")
        logger.error(currentRequest)
    logfile.write("protocol: " + reqObj["protocol"] + "\n")
    logfile.write("data prefix: " + reqObj["file_prefix"] + "\n")
    logfile.write("flux: " + str(flux) + "\n")
    logfile.write("transimission percent: " + str(transmissionReadback) + "\n")
    logfile.write("total current (BCU): " + str(getPvDesc("totalCurrentBCU")) +
                  "\n")
    logfile.write("omega start: " + str(reqObj["sweep_start"]) + "\n")
    logfile.write("omega end: " + str(reqObj["sweep_end"]) + "\n")
    logfile.write("image width: " + str(reqObj["img_width"]) + "\n")
    logfile.write("exposure time per image (s): " +
                  str(reqObj["exposure_time"]) + "\n")
    logfile.write("detector distance: " + str(reqObj["detDist"]) + "\n")
    logfile.write("wavelength: " + str(reqObj["wavelength"]) + "\n")
    logfile.close()
    visitName = daq_utils.getVisitName()
    try:  #I'm worried about unforseen ispyb db errors
        #rasters results are entered in ispyb by the GUI, no need to wait
        if wait:
            time.sleep(getBlConfig(ISPYB_RESULT_ENTRY_DELAY))
        currentIspybDCID = ispybLib.insertResult(newResult, "mxExpParams",
                                                 currentRequest, visitName)
    except Exception as e:
        currentIspybDCID = 999999
        logger.error("logMxRequestParams - ispyb error: %s" % e)
Ejemplo n.º 7
0
def take_crystal_picture(filename=None,czoom=0,reqID=None):
  zoom = int(czoom)
  if not (has_xtalview):
    return
  if (1):
    if (zoom==0):
      r=requests.get(xtal_url)
    else:
      r=requests.get(xtal_url_small)
  else: #password, need to change to requests module if we need this
    comm_s = "curl -u %s:%s -o %s.jpg -s %s" % (xtalview_user,xtalview_pass,filename,xtal_url)
  data = r.content
  if (filename != None):
    fd = open(filename+".jpg","w+")
    fd.write(data)
    fd.close()
  if (reqID != None):
    xtalpicJpegDataResult = {}
    imgRef = db_lib.addFile(data)
    xtalpicJpegDataResult["data"] = imgRef
    db_lib.addResultforRequest("xtalpicJpeg",reqID,xtalpicJpegDataResult)
Ejemplo n.º 8
0
def take_crystal_picture(filename=None, czoom=0, reqID=None, omega=-999):
    zoom = int(czoom)
    if not (has_xtalview):
        return
    if (zoom == 0):
        r = requests.get(xtal_url)
    else:
        r = requests.get(xtal_url_small)
    data = r.content
    if (filename != None):
        fd = open(filename + ".jpg", "wb+")
        fd.write(data)
        fd.close()
    if (reqID != None):
        xtalpicJpegDataResult = {}
        imgRef = db_lib.addFile(data)
        xtalpicJpegDataResult["data"] = imgRef
        xtalpicJpegDataResult["omegaPos"] = omega
        db_lib.addResultforRequest("xtalpicJpeg",
                                   reqID,
                                   owner=owner,
                                   result_obj=xtalpicJpegDataResult,
                                   beamline=beamline)
Ejemplo n.º 9
0
def logMxRequestParams(currentRequest):
  resultObj = {"requestObj":currentRequest["request_obj"]}
  db_lib.addResultforRequest("mxExpParams",currentRequest["request_id"],resultObj)  
  db_lib.beamlineInfo('john', 'currentSampleID', info_dict={'sampleID':currentRequest["sample_id"]})
  db_lib.beamlineInfo('john', 'currentRequestID', info_dict={'requestID':currentRequest["request_id"]})
Ejemplo n.º 10
0
def dna_execute_collection3(
    dna_start,
    dna_range,
    dna_number_of_images,
    dna_exptime,
    dna_directory,
    prefix,
    start_image_number,
    overlap,
    dna_run_num,
    charRequest,
):
    global collect_and_characterize_success, dna_have_strategy_results, dna_have_index_results, picture_taken
    global dna_strategy_exptime, dna_strategy_start, dna_strategy_range, dna_strategy_end, dna_strat_dist
    global screeningoutputid

    characterizationParams = charRequest["request_obj"]["characterizationParams"]
    dna_res = float(characterizationParams["aimed_resolution"])
    print "dna_res = " + str(dna_res)
    dna_filename_list = []
    print "number of images " + str(dna_number_of_images) + " overlap = " + str(overlap) + " dna_start " + str(
        dna_start
    ) + " dna_range " + str(dna_range) + " prefix " + prefix + " start number " + str(start_image_number) + "\n"
    collect_and_characterize_success = 0
    dna_have_strategy_results = 0
    dna_have_index_results = 0
    dg2rd = 3.14159265 / 180.0
    if daq_utils.detector_id == "ADSC-Q315":
        det_radius = 157.5
    elif daq_utils.detector_id == "ADSC-Q210":
        det_radius = 105.0
    elif daq_utils.detector_id == "PILATUS-6":
        det_radius = 212.0
    else:  # default Pilatus
        det_radius = 212.0
    #####  theta_radians = daq_lib.get_field("theta") * dg2rd
    theta_radians = 0.0
    wave = 12398.5 / beamline_lib.get_mono_energy()  # for now
    dx = det_radius / (tan(2.0 * (asin(wave / (2.0 * dna_res))) - theta_radians))
    print "distance = ", dx
    # skinner - could move distance and wave and scan axis here, leave wave alone for now
    print "skinner about to take reference images."
    for i in range(0, int(dna_number_of_images)):
        print "skinner prefix7 = " + prefix[0:7] + " " + str(start_image_number) + "\n"
        if len(prefix) > 8:
            if (prefix[0:7] == "postref") and (start_image_number == 1):
                print "skinner postref bail\n"
                time.sleep(float(dna_number_of_images * float(dna_exptime)))
                break
        # skinner roi - maybe I can measure and use that for dna_start so that first image is face on.
        dna_start = daq_lib.get_field("datum_omega")
        colstart = float(dna_start) + (i * (abs(overlap) + float(dna_range)))
        dna_prefix = "ref-" + prefix + "_" + str(dna_run_num)
        image_number = start_image_number + i
        dna_prefix_long = dna_directory + "/" + dna_prefix
        filename = daq_utils.create_filename(dna_prefix_long, image_number)
        beamline_lib.mva("Omega", float(colstart))
        #####    daq_lib.move_axis_absolute(daq_lib.get_field("scan_axis"),colstart)
        #####    daq_lib.take_image(colstart,dna_range,dna_exptime,filename,daq_lib.get_field("scan_axis"),0,1)
        daq_utils.take_crystal_picture(reqID=charRequest["request_id"])
        ######### BECAUSE I FAKE IT    imagesAttempted = collect_detector_seq(dna_range,dna_range,dna_exptime,dna_prefix,dna_directory,image_number)
        if i == 0:
            commFake = "ln -sf /h/pxuser/skinner/testdata/B1GGTApo_9_00001.cbf " + filename
        else:
            commFake = "ln -sf /h/pxuser/skinner/testdata/B1GGTApo_9_00181.cbf " + filename
        os.system(commFake)
        dna_filename_list.append(filename)
        diffImgJpegData = daq_utils.diff2jpeg(filename, reqID=charRequest["request_id"])  # returns a dictionary
        #    diffImgJpegData["timestamp"] = time.time()
        #    imgRef = db_lib.addFile(diffImgJpegData["data"])
        #    diffImgJpegData["data"] = imgRef
        #    imgRef = db_lib.addFile(diffImgJpegData["thumbData"])
        #    diffImgJpegData["thumbData"] = imgRef
        picture_taken = 1
    #                xml_from_file_list(flux,x_beamsize,y_beamsize,max_exptime_per_dc,aimed_completeness,file_list):
    edna_energy_ev = (12.3985 / wave) * 1000.0
    #####  xbeam_size = beamline_lib.get_motor_pos("slitHum")
    #####  ybeam_size = beamline_lib.get_motor_pos("slitVum")
    #  if (xbeam_size == 0.0 or ybeam_size == 0.0): #don't know where to get these from yet
    if 1:
        xbeam_size = 0.1
        ybeam_size = 0.16
    else:
        xbeam_size = xbeam_size / 1000
        ybeam_size = ybeam_size / 1000
    aimed_completeness = characterizationParams["aimed_completeness"]
    aimed_multiplicity = characterizationParams["aimed_multiplicity"]
    aimed_resolution = characterizationParams["aimed_resolution"]
    aimed_ISig = characterizationParams["aimed_ISig"]
    timeout_check = 0
    #####  while(not os.path.exists(dna_filename_list[len(dna_filename_list)-1])): #this waits for edna images
    if 0:
        timeout_check = timeout_check + 1
        time.sleep(1.0)
        if timeout_check > 10:
            break
    print "generating edna input\n"
    #  edna_input_filename = edna_input_xml.xml_from_file_list(edna_energy_ev,xbeam_size,ybeam_size,1000000,aimed_completness,aimed_ISig,aimed_multiplicity,aimed_resolution,dna_filename_list)
    #####  flux = 10000000000 * beamline_lib.get_epics_pv("flux","VAL")
    flux = 600000000.0  # for now
    edna_input_filename = dna_directory + "/adsc1_in.xml"
    edna_input_xml_command = (
        "/h/data/backed-up/pxsys/skinner/edna_header_code/makeAnEDNAXML-bnl.sh 1232 %s %s none %f %f 4000 0.01 0.01 0 xh1223_2_ %f %f %f > %s"
        % (dna_directory, dna_prefix, 3, aimed_ISig, flux, xbeam_size, ybeam_size, edna_input_filename)
    )
    #####  edna_input_xml_command = "ssh swill \"/h/data/backed-up/pxsys/skinner/edna_header_code/makeAnEDNAXML-bnl.sh 1232 %s %s none %f %f 4000 0.01 0.01 0 xh1223_2_ %f %f %f\" > %s" % (daq_lib.data_directory_name,dna_prefix,3,aimed_ISig,flux,xbeam_size,ybeam_size,edna_input_filename)
    print edna_input_xml_command
    comm_sss = "echo " + edna_input_xml_command + "> edna_comm.txt"
    os.system(comm_sss)
    os.system(edna_input_xml_command)

    print "done generating edna input\n"
    #  command_string = "cd %s; /usr/local/crys/edna-mx/mxv1/bin/edna-mxv1-characterisation.py --verbose --data %s" % (dna_directory,edna_input_filename)
    command_string = "/usr/local/crys/edna-mx/mxv1/bin/edna-mxv1-characterisation.py --verbose --data %s" % (
        edna_input_filename
    )
    #  command_string = "/usr/local/crys/edna-mx/mxv1/bin/edna-mxv1-characterisation.py --verbose --data /img11/data1/pxuser/staff/skinner/edna_run/adsc1_in.xml"
    # old  command_string = "$EDNA_HOME/mxv1/bin/edna-mxv1-characterisation --data " + edna_input_filename
    print command_string
    #  for i in range (0,len(dna_filename_list)):
    #    command_string = command_string + " " + dna_filename_list[i]
    broadcast_output("\nProcessing with EDNA. Please stand by.\n")
    if os.path.exists("edna.log"):
        os.remove("edna.log")
    if os.path.exists("edna.err"):
        os.remove("edna.err")
    edna_execution_status = os.system("%s > edna.log 2> edna.err" % command_string)
    #####  fEdnaLogFile = open(daq_lib.get_misc_dir_name() + "/edna.log", "r" )
    fEdnaLogFile = open("./edna.log", "r")
    ednaLogLines = fEdnaLogFile.readlines()
    fEdnaLogFile.close()
    for outline in ednaLogLines:
        # for outline in os.popen(command_string,'r',0).readlines():
        ####skinner6/11 seg faults?    broadcast_output(outline)
        if string.find(outline, "EdnaDir") != -1:
            (param, dirname) = string.split(outline, "=")
            strXMLFileName = (
                dirname[0 : len(dirname) - 1]
                + "/ControlInterfacev1_2/Characterisation/ControlCharacterisationv1_3_dataOutput.xml"
            )
        #####      strXMLFileName = dirname[0:len(dirname)-1]+"/ControlInterfacev1_2/Characterisation/ControlCharacterisationv1_1_dataOutput.xml"
        if string.find(outline, "characterisation successful!") != -1:
            collect_and_characterize_success = 1
    if not collect_and_characterize_success:
        dna_comment = "Indexing Failure"
        #####    pxdb_lib.update_sweep(2,daq_lib.sweep_seq_id,dna_comment)
        return 0
    xsDataCharacterisation = XSDataResultCharacterisation.parseFile(strXMLFileName)
    xsDataIndexingResult = xsDataCharacterisation.getIndexingResult()
    xsDataIndexingSolutionSelected = xsDataIndexingResult.getSelectedSolution()
    xsDataStatisticsIndexing = xsDataIndexingSolutionSelected.getStatistics()
    numSpotsFound = xsDataStatisticsIndexing.getSpotsTotal().getValue()
    numSpotsUsed = xsDataStatisticsIndexing.getSpotsUsed().getValue()
    numSpotsRejected = numSpotsFound - numSpotsUsed
    beamShiftX = xsDataStatisticsIndexing.getBeamPositionShiftX().getValue()
    beamShiftY = xsDataStatisticsIndexing.getBeamPositionShiftY().getValue()
    spotDeviationR = xsDataStatisticsIndexing.getSpotDeviationPositional().getValue()
    try:
        spotDeviationTheta = xsDataStatisticsIndexing.getSpotDeviationAngular().getValue()
    except AttributeError:
        spotDeviationTheta = 0.0
    diffractionRings = 0  # for now, don't see this in xml except message string
    reflections_used = 0  # for now
    reflections_used_in_indexing = 0  # for now
    rejectedReflections = 0  # for now
    xsDataOrientation = xsDataIndexingSolutionSelected.getOrientation()
    xsDataMatrixA = xsDataOrientation.getMatrixA()
    rawOrientationMatrix_a_x = xsDataMatrixA.getM11()
    rawOrientationMatrix_a_y = xsDataMatrixA.getM12()
    rawOrientationMatrix_a_z = xsDataMatrixA.getM13()
    rawOrientationMatrix_b_x = xsDataMatrixA.getM21()
    rawOrientationMatrix_b_y = xsDataMatrixA.getM22()
    rawOrientationMatrix_b_z = xsDataMatrixA.getM23()
    rawOrientationMatrix_c_x = xsDataMatrixA.getM31()
    rawOrientationMatrix_c_y = xsDataMatrixA.getM32()
    rawOrientationMatrix_c_z = xsDataMatrixA.getM33()
    xsDataCrystal = xsDataIndexingSolutionSelected.getCrystal()
    xsDataCell = xsDataCrystal.getCell()
    unitCell_alpha = xsDataCell.getAngle_alpha().getValue()
    unitCell_beta = xsDataCell.getAngle_beta().getValue()
    unitCell_gamma = xsDataCell.getAngle_gamma().getValue()
    unitCell_a = xsDataCell.getLength_a().getValue()
    unitCell_b = xsDataCell.getLength_b().getValue()
    unitCell_c = xsDataCell.getLength_c().getValue()
    mosaicity = xsDataCrystal.getMosaicity().getValue()
    xsSpaceGroup = xsDataCrystal.getSpaceGroup()
    spacegroup_name = xsSpaceGroup.getName().getValue()
    pointGroup = spacegroup_name  # for now
    bravaisLattice = pointGroup  # for now
    statusDescription = "ok"  # for now
    try:
        spacegroup_number = xsSpaceGroup.getITNumber().getValue()
    except AttributeError:
        spacegroup_number = 0
    xsStrategyResult = xsDataCharacterisation.getStrategyResult()
    resolutionObtained = -999
    if xsStrategyResult != None:
        dna_have_strategy_results = 1
        xsCollectionPlan = xsStrategyResult.getCollectionPlan()
        xsStrategySummary = xsCollectionPlan[0].getStrategySummary()
        resolutionObtained = xsStrategySummary.getRankingResolution().getValue()
        xsCollectionStrategy = xsCollectionPlan[0].getCollectionStrategy()
        xsSubWedge = xsCollectionStrategy.getSubWedge()
        for i in range(0, len(xsSubWedge)):
            xsExperimentalCondition = xsSubWedge[i].getExperimentalCondition()
            xsGoniostat = xsExperimentalCondition.getGoniostat()
            xsDetector = xsExperimentalCondition.getDetector()
            xsBeam = xsExperimentalCondition.getBeam()
            dna_strategy_start = xsGoniostat.getRotationAxisStart().getValue()
            dna_strategy_start = dna_strategy_start - (dna_strategy_start % 0.1)
            dna_strategy_range = xsGoniostat.getOscillationWidth().getValue()
            dna_strategy_range = dna_strategy_range - (dna_strategy_range % 0.1)
            dna_strategy_end = xsGoniostat.getRotationAxisEnd().getValue()
            dna_strategy_end = (dna_strategy_end - (dna_strategy_end % 0.1)) + dna_strategy_range
            dna_strat_dist = xsDetector.getDistance().getValue()
            dna_strat_dist = dna_strat_dist - (dna_strat_dist % 1)
            dna_strategy_exptime = xsBeam.getExposureTime().getValue()
    # wtf?      dna_strategy_exptime = dna_strategy_exptime-(dna_strategy_exptime%.2)
    program = "edna-1.0"  # for now
    #####  screeningoutputid = pxdb_lib.insert_dna_index_results(daq_lib.sweep_seq_id,daq_lib.get_field("xtal_id"),program,statusDescription,rejectedReflections,resolutionObtained,spotDeviationR,spotDeviationTheta,beamShiftX,beamShiftY,numSpotsFound,numSpotsUsed,numSpotsRejected,mosaicity,diffractionRings,spacegroup_name,pointGroup,bravaisLattice,rawOrientationMatrix_a_x,rawOrientationMatrix_a_y,rawOrientationMatrix_a_z,rawOrientationMatrix_b_x,rawOrientationMatrix_b_y,rawOrientationMatrix_b_z,rawOrientationMatrix_c_x,rawOrientationMatrix_c_y,rawOrientationMatrix_c_z,unitCell_a,unitCell_b,unitCell_c,unitCell_alpha,unitCell_beta,unitCell_gamma)
    dna_comment = (
        "spacegroup = "
        + str(spacegroup_name)
        + " mosaicity = "
        + str(mosaicity)
        + " resolutionHigh = "
        + str(resolutionObtained)
        + " cell_a = "
        + str(unitCell_a)
        + " cell_b = "
        + str(unitCell_b)
        + " cell_c = "
        + str(unitCell_c)
        + " cell_alpha = "
        + str(unitCell_alpha)
        + " cell_beta = "
        + str(unitCell_beta)
        + " cell_gamma = "
        + str(unitCell_gamma)
        + " status = "
        + str(statusDescription)
    )
    #####  print "\n\n skinner " + dna_comment + "\n" +str(daq_lib.sweep_seq_id) + "\n"
    print "\n\n skinner " + dna_comment + "\n"
    #####  pxdb_lib.update_sweep(2,daq_lib.sweep_seq_id,dna_comment)
    if dna_have_strategy_results:
        #####    pxdb_lib.insert_to_screening_strategy_table(screeningoutputid,dna_strategy_start,dna_strategy_end,dna_strategy_range,dna_strategy_exptime,resolutionObtained,program)
        dna_strat_comment = (
            "\ndna Strategy results: Start="
            + str(dna_strategy_start)
            + " End="
            + str(dna_strategy_end)
            + " Width="
            + str(dna_strategy_range)
            + " Time="
            + str(dna_strategy_exptime)
            + " Dist="
            + str(dna_strat_dist)
        )
        #    characterizationResult = {}
        characterizationResultObj = {}
        #    characterizationResult["type"] = "characterizationStrategy"
        #   characterizationResult["timestamp"] = time.time()
        characterizationResultObj = {
            "strategy": {
                "start": dna_strategy_start,
                "end": dna_strategy_end,
                "width": dna_strategy_range,
                "exptime": dna_strategy_exptime,
                "detDist": dna_strat_dist,
            }
        }
        #    characterizationResult["resultObj"] = characterizationResultObj
        db_lib.addResultforRequest("characterizationStrategy", charRequest["request_id"], characterizationResultObj)
        #####    pxdb_lib.update_sweep(2,daq_lib.sweep_seq_id,dna_strat_comment)
        xsStrategyStatistics = xsCollectionPlan[0].getStatistics()
        xsStrategyResolutionBins = xsStrategyStatistics.getResolutionBin()
        now = time.time()
        #  edna_isig_plot_filename = dirname[0:len(dirname)-1] + "/edna_isig_res_" + str(now) + ".txt"
        edna_isig_plot_filename = dirname[0 : len(dirname) - 1] + "/edna_isig_res.txt"
        isig_plot_file = open(edna_isig_plot_filename, "w")
        for i in range(0, len(xsStrategyResolutionBins) - 1):
            i_over_sigma_bin = xsStrategyResolutionBins[i].getIOverSigma().getValue()
            maxResolution_bin = xsStrategyResolutionBins[i].getMaxResolution().getValue()
            print str(maxResolution_bin) + " " + str(i_over_sigma_bin)
            isig_plot_file.write(str(maxResolution_bin) + " " + str(i_over_sigma_bin) + "\n")
        isig_plot_file.close()
    if dna_have_strategy_results:
        broadcast_output(dna_strat_comment)

    return 1
Ejemplo n.º 11
0
def generateGridMap(rasterRequest):
    reqObj = rasterRequest["request_obj"]
    rasterDef = reqObj["rasterDef"]
    stepsize = float(rasterDef["stepsize"])
    omega = float(rasterDef["omega"])
    rasterStartX = float(rasterDef["x"])
    rasterStartY = float(rasterDef["y"])
    rasterStartZ = float(rasterDef["z"])
    omegaRad = math.radians(omega)
    filePrefix = reqObj["directory"] + "/" + reqObj["file_prefix"]
    #  testImgFileList = glob.glob("/home/pxuser/Test-JJ/DataSets/Eiger1M-Tryps-cbf/*.cbf")
    testImgFileList = glob.glob("/h/pxuser/skinner/Eiger1M/*.cbf")
    testImgCount = 0
    rasterCellMap = {}
    for i in xrange(len(rasterDef["rowDefs"])):
        numsteps = float(rasterDef["rowDefs"][i]["numsteps"])
        if i % 2 == 0:  # left to right if even, else right to left - a snake attempt
            startX = rasterDef["rowDefs"][i]["start"]["x"] + (
                stepsize / 2.0
            )  # this is relative to center, so signs are reversed from motor movements.
        else:
            startX = (numsteps * stepsize) + rasterDef["rowDefs"][i]["start"]["x"] - (stepsize / 2.0)
        startY = rasterDef["rowDefs"][i]["start"]["y"] + (stepsize / 2.0)
        xRelativeMove = startX
        yyRelativeMove = startY * sin(omegaRad)
        yxRelativeMove = startY * cos(omegaRad)
        # old    yxRelativeMove = startY*sin(omegaRad)
        zMotAbsoluteMove = rasterStartZ - xRelativeMove

        # old    yMotAbsoluteMove = rasterStartY-yyRelativeMove
        #    xMotAbsoluteMove = yxRelativeMove+rasterStartX
        yMotAbsoluteMove = rasterStartY + yyRelativeMove
        xMotAbsoluteMove = rasterStartX - yxRelativeMove
        numsteps = int(rasterDef["rowDefs"][i]["numsteps"])
        for j in xrange(numsteps):
            if i % 2 == 0:  # left to right if even, else right to left - a snake attempt
                zMotCellAbsoluteMove = zMotAbsoluteMove - (j * stepsize)
            else:
                zMotCellAbsoluteMove = zMotAbsoluteMove + (j * stepsize)
            #      zMotAbsoluteMove = zMotAbsoluteMove-(j*stepsize)
            dataFileName = daq_utils.create_filename(filePrefix + "_" + str(i), j + 1)
            os.system("mkdir -p " + reqObj["directory"])
            comm_s = "ln -sf " + testImgFileList[testImgCount] + " " + dataFileName
            os.system(comm_s)
            testImgCount += 1
            rasterCellCoords = {"x": xMotAbsoluteMove, "y": yMotAbsoluteMove, "z": zMotCellAbsoluteMove}
            rasterCellMap[dataFileName[:-4]] = rasterCellCoords
    comm_s = "ls -rt " + reqObj["directory"] + "/" + reqObj["file_prefix"] + "*.cbf|dials.find_spots_client"
    print comm_s
    dialsResultObj = xmltodict.parse("<data>\n" + os.popen(comm_s).read() + "</data>\n")
    print "done parsing dials output"
    print dialsResultObj
    if rasterRequest["request_obj"].has_key("parentReqID"):
        parentReqID = rasterRequest["request_obj"]["parentReqID"]
    else:
        parentReqID = -1
    rasterResultObj = {
        "parentReqID": parentReqID,
        "rasterCellMap": rasterCellMap,
        "rasterCellResults": {"type": "dialsRasterResult", "resultObj": dialsResultObj},
    }
    #  rasterResult = daq_utils.createResult("rasterResult",rasterResultObj)
    rasterResult = db_lib.addResultforRequest("rasterResult", rasterRequest["request_id"], rasterResultObj)
    return rasterResult
Ejemplo n.º 12
0
os.system(comm_s)
os.chdir(runningDir)

filePrefix = sys.argv[2]
numstart = int(sys.argv[3])
numimages = int(sys.argv[4])
request_id = int(sys.argv[5])

expectedFilenameList = []
timeoutLimit = 60  #for now
prefix_long = directory + "/" + filePrefix
for i in range(numstart, numstart + numimages):
    filename = daq_utils.create_filename(prefix_long, i)
    expectedFilenameList.append(filename)
timeout_check = 0
while (not os.path.exists(expectedFilenameList[len(expectedFilenameList) -
                                               1])):  #this waits for images
    timeout_check = timeout_check + 1
    time.sleep(1.0)
    if (timeout_check > timeoutLimit):
        break
comm_s = "xia2 " + directory
print(comm_s)
os.system(comm_s)
fd = open("xia2.json")
resultObj = json.loads(fd.read())
fd.close()
print(resultObj)
db_lib.addResultforRequest("xia2", request_id, resultObj)
print("finished xia2")
Ejemplo n.º 13
0
  program = "edna-1.0" # for now
#####  screeningoutputid = pxdb_lib.insert_dna_index_results(daq_lib.sweep_seq_id,daq_lib.get_field("xtal_id"),program,statusDescription,rejectedReflections,resolutionObtained,spotDeviationR,spotDeviationTheta,beamShiftX,beamShiftY,numSpotsFound,numSpotsUsed,numSpotsRejected,mosaicity,diffractionRings,spacegroup_name,pointGroup,bravaisLattice,rawOrientationMatrix_a_x,rawOrientationMatrix_a_y,rawOrientationMatrix_a_z,rawOrientationMatrix_b_x,rawOrientationMatrix_b_y,rawOrientationMatrix_b_z,rawOrientationMatrix_c_x,rawOrientationMatrix_c_y,rawOrientationMatrix_c_z,unitCell_a,unitCell_b,unitCell_c,unitCell_alpha,unitCell_beta,unitCell_gamma)
  dna_comment =  "spacegroup = " + str(spacegroup_name) + " mosaicity = " + str(mosaicity) + " resolutionHigh = " + str(resolutionObtained) + " cell_a = " + str(unitCell_a) + " cell_b = " + str(unitCell_b) + " cell_c = " + str(unitCell_c) + " cell_alpha = " + str(unitCell_alpha) + " cell_beta = " + str(unitCell_beta) + " cell_gamma = " + str(unitCell_gamma) + " status = " + str(statusDescription)
#####  print "\n\n skinner " + dna_comment + "\n" +str(daq_lib.sweep_seq_id) + "\n"
  print("\n\n skinner " + dna_comment + "\n") 
#####  pxdb_lib.update_sweep(2,daq_lib.sweep_seq_id,dna_comment)
  if (dna_have_strategy_results):
#####    pxdb_lib.insert_to_screening_strategy_table(screeningoutputid,dna_strategy_start,dna_strategy_end,dna_strategy_range,dna_strategy_exptime,resolutionObtained,program)
    dna_strat_comment = "\ndna Strategy results: Start=" + str(dna_strategy_start) + " End=" + str(dna_strategy_end) + " Width=" + str(dna_strategy_range) + " Time=" + str(dna_strategy_exptime) + " Dist=" + str(dna_strat_dist)
#    characterizationResult = {}
    characterizationResultObj = {}
#    characterizationResult["type"] = "characterizationStrategy"
 #   characterizationResult["timestamp"] = time.time()
    characterizationResultObj = {"strategy":{"start":dna_strategy_start,"end":dna_strategy_end,"width":dna_strategy_range,"exptime":dna_strategy_exptime,"detDist":dna_strat_dist}}
#    characterizationResult["resultObj"] = characterizationResultObj
    db_lib.addResultforRequest("characterizationStrategy",request_id, characterizationResultObj)
#####    pxdb_lib.update_sweep(2,daq_lib.sweep_seq_id,dna_strat_comment)
    xsStrategyStatistics = xsCollectionPlan[0].getStatistics()
    xsStrategyResolutionBins = xsStrategyStatistics.getResolutionBin()
    now = time.time()
#  edna_isig_plot_filename = dirname[0:len(dirname)-1] + "/edna_isig_res_" + str(now) + ".txt"
    edna_isig_plot_filename = dirname[0:len(dirname)-1] + "/edna_isig_res.txt"
    isig_plot_file = open(edna_isig_plot_filename,"w")
    for i in range (0,len(xsStrategyResolutionBins)-1):
      i_over_sigma_bin = xsStrategyResolutionBins[i].getIOverSigma().getValue()
      maxResolution_bin = xsStrategyResolutionBins[i].getMaxResolution().getValue()
      print(str(maxResolution_bin) + " " + str(i_over_sigma_bin))
      isig_plot_file.write(str(maxResolution_bin) + " " + str(i_over_sigma_bin)+"\n")
    isig_plot_file.close()
  if (dna_have_strategy_results):
#    broadcast_output(dna_strat_comment)
Ejemplo n.º 14
0
def eScan(energyScanRequest):
  sampleID = energyScanRequest["sample_id"]
  reqObj = energyScanRequest["request_obj"]
  exptime = reqObj['exposure_time']
  print("energy scan for " + str(reqObj['scanEnergy']))
  scan_element = "Se"
  scanID = RE(dscan(omega,-20,20,10,exptime))
  scanData = db[scanID]
  for ev in get_events(scanData):
    if ('mercury_mca_spectrum' in ev['data']):
      print(ev['seq_num'], ev['data']['mercury_mca_spectrum'].sum())
      
  scanDataTable = get_table(scanData)
#these next lines only make sense for the mca
  specFile = open("spectrumData.txt","w+")
  for i in range (0,len(scanDataTable.mercury_mca_spectrum.values)):
    for j in range (0,len(scanDataTable.mercury_mca_spectrum.values[i])):
      specFile.write(str(scanDataTable.mercury_mca_spectrum.values[i][j]) + ",")
    specFile.write("\n")
  specFile.close()
#  scanDataTable = get_table(scanData,["omega","cam_7_stats1_total"])  
  eScanResultObj = {}
  eScanResultObj["databrokerID"] = scanID
  eScanResultObj["sample_id"] = sampleID  
  eScanResult = db_lib.addResultforRequest("eScanResult",energyScanRequest["request_id"], eScanResultObj)  
  print(scanDataTable)
  if (reqObj["runChooch"]):
    chooch_prefix = "choochData1"
    choochOutfileName = chooch_prefix+".efs"
    choochInputFileName = "/nfs/skinner/temp/choochData1.raw"
    comm_s = "chooch -e %s -o %s %s" % (scan_element, choochOutfileName,choochInputFileName)
#  comm_s = "chooch -e %s -o %s -p %s %s" % (scan_element,chooch_prefix+".efs",chooch_prefix+".ps",chooch_prefix+".raw")
    print(comm_s)
    choochInputData_x = []
    choochInputData_y = []
    choochInputFile = open(choochInputFileName,"r")
    for outputLine in choochInputFile.readlines():
      tokens = outputLine.split()
      if (len(tokens) == 2): #not a very elegant way to get past the first two lines that I don't need.    
        choochInputData_x.append(float(tokens[0]))
        choochInputData_y.append(float(tokens[1]))
    choochInputFile.close()
    for outputline in os.popen(comm_s).readlines():
      print(outputline)
      tokens = outputline.split()    
      if (len(tokens)>4):
        if (tokens[1] == "peak"):
          peak = float(tokens[3])
          fprime_peak = float(tokens[7])
          f2prime_peak = float(tokens[5])        
        elif (tokens[1] == "infl"):
          infl = float(tokens[3])
          fprime_infl = float(tokens[7])
          f2prime_infl = float(tokens[5])        
        else:
          pass
#  os.system("xmgrace spectrum.spec&")
#  os.system("gv.sh "+chooch_prefix+".ps") #kludged with a shell call to get around gv bug
#  os.system("ln -sf "+chooch_prefix+".ps latest_chooch_plot.ps")
    choochResultObj = {}
    choochResultObj["infl"] = infl
    choochResultObj["peak"] = peak
    choochResultObj["f2prime_infl"] = f2prime_infl
    choochResultObj["fprime_infl"] = fprime_infl
    choochResultObj["f2prime_peak"] = f2prime_peak
    choochResultObj["fprime_peak"] = fprime_peak
    choochResultObj["sample_id"] = sampleID
    choochOutFile = open("/nfs/skinner/temp/choochData1.efs","r")
    chooch_graph_x = []
    chooch_graph_y1 = []
    chooch_graph_y2 = []
    for outLine in choochOutFile.readlines():
      tokens = outLine.split()
      chooch_graph_x.append(float(tokens[0]))
      chooch_graph_y1.append(float(tokens[1]))
      chooch_graph_y2.append(float(tokens[2]))
    choochOutFile.close()
    choochResultObj["choochOutXAxis"] = chooch_graph_x
    choochResultObj["choochOutY1Axis"] = chooch_graph_y1
    choochResultObj["choochOutY2Axis"] = chooch_graph_y2
    choochResultObj["choochInXAxis"] = choochInputData_x
    choochResultObj["choochInYAxis"] = choochInputData_y  
#    plt.plot(chooch_graph_x,chooch_graph_y1)
#    plt.plot(chooch_graph_x,chooch_graph_y2)
#    plt.show()
#    print(choochResultObj)
    choochResult = db_lib.addResultforRequest("choochResult",energyScanRequest["request_id"], choochResultObj)
    choochResultID = choochResult["result_id"]
    set_field("choochResultFlag",choochResultID)
Ejemplo n.º 15
0
#fastdpComm = db_lib.getBeamlineConfigParam(os.environ["BEAMLINE_ID"],"fastdpComm")
dimpleComm = db_lib.getBeamlineConfigParam(os.environ["BEAMLINE_ID"],"dimpleComm")  
comm_s = "ssh  -q " + node + " \"cd " + runningDir + fastdpComm + hdfFilepattern  + "\""
#comm_s = "ssh  -q " + node + " \"cd " + runningDir +";source /nfs/skinner/wrappers/fastDPWrap2;fast_dp -j 12 -J 12 -k 60 " + hdfFilepattern  + "\"" 

#comm_s = "ssh  -q " + node + " \"cd " + runningDir +";source /nfs/skinner/wrappers/fastDPWrap;/usr/local/crys-local/fast_dp/bin/fast_dp -J 16 -j 16 -k 70  " + hdfFilepattern  + "\""
print(comm_s)
os.system(comm_s)
fastDPResultFile = runningDir+"/fast_dp.xml"
#fastDPResultFile = "/GPFS/CENTRAL/xf17id2/skinner/ispyb/fast_dp.xml"
#fd = open("fast_dp.xml")
fd = open(fastDPResultFile)
resultObj = xmltodict.parse(fd.read())
print("finished fast_dp")
print(resultObj)
resultID = db_lib.addResultforRequest("fastDP",request_id,owner,resultObj,beamline=os.environ["BEAMLINE_ID"])
newResult = db_lib.getResult(resultID)
visitName = db_lib.getBeamlineConfigParam(os.environ["BEAMLINE_ID"],"visitName")
try:
  ispybLib.insertResult(newResult,"fastDP",request,visitName,ispybDCID,fastDPResultFile)
except:
  print("ispyb error")
if (runFastEP):
  os.system("fast_ep") #looks very bad! running on ca1!
if (runDimple):
  sampleID = request["sample"]
  sample = db_lib.getSampleByID(sampleID)
  try:
    modelFilename = sample["model"]
    if (modelFilename == 'nan'):
      modelPDBname = "model.pdb"
Ejemplo n.º 16
0
node = sys.argv[5]
runDimple = int(sys.argv[6])
dimpleNode = sys.argv[7]
ispybDCID = int(sys.argv[8])

comm_s = f"ssh -q {node} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}fast_dp.sh {request_id} {numstart}\""
logger.info(comm_s)
os.system(comm_s)

fastDPResultFile = runningDir + "/fast_dp.xml"
fd = open(fastDPResultFile)
resultObj = xmltodict.parse(fd.read())
logger.info("finished fast_dp")
resultID = db_lib.addResultforRequest("fastDP",
                                      request_id,
                                      owner,
                                      resultObj,
                                      beamline=os.environ["BEAMLINE_ID"])
newResult = db_lib.getResult(resultID)
visitName = getBlConfig("visitName")
try:
    ispybLib.insertResult(newResult, "fastDP", request, visitName, ispybDCID,
                          fastDPResultFile)
except Exception as e:
    logger.error("runfastdph5 insert result ispyb error: %s" % e)
if (runFastEP):
    os.system("fast_ep")  #looks very bad! running on ca1!
if (runDimple):
    dimpleComm = getBlConfig("dimpleComm")
    comm_s = f"ssh -q {dimpleNode} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}dimple.sh {request_id} {numstart}\""
    logger.info(f"running dimple: {comm_s}")
Ejemplo n.º 17
0
def generateGridMap(rasterRequest):
  global dialsResultDict,rasterRowResultsList

  reqObj = rasterRequest["request_obj"]
  rasterDef = reqObj["rasterDef"]
  stepsize = float(rasterDef["stepsize"])
  omega = float(rasterDef["omega"])
  rasterStartX = float(rasterDef["x"])
  rasterStartY = float(rasterDef["y"])
  rasterStartZ = float(rasterDef["z"])
  omegaRad = math.radians(omega)
  filePrefix = reqObj["directory"]+"/"+reqObj["file_prefix"]
  testImgFileList = glob.glob("/GPFS/CENTRAL/XF17ID1/skinner/eiger16M/cbf/*.cbf")  
#  testImgFileList = glob.glob("/GPFS/CENTRAL/XF17ID1/skinner/testdata/Eiger1M/*.cbf")
  testImgCount = 0
  rasterCellMap = {}
  os.system("mkdir -p " + reqObj["directory"])
  for i in range(len(rasterDef["rowDefs"])):
    numsteps = float(rasterDef["rowDefs"][i]["numsteps"])
    if (i%2 == 0): #left to right if even, else right to left - a snake attempt
      startX = rasterDef["rowDefs"][i]["start"]["x"]+(stepsize/2.0) #this is relative to center, so signs are reversed from motor movements.
    else:
      startX = (numsteps*stepsize) + rasterDef["rowDefs"][i]["start"]["x"]-(stepsize/2.0)
    startY = rasterDef["rowDefs"][i]["start"]["y"]+(stepsize/2.0)

    xRelativeMove = startX
    yzRelativeMove = startY*sin(omegaRad)
    yyRelativeMove = startY*cos(omegaRad)


    xMotAbsoluteMove = rasterStartX+xRelativeMove    
    yMotAbsoluteMove = rasterStartY-yyRelativeMove
    zMotAbsoluteMove = rasterStartZ-yzRelativeMove

    numsteps = int(rasterDef["rowDefs"][i]["numsteps"])
    for j in range(numsteps):
      if (i%2 == 0): #left to right if even, else right to left - a snake attempt
        xMotCellAbsoluteMove = xMotAbsoluteMove+(j*stepsize)
      else:
        xMotCellAbsoluteMove = xMotAbsoluteMove-(j*stepsize)

      dataFileName = daq_utils.create_filename(filePrefix+"_Raster_"+str(i),j+1)
 ##     comm_s = "ln -sf " + testImgFileList[testImgCount] + " " + dataFileName      
##      os.system(comm_s)
      testImgCount+=1
      rasterCellCoords = {"x":xMotCellAbsoluteMove,"y":yMotAbsoluteMove,"z":zMotAbsoluteMove}
      rasterCellMap[dataFileName[:-4]] = rasterCellCoords
#commented out all of the processing, as this should have been done by the thread
  if ("parentReqID" in rasterRequest["request_obj"]):
    parentReqID = rasterRequest["request_obj"]["parentReqID"]
  else:
    parentReqID = -1
  print("RASTER CELL RESULTS")
  dialsResultLocalList = []
  for i in range (0,len(rasterRowResultsList)):
    for j in range (0,len(rasterRowResultsList[i])):
      try:
        dialsResultLocalList.append(rasterRowResultsList[i][j])
      except KeyError: #this is to deal with single cell row. Instead of getting back a list of one row, I get back just the row from Dials.
        dialsResultLocalList.append(rasterRowResultsList[i])
        break
###############
  print(dialsResultLocalList)

  rasterResultObj = {"sample_id": rasterRequest["sample_id"],"parentReqID":parentReqID,"rasterCellMap":rasterCellMap,"rasterCellResults":{"type":"dialsRasterResult","resultObj":dialsResultLocalList}}
  rasterResult = db_lib.addResultforRequest("rasterResult",rasterRequest["request_id"], rasterResultObj)
  return rasterResult
Ejemplo n.º 18
0
for i in range (numstart,numstart+numimages):
  filename = daq_utils.create_filename(prefix_long,i)
  expectedFilenameList.append(filename)
#for i in range (0,len(expectedFilenameList)):
#  print expectedFilenameList[i]
timeout_check = 0
while(not os.path.exists(expectedFilenameList[len(expectedFilenameList)-1])): #this waits for images
  timeout_check = timeout_check + 1
  time.sleep(1.0)
  if (timeout_check > timeoutLimit):
    break
node = "cpu-004"
comm_s = "ssh  -q " + node + " \"cd " + runningDir +";fast_dp " + expectedFilenameList[0] + "\""  
#comm_s = "fast_dp " + expectedFilenameList[0] #note this the first image
print(comm_s)
os.system(comm_s)
fd = open("fast_dp.xml")
#nresult = {}
#result["timestamp"] = time.time()
#result["type"] = "fastDP"
resultObj = xmltodict.parse(fd.read())
#result["resultObj"] = resultObj
db_lib.addResultforRequest("fastDP",request_id,resultObj)
print("finished fast_dp")
if (runFastEP):
  os.system("fast_ep")




Ejemplo n.º 19
0
prefix_long = directory+"/"+filePrefix
for i in range (numstart,numstart+numimages):
  filename = daq_utils.create_filename(prefix_long,i)
  expectedFilenameList.append(filename)
#for i in range (0,len(expectedFilenameList)):
#  print expectedFilenameList[i]
timeout_check = 0
while(not os.path.exists(expectedFilenameList[len(expectedFilenameList)-1])): #this waits for images
  timeout_check = timeout_check + 1
  time.sleep(1.0)
  if (timeout_check > timeoutLimit):
    break
comm_s = "xia2 " + directory
print comm_s
os.system(comm_s)
#result = {}
#result["timestamp"] = time.time()
#result["type"] = "xia2"
fd = open("xia2.json")
resultObj = json.loads(fd.read())
fd.close()
print resultObj
#result["resultObj"] = resultObj
db_lib.addResultforRequest("xia2",request_id,resultObj)
print "finished xia2"