From 16d3f6ccf14f456fbd4c7bb3a4ac3ed179c8b1ee Mon Sep 17 00:00:00 2001 From: gac-x04sa Date: Thu, 4 Jul 2019 16:15:48 +0200 Subject: [PATCH] Closedown --- config/diffcalc/.nfs000000000b31ee0e00000c6d | 0 config/diffcalc/test1.json | 36 ++++++- config/diffcalc/test2.json | 16 +++- config/settings.properties | 4 +- devices/detector_image.properties | 6 +- script/cpython/image_functions.py | 2 +- script/cpython/wrapper.py | 4 +- script/local.py | 98 +++++++++++++++++++- script/utils/Auto.py | 1 - 9 files changed, 151 insertions(+), 16 deletions(-) delete mode 100644 config/diffcalc/.nfs000000000b31ee0e00000c6d diff --git a/config/diffcalc/.nfs000000000b31ee0e00000c6d b/config/diffcalc/.nfs000000000b31ee0e00000c6d deleted file mode 100644 index e69de29..0000000 diff --git a/config/diffcalc/test1.json b/config/diffcalc/test1.json index 46df850..997f94e 100644 --- a/config/diffcalc/test1.json +++ b/config/diffcalc/test1.json @@ -1,6 +1,6 @@ { "name": "test1", - "crystal": "['cubic', 'Triclinic', 7.723, 7.707, 7.723, 90.0, 89.265, 90.0]", + "crystal": "['cubic', 'Triclinic', 7.723071056222668, 7.702898811460209, 7.720064193668625, 89.99965543112849, 89.21875367198528, 89.99500143686504]", "reflist": { "1": { "tag": "None", @@ -8,6 +8,34 @@ "pos": "[5.0, 9.3822, 19.7785, 104.4223, 0, 0]", "energy": 9.5007, "time": "2019-07-04T08:48:00.667000" + }, + "2": { + "tag": "None", + "hkl": "[2.0, 0.0, 2.0]", + "pos": "[5.0, 19.054, 20.167, 13.8111, 0, 0]", + "energy": 9.5007, + "time": "2019-07-04T09:47:45.672000" + }, + "3": { + "tag": "None", + "hkl": "[2.0, 2.0, 2.0]", + "pos": "[5.0, 27.1074, 21.198, 61.8741, 0, 0]", + "energy": 9.5007, + "time": "2019-07-04T10:13:37.671000" + }, + "4": { + "tag": "None", + "hkl": "[0.0, -1.0, 2.0]", + "pos": "[5.0, 9.5098, 19.7025, -76.397, 0, 0]", + "energy": 9.5007, + "time": "2019-07-04T10:46:10.117000" + }, + "5": { + "tag": "None", + "hkl": "[0.0, 3.0, 2.0]", + "pos": "[5.0, 28.827, 21.7498, 107.7429, 0, 0]", + "energy": 9.5007, + "time": "2019-07-04T10:56:41.220000" } }, "orientlist": {}, @@ -18,9 +46,9 @@ "n_phi_configured": "[0.0, 0.0, 1.0]" }, "u": [ - "1.0, 0.0, 0.0", - "0.0, 1.0, 0.0", - "0.0, 0.0, 1.0" + "0.9999129122215213, 0.007489577628036139, 0.010866195269269147", + "-0.007454780892516531, 0.999966966138507, -0.0032392705343809503", + "-0.01089009708500512, 0.0031579833286385197, 0.9999357143970682" ], "ub": null, "or0": null, diff --git a/config/diffcalc/test2.json b/config/diffcalc/test2.json index 49d3eac..305dc7f 100644 --- a/config/diffcalc/test2.json +++ b/config/diffcalc/test2.json @@ -3,11 +3,25 @@ "crystal": "['cubic', 'Triclinic', 7.723, 7.707, 7.723, 90.0, 89.265, 90.0]", "reflist": { "1": { - "tag": null, + "tag": "None", "hkl": "[0.0, 1.0, 2.0]", "pos": "[5.0, 9.3822, 19.7785, 104.4223, 0, 0]", "energy": 9.5007, "time": "2019-07-04T08:48:00.667000" + }, + "2": { + "tag": "None", + "hkl": "[2.0, 0.0, 2.0]", + "pos": "[5.0, 19.054, 20.167, 13.8111, 0, 0]", + "energy": 9.5007, + "time": "2019-07-04T09:47:45.672000" + }, + "3": { + "tag": null, + "hkl": "[2.0, 2.0, 2.0]", + "pos": "[5.0, 27.1074, 21.198, 61.8741, 0, 0]", + "energy": 9.5007, + "time": "2019-07-04T10:13:37.671000" } }, "orientlist": {}, diff --git a/config/settings.properties b/config/settings.properties index 2a8ee78..4572a8e 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,4 +1,4 @@ -#Thu Jul 04 09:12:28 CEST 2019 +#Thu Jul 04 16:08:25 CEST 2019 count_time=1.0 geometry=fourcv -roi=219 102 239 122 +roi=173 88 285 136 diff --git a/devices/detector_image.properties b/devices/detector_image.properties index 13a1cea..dd78ba7 100644 --- a/devices/detector_image.properties +++ b/devices/detector_image.properties @@ -1,8 +1,8 @@ -#Mon Feb 11 13:57:36 CET 2019 -colormap=Temperature +#Thu Jul 04 14:34:38 CEST 2019 +colormap=Flame colormapAutomatic=false colormapLogarithmic=false -colormapMax=10.0 +colormapMax=1000.0 colormapMin=0.0 flipHorizontally=false flipVertically=false diff --git a/script/cpython/image_functions.py b/script/cpython/image_functions.py index 480cd47..dab5206 100644 --- a/script/cpython/image_functions.py +++ b/script/cpython/image_functions.py @@ -1,6 +1,6 @@ import numpy -def img_get_int(fname, thres1, thres2, thres3, thres4, header, width, height, depth, x1,y1,x2,y2, bx1,by1,bx2,by2 ): +def img_get_int(fname, thres1, thres2, thres3, thres4, header, width, height, depth, x1,y1,x2,y2, bx1,by1,bx2,by2 , filter_median = False, filter_nsigma = 0): # read actual image file img = numpy.fromfile(fname, dtype=numpy.uint32) img.shape = height, width diff --git a/script/cpython/wrapper.py b/script/cpython/wrapper.py index 7f5ef2b..58e431e 100644 --- a/script/cpython/wrapper.py +++ b/script/cpython/wrapper.py @@ -1,7 +1,7 @@ from jeputils import * -def img_get_int(fname, thres1, thres2, thres3, thres4, header, width, height, depth, x1,y1,x2,y2, bx1,by1,bx2,by2 ): - ret = call_jep("cpython/image_functions", "img_get_int", [fname, thres1, thres2, thres3, thres4, header, width, height, depth, x1,y1,x2,y2, bx1,by1,bx2,by2]) +def img_get_int(fname, thres1, thres2, thres3, thres4, header, width, height, depth, x1,y1,x2,y2, bx1,by1,bx2,by2 , filter_median = False, filter_nsigma = 0)): + ret = call_jep("cpython/image_functions", "img_get_int", [fname, thres1, thres2, thres3, thres4, header, width, height, depth, x1,y1,x2,y2, bx1,by1,bx2,by2, filter_median, filter_nsigma)]) #return ret #TODO: Why I_sum ans I_sum_bgr are strings? (I_sum, area_I, thresh1_count, thresh2_count, thresh3_count, thresh4_count, I_sum_bgr, area_bgr) = ret diff --git a/script/local.py b/script/local.py index 8e17561..e50bf5f 100644 --- a/script/local.py +++ b/script/local.py @@ -272,8 +272,8 @@ def get_diag_channels(): return diag_channels def get_diag_name(diag): - return ch.psi.utils.Str.toTitleCase(diag.getName()).replace(" ", "") - + return ch.psi.utils.Str.toTitleCase(diag if is_string(diag) else diag.getName()).replace(" ", "") + def print_diag(): for f in get_diag_channels(): print "%-25s %s" % (get_diag_name(f) , str(f.read())) @@ -378,6 +378,100 @@ def wait_for_file_size(filepath, size, timeout = None): time.sleep(wait_time) +################################################################################################### +# Scan commands +################################################################################################### + +def relscan(motor, start, end, number_of_steps, count_time): + """ + Relative scan + """ + set_count_time(count_time) + detectors = [mythen, mythen.acquire_time, pixel, pixel.image_filename, image.intensity,image.corrected_intensity, image.matrix] + #TODO: Set based on experiment context + pixel.set_path("../../expdata/bml_20190703/pixel/", "images") + #TODO: should be set automatically + set_roi(173,88,285,136) + show_panel(detector_image) + pixel.show() + pixel.assert_ready() + return lscan (motor, detectors, start, end, int(number_of_steps), relative=True, before_read=before_sample, after_read=after_sample) + +def absscan(motor, start, end, number_of_steps, count_time): + """ + Absolute scan + """ + set_count_time(count_time) + detectors = [mythen, mythen.acquire_time, pixel, pixel.image_filename, image.intensity,image.corrected_intensity, image.matrix] + #TODO: Set based on experiment context + pixel.set_path("../../expdata/bml_20190703/pixel/", "images") + #TODO: should be set automatically + set_roi(173,88,285,136) + show_panel(detector_image) + pixel.show() + pixel.assert_ready() + return lscan (motor, detectors, start, end, int(number_of_steps), relative=False, before_read=before_sample, after_read=after_sample) + +def abs2scan(motor1, start1, end1, motor2, start2, end2, number_of_steps, count_time): + """ + Absolute scan of 2 motors + """ + set_count_time(count_time) + detectors = [mythen, mythen.acquire_time, pixel, pixel.image_filename, image.intensity,image.corrected_intensity, image.matrix] + #TODO: Set based on experiment context + pixel.set_path("../../expdata/bml_20190703/pixel/", "images") + #TODO: should be set automatically + set_roi(173,88,285,136) + show_panel(detector_image) + pixel.show() + pixel.assert_ready() + return lscan ([motor1, motor2], detectors, [start1, start2], [end1, end2], int(number_of_steps), relative=False, before_read=before_sample, after_read=after_sample) + +def hrodscan(start, end, number_of_steps, count_time): + """ + Scan on l + """ + return absscan (h, start, end, number_of_steps, count_time) + +def krodscan(start, end, number_of_steps, count_time): + """ + Scan on k + """ + return absscan (k, start, end, number_of_steps, count_time) + +def lrodscan(start, end, number_of_steps, count_time): + """ + Scan on l + """ + return absscan (l, start, end, number_of_steps, count_time) + + +def hkllinscan(hstart, hfinish, kstart, kfinish, lstart, lfinish, number_of_steps, count_time): + """ + Linear scan on hkl + """ + vector = [] + hs = float(hfinish - hstart)/number_of_steps + ks = float(kfinish - kstart)/number_of_steps + ls = float(lfinish - lstart)/number_of_steps + for i in range(number_of_steps+1): + hp = hstart + i * hs + kp = kstart + i * ks + lp = lstart + i * ls + vector.append([hp, kp, lp] ) + + set_count_time(count_time) + detectors = [mythen, mythen.acquire_time, pixel, pixel.image_filename, image.intensity,image.corrected_intensity, image.matrix] + #TODO: Set based on experiment context + pixel.set_path("../../expdata/bml_20190703/pixel/", "images") + #TODO: should be set automatically + set_roi(173,88,285,136) + show_panel(detector_image) + pixel.show() + pixel.assert_ready() + return hklscan(vector, detectors,latency = 0.0, before_read=before_sample, after_read=after_sample) + + ################################################################################################### # Configuration diff --git a/script/utils/Auto.py b/script/utils/Auto.py index 7de8d3c..33c7149 100644 --- a/script/utils/Auto.py +++ b/script/utils/Auto.py @@ -297,4 +297,3 @@ def auto_after_sample(rec, scan): else: RETRY_COUNT = 0 return True - \ No newline at end of file