@@ -361,6 +361,66 @@ def Reader(self,filename, ParentFrame=None, **unused):
361361 except :
362362 return False
363363
364+ class SHELX4ED_ReaderClass (G2obj .ImportStructFactor ):
365+ 'Routines to import F**2, sig(F**2), exp# & Z-pos reflections from a Shelx HKLF 4 microED file'
366+ def __init__ (self ):
367+ if 'linux' in sys .platform : # wx 3.0.0.0 on gtk does not like Unicode in menus
368+ formatName = 'HKLF 4ed'
369+ longFormatName = 'Shelx HKLF 4ed [hkl, Fo2, sig(Fo2), exp#, Z-pos] Structure factor text file'
370+ else :
371+ formatName = u'Shelx HKLF 4ed F\u00b2 '
372+ longFormatName = u'Shelx HKLF 4ed [hkl, Fo\u00b2 , sig(Fo\u00b2 ), exp#, Z-pos] Structure factor text file'
373+ super (self .__class__ ,self ).__init__ ( # fancy way to self-reference
374+ extensionlist = ('.hkl' ,'.HKL' ),
375+ strictExtension = False ,
376+ formatName = formatName ,
377+ longFormatName = longFormatName )
378+
379+ def ContentsValidator (self , filename ):
380+ 'Make sure file contains the expected columns on numbers'
381+ return True
382+ # return ColumnValidator(self, filepointer)
383+
384+ def Reader (self ,filename , ParentFrame = None , ** unused ):
385+ 'Read the file'
386+ try :
387+ fp = open (filename ,'r' )
388+ for line ,S in enumerate (fp ):
389+ self .errors = ' Error reading line ' + str (line + 1 )
390+ if S [0 ] == '#' : continue #ignore comments, if any
391+ try : # use a simple split if possible
392+ items = S .split ()
393+ if len (items ) > 5 :
394+ h ,k ,l ,Fo ,sigFo ,Nexp ,Zpos = items [:7 ]
395+ else :
396+ h ,k ,l ,Fo ,sigFo = items [:5 ]
397+ Nexp = '0'
398+ Zpos = '0.'
399+ h ,k ,l = [int (h ),int (k ),int (l )]
400+ except : # but sometimes if no space between k & F
401+ # need to use some fixed formatting
402+ h ,k ,l = S [:12 ].split ()
403+ h ,k ,l = [int (h ),int (k ),int (l )]
404+ Fo ,sigFo = S [12 :].split ()[:2 ]
405+ if not any ([h ,k ,l ]):
406+ break
407+ Fo = float (Fo )
408+ sigFo = float (sigFo )
409+ Nexp = int (Nexp )
410+ Zpos = float (Zpos )
411+ # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
412+ self .RefDict ['RefList' ].append ([h ,k ,l ,1 ,0 ,Fo ,sigFo ,0 ,Fo ,0 ,0 ,1 ,Nexp ,Zpos ])
413+ #self.RefDict['FF'].append({}) # now done in OnImportSfact
414+ fp .close ()
415+ self .errors = 'Error after reading reflections (unexpected!)'
416+ self .RefDict ['RefList' ] = np .array (self .RefDict ['RefList' ])
417+ self .RefDict ['Type' ] = 'SEC'
418+ self .RefDict ['Super' ] = 0
419+ self .UpdateParameters (Type = 'SEC' ,Wave = 0.02851 ) # histogram type
420+ return True
421+ except :
422+ return False
423+
364424class M90_ReaderClass (G2obj .ImportStructFactor ):
365425 'Routines to import F**2, sig(F**2) reflections from a JANA M90/M91 file'
366426 def __init__ (self ):
0 commit comments