Exemple #1
0
def loop_center_xrec():
    global face_on

    daq_lib.abort_flag = 0

    for i in xrange(0, 360, 40):
        if daq_lib.abort_flag == 1:
            return 0
        mva("Omega", i)
        pic_prefix = "findloop_" + str(i)
        #    time.sleep(0.1)
        daq_utils.take_crystal_picture(filename=pic_prefix)
    comm_s = "xrec " + os.environ["CONFIGDIR"] + "/xrec_360_40.txt xrec_result.txt"
    print comm_s
    os.system(comm_s)
    xrec_out_file = open("xrec_result.txt", "r")
    target_angle = 0.0
    radius = 0
    x_centre = 0
    y_centre = 0
    reliability = 0
    for result_line in xrec_out_file.readlines():
        print result_line
        tokens = split(result_line)
        tag = tokens[0]
        val = tokens[1]
        if tag == "TARGET_ANGLE":
            target_angle = float(val)
        elif tag == "RADIUS":
            radius = float(val)
        elif tag == "Y_CENTRE":
            y_centre_xrec = float(val)
        elif tag == "X_CENTRE":
            x_centre_xrec = float(val)
        elif tag == "RELIABILITY":
            reliability = int(val)
        elif tag == "FACE":
            face_on = float(tokens[3])
    xrec_out_file.close()
    xrec_check_file = open("Xrec_check.txt", "r")
    check_result = int(xrec_check_file.read(1))
    print "result = " + str(check_result)
    xrec_check_file.close()
    if reliability < 70 or check_result == 0:  # bail if xrec couldn't align loop
        return 0
    mva("Omega", target_angle)
    x_center = daq_utils.lowMagPixX / 2
    y_center = daq_utils.lowMagPixY / 2
    #  set_epics_pv("image_X_center","A",x_center)
    #  set_epics_pv("image_Y_center","A",y_center)
    print "center on click " + str(x_center) + " " + str(y_center - radius)
    print "center on click " + str((x_center * 2) - y_centre_xrec) + " " + str(x_centre_xrec)
    center_on_click(x_center, y_center - radius, source="macro")
    center_on_click((x_center * 2) - y_centre_xrec, x_centre_xrec, source="macro")
    mva("Omega", face_on)
    # now try to get the loopshape starting from here
    return 1
Exemple #2
0
def display_images():

  currentRequestID = db_lib.beamlineInfo('john', 'currentRequestID')["requestID"]
  print "display images for req " + str(currentRequestID)
  data_directory_name = getDetPv("data_filepath_rbv")
  numimages = getDetPv("numimages")
  prefix = getDetPv("data_filename_rbv")
  image_period = getDetPv("image_period")
  numstart = getDetPv("file_number_rbv")
  numstart = numstart - 1
  if (numimages>10 and image_period<10):
    sample = 10
  else:
    sample = 1
  filelist = []
  for i in range (numstart,numstart+numimages,sample):
    filename = "%s/%s_%05d.cbf" % (data_directory_name,prefix,i)
    filelist.append(filename)
  filename = "%s/%s_%05d.cbf" % (data_directory_name,prefix,numimages+numstart-1) # last image
  if (len(filelist) > 0):
    if (filename != filelist[len(filelist)-1]):
      filelist.append(filename)  
  for j in range (0,len(filelist)):
    filename = filelist[j]
    last_dot = string.rfind(filename,".")
    i = int(filename[last_dot-5:last_dot])
    print "looking for " + filename
    while not (os.path.exists(filename)):
      os.system("ls " + data_directory_name + " >/dev/null")
      time.sleep(0.03)
      if (jpeg_needed == -99):
        return
#    time.sleep(0.1) 
    print "found for " + filename
    time.sleep(.05) #got a corrupted file error in albula w/0 this, might not happen in real collection
##    daq_utils.albulaDisp(filename) #why have the logger kicking off albula? Because that's what it does for now, don't bother with eiger, use monitor
    daq_utils.diff2jpeg(filename,JPEGfilename=None,reqID=currentRequestID)
