diff --git a/calibrationSuite/psana2Base.py b/calibrationSuite/psana2Base.py index 74b5f09..e96b52b 100755 --- a/calibrationSuite/psana2Base.py +++ b/calibrationSuite/psana2Base.py @@ -97,6 +97,7 @@ def setupPsana(self): try: self.step_value = self.myrun.Detector("step_value") self.step_docstring = self.myrun.Detector("step_docstring") + ##print('foo', self.step_value, self.step_docstring) except: self.step_value = self.step_docstring = None @@ -297,11 +298,12 @@ def getScanValue(self, step, useStringInfo=False): ##print(self.step_value(step),self.step_docstring(step),useStringInfo) if useStringInfo: payload = self.step_docstring(step) - ##print(payload) + print(payload) sv = eval(payload.split()[-1][:-1]) + ##print('sv', sv) print("step", int(self.step_value(step)), sv) logger.info("step" + str(int(self.step_value(step))) + str(sv)) - return sv + return int(float(sv)) return self.step_value(step) def plainGetRawData(self, evt): diff --git a/data/cometPinhole.npy b/data/cometPinhole.npy new file mode 100644 index 0000000..d6632bc Binary files /dev/null and b/data/cometPinhole.npy differ diff --git a/data/smallRegionFourAsicsForBhavna.npy b/data/smallRegionFourAsicsForBhavna.npy new file mode 100644 index 0000000..d9efa88 Binary files /dev/null and b/data/smallRegionFourAsicsForBhavna.npy differ diff --git a/data/smallRegionTwoAsicsForBhavna.npy b/data/smallRegionTwoAsicsForBhavna.npy new file mode 100644 index 0000000..3af36ac Binary files /dev/null and b/data/smallRegionTwoAsicsForBhavna.npy differ diff --git a/setup.sh b/setup.sh index 0808a48..eeee827 100644 --- a/setup.sh +++ b/setup.sh @@ -7,11 +7,9 @@ current_dir=$(pwd) export PYTHONPATH="$PYTHONPATH:$current_dir" # so output folders are written in a shared location -#export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1003721/results/scripts/" -export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/scratch/" echo "export OUTPUT_ROOT="\"$OUTPUT_ROOT\" # point to which config file to use #export SUITE_CONFIG="rixSuiteConfig.py" export SUITE_CONFIG="epixMSuiteConfig.py" -echo "export SUITE_CONFIG="\"$SUITE_CONFIG\" \ No newline at end of file +echo "export SUITE_CONFIG="\"$SUITE_CONFIG\" diff --git a/standalone_scripts/simpler_epixhr.py b/standalone_scripts/simpler_epixhr.py index c98c4d1..03c75bc 100644 --- a/standalone_scripts/simpler_epixhr.py +++ b/standalone_scripts/simpler_epixhr.py @@ -19,6 +19,7 @@ ds = DataSource(exp="%s" % (expt), run=run) myrun = next(ds.runs()) det = myrun.Detector("epixhr") +det = myrun.Detector("epixm") from psmon import publish diff --git a/suite_scripts/AnalyzeH5.py b/suite_scripts/AnalyzeH5.py index 03e9faa..8d5b979 100644 --- a/suite_scripts/AnalyzeH5.py +++ b/suite_scripts/AnalyzeH5.py @@ -40,7 +40,8 @@ def __init__(self): self.files = args.files.replace(" ", "") print(self.files) self.outputDir = args.path - logging.info("Output dir: " + self.outputDir) + print("output dir:", self.outputDir) + ##logging.info("Output dir: " + self.outputDir) self.label = args.label self.camera = 0 @@ -55,6 +56,7 @@ def identifyAnalysis(self): try: self.analysisType = self.h5Files[0]["analysisType"] self.sliceCoordinates = self.h5Files[0]["sliceCoordinates"][()] + print('slice coordinates:', self.sliceCoordinates) except: ## do something useful here, maybe self.analysisType = None @@ -82,13 +84,13 @@ def clusterAnalysis(self): except: pass - self.nBins = 100 + self.nBins = 200## for epixM with a lot of 2 photon events... self.lowEnergyCut = 4 ## fix - should be 0.5 photons or something self.highEnergyCut = 15 ## fix - should be 1.5 photons or something ##tmp npyFileName = "%s/r%d_clusters.npy" % (self.outputDir, self.run) np.save(npyFileName, clusters) - logger.info("Wrote file: " + npyFileName) + ##logger.info("Wrote file: " + npyFileName) self.analyzeSimpleClusters(clusters) @@ -148,7 +150,7 @@ def analyzeSimpleClusters(self, clusters): rows = self.sliceEdges[0] cols = self.sliceEdges[1] - m = 1## temp hack + m = 1## temp hack, Kaz's favorite asic, off by 1 fitInfo = np.zeros((maximumModule, rows, cols, 5)) ## mean, std, area, mu, sigma for i in range(rows): for j in range(cols): @@ -176,7 +178,7 @@ def analyzeSimpleClusters(self, clusters): plt.figtext(0.7, 0.8, "%d entries (peak)" % (area)) plt.figtext(0.7, 0.75, "mu %0.2f" % (mu)) plt.figtext(0.7, 0.7, "sigma %0.2f" % (sigma)) - figFileName = "%s/%s_m%d_r%d_c%d_r%d_c%d_%s_E.png" % ( + figFileName = "%s/%s_r%d_c%d_m%d_r%d_c%d_%s_E.png" % ( self.outputDir, self.__class__.__name__, self.run, diff --git a/suite_scripts/LinearityPlotsParallelSlice.py b/suite_scripts/LinearityPlotsParallelSlice.py index e361966..e3324f5 100755 --- a/suite_scripts/LinearityPlotsParallelSlice.py +++ b/suite_scripts/LinearityPlotsParallelSlice.py @@ -27,12 +27,12 @@ class LinearityPlotsParallel(BasicSuiteScript): def __init__(self): super().__init__("scan") ##self) - self.saturated = [True, False][0] + self.saturated = [True, False][1] print("using saturation fit =", self.saturated) logger.info("using saturation fit =" + str(self.saturated)) self.residuals = [True, False][0] self.profiles = [True, False][1] - self.seabornProfiles = [True, False][1] + self.seabornProfiles = [True, False][0] try: print("positive events:", "positive" in self.special) logger.info("positive events:" + str("positive" in self.special)) @@ -172,8 +172,8 @@ def analyze_h5(self, dataFile, label): lpp.plotDataROIs(rois.T, fluxes, "ROIs") def analyze_h5_slice(self, dataFile, label): - module = 0 - nModules = 1 + module = 2 + nModules = 3 data = h5py.File(dataFile) fluxes = data["fluxes"][()] pixels = data["slice"][()] @@ -185,15 +185,16 @@ def analyze_h5_slice(self, dataFile, label): for i in range(rows): for j in range(cols): iDet, jDet = self.sliceToDetector(i, j) - self.fitInfo[module, i, j, 8] = self.g0Ped[module, iDet, jDet] - self.fitInfo[module, i, j, 9] = self.g1Ped[module, iDet, jDet] - self.fitInfo[module, i, j, 10] = self.g0Gain[module, iDet, jDet] - self.fitInfo[module, i, j, 11] = self.g1Gain[module, iDet, jDet] - self.fitInfo[module, i, j, 12] = self.offset[module, iDet, jDet] - g0 = pixels[:, i, j] < lpp.g0cut + if False: + self.fitInfo[module, i, j, 8] = self.g0Ped[module, iDet, jDet] + self.fitInfo[module, i, j, 9] = self.g1Ped[module, iDet, jDet] + self.fitInfo[module, i, j, 10] = self.g0Gain[module, iDet, jDet] + self.fitInfo[module, i, j, 11] = self.g1Gain[module, iDet, jDet] + self.fitInfo[module, i, j, 12] = self.offset[module, iDet, jDet] + g0 = pixels[:, module, i, j] < lpp.g0cut g1 = np.logical_not(g0) if len(g0[g0]) > 2: - y = np.bitwise_and(pixels[:, i, j][g0], lpp.gainBitsMask) + y = np.bitwise_and(pixels[:, module, i, j][g0], lpp.gainBitsMask) y_g0_max = y.max() x = fluxes[g0] if self.profiles: @@ -208,6 +209,8 @@ def analyze_h5_slice(self, dataFile, label): ##np.save("temp_r%dc%d_x.py" %(i,j), fluxes[g0]) ##np.save("temp_r%dc%d_y.py" %(i,j), y) ##np.save("temp_r%dc%d_func.py" %(i,j), fitFunc) + ##print(fitInfo.shape) + ##print(fitPar) self.fitInfo[module, i, j, 0:2] = fitPar[0:2] ## indices for saturated case self.fitInfo[module, i, j, 2] = r2 self.fitInfo[module, i, j, 6] = y_g0_max @@ -226,7 +229,7 @@ def analyze_h5_slice(self, dataFile, label): plt.figure(1) if len(g1[g1]) > 2: - y = np.bitwise_and(pixels[:, i, j][g1], lpp.gainBitsMask) + y = np.bitwise_and(pixels[:, module, i, j][g1], lpp.gainBitsMask) y_g1_min = y.min() x = fluxes[g1] if self.profiles: @@ -372,7 +375,7 @@ def analyze_h5_slice(self, dataFile, label): fluxes=flux, rois=np.array(roiMeans), pixels=np.array(singlePixelData), - slice=rawFrames[0][lpp.regionSlice], + slice=rawFrames[lpp.regionSlice] ) nGoodEvents += 1 @@ -410,6 +413,7 @@ def analyze_h5_slice(self, dataFile, label): logger.info("Wrote file: " + fileName) if False: + print("this is broken") label = "rawInTimeDot" if doKazFlux: label = "raw_smarterPoints" diff --git a/suite_scripts/SimpleClustersParallelSlice.py b/suite_scripts/SimpleClustersParallelSlice.py index 2678913..c9de2bb 100644 --- a/suite_scripts/SimpleClustersParallelSlice.py +++ b/suite_scripts/SimpleClustersParallelSlice.py @@ -128,7 +128,7 @@ def analyze_h5(self, dataFile, label): smd = sic.ds.smalldata(filename="%s/%s_c%d_r%d_n%d.h5" % (sic.outputDir, sic.className, sic.camera, sic.run, size)) ## 50x50 pixels, 3x3 clusters, 10% occ., 2 sensors - maxClusters = int(50 * 50 / 3 / 3 * 0.1 * 2) + maxClusters = 1000##int(50 * 50 / 3 / 3 * 0.1 * 2) try: seedCut = sic.detectorInfo.seedCut except: diff --git a/suite_scripts/TimeScanParallelSlice.py b/suite_scripts/TimeScanParallelSlice.py index 887c60a..034d5df 100755 --- a/suite_scripts/TimeScanParallelSlice.py +++ b/suite_scripts/TimeScanParallelSlice.py @@ -29,6 +29,8 @@ def __init__(self): pass def plotData(self, rois, pixels, delays, label): +## print(type(delays)) +## print('delays here:', delays) for i, roi in enumerate(self.ROIs): ax = plt.subplot() ax.plot(delays, rois[i], label=self.ROIfileNames[i]) @@ -36,7 +38,7 @@ def plotData(self, rois, pixels, delays, label): minor_locator = AutoMinorLocator(5) ax.xaxis.set_minor_locator(minor_locator) plt.grid(which="minor", linewidth=0.5) - plt.xlabel("Time delay (Ticks)") + plt.xlabel("Time delay (Ticks/1000)") # plt.ylabel('Step Mean (keV)') plt.ylabel("Step Mean (ADU)") plt.grid(which="major", linewidth=0.75) @@ -56,7 +58,7 @@ def plotData(self, rois, pixels, delays, label): minor_locator = AutoMinorLocator(5) ax.xaxis.set_minor_locator(minor_locator) plt.grid(which="minor", linewidth=0.5) - plt.xlabel("Time delay (Ticks)") + plt.xlabel("Time delay (Ticks/1000)") # plt.ylabel('Step Mean (keV)') plt.ylabel("Step Mean (ADU)") ##plt.yscale('log') @@ -76,7 +78,7 @@ def plotData(self, rois, pixels, delays, label): minor_locator = AutoMinorLocator(5) ax.xaxis.set_minor_locator(minor_locator) plt.grid(which="minor", linewidth=0.5) - plt.xlabel("Delay (Ticks)") + plt.xlabel("Delay (Ticks/1000)") plt.ylabel("Pixel ADU") figFileName = "%s/%s_r%d_c%d_%s_pixel%d.png" % (self.outputDir, self.__class__.__name__, self.run, self.camera, label, i) @@ -119,10 +121,14 @@ def analyze_h5(self, dataFile, norm, label): a = h5py.File(dataFile)[norm] delays = np.array([k for k in a.keys()]) - delays = delays.astype("int") + print(delays) + ##delays = delays.astype('float').astype("int") + ##delays = delays.astype('float').astype("int") delays.sort() d = np.array([a[str(k)] for k in delays]) delays = np.array([d for d in delays]) + delays = [eval(d)/1000. for d in delays] + ##delays /= 1000. print(delays) runString = "_r%d" % (self.run) @@ -168,7 +174,7 @@ def analyze_h5(self, dataFile, norm, label): offset = len(tsp.ROIs) stepGen = tsp.getStepGen() - ## for nstep, step in enumerate (tsp.ds.steps()): + ##for nstep, step in enumerate (tsp.ds.steps()): for nstep, step in enumerate(stepGen): ##scanValue = tsp.getScanValue(step, useStringInfo=True) scanValue = tsp.getScanValue(step, True) @@ -193,12 +199,12 @@ def analyze_h5(self, dataFile, norm, label): ##tsp.isBeamEvent(evt): if tsp.detectorInfo.detectorType == 'epixm' or tsp.isBeamEvent(evt):##FEE hack - frames = tsp.getRawData(evt, gainBitsMasked=True) + frames = tsp.getRawData(evt)##, gainBitsMasked=True) ##print("real beam on event", nstep, nevt) ##logger.info("real beam on event" + str(nstep) + ", " + str(nevt)) elif tsp.use_281_for_old_data and ec[281]: - frames = tsp.getRawData(evt, gainBitsMasked=True) - ##print("281 only...") + frames = tsp.getRawData(evt)##, gainBitsMasked=True) + print("281 only...") elif ec[137]: tsp.flux = tsp._getFlux(evt) ## fix this continue @@ -208,7 +214,7 @@ def analyze_h5(self, dataFile, norm, label): continue else: tsp.flux = tsp._getFlux(evt) ## fix this - frames = tsp.getRawData(evt, gainBitsMasked=True) + frames = tsp.getRawData(evt)##, gainBitsMasked=True) if frames is None: ##print("no frame") diff --git a/suite_scripts/epixMSuiteConfig.py b/suite_scripts/epixMSuiteConfig.py index 27985ed..1e3da89 100755 --- a/suite_scripts/epixMSuiteConfig.py +++ b/suite_scripts/epixMSuiteConfig.py @@ -12,28 +12,32 @@ ##experimentHash = {'exp':'mfxx1005021', 'location':'MfxEndstation', 'fluxSource':'MFX-USR-DIO', 'fluxChannels':[11], 'fluxSign':-1} ##experimentHash = {'exp':'rixc00121', 'location':'RixEndstation', singlePixelArray = [] -for i in range(4): +for i in range(1,3): singlePixelArray.append([i, 10, 10]) singlePixelArray.append([i, 10, 100]) singlePixelArray.append([i, 100, 10]) singlePixelArray.append([i, 100, 100]) + singlePixelArray.append([i, 150, 150]) + singlePixelArray.append([i, 80, 20]) + +singlePixelArray.append([2, 178, 367]) experimentHash = { "detectorType": "epixm", - ##"exp": "rixx1005922", - "exp": "rixx1003721", + "exp": "rixx1005922", + ##"exp": "rixx1003721", "location": "RixEndstation", "analyzedModules":[1,2], "seedCut":40, ## pure guess "neighborCut":10, ##pure guess "fluxSource": "MfxDg1BmMon", - 'fluxChannels':[8, 14], + 'fluxChannels':[11], "fluxSign": -1, "singlePixels": singlePixelArray, # 'ROIs':['module0', 'module2', 'module4', 'module6', 'module10','module12', 'module14'] # 'ROIs':['roiFromSwitched_e557_rmfxx1005021'] ## 'ROIs':['allHRasicPixels', 'goodboxROI']#'roiAbove7k_raw_r123'] ##"ROIs": ["../data/XavierV4_2", "../data/OffXavierV4_2"], - "ROIs": ["../data/smallRegionFourAsics.npy"], - "regionSlice": np.s_[0:4, 40:60:, 170:200],## random + "ROIs": ["../data/cometPinhole.npy", "../data/smallRegionFourAsics.npy", "../data/smallRegionTwoAsicsForBhavna.npy"], + "regionSlice": np.s_[0:4, 150:180:, 340:368],## small region near Kaz rec } diff --git a/suite_scripts/simplePhotonCounter.py b/suite_scripts/simplePhotonCounter.py index 529d810..08a3e53 100755 --- a/suite_scripts/simplePhotonCounter.py +++ b/suite_scripts/simplePhotonCounter.py @@ -51,10 +51,11 @@ def __init__(self): if evt is None: break if not spc.isBeamEvent(evt): - print('foo') + ##print('foo') continue if spc.fakePedestal is not None: + rawFrames = spc.getRawData(evt) frames = rawFrames.astype("float") - spc.fakePedestal frames /= gain ## psana may not have the right default else: