@@ -315,6 +315,29 @@ def jobToBlock(self, job=None, name=None):
315
315
cifDict = cifDict
316
316
))
317
317
if job .type .is_cwl :
318
+ # _pd_calib
319
+ category = '_pd_calib'
320
+ prettyCategory = 'calib'
321
+ icon = 'arrows-alt-h'
322
+ name = '2theta_offset'
323
+ dataBlock [param ][category ] = {}
324
+ dataBlock [param ][category ][name ] = dict (Parameter (
325
+ float (job .pattern .zero_shift .value ),
326
+ error = float (job .pattern .zero_shift .error ),
327
+ category = category ,
328
+ prettyCategory = prettyCategory ,
329
+ name = name ,
330
+ prettyName = '2θ offset' ,
331
+ shortPrettyName = "offset" ,
332
+ icon = icon ,
333
+ url = url + category ,
334
+ cifDict = 'pd' ,
335
+ absDelta = 0.2 ,
336
+ unit = '°' ,
337
+ fittable = True ,
338
+ fit = not job .pattern .zero_shift .fixed
339
+ ))
340
+
318
341
name = 'wavelength'
319
342
category = '_diffrn_radiation_wavelength'
320
343
prettyCategory = 'radiation'
@@ -658,29 +681,6 @@ def jobToBlock(self, job=None, name=None):
658
681
fittable = True ,
659
682
fit = not job .parameters .sigma2 .fixed
660
683
))
661
- # _pd_calib
662
- category = '_pd_calib'
663
- prettyCategory = 'calib'
664
- icon = 'arrows-alt-h'
665
- name = '2theta_offset'
666
- dataBlock [param ][category ] = {}
667
- dataBlock [param ][category ][name ] = dict (Parameter (
668
- float (job .pattern .zero_shift .value ),
669
- error = float (job .pattern .zero_shift .error ),
670
- category = category ,
671
- prettyCategory = prettyCategory ,
672
- name = name ,
673
- prettyName = '2θ offset' ,
674
- shortPrettyName = "offset" ,
675
- icon = icon ,
676
- url = url + category ,
677
- cifDict = 'pd' ,
678
- absDelta = 0.2 ,
679
- unit = '°' ,
680
- fittable = True ,
681
- fit = not job .pattern .zero_shift .fixed
682
- ))
683
-
684
684
#
685
685
# _pd_meas
686
686
category = '_pd_meas'
@@ -859,20 +859,31 @@ def jobToData(self, job=None):
859
859
y_name = name_core + '_I0'
860
860
err_name = "s_" + name_core + '_I0'
861
861
x_points = job .datastore .store [x_name ].data
862
- y_points = np . ones_like ( x_points ) # job.datastore.store[y_name].data
862
+ y_points = job .datastore .store [y_name ].data
863
863
err_points = job .datastore .store [err_name ].data
864
864
865
- name = '2theta_scan'
866
-
867
- ed_points [name ] = dict (Parameter (
868
- x_points ,
869
- category = category ,
870
- name = name ,
871
- prettyName = '2θ' ,
872
- shortPrettyName = '2θ' ,
873
- url = url + category ,
874
- cifDict = cifDict
875
- ))
865
+ if job .type .is_cwl :
866
+ name = '2theta_scan'
867
+ ed_points [name ] = dict (Parameter (
868
+ x_points ,
869
+ category = category ,
870
+ name = name ,
871
+ prettyName = '2θ' ,
872
+ shortPrettyName = '2θ' ,
873
+ url = url + category ,
874
+ cifDict = cifDict
875
+ ))
876
+ else :
877
+ name = 'time_of_flight'
878
+ ed_points [name ] = dict (Parameter (
879
+ x_points ,
880
+ category = category ,
881
+ name = name ,
882
+ prettyName = 'ms' ,
883
+ shortPrettyName = 'ms' ,
884
+ url = url + category ,
885
+ cifDict = cifDict
886
+ ))
876
887
name = 'intensity_total'
877
888
ed_points [name ] = dict (Parameter (
878
889
y_points ,
@@ -1119,7 +1130,7 @@ def blocksToLoopJob(self, blockIdx, category, name, rowIndex, field, value):
1119
1130
p_category = BLOCK2JOB [category ]
1120
1131
# get category
1121
1132
# assumption of the first loop, since there is only one background currently
1122
- job_with_category = getattr (self ._job , p_category )[0 ]
1133
+ job_with_category = getattr (self ._job , p_category )[rowIndex ]
1123
1134
# should we get the loop item?
1124
1135
# this works for the background, but not for scale etc.
1125
1136
try :
@@ -1749,6 +1760,34 @@ def setDataBlocksCif(self):
1749
1760
cifMeasOnlyReduced = ['\n ' .join (block ) for block in cifMeasOnlyReduced ]
1750
1761
cifMeasOnlyReduced = [f'\n { block } ' for block in cifMeasOnlyReduced ]
1751
1762
cifMeasOnlyReduced = [block .rstrip () for block in cifMeasOnlyReduced ]
1763
+ # remove all the values from the last block
1764
+ cifMeasOnlyReduced [0 ] = cifMeasOnlyReduced [0 ].split ('[' )[0 ]
1765
+
1766
+ meas_string = [block .split ('\n ' )[- 1 ] for block in self ._dataBlocksCifMeasOnly ][- 1 ]
1752
1767
self ._dataBlocksCif = [[noMeas , measOnlyReduced ] for (noMeas , measOnlyReduced ) in zip (self ._dataBlocksCifNoMeas , cifMeasOnlyReduced )]
1768
+
1769
+ import re
1770
+ # Extract the three lists using regex
1771
+ matches = re .findall (r'\[([^\]]+)\]' , meas_string )
1772
+ if len (matches ) == 3 :
1773
+ ast , ae = self .parse_numbers (matches [0 ])
1774
+ bs , be = self .parse_numbers (matches [1 ])
1775
+ cs , ce = self .parse_numbers (matches [2 ])
1776
+
1777
+ values = ""
1778
+ for i in range (3 ):
1779
+ values += f"{ ast [i ]:<6} { bs [i ]:<8} { cs [i ]:<6} \n "
1780
+ print ("... ... ..." )
1781
+ values += (".. ... ...\n " )
1782
+ for i in range (3 ):
1783
+ values += f"{ ae [i ]:<6} { be [i ]:<8} { ce [i ]:<6} \n "
1784
+ self ._dataBlocksCif [0 ].extend ([values ])
1785
+
1753
1786
console .debug (formatMsg ('sub' , f'{ len (self ._dataBlocksCif )} experiment(s)' , 'simplified meas data' , 'to CIF string' , 'converted' ))
1754
1787
self .dataBlocksCifChanged .emit ()
1788
+
1789
+ # Function to parse numbers, ignoring "..."
1790
+ @staticmethod
1791
+ def parse_numbers (lst_str ):
1792
+ values = [float (num ) for num in lst_str .split () if num != '...' ]
1793
+ return values [:3 ], values [- 3 :] # First 3 and last 3 elements
0 commit comments