##huh? I think the filelist takes care of this    if (j%10 == 0):
    now = time.time()
    print "take xtal picture"
    daq_utils.runDials(filename)
    daq_utils.take_crystal_picture(filename=None,czoom=0,reqID=currentRequestID,omega=beamline_lib.motorPosFromDescriptor("omega")) #but this is unlikely to be synchronized with diff image
Exemple #3
0
def getXrecLoopShape(currentRequest):
  sampleID = currentRequest["sample_id"]
#  beamline_support.set_any_epics_pv("XF:17IDC-ES:FMX{Cam:07}MJPGZOOM:NDArrayPort","VAL","ROI1") #not the best, but I had timing issues doing it w/o a sleep
  for i in range(4):
    if (daq_lib.abort_flag == 1):
      return 0
    mvaDescriptor("omega",i*30)
    pic_prefix = "findloopshape_" + str(i)
    time.sleep(1.0) # for vid lag, sucks
    daq_utils.take_crystal_picture(filename=pic_prefix,czoom=1)
  comm_s = "xrec30 " + os.environ["CONFIGDIR"] + "/xrec30.txt xrec30_result.txt"
  os.system(comm_s)
  print ("face on = " + str(face_on))
  mvaDescriptor("omega",face_on) #global, yuk.
  os.system("cp /dev/shm/masks2_hull_0.txt loopPoints.txt")
  polyPoints = [] 
  rasterPoly = None     
  filename = "loopPoints.txt"
  xrec_out_file = open(filename,"r")  
  resultLine = xrec_out_file.readline()
  xrec_out_file.close() 
  tokens = resultLine.split()
  numpoints = int(tokens[0])
  for i in range(1,len(tokens)-1,2):
    point = [tokens[i],tokens[i+1]]
    correctedPoint = [daq_utils.screenPixX-int(tokens[i]),daq_utils.screenPixY-int(tokens[i+1])] 
    polyPoint = QtCore.QPointF(float(correctedPoint[0]),float(correctedPoint[1]))
    polyPoints.append(polyPoint)
    newLoopPoint = QtGui.QGraphicsEllipseItem(correctedPoint[0],correctedPoint[1],3,3)      
  rasterPoly = QtGui.QGraphicsPolygonItem(QtGui.QPolygonF(polyPoints))
  polyBoundingRect = rasterPoly.boundingRect()
  raster_w = int(polyBoundingRect.width())
  raster_h = int(polyBoundingRect.height())
  center_x = int(polyBoundingRect.center().x())
  center_y = int(polyBoundingRect.center().y())
  if (currentRequest['request_obj']['protocol'] == "multiCol"):
    stepsizeMicrons = currentRequest['request_obj']['gridStep']
  else:
    stepsizeMicrons = 30.0 #for now.
  rasterReqID = definePolyRaster(currentRequest,raster_w,raster_h,stepsizeMicrons,center_x,center_y,rasterPoly)
  return rasterReqID
Exemple #4
0
def getXrecLoopShape(currentRequest):
    sampleID = currentRequest["sample_id"]
    beamline_support.set_any_epics_pv(
        "FAMX-cam1:MJPGZOOM:NDArrayPort", "VAL", "ROI1"
    )  # not the best, but I had timing issues doing it w/o a sleep
    for i in xrange(4):
        if daq_lib.abort_flag == 1:
            return 0
        mvr("Omega", i * 30)
        pic_prefix = "findloopshape_" + str(i)
        #    time.sleep(0.1)
        daq_utils.take_crystal_picture(filename=pic_prefix, czoom=1)
    comm_s = "xrec30 " + os.environ["CONFIGDIR"] + "/xrec30.txt xrec30_result.txt"
    os.system(comm_s)
    mva("Omega", face_on)
    os.system("cp /dev/shm/masks2_hull_0.txt loopPoints.txt")
    polyPoints = []
    rasterPoly = None
    filename = "loopPoints.txt"
    xrec_out_file = open(filename, "r")
    resultLine = xrec_out_file.readline()
    xrec_out_file.close()
    tokens = string.split(resultLine)
    numpoints = int(tokens[0])
    for i in xrange(1, len(tokens) - 1, 2):
        point = [tokens[i], tokens[i + 1]]
        correctedPoint = [daq_utils.screenPixX - int(tokens[i]), daq_utils.screenPixY - int(tokens[i + 1])]
        polyPoint = QtCore.QPointF(float(correctedPoint[0]), float(correctedPoint[1]))
        polyPoints.append(polyPoint)
        newLoopPoint = QtGui.QGraphicsEllipseItem(correctedPoint[0], correctedPoint[1], 3, 3)
    rasterPoly = QtGui.QGraphicsPolygonItem(QtGui.QPolygonF(polyPoints))
    polyBoundingRect = rasterPoly.boundingRect()
    raster_w = int(polyBoundingRect.width())
    raster_h = int(polyBoundingRect.height())
    center_x = int(polyBoundingRect.center().x())
    center_y = int(polyBoundingRect.center().y())
    stepsizeMicrons = 30.0  # for now.
    rasterReqID = definePolyRaster(currentRequest, raster_w, raster_h, stepsizeMicrons, center_x, center_y, rasterPoly)
    return rasterReqID
Exemple #5
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
Exemple #6
0
def insertResult(result,
                 resultType,
                 request,
                 visitName,
                 dc_id=None,
                 xmlFileName=None):  #xmlfilename for fastDP
    #keep in mind that request type can be standard and result type be fastDP - multiple results per req.

    cbfComm = db_lib.getBeamlineConfigParam(beamline, "cbfComm")
    try:
        sessionid = core.retrieve_visit_id(visitName)
    except ISPyBNoResultException as e:
        logger.error(
            "caught ISPyBNoResultException: %s. make sure visit name is in the format mx999999-1234"
            % e)
        propNum = visitName.split('-')[0]
        sessionid = createVisit(propNum)
    request_type = request['request_type']
    if request_type in ('standard', 'vector'):
        sample = request[
            'sample']  # this needs to be created and linked to a DC group
        if (resultType == 'fastDP'):
            mx_data_reduction_dict = xml_file_to_dict(xmlFileName)
            (app_id, ap_id, scaling_id,
             integration_id) = mx_data_reduction_to_ispyb(
                 mx_data_reduction_dict, dc_id, mxprocessing)
            mxprocessing.upsert_program_ex(program_id=app_id, status=1)

        elif resultType == 'mxExpParams':
            result_obj = result['result_obj']
            request_obj = result_obj['requestObj']
            directory = request_obj["directory"]
            filePrefix = request_obj['file_prefix']
            basePath = request_obj["basePath"]
            visitName = daq_utils.getVisitName()
            jpegDirectory = visitName + "/jpegs/" + directory[
                directory.find(visitName) + len(visitName):len(directory)]
            fullJpegDirectory = basePath + "/" + jpegDirectory
            jpegImagePrefix = fullJpegDirectory + "/" + filePrefix
            daq_utils.take_crystal_picture(filename=jpegImagePrefix)
            jpegImageFilename = jpegImagePrefix + ".jpg"
            jpegImageThumbFilename = jpegImagePrefix + "t.jpg"
            node = db_lib.getBeamlineConfigParam(beamline, "adxvNode")
            comm_s = "ssh -q " + node + " \"convert " + jpegImageFilename + " -resize 40% " + jpegImageThumbFilename + "\"&"
            logger.info('resizing image: %s' % comm_s)
            os.system(comm_s)
            seqNum = int(detSeqNumPV.get())
            hdfSampleDataPattern = directory + "/" + filePrefix + "_"
            hdfRowFilepattern = hdfSampleDataPattern + str(int(
                float(seqNum))) + "_master.h5"

            # keep in mind I could do the jpeg conversion here, but maybe best to allow synchWeb on demand.
            cbfDir = directory
            CBF_conversion_pattern = cbfDir + "/" + filePrefix + "_"
            JPEG_conversion_pattern = fullJpegDirectory + "/" + filePrefix + "_"
            node = db_lib.getBeamlineConfigParam(beamline, "adxvNode")
            adxvComm = os.environ["PROJDIR"] + db_lib.getBeamlineConfigParam(
                daq_utils.beamline, "adxvComm")
            comm_s = "ssh -q " + node + " \"sleep 6;" + cbfComm + " " + hdfRowFilepattern + " 1:1 " + CBF_conversion_pattern + ";" + adxvComm + " -sa " + CBF_conversion_pattern + "000001.cbf " + JPEG_conversion_pattern + "0001.jpeg;convert " + JPEG_conversion_pattern + "0001.jpeg -resize 10% " + JPEG_conversion_pattern + "0001.thumb.jpeg\"&"
            logger.info('diffraction thumbnail image: %s' % comm_s)
            os.system(comm_s)
            # Create a new data collection group entry:
            params = mxacquisition.get_data_collection_group_params()
            params['parentid'] = sessionid
            if request_type == 'standard':
                params['experimenttype'] = 'OSC'
            elif request_type == 'vector':
                params['experimenttype'] = 'Helical'
            return createDataCollection(directory, filePrefix,
                                        jpegImageFilename, params, request_obj,
                                        sessionid)
