コード例 #1
0
def monitor_normalize(sansdata,mon0=1e8):
    """"\
    Given a SansData object, normalize the data to the provided monitor
    
    **Inputs**
    
    sansdata (sans2d): data in
    
    mon0 (float): provided monitor
    
    **Returns**
    
    output (sans2d): corrected for dead time
    
    2010-01-01 Andrew Jackson?
    """    
    monitor=sansdata.metadata['run.moncnt']
    result=sansdata.data.x*mon0/monitor
    res=SansData()
    res.data.x=result
    res.metadata=deepcopy(sansdata.metadata)
    #added res.q
    res.q=copy(sansdata.q)
    res.qx=copy(sansdata.qx)
    res.qy=copy(sansdata.qy)
    res.theta=copy(sansdata.theta)
    return res
コード例 #2
0
def correct_dead_time(sansdata,deadtime=3.4e-6):
    """\
    Correct for the detector recovery time after each detected event
    (suppresses counts as count rate increases)
    
    **Inputs**
    
    sansdata (sans2d): data in
    
    deadtime (float): detector dead time (nonparalyzing?)
    
    **Returns**
    
    output (sans2d): corrected for dead time
    
    2010-01-01 Andrew Jackson?
    """
    
    dscale = 1/(1-deadtime*(np.sum(sansdata.data.x)/sansdata.metadata["run.rtime"]))
    
    result = SansData()
    result.data.x = sansdata.data.x*dscale
    result.metadata=deepcopy(sansdata.metadata)
    result.q = copy(sansdata.q)
    result.qx = copy(sansdata.qx)
    result.qy = copy(sansdata.qy)
    result.theta = copy(sansdata.theta)
    
    return result
コード例 #3
0
def PixelsToQ(data, correct_solid_angle=True):
    """
    generate a q_map for sansdata. Each pixel will have 4 values: (qx,qy,q,theta)

        
    **Inputs**
    
    data (sans2d): data in
    
    correct_solid_angle {Correct solid angle} (bool): Apply correction for mapping
        curved Ewald sphere to flat detector
    
    **Returns**
    
    output (sans2d): converted to I vs. Qx, Qy
    
    2016-04-06 Brian Maranville  
    """
    L2=data.metadata['det.dis']
    x0=data.metadata['det.beamx'] #should be close to 64
    y0=data.metadata['det.beamy'] #should be close to 64
    wavelength=data.metadata['resolution.lmda']
    shape=data.data.x.shape

    qx=np.empty(shape,'Float64')
    qy=np.empty(shape,'Float64')
    
    x,y = np.indices(shape)
    X=data.metadata['det.pixelsizex']/10.0*(x-x0) # in mm in nexus
    Y=data.metadata['det.pixelsizey']/10.0*(y-y0)
    r=np.sqrt(X**2+Y**2)
    theta=np.arctan2(r,L2*100)/2 #remember to convert L2 to cm from meters
    q=(4*np.pi/wavelength)*np.sin(theta)
    alpha=np.arctan2(Y,X)
    qx=q*np.cos(alpha)
    qy=q*np.sin(alpha)
    if correct_solid_angle:
        data.data.x = data.data.x * (np.cos(theta)**3)
    res=SansData()
    res.data=copy(data.data)
    res.metadata=deepcopy(data.metadata)
    #Adding res.q
    res.q = q
    res.qx=qx
    res.qy=qy
    res.theta=theta
    return res
コード例 #4
0
def correct_detector_efficiency(sansdata):
    """
    Given a SansData object, corrects for the efficiency of the detection process 
    
    **Inputs**
    
    sansdata (sans2d): data in
    
    **Returns**
    
    output (sans2d): corrected for efficiency
    
    2016-08-03 Brian Maranville and Andrew Jackson
    """
    
    L2=sansdata.metadata['det.dis']
    lambd = sansdata.metadata["resolution.lmda"]
    shape=sansdata.data.x.shape
    (x0,y0) = np.shape(sansdata.data.x)
    x,y = np.indices(shape)
    X = sansdata.metadata['det.pixelsizex']/10.0*(x-x0/2)
    Y = sansdata.metadata['det.pixelsizey']/10.0*(y-y0/2)
    r=np.sqrt(X**2+Y**2)
    theta_det=np.arctan2(r,L2*100)/2
    
    stAl = 0.00967*lambd*0.8 #dimensionless, constants from JGB memo
    stHe = 0.146*lambd*2.5
    
    ff = np.exp(-stAl/np.cos(theta_det))*(1-np.exp(-stHe/np.cos(theta_det))) / ( np.exp(-stAl)*(1-np.exp(-stHe)) )

    res=SansData()
    res.data.x=sansdata.data.x/ff
    #if not sansdata.data.variance==None:
            #res.data.variance=sansdata.data.variance/ff

    res.metadata=deepcopy(sansdata.metadata)
    res.q = copy(sansdata.q)
    res.qx=copy(sansdata.qx)
    res.qy=copy(sansdata.qy)
    #note that the theta calculated for this correction is based on the center of the
    #detector and NOT the center of the beam. Thus leave the q-relevant theta alone.
    res.theta=copy(sansdata.theta)

    return res