예제 #1
0
파일: fitfuncs.py 프로젝트: t1mur/odysseus
def ideal_fermi_radial(r, n0, q, r_cloud):
    """1D radial column density of an ideal Fermi gas

    The radial column density of an ideal Fermi gas around its center of mass.
    This is usually obtained by radially averaging an image of the atom cloud
    after time of flight from a trap with equal trap frequencies along both
    image axes.

    **Inputs**

      * r: 1D array containing the radial coordinate
      * n0: central optical density
      * q: logarithm of the fugacity, q = mu*beta
      * r_cloud: the radius of the atom cloud after expansion, in pixels.
                 for low temperatures T/T_F << 1, this is equal to the
                 Fermi radius times the expansion factor, for high T/T_F
                 to the thermal radius times the expansion factor.

    **Outputs**

      * coldensity: 1D array of the same length as r, containing the column
                    density for the ideal Fermi gas

    **References**

    [1] Ketterle and Zwierlein, p.69, eq.65

    """

    fq = np.log(1+np.e**q)*(1+np.e**q)/np.e**q
    coldensity = n0*fermi_poly2(q-r**2/np.float(r_cloud)**2*fq)/fermi_poly2(q)

    return coldensity
예제 #2
0
def ideal_fermi_radial(r, n0, q, r_cloud):
    """1D radial column density of an ideal Fermi gas

    The radial column density of an ideal Fermi gas around its center of mass.
    This is usually obtained by radially averaging an image of the atom cloud
    after time of flight from a trap with equal trap frequencies along both
    image axes.

    **Inputs**

      * r: 1D array containing the radial coordinate
      * n0: central optical density
      * q: logarithm of the fugacity, q = mu*beta
      * r_cloud: the radius of the atom cloud after expansion, in pixels.
                 for low temperatures T/T_F << 1, this is equal to the
                 Fermi radius times the expansion factor, for high T/T_F
                 to the thermal radius times the expansion factor.

    **Outputs**

      * coldensity: 1D array of the same length as r, containing the column
                    density for the ideal Fermi gas

    **References**

    [1] Ketterle and Zwierlein, p.69, eq.65

    """

    r_cloud = np.float(r_cloud)
    fq = np.log(1+np.exp(q)) * (1+np.exp(q))/np.exp(q)
    coldensity = n0*fermi_poly2(q-r**2/r_cloud**2*fq)/fermi_poly2(q)

    return coldensity
예제 #3
0
def idealfermi_2D_angled(p, xx, yy):
    """The 2D distribution when imaging an ideal Fermi gas, can be elliptical.

    Similar to `idealfermi_2D` but including a rotation angle. This angle
    specifies how the cloud is rotated with respect to the image axis.
    This does make the fit slower.
    Note that the actual 2-D arrays need to be flattened to 1-D for a fit to
    work.

    **Inputs**

      p : array_like
          peters, an array of floats with the following elements:
          * p[0] cloud center x
          * p[1] cloud center y
          * p[2] TF width x
          * p[3] TF width y
          * p[4] peak OD
          * p[5] log fugacity
          * p[6] background offset
          * p[7] x slope
          * p[8] Y slope
          * p[9] rotation angle in rad of cloud with respect to the image axis
      xx : ndarray
          The indices along the x-axis of the image.
      yy : ndarray
          The indices along the y-axis of the image.

    **Outputs**

      coldensity : ndarray
          The result of evaluating the 2D distribution.
    """
    print 'called'
    # do the coordinate rotation
    rr = (xx - p[0]) * np.cos(p[9]) - (yy - p[1]) * np.sin(p[9])
    ss = (xx - p[0]) * np.sin(p[9]) + (yy - p[1]) * np.cos(p[9])

    fq = np.log(1 + np.exp(p[5])) * (1 + np.exp(p[5])) / np.exp(p[5])

    coldensity = p[4] * fermi_poly2(p[5] - (rr**2 / p[2]**2 +
                                            ss**2 / p[3]**2) * fq) \
               / fermi_poly2(p[5]) + p[6] + p[7] * xx + p[8] * yy

    #coldensity = p[4] * fp2cython(p[5] - (rr**2 / p[2]**2 +
    #ss**2 / p[3]**2) * fq) \
    #/ fermi_poly2(p[5]) + p[6] + p[7] * xx + p[8] * yy

    #coldensity = p[4] * fp2cython(p[5] - (rr**2 / p[2]**2 +
    #ss**2 / p[3]**2) * fq) \
    #/ fp2cython(np.array([p[5]])) + p[6] + p[7] * xx + p[8] * yy
    return coldensity
