diff --git a/.gitignore b/.gitignore index c3395165..bfc26078 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ -/data -/sessions /context -/log +/data /extensions +/log +/sessions +/www script/cachedir script/Lib script/*.class -/script/ +script/*.pyc +plugins/*.class diff --git a/script/HoloScan.py b/script/HoloScan.py new file mode 100644 index 00000000..80896c8e --- /dev/null +++ b/script/HoloScan.py @@ -0,0 +1,15 @@ +""" +Arguments: + +SENSORS (list) +PHI_RANGE (tuple (min, max)) +THETA_RANGE (tuple (min, max)) +STEPS (tuple (phi, theta)) +LATENCY (double) +RELATIVE (BOOLEAN) +""" + + +#set_preference(Preference.ENABLED_PLOTS, [phi, theta, scienta.dataMatrix, integration]) +set_preference(Preference.PLOT_TYPES, {integration:1}) +ascan((phi, theta), SENSORS, (PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS, LATENCY, RELATIVE, before_read=trig_scienta) \ No newline at end of file diff --git a/script/ManipulatorScan.py b/script/ManipulatorScan.py new file mode 100644 index 00000000..54aa40fa --- /dev/null +++ b/script/ManipulatorScan.py @@ -0,0 +1,14 @@ +""" +Arguments: + +MOTOR (device) +SENSORS (list) +RANGE (tuple (min, max)) +STEPS (int or tuple) +LATENCY (double) +RELATIVE (BOOLEAN) +""" + + +set_preference(Preference.PLOT_TYPES,{'integration':1}); +lscan(MOTOR, SENSORS, RANGE[0], RANGE[1], STEPS, LATENCY, RELATIVE, before_read=trig_scienta) \ No newline at end of file diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py new file mode 100644 index 00000000..82389c4e --- /dev/null +++ b/script/XPSSpectrum.py @@ -0,0 +1,32 @@ +#Parameters (global variables): +# ranges: list of RangeSelection + +if scienta.acquisitionMode == scienta.AcquisitionMode.Fixed: + scienta.acquisitionMode = scienta.AcquisitionMode.Swept +ret=[] + +names=[] +for i in range(len(ranges)): + names.append(str(ranges[i])) +plots = plot(None, names) +try: + for i in range(len(ranges)): + scienta.lowEnergy.put(ranges[i].min) + scienta.highEnergy.put(ranges[i].max) + + vars = ranges[i].vars + if vars is not None and len(vars)==3: + scienta.stepTime.write(vars[0]) + scienta.stepSize.write(vars[1]) + scienta.setIterations(vars[2]) + + trig_scienta() + ydata = scienta.spectrum.read() + xdata = scienta.spectrumX + plots[i].getSeries(0).setData(xdata, ydata) + ret.append((xdata, ydata)) + #time.sleep(3.0) +finally: + if not scienta.isReady(): + scienta.stop() +set_return(to_array(ret,'o')) \ No newline at end of file diff --git a/script/local.py b/script/local.py new file mode 100644 index 00000000..bc103574 --- /dev/null +++ b/script/local.py @@ -0,0 +1,57 @@ +import random +import ch.psi.pshell.dev.Readable.ReadableArray as ReadableArray + +class SimulatedOutput(Writable): + def getName(self): + return "SimulatedOutput" + + def write(self, value): + pass + + +class SimulatedInput(Readable): + def __init__(self): + self.x = 0.0 + + def getName(self): + return "SimulatedInput" + + def read(self): + self.x = self.x + 0.2 + noise = (random.random() - 0.5) / 20.0 + return math.sin(self.x) + noise + + +sout = SimulatedOutput() +sinp = SimulatedInput() + +def integrate_image(): + data = scienta.data.read() + #Integrate and plot + (width,height) = scienta.getImageSize().tolist() + integration = [] + for i in range(width): + p=0.0 + for j in range(height): + p=p+data[j*width+i] + integration.append(p) + return integration + + +class ImageIntegrator(ReadableArray): + def getName(self): + return "integration" + + def getSize(self): + (width,height) = scienta.getImageSize().tolist() + return width + + def read(self): + return to_array(integrate_image(),'d') + +integration = ImageIntegrator() + + +def trig_scienta(): + scienta.start() + scienta.waitReady(-1)