Exemple #7
0
def insertResult(result,
                 resultType,
                 request,
                 visitName,
                 dc_id=None,
                 xmlFileName=None):  #xmlfilename for fastDP
    #keep in mind that request type can be standard and result type be fastDP - multiple results per req.

    try:
        sessionid = core.retrieve_visit_id(visitName)
    except ISPyBNoResultException as e:
        logger.error(
            "insert result - caught ISPyBNoResultException: '%s'. make sure visit name is in the format mx999999-1234. NOT HAVING MX IN FRONT IS A SIGN OF PROBLEMS - try newVisit() in that case."
            % e)
        propNum = visitName.split('-')[0]
        sessionid = createVisit(propNum)
    request_type = request['request_type']
    if request_type in ('standard', 'vector'):
        sample = request[
            'sample']  # this needs to be created and linked to a DC group
        if (resultType == 'fastDP'):
            mx_data_reduction_dict = xml_file_to_dict(xmlFileName)
            (app_id, ap_id, scaling_id,
             integration_id) = mx_data_reduction_to_ispyb(
                 mx_data_reduction_dict, dc_id, mxprocessing)
            mxprocessing.upsert_program_ex(program_id=app_id, status=1)

        elif resultType == 'mxExpParams':
            result_obj = result['result_obj']
            request_obj = result_obj['requestObj']
            directory = request_obj["directory"]
            filePrefix = request_obj['file_prefix']
            basePath = request_obj["basePath"]
            visitName = daq_utils.getVisitName()
            jpegDirectory = visitName + "/jpegs/" + directory[
                directory.find(visitName) + len(visitName):len(directory)]
            fullJpegDirectory = basePath + "/" + jpegDirectory
            jpegImagePrefix = fullJpegDirectory + "/" + filePrefix
            daq_utils.take_crystal_picture(filename=jpegImagePrefix)
            jpegImageFilename = jpegImagePrefix + ".jpg"
            jpegImageThumbFilename = jpegImagePrefix + "t.jpg"
            node = db_lib.getBeamlineConfigParam(beamline, "adxvNode")
            comm_s = f"ssh -q {node} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}resize.sh {jpegImageFilename} {jpegImageThumbFilename} 40% \"&"
            logger.info('resizing image: %s' % comm_s)
            os.system(comm_s)

            seqNum = int(detSeqNumPV.get())
            node = db_lib.getBeamlineConfigParam(beamline, "adxvNode")
            request_id = result['request']
            comm_s = f"ssh -q {node} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}eiger2cbf.sh {request_id} 1 1 0 {seqNum}\""
            logger.info(f'diffraction thumbnail conversion to cbf: {comm_s}')
            os.system(comm_s)
            comm_s = f"ssh -q {node} \"{os.environ['MXPROCESSINGSCRIPTSDIR']}cbf2jpeg.sh {request_id}\""
            logger.info(f'diffraction thumbnail conversion to jpeg: {comm_s}')
            os.system(comm_s)
            # Create a new data collection group entry:
            params = mxacquisition.get_data_collection_group_params()
            params['parentid'] = sessionid
            if request_type == 'standard':
                params['experimenttype'] = 'OSC'
            elif request_type == 'vector':
                params['experimenttype'] = 'Helical'
            return createDataCollection(directory, filePrefix,
                                        jpegImageFilename, params, request_obj,
                                        sessionid)
