Changeset a309667 in sasview for src/sas/sascalc


Ignore:
Timestamp:
Sep 11, 2017 6:07:53 AM (7 years ago)
Author:
lewis
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ccf58fb
Parents:
9b90bf8
Message:

Tidy up IDF code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/corfunc/transform_thread.py

    r9b90bf8 ra309667  
    5353 
    5454            # ----- Interface Distribution function ----- 
    55             # dmax = 200.0 # Max real space value to calculate IDF up to 
    56             # dstep = 0.5 # Evaluate the IDF in steps of dstep along the real axis 
    57             # qmax = 1.0 # Max q value to integrate up to when calculating IDF 
     55            idf = dct(-qs**4 * (iqs-background)) 
    5856 
    59             # Units of x axis depend on qmax (for some reason?). This scales 
    60             # the xgamma array appropriately, since qmax was set to 0.6 in 
    61             # the original fortran code. 
    62             # x_scale = qmax / 0.6 
     57            if self.check_if_cancelled(): return 
    6358 
    64             # xgamma = np.arange(0, dmax/x_scale, step=dstep/x_scale) 
    65             # idf = np.zeros(len(xgamma)) 
    66             idf = dct(-qs**4 * (iqs-background)) 
     59            # Manually calculate IDF(0.0), since scipy DCT tends to give us a 
     60            # very large negative value. 
     61            # IDF(x) = int_0^inf q^4 * I(q) * cos(q*x) * dq 
     62            # => IDF(0) = int_0^inf q^4 * I(q) * dq 
    6763            idf[0] = trapz(-qs**4 * (iqs-background), qs) 
    68             idf /= Q 
    69  
    70             # nth moment = integral(q^n * I(q), q=0, q=inf) 
    71             # moment = np.zeros(5) 
    72             # for n in range(5): 
    73             #     integrand = qs**n * (iqs-background) 
    74             #     moment[n] = trapz(integrand[qs < qmax], qs[qs < qmax]) 
    75             #     if self.check_if_cancelled(): return 
    76             # 
    77             # # idf(x) = -integral(q^4 * I(q)*cos(qx), q=0, q=inf) / 2nd moment 
    78             # # => idf(0) = -integral(q^4 * I(q), 0, inf) / (2nd moment) 
    79             # #  = -(4th moment)/(2nd moment) 
    80             # idf[0] = -moment[4] / moment[2] 
    81             # for i in range(1, len(xgamma)): 
    82             #     d = xgamma[i] 
    83             # 
    84             #     integrand = -qs**4 * (iqs-background) * np.cos(d*qs) 
    85             #     idf[i] = trapz(integrand[qs < qmax], qs[qs < qmax]) 
    86             #     idf[i] /= moment[2] 
    87             #     if self.check_if_cancelled(): return 
    88             # 
    89             # xgamma *= x_scale 
     64            idf /= Q # Normalise using scattering invariant 
    9065 
    9166        except Exception as e: 
Note: See TracChangeset for help on using the changeset viewer.