Changeset 077207b in sasview for sanscalculator
- Timestamp:
- Jan 4, 2013 7:30:31 AM (12 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d7b6913
- Parents:
- ab7e3a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sanscalculator/src/sans/calculator/sans_gen.py
rab7e3a4 r077207b 4 4 from sans.models.BaseComponent import BaseComponent 5 5 import sans.models.sans_extension.sld2i as mod 6 from periodictable import formula 6 7 import numpy 7 8 import os … … 54 55 self.params['scale'] = 1.0 55 56 self.params['background'] = 0.0 56 self.params['Up_frac_i'] = 1.057 self.params['Up_frac_f'] = 1.057 self.params['Up_frac_i'] = 0.5 58 self.params['Up_frac_f'] = 0.5 58 59 self.params['Up_theta'] = 0.0 59 60 self.description='GenSAS' … … 440 441 ## List of allowed extensions 441 442 ext = ['.pdb', '.PDB'] 442 443 443 444 def read(self, path): 444 445 """ … … 458 459 sld_my = numpy.zeros(0) 459 460 sld_mz = numpy.zeros(0) 460 pix_symbol = numpy.zeros(0) #numpy.array([])461 pix_symbol = numpy.zeros(0) 461 462 try: 462 463 input_f = open(path, 'rb') 463 464 buff = input_f.read() 464 #buff.replace(' ', '')465 465 lines = buff.split('\n') 466 466 input_f.close() 467 467 for line in lines: 468 468 try: 469 toks = line.split()469 #toks = line.split() 470 470 # check if line starts with "ATOM" 471 if toks[0].count('ATM') > 0 or toks[0] == 'ATOM': 471 if line[0:6].strip().count('ATM') > 0 or \ 472 line[0:6].strip() == 'ATOM': 472 473 # define fields of interest 473 atom_id = toks[1] 474 atom_name = toks[2] 475 if line[12] == '' or len(atom_name) == 4: 476 atom_name = atom_name[0].upper() 477 else: 478 atom_name = atom_name[0].upper() + \ 479 atom_name[1].lower() 474 atom_id = line[6:11].strip() 475 atom_name = line[12:16].strip() 480 476 try: 481 float( toks[3])482 ind = 3477 float(line[12]) 478 atom_name = atom_name[1].upper() 483 479 except: 484 ind = 4 485 res_name = toks[ind] 486 #chain_name = toks[3].strip() 487 #residue_id = toks[4].strip() 488 try: 489 float(toks[4]) 490 except: 491 ind += 1 492 ind += 1 493 _pos_x = float(toks[ind]) 494 ind += 1 495 _pos_y = float(toks[ind]) 496 ind += 1 497 _pos_z = float(toks[ind]) 480 if len(atom_name) == 4: 481 atom_name = atom_name[0].upper() 482 elif line[12] != ' ': 483 atom_name = atom_name[0].upper() + \ 484 atom_name[1].lower() 485 else: 486 atom_name = atom_name[0].upper() 487 #res_name = line[17:20].strip() 488 #chain_name = line[21:22].strip() 489 _pos_x = float(line[30:38].strip()) 490 _pos_y = float(line[38:46].strip()) 491 _pos_z = float(line[46:54].strip()) 492 498 493 pos_x = numpy.append(pos_x, _pos_x) 499 494 pos_y = numpy.append(pos_y, _pos_y) 500 495 pos_z = numpy.append(pos_z, _pos_z) 501 sld_n = numpy.append(sld_n, 7e-06) 496 try: 497 #from periodictable import nsf 498 #val = nsf.neutron_sld(atom_name) 499 val = formula(atom_name).atoms.keys()[0].neutron.b_c 500 # sld in Ang unit (from fm) 501 val = float(val) 502 val *= 1.0e-5 503 sld_n = numpy.append(sld_n, val) 504 except: 505 print "Error: set the sld of %s to zero"% atom_name 506 sld_n = numpy.append(sld_n, 0.0) 502 507 sld_mx = numpy.append(sld_mx, 0) 503 508 sld_my = numpy.append(sld_my, 0) … … 883 888 self.ynodes = None 884 889 self.znodes = None 885 890 886 891 def set_stepsize(self): 887 892 """
Note: See TracChangeset
for help on using the changeset viewer.