예제 #4
0
def idealfermi_2D_angled(p, xx, yy):
    """The 2D distribution when imaging an ideal Fermi gas, can be elliptical.

    Similar to `idealfermi_2D` but including a rotation angle. This angle
    specifies how the cloud is rotated with respect to the image axis.
    This does make the fit slower.
    Note that the actual 2-D arrays need to be flattened to 1-D for a fit to
    work.

    **Inputs**

      p : array_like
          peters, an array of floats with the following elements:
          * p[0] cloud center x
          * p[1] cloud center y
          * p[2] TF width x
          * p[3] TF width y
          * p[4] peak OD
          * p[5] log fugacity
          * p[6] background offset
          * p[7] x slope
          * p[8] Y slope
          * p[9] rotation angle in rad of cloud with respect to the image axis
      xx : ndarray
          The indices along the x-axis of the image.
      yy : ndarray
          The indices along the y-axis of the image.

    **Outputs**

      coldensity : ndarray
          The result of evaluating the 2D distribution.
    """
    print 'called'
    # do the coordinate rotation
    rr = (xx - p[0]) * np.cos(p[9]) - (yy - p[1]) * np.sin(p[9])
    ss = (xx - p[0]) * np.sin(p[9]) + (yy - p[1]) * np.cos(p[9])

    fq = np.log(1 + np.exp(p[5])) * (1 + np.exp(p[5])) / np.exp(p[5])

    coldensity = p[4] * fermi_poly2(p[5] - (rr**2 / p[2]**2 +
                                            ss**2 / p[3]**2) * fq) \
               / fermi_poly2(p[5]) + p[6] + p[7] * xx + p[8] * yy

    #coldensity = p[4] * fp2cython(p[5] - (rr**2 / p[2]**2 +
                                            #ss**2 / p[3]**2) * fq) \
               #/ fermi_poly2(p[5]) + p[6] + p[7] * xx + p[8] * yy

    #coldensity = p[4] * fp2cython(p[5] - (rr**2 / p[2]**2 +
                                            #ss**2 / p[3]**2) * fq) \
               #/ fp2cython(np.array([p[5]])) + p[6] + p[7] * xx + p[8] * yy
    return coldensity
예제 #5
0
 def fitFunc(positions,x0,y0,A,sigmaX,sigmaY,betaMu,B ):
     """ Parabola
     data is a 2 row array of positions
     e.g.
     0 1 2 3 4 5 0 1 2 3 4 5...
     0 0 0 0 0 0 1 1 1 1 1 1...    
     so data[0] is x
     data[1] is y
     Note that we use an implementation of the poly log file optimised to perform the polylog calls:
     fermi_poly2(x), equal to -Li_2(-e^x)
     """
     return A*(polylog.fermi_poly2(betaMu-((positions[0]-x0)/(2*sigmaX))**2.-((positions[1]-y0)/(2*sigmaY))**2.))/(polylog.fermi_poly2(betaMu))+B
예제 #6
0
def idealfermi_2D(p, xx, yy):
    """The 2D distribution when imaging an ideal Fermi gas, can be elliptical.

    Note that the actual 2-D arrays need to be flattened to 1-D for a fit to
    work.

    **Inputs**

      p : array_like
          peters, an array of floats with the following elements:
          * p[0] cloud center x
          * p[1] cloud center y
          * p[2] TF width x
          * p[3] TF width y
          * p[4] peak OD
          * p[5] log fugacity
          * p[6] background offset
          * p[7] x slope
          * p[8] Y slope
      xx : ndarray
          The indices along the x-axis of the image.
      yy : ndarray
          The indices along the y-axis of the image.

    **Outputs**

      coldensity : ndarray
          The result of evaluating the 2D distribution.
    """

    fq = np.log(1 + np.exp(p[5])) * (1 + np.exp(p[5])) / np.exp(p[5])

    coldensity = p[4] * fermi_poly2(p[5] - ((xx-p[0])**2/p[2]**2 +
                                            (yy-p[1])**2/p[3]**2) * fq) \
               / fermi_poly2(p[5]) + p[6] + p[7] * xx + p[8] * yy

    return coldensity
예제 #7
0
def idealfermi_2D(p, xx, yy):
    """The 2D distribution when imaging an ideal Fermi gas, can be elliptical.

    Note that the actual 2-D arrays need to be flattened to 1-D for a fit to
    work.

    **Inputs**

      p : array_like
          peters, an array of floats with the following elements:
          * p[0] cloud center x
          * p[1] cloud center y
          * p[2] TF width x
          * p[3] TF width y
          * p[4] peak OD
          * p[5] log fugacity
          * p[6] background offset
          * p[7] x slope
          * p[8] Y slope
      xx : ndarray
          The indices along the x-axis of the image.
      yy : ndarray
          The indices along the y-axis of the image.

    **Outputs**

      coldensity : ndarray
          The result of evaluating the 2D distribution.
    """

    fq = np.log(1 + np.exp(p[5])) * (1 + np.exp(p[5])) / np.exp(p[5])

    coldensity = p[4] * fermi_poly2(p[5] - ((xx-p[0])**2/p[2]**2 +
                                            (yy-p[1])**2/p[3]**2) * fq) \
               / fermi_poly2(p[5]) + p[6] + p[7] * xx + p[8] * yy

    return coldensity
예제 #8
0
 def test_fermi_poly2_float(self):
     testfloat = 1.
     assert_approx_equal(- lerch.Li(2, -np.exp(testfloat)), \
                         polylog.fermi_poly2(testfloat), significant=7)
예제 #9
0
 def test_fermi_poly2(self):
     fp_approx1 = polylog.fermi_poly2(self.xx1)
     # the polynomial approximation should be good to 1e-7, fails for
     # higher precision test
     assert_array_almost_equal(self.exact1, fp_approx1, decimal=7)