1414from .. import GSASIIfiles as G2fil
1515from .. import GSASIIpath
1616
17- instprmList = [('Bank' ,1.0 ), ('Lam' ,0.413263 ), ('Polariz.' ,0.99 ),
18- ('SH/L' ,0.002 ), ('Type' ,'PXC' ), ('U' ,1.163 ), ('V' ,- 0.126 ),
17+ instprmList = [('Bank' ,1.0 ), ('Lam' ,0.413263 ), ('Polariz.' ,0.99 ),
18+ ('SH/L' ,0.002 ), ('Type' ,'PXC' ), ('U' ,1.163 ), ('V' ,- 0.126 ),
1919 ('W' ,0.063 ), ('X' ,0.0 ), ('Y' ,0.0 ), ('Z' ,0.0 ), ('Zero' ,0.0 )]
2020# comments
2121# sample parameters
2828# 'Thick': 1.0, 'Contrast': [0.0, 0.0], 'Trans': 1.0, 'SlitLen': 0.0}
2929
3030class MIDAS_Zarr_Reader (G2obj .ImportPowderData ):
31- '''Routine to read multiple powder patterns from a Zarr file
32- created by MIDAS. Perhaps in the future, other software might also
33- use this file type as well.
31+ '''Routine to read multiple powder patterns from a Zarr file
32+ created by MIDAS. Perhaps in the future, other software might also
33+ use this file type as well.
3434
35- For Midas, the main file is <file>.zip, but optionally sample and
36- instrument parameters can be placed in <file>.samprm and <file>.instprm.
35+ For Midas, the main file is <file>.zip, but optionally sample and
36+ instrument parameters can be placed in <file>.samprm and <file>.instprm.
3737 Any parameters placed in those files will override values set in the .zip
3838 file.
3939 '''
@@ -43,8 +43,6 @@ def __init__(self):
4343 if zarr is None :
4444 self .UseReader = False
4545 msg = 'MIDAS_Zarr Reader skipped because zarr module is not installed.'
46- if GSASIIpath .condaTest ():
47- msg += ' To fix this press "Install packages" button below'
4846 G2fil .ImportErrorMsg (msg ,{'MIDAS Zarr importer' :['zarr' ]})
4947 super (self .__class__ ,self ).__init__ ( # fancy way to self-reference
5048 extensionlist = ('.zarr.zip' ,),strictExtension = True ,
@@ -68,18 +66,18 @@ def ContentsValidator(self, filename):
6866 return False
6967
7068 def Reader (self , filename , ParentFrame = None , ** kwarg ):
71- '''Scan file for sections needed by defined file types (currently
69+ '''Scan file for sections needed by defined file types (currently
7270 only Midas) and then use appropriate routine to read the file.
73- Most of the time the results are placed in the buffer arg (if supplied)
74- so the file is not read on most calls.
71+ Most of the time the results are placed in the buffer arg (if supplied)
72+ so the file is not read on most calls.
7573
76- For MIDAS, masking can eliminate some or all points in an azimuthal
77- region. This will only return "lineouts" (aka diffractograms) that
78- have 20 or more points in them.
74+ For MIDAS, masking can eliminate some or all points in an azimuthal
75+ region. This will only return "lineouts" (aka diffractograms) that
76+ have 20 or more points in them.
7977
80- Note that if Reader.selections is used to select individual
81- "lineouts", the selections are numbered against all possible
82- "lineouts" not the ones that have 20 or more points.
78+ Note that if Reader.selections is used to select individual
79+ "lineouts", the selections are numbered against all possible
80+ "lineouts" not the ones that have 20 or more points.
8381 '''
8482 fpbuffer = kwarg .get ('buffer' ,{})
8583 if not hasattr (self ,'blknum' ):
@@ -99,7 +97,7 @@ def Reader(self, filename, ParentFrame=None, **kwarg):
9997 return False
10098 finally :
10199 del fp
102-
100+
103101 if self .mode == 'midas' :
104102 return self .readMidas (filename , fpbuffer )
105103
@@ -125,7 +123,7 @@ def readMidas(self, filename, fpbuffer={}):
125123 try :
126124 fp = zarr .open (filename , 'r' )
127125 fpbuffer ['REtaMap' ] = np .array (fp ['REtaMap' ]) # 4 x Nbins x Nazimuth
128- # [0]: radius; [1] 2theta; [2] eta; [3] bin area
126+ # [0]: radius; [1] 2theta; [2] eta; [3] bin area
129127 # tabulate integrated intensities image & eta
130128 fpbuffer ['intenArr' ] = []
131129 fpbuffer ['attributes' ] = []
@@ -143,20 +141,20 @@ def readMidas(self, filename, fpbuffer={}):
143141 fpbuffer ['unmasked' ] = [(fpbuffer ['REtaMap' ][3 ][:,i ] != 0 ) for i in range (Nazim )] # will be True if area is >0
144142 # find the azimuths with more than 20 points
145143 mAzm = [i for i in range (Nazim ) if sum (fpbuffer ['unmasked' ][i ]) > 20 ]
146-
144+
147145 # generate a list of lineouts to be read from selections
148146 if self .selections :
149147 sel = self .selections
150148 else :
151149 sel = range (Nimg * Nazim ) # nothing selected, use all
152150 # fpbuffer['2Read'] is the list of lineouts to be read, where each entry
153151 # contains two values, the azumuth and the image number (iAzm,iImg)
154- # defined points for each lineout are then
152+ # defined points for each lineout are then
155153 # intensities : fpbuffer['intenArr'][iImg][:,iAzm][unmasked[iAzm]]
156154 # 2thetas: fpbuffer['REtaMap'][1][:,iAzm][unmasked[iAzm]]
157155 fpbuffer ['2Read' ] = [(i % Nazim ,i // Nazim ) for i in sel if i % Nazim in mAzm ]
158156 # xfrom Zarr dict into a native dict
159- self .MIDASinstprm = {i :j [0 ] for i ,j in fp ['InstrumentParameters' ].items ()}
157+ self .MIDASinstprm = {i :j [0 ] for i ,j in fp ['InstrumentParameters' ].items ()}
160158 # change a few keys
161159 for key ,newkey in [('Polariz' ,'Polariz.' ),('SH_L' ,'SH/L' )]:
162160 if key in self .MIDASinstprm :
@@ -167,7 +165,7 @@ def readMidas(self, filename, fpbuffer={}):
167165 return False
168166 finally :
169167 del fp
170- # get overriding sample & instrument parameters
168+ # get overriding sample & instrument parameters
171169 self .MIDASsampleprm = {}
172170 samplefile = os .path .splitext (filename )[0 ] + '.samprm'
173171 if os .path .exists (samplefile ):
@@ -189,7 +187,7 @@ def readMidas(self, filename, fpbuffer={}):
189187 fp .close ()
190188 nbank ,self .instvals = G2fil .ReadInstprm (instLines , None , self .Sample )
191189 #======================================================================
192- # start reading
190+ # start reading
193191 #======================================================================
194192 # look for the next non-empty scan (lineout)
195193 iAzm ,iImg = fpbuffer ['2Read' ][self .blknum ]
@@ -211,16 +209,16 @@ def readMidas(self, filename, fpbuffer={}):
211209 omega = 999. # indicates an error
212210 try :
213211 omega = 0.5 * (
214- fpbuffer ['attributes' ][iImg ]['FirstOme' ] +
212+ fpbuffer ['attributes' ][iImg ]['FirstOme' ] +
215213 fpbuffer ['attributes' ][iImg ]['LastOme' ])
216214 except :
217215 pass
218216 eta = sum (fpbuffer ['REtaMap' ][2 ][:,iAzm ][unmasked ])/ sum (unmasked ) # compute an averaged Phi value
219217 radius = 1000 # sample to detector distance (mm)
220218 if 'Distance' in self .MIDASinstprm :
221219 radius = self .MIDASinstprm ['Distance' ]/ 1000 # convert from microns
222-
223- # now transfer instprm & sample prms into current histogram
220+
221+ # now transfer instprm & sample prms into current histogram
224222 self .pwdparms ['Instrument Parameters' ] = [{}, {}]
225223 inst = {}
226224 inst .update (instprmList )
0 commit comments