Exemple #8
0
def insertResult(result,resultType,request,visitName,dc_id=None,xmlFileName=None): #xmlfilename for fastDP
#keep in mind that request type can be standard and result type be fastDP - multiple results per req.

 cbfComm = db_lib.getBeamlineConfigParam(daq_utils.beamline,"cbfComm")
 try:
   sessionid = core.retrieve_visit_id(visitName)
 except ISPyBNoResultException:
   print("caught ISPyBNoResultException")
   sessionid = createVisit(visitName)
 request_type = request['request_type']
 if request_type in('standard', 'vector') :
   sample = request['sample'] # this needs to be created and linked to a DC group
   if (resultType == 'fastDP'):
     mx_data_reduction_dict = xml_file_to_dict(xmlFileName)
     (app_id, ap_id, scaling_id, integration_id) = mx_data_reduction_to_ispyb(mx_data_reduction_dict, dc_id, mxprocessing)
         
   elif resultType == 'mxExpParams':
     result_obj = result['result_obj']
     request_obj = result_obj['requestObj']
     directory = request_obj["directory"]
     filePrefix = request_obj['file_prefix']
     basePath = request_obj["basePath"]
     visitName = daq_utils.getVisitName()
     jpegDirectory = visitName + "/jpegs/" + directory[directory.find(visitName)+len(visitName):len(directory)]  
#     jpegDirectory = "jpegs" + directory[directory.find(basePath)+len(basePath):len(directory)]
     fullJpegDirectory = basePath + "/" + jpegDirectory
     jpegImagePrefix = fullJpegDirectory+"/"+filePrefix     
     daq_utils.take_crystal_picture(filename=jpegImagePrefix)
     jpegImageFilename = jpegImagePrefix+".jpg"
     jpegImageThumbFilename = jpegImagePrefix+"t.jpg"
     node = db_lib.getBeamlineConfigParam(daq_utils.beamline,"adxvNode")
#     node = db_lib.getBeamlineConfigParam(daq_utils.beamline,"spotNode1")          
     comm_s = "ssh -q " + node + " \"convert " + jpegImageFilename + " -resize 40% " + jpegImageThumbFilename + "\"&"     
     print(comm_s)
     os.system(comm_s)
#     seqNum = int(det_lib.detector_get_seqnum())
     seqNum = int(detSeqNumPV.get())          
     hdfSampleDataPattern = directory+"/"+filePrefix+"_" 
     hdfRowFilepattern = hdfSampleDataPattern + str(int(float(seqNum))) + "_master.h5"
     
#jpeg folder     cbfDir = os.getcwd()+"/jpegs/"+directory[len(os.getcwd()):len(directory)] #good luck with that working

# keep in mind I could do the jpeg conversion here, but maybe best to allow synchWeb on demand.
     cbfDir = directory
     CBF_conversion_pattern = cbfDir + "/" + filePrefix+"_"
     JPEG_conversion_pattern = fullJpegDirectory + "/" + filePrefix+"_"
     node = db_lib.getBeamlineConfigParam(daq_utils.beamline,"adxvNode")
#     node = db_lib.getBeamlineConfigParam(daq_utils.beamline,"spotNode1")     
     adxvComm = os.environ["PROJDIR"] + db_lib.getBeamlineConfigParam(daq_utils.beamline,"adxvComm")     
     comm_s = "ssh -q " + node + " \"sleep 6;" + cbfComm + " "  + hdfRowFilepattern  + " 1 " + CBF_conversion_pattern + "0001.cbf;" + adxvComm + " -sa "  + CBF_conversion_pattern + "0001.cbf " + JPEG_conversion_pattern + "0001.jpeg;convert " + JPEG_conversion_pattern + "0001.jpeg -resize 10% " + JPEG_conversion_pattern + "0001.thumb.jpeg\"&"
