Exemple #1
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")
Exemple #2
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)
Exemple #3
0
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}")
    os.system(comm_s)
Exemple #4
0
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"
    else: