Changeset 577 for trunk/GSASIIIO.py
- Timestamp:
- Apr 27, 2012 9:45:26 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r573 r577 234 234 return PawleyPeaks 235 235 236 # this will be removed eventually 236 237 def GetHKLData(filename): 237 238 print 'Reading: '+filename … … 1350 1351 return True 1351 1352 1353 ###################################################################### 1354 class ImportStructFactor(object): 1355 '''Defines a base class for the reading of files with tables 1356 of structure factors 1357 ''' 1358 def __init__(self, 1359 formatName, 1360 longFormatName=None, 1361 extensionlist=[], 1362 strictExtension=False, 1363 ): 1364 self.formatName = formatName # short string naming file type 1365 if longFormatName: # longer string naming file type 1366 self.longFormatName = longFormatName 1367 else: 1368 self.longFormatName = formatName 1369 # define extensions that are allowed for the file type 1370 # for windows, remove any extensions that are duplicate, as case is ignored 1371 if sys.platform == 'windows' and extensionlist: 1372 extensionlist = list(set([s.lower() for s in extensionlist])) 1373 self.extensionlist = extensionlist 1374 # If strictExtension is True, the file will not be read, unless 1375 # the extension matches one in the extensionlist 1376 self.strictExtension = strictExtension 1377 # define contents of Structure Factor entry 1378 self.Controls = { # dictionary with plotting controls 1379 'Type' : 'Fosq', 1380 'ifFc' : None, 1381 'HKLmax' : [None,None,None], 1382 'HKLmin' : [None,None,None], 1383 'FoMax' : None, # maximum observed structure factor 1384 'Zone' : '001', 1385 'Layer' : 0, 1386 'Scale' : 1.0, 1387 'log-lin' : 'lin', 1388 } 1389 self.Parameters = [ # list with data collection parameters 1390 ('SXC',1.5428), 1391 ['SXC',1.5428], 1392 ['Type','Lam'] 1393 ] 1394 self.RefList = [] 1395 self.warnings = '' 1396 self.errors = '' 1397 1398 def PhaseSelector(self, ChoiceList, ParentFrame=None, 1399 title='Select a structure factor', size=None): 1400 ''' Provide a wx dialog to select a dataset if the file contains more 1401 than one 1402 ''' 1403 dlg = wx.SingleChoiceDialog( 1404 ParentFrame, 1405 title, 1406 'Structure Factor Selection', 1407 ChoiceList, 1408 ) 1409 if size: dlg.SetSize(size) 1410 if dlg.ShowModal() == wx.ID_OK: 1411 sel = dlg.GetSelection() 1412 dlg.Destroy() 1413 return sel 1414 else: 1415 dlg.Destroy() 1416 return None 1417 1418 def ShowBusy(self): 1419 wx.BeginBusyCursor() 1420 1421 def DoneBusy(self): 1422 wx.EndBusyCursor() 1423 1424 # def Reader(self, filename, filepointer, ParentFrame=None): 1425 # '''This method must be supplied in the child class 1426 # it will read the file 1427 # ''' 1428 # return True # if read OK 1429 # return False # if an error occurs 1430 1431 def ExtensionValidator(self, filename): 1432 '''This methods checks if the file has the correct extension 1433 Return False if this filename will not be supported by this reader 1434 Return True if the extension matches the list supplied by the reader 1435 Return None if the reader allows un-registered extensions 1436 ''' 1437 if filename: 1438 ext = os.path.splitext(filename)[1] 1439 if sys.platform == 'windows': ext = ext.lower() 1440 if ext in self.extensionlist: return True 1441 if self.strictExtension: return False 1442 return None 1443 1444 def ContentsValidator(self, filepointer): 1445 '''This routine will attempt to determine if the file can be read 1446 with the current format. 1447 This will typically be overridden with a method that 1448 takes a quick scan of [some of] 1449 the file contents to do a "sanity" check if the file 1450 appears to match the selected format. 1451 Expected to be called via self.Validator() 1452 ''' 1453 #filepointer.seek(0) # rewind the file pointer 1454 return True
Note: See TracChangeset
for help on using the changeset viewer.