#     comm_s = "ssh -q " + node + " \"sleep 6;" + cbfComm + " "  + hdfRowFilepattern  + " 1 " + CBF_conversion_pattern + "0001.cbf;" + adxvComm + " -sa "  + CBF_conversion_pattern + "0001.cbf " + JPEG_conversion_pattern + "0001.jpeg;cp " + JPEG_conversion_pattern + "0001.jpeg " + JPEG_conversion_pattern + "0001.thumb.jpeg\"&"     
     print(comm_s)
     os.system(comm_s)
     # Create a new data collection group entry:
     params = mxacquisition.get_data_collection_group_params()
     params['parentid'] = sessionid
     # params['sampleid'] = ?
     if request_type == 'standard':
       params['experimenttype'] = 'OSC'
     elif request_type == 'vector':
       params['experimenttype'] = 'Helical'
     params['starttime'] = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
     params['endtime'] = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
#     params['starttime'] = datetime.fromtimestamp(request['time']).strftime('%Y-%m-%d %H:%M:%S')
#     params['endtime'] = datetime.fromtimestamp(request['time']).strftime('%Y-%m-%d %H:%M:%S')
     dcg_id = mxacquisition.insert_data_collection_group(list(params.values()))
     print("dcg_id: %i" % dcg_id)
     params = mxacquisition.get_data_collection_params()
     params['parentid'] = dcg_id
     params['visitid'] = sessionid
     params['imgdir'] = directory
     params['imgprefix'] = filePrefix
     params['imgsuffix'] = 'cbf' # assume CBF ...?
     params['wavelength'] = request_obj['wavelength']
     params['starttime'] = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
#     params['starttime'] = datetime.fromtimestamp(request['time']).strftime('%Y-%m-%d %H:%M:%S')     
     params['run_status'] = 'DataCollection Successful' # assume success / not aborted
     params['datacollection_number'] = request_obj['runNum']
     params['n_images'] = int(round((request_obj['sweep_end'] - request_obj['sweep_start']) / request_obj['img_width']))
     params['exp_time'] = request_obj['exposure_time']
     params['start_image_number'] = request_obj['file_number_start']
     params['axis_start'] = request_obj['sweep_start']
     params['axis_end'] = request_obj['sweep_end']
     params['axis_range'] = request_obj['img_width']
     params['resolution'] = request_obj['resolution']
     params['detector_distance'] = request_obj['detDist']
     params['slitgap_horizontal'] = request_obj['slit_width']
     params['slitgap_vertical'] = request_obj['slit_height']
     params['transmission'] = request_obj['attenuation']
     params['file_template'] = '%s_####.cbf' % (request_obj['file_prefix']) # assume cbf ...
#     params['file_template'] = '%s_%s_####.cbf' % (request_obj['file_prefix'], request_obj['runNum']) # assume cbf ...     
       # params['flux'] = ?
     params['overlap'] = 0.0
     params['rotation_axis'] = 'Omega' # assume Omega unless we know otherwise
     print("jpegimfilename = " + jpegImageFilename)
     params['xtal_snapshot1'] = jpegImageFilename
#     params['xtal_snapshot1'] = '/dls/i03/data/2016/cm14451-2/jpegs/20160413/test_xtal/xtal1_1_1_0.0.png'     
     params['xtal_snapshot2'] = '/dls/i03/data/2016/cm14451-2/jpegs/20160413/test_xtal/xtal1_1_1_90.0.png'
     params['xtal_snapshot3'] = '/dls/i03/data/2016/cm14451-2/jpegs/20160413/test_xtal/xtal1_3_1_183.0.png'
     params['xtal_snapshot4'] = '/dls/i03/data/2016/cm14451-2/jpegs/20160413/test_xtal/xtal1_3_1_93.0.png'
     dc_id = mxacquisition.insert_data_collection(list(params.values()))
     print("dc_id: %i" % dc_id)
     return dc_id
