Changeset 1b28ff5 in sasview
- Timestamp:
- Jan 10, 2013 6:01:13 PM (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:
- be0fe41
- Parents:
- b1174ec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sanscalculator/src/sans/calculator/sans_gen.py
rdbc01f2 r1b28ff5 576 576 :raise ValueError: when the length of the data vectors are inconsistent 577 577 """ 578 579 580 578 try: 581 input_f = numpy.loadtxt(path, dtype='float', skiprows=1, 582 ndmin=1, unpack=True) 583 pos_x = numpy.array(input_f[0]) 584 pos_y = numpy.array(input_f[1]) 585 pos_z = numpy.array(input_f[2]) 586 sld_n = numpy.array(input_f[3]) 587 sld_mx = numpy.array(input_f[4]) 588 sld_my = numpy.array(input_f[5]) 589 sld_mz = numpy.array(input_f[6]) 590 ncols = len(input_f) 591 if ncols == 8: 592 vol_pix = numpy.array(input_f[7]) 593 elif ncols == 7: 594 vol_pix = None 595 else: 596 raise 579 pos_x = numpy.zeros(0) 580 pos_y = numpy.zeros(0) 581 pos_z = numpy.zeros(0) 582 sld_n = numpy.zeros(0) 583 sld_mx = numpy.zeros(0) 584 sld_my = numpy.zeros(0) 585 sld_mz = numpy.zeros(0) 586 try: 587 # Use numpy to speed up loading 588 input_f = numpy.loadtxt(path, dtype='float', skiprows=1, 589 ndmin=1, unpack=True) 590 raise 591 pos_x = numpy.array(input_f[0]) 592 pos_y = numpy.array(input_f[1]) 593 pos_z = numpy.array(input_f[2]) 594 sld_n = numpy.array(input_f[3]) 595 sld_mx = numpy.array(input_f[4]) 596 sld_my = numpy.array(input_f[5]) 597 sld_mz = numpy.array(input_f[6]) 598 ncols = len(input_f) 599 if ncols == 8: 600 vol_pix = numpy.array(input_f[7]) 601 elif ncols == 7: 602 vol_pix = None 603 except: 604 print "HERE" 605 # For older version of numpy 606 input_f = open(path, 'rb') 607 buff = input_f.read() 608 lines = buff.split('\n') 609 input_f.close() 610 for line in lines: 611 toks = line.split() 612 try: 613 _pos_x = float(toks[0]) 614 _pos_y = float(toks[1]) 615 _pos_z = float(toks[2]) 616 _sld_n = float(toks[3]) 617 _sld_mx = float(toks[4]) 618 _sld_my = float(toks[5]) 619 _sld_mz = float(toks[6]) 620 621 pos_x = numpy.append(pos_x, _pos_x) 622 pos_y = numpy.append(pos_y, _pos_y) 623 pos_z = numpy.append(pos_z, _pos_z) 624 sld_n = numpy.append(sld_n, _sld_n) 625 sld_mx = numpy.append(sld_mx, _sld_mx) 626 sld_my = numpy.append(sld_my, _sld_my) 627 sld_mz = numpy.append(sld_mz, _sld_mz) 628 try: 629 _vol_pix = float(toks[7]) 630 vol_pix = numpy.append(vol_pix, _vol_pix) 631 except: 632 vol_pix = None 633 except: 634 # Skip non-data lines 635 pass 636 597 637 pos_x -= (min(pos_x) + max(pos_x)) / 2.0 598 638 pos_y -= (min(pos_y) + max(pos_y)) / 2.0
Note: See TracChangeset
for help on using the changeset viewer.