Exemple #9
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
#12/15 not sure why dna_run_num in prefix    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.mvaDescriptor("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 /nfs/skinner/testdata/johnPil6/data/B1GGTApo_9_00001.cbf " + filename
    else:
      commFake = "ln -sf /nfs/skinner/testdata/johnPil6/data/B1GGTApo_9_00181.cbf " + filename
    os.system(commFake)
    print(commFake)
    dna_filename_list.append(filename)
###4/16, don't bother with image server for now    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 = .1
    ybeam_size = .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
#####  flux = 10000000000 * beamline_lib.get_epics_pv("flux","VAL")
  flux = 600000000.0  #for now
  edna_input_filename = dna_directory + "/adsc1_in.xml"
  
  comm_s = "ssh -q xf17id1-srv1 \"" + os.environ["LSDCHOME"] + "/runEdna.py " + dna_directory + " " + dna_prefix + " " + str(aimed_ISig) + " " + str(flux) + " " + str(xbeam_size) + " " + str(ybeam_size) + " " + edna_input_filename + " " + str(charRequest["request_id"]) + "\""
  print(comm_s)
  os.system(comm_s)

  return 1
Exemple #10
0
def loop_center_xrec():
  global face_on

  daq_lib.abort_flag = 0    

  for i in range(0,360,40):
    if (daq_lib.abort_flag == 1):
      print("caught abort in loop center")
      return 0
    mvaDescriptor("omega",i)
    pic_prefix = "findloop_" + str(i)
    time.sleep(1.0) #for video lag. This sucks
    daq_utils.take_crystal_picture(filename=pic_prefix)
  comm_s = "xrec " + os.environ["CONFIGDIR"] + "/xrec_360_40.txt xrec_result.txt"
  print(comm_s)
  os.system(comm_s)
  xrec_out_file = open("xrec_result.txt","r")
  target_angle = 0.0
  radius = 0
  x_centre = 0
  y_centre = 0
  reliability = 0
  for result_line in xrec_out_file.readlines():
    print(result_line)
    tokens = result_line.split()
    tag = tokens[0]
    val = tokens[1]
    if (tag == "TARGET_ANGLE"):
      target_angle = float(val )
    elif (tag == "RADIUS"):
      radius = float(val )
    elif (tag == "Y_CENTRE"):
      y_centre_xrec = float(val )
    elif (tag == "X_CENTRE"):
      x_centre_xrec = float(val )
    elif (tag == "RELIABILITY"):
      reliability = int(val )
    elif (tag == "FACE"):
      face_on = float(tokens[3])
  xrec_out_file.close()
  xrec_check_file = open("Xrec_check.txt","r")  
  check_result =  int(xrec_check_file.read(1))
  print("result = " + str(check_result))
  xrec_check_file.close()
  if (reliability < 70 or check_result == 0): #bail if xrec couldn't align loop
    return 0
  mvaDescriptor("omega",target_angle)
  x_center = daq_utils.lowMagPixX/2
  y_center = daq_utils.lowMagPixY/2
#  set_epics_pv("image_X_center","A",x_center)
#  set_epics_pv("image_Y_center","A",y_center)
  print("center on click " + str(x_center) + " " + str(y_center-radius))
  print("center on click " + str((x_center*2) - y_centre_xrec) + " " + str(x_centre_xrec))
  fovx = daq_utils.lowMagFOVx
  fovy = daq_utils.lowMagFOVy
  center_on_click(x_center,y_center-radius,fovx,fovy,source="macro")
  center_on_click((x_center*2) - y_centre_xrec,x_centre_xrec,fovx,fovy,source="macro")
#  center_on_click(y_centre_xrec,x_centre_xrec,source="macro")  
  mvaDescriptor("omega",face_on)
  #now try to get the loopshape starting from here
  return 1