Exemplo n.º 1
0
 def test_testUfuncs1(self):
     # Test various functions such as sin, cos.
     (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
     assert_(eq(np.cos(x), cos(xm)))
     assert_(eq(np.cosh(x), cosh(xm)))
     assert_(eq(np.sin(x), sin(xm)))
     assert_(eq(np.sinh(x), sinh(xm)))
     assert_(eq(np.tan(x), tan(xm)))
     assert_(eq(np.tanh(x), tanh(xm)))
     with np.errstate(divide='ignore', invalid='ignore'):
         assert_(eq(np.sqrt(abs(x)), sqrt(xm)))
         assert_(eq(np.log(abs(x)), log(xm)))
         assert_(eq(np.log10(abs(x)), log10(xm)))
     assert_(eq(np.exp(x), exp(xm)))
     assert_(eq(np.arcsin(z), arcsin(zm)))
     assert_(eq(np.arccos(z), arccos(zm)))
     assert_(eq(np.arctan(z), arctan(zm)))
     assert_(eq(np.arctan2(x, y), arctan2(xm, ym)))
     assert_(eq(np.absolute(x), absolute(xm)))
     assert_(eq(np.equal(x, y), equal(xm, ym)))
     assert_(eq(np.not_equal(x, y), not_equal(xm, ym)))
     assert_(eq(np.less(x, y), less(xm, ym)))
     assert_(eq(np.greater(x, y), greater(xm, ym)))
     assert_(eq(np.less_equal(x, y), less_equal(xm, ym)))
     assert_(eq(np.greater_equal(x, y), greater_equal(xm, ym)))
     assert_(eq(np.conjugate(x), conjugate(xm)))
     assert_(eq(np.concatenate((x, y)), concatenate((xm, ym))))
     assert_(eq(np.concatenate((x, y)), concatenate((x, y))))
     assert_(eq(np.concatenate((x, y)), concatenate((xm, y))))
     assert_(eq(np.concatenate((x, y, x)), concatenate((x, ym, x))))
Exemplo n.º 2
0
def critical_friction(sig1, sig3, pp):
    """
    A function that computes the critical friction coefficient
    that would induce slip for the given combination of minimum
    and maximum principal stress and pore pressure

    Parameters
    ----------
    sig1 : float or array_like
        The maximum (most compressive) principal stress. If `sig1` is
        array_like then `sig3` must be a scalar of type float
    sig3 : float or array_like
        The minimum (least compressive) principal stress.  If `sig3` is
        array_like then `sig1` must be a scalar of type float
    pp : float
        The pore pressure

    Returns
    -------
    mu_c : float or array_like
        The critical friction coefficient. If either sig1 or sig3 are
        array_like then the result will be an array containing the
        critical friction coefficient for each entry in the array.
    """

    arg = (sig1 - sig3) / (sig1 + sig3 - 2.0 * pp)
    phic = ma.arcsin(arg)
    muc = ma.tan(phic)
    return muc
Exemplo n.º 3
0
 def test_testUfuncs1(self):
     # Test various functions such as sin, cos.
     (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
     assert_(eq(np.cos(x), cos(xm)))
     assert_(eq(np.cosh(x), cosh(xm)))
     assert_(eq(np.sin(x), sin(xm)))
     assert_(eq(np.sinh(x), sinh(xm)))
     assert_(eq(np.tan(x), tan(xm)))
     assert_(eq(np.tanh(x), tanh(xm)))
     with np.errstate(divide='ignore', invalid='ignore'):
         assert_(eq(np.sqrt(abs(x)), sqrt(xm)))
         assert_(eq(np.log(abs(x)), log(xm)))
         assert_(eq(np.log10(abs(x)), log10(xm)))
     assert_(eq(np.exp(x), exp(xm)))
     assert_(eq(np.arcsin(z), arcsin(zm)))
     assert_(eq(np.arccos(z), arccos(zm)))
     assert_(eq(np.arctan(z), arctan(zm)))
     assert_(eq(np.arctan2(x, y), arctan2(xm, ym)))
     assert_(eq(np.absolute(x), absolute(xm)))
     assert_(eq(np.equal(x, y), equal(xm, ym)))
     assert_(eq(np.not_equal(x, y), not_equal(xm, ym)))
     assert_(eq(np.less(x, y), less(xm, ym)))
     assert_(eq(np.greater(x, y), greater(xm, ym)))
     assert_(eq(np.less_equal(x, y), less_equal(xm, ym)))
     assert_(eq(np.greater_equal(x, y), greater_equal(xm, ym)))
     assert_(eq(np.conjugate(x), conjugate(xm)))
     assert_(eq(np.concatenate((x, y)), concatenate((xm, ym))))
     assert_(eq(np.concatenate((x, y)), concatenate((x, y))))
     assert_(eq(np.concatenate((x, y)), concatenate((xm, y))))
     assert_(eq(np.concatenate((x, y, x)), concatenate((x, ym, x))))
Exemplo n.º 4
0
 def transform_non_affine(self, a):
     # With safeguards
     # TODO: Can improve this?
     a = np.deg2rad(a)  # convert to radians
     m = ma.masked_where((a < -self._thresh) | (a > self._thresh), a)
     if m.mask.any():
         return ma.log(np.abs(ma.tan(m) + 1 / ma.cos(m)))
     else:
         return np.log(np.abs(np.tan(a) + 1 / np.cos(a)))
Exemplo n.º 5
0
 def transform_non_affine(self, a):
     # NOTE: Critical to truncate valid range inside transform *and*
     # in limit_range_for_scale or get weird duplicate tick labels. This
     # is not necessary for positive-only scales because it is harder to
     # run up right against the scale boundaries.
     with np.errstate(divide='ignore', invalid='ignore'):
         m = ma.masked_where((a <= -90) | (a >= 90), a)
         if m.mask.any():
             m = np.deg2rad(m)
             return ma.log(ma.abs(ma.tan(m) + 1 / ma.cos(m)))
         else:
             a = np.deg2rad(a)
             return np.log(np.abs(np.tan(a) + 1 / np.cos(a)))
Exemplo n.º 6
0
 def transform_non_affine(self, a):
     """
     This transform takes a numpy array and returns a transformed copy.
     Since the range of the Mercator scale is limited by the
     user-specified threshold, the input array must be masked to
     contain only valid values.  Matplotlib will handle masked arrays
     and remove the out-of-range data from the plot.  However, the
     returned array *must* have the same shape as the input array, since
     these values need to remain synchronized with values in the other
     dimension.
     """
     masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
     if masked.mask.any():
         return ma.log(np.abs(ma.tan(masked) + 1 / ma.cos(masked)))
     else:
         return np.log(np.abs(np.tan(a) + 1 / np.cos(a)))
Exemplo n.º 7
0
 def transform_non_affine(self, a):
     """
     This transform takes an Nx1 ``numpy`` array and returns a
     transformed copy.  Since the range of the Mercator scale
     is limited by the user-specified threshold, the input
     array must be masked to contain only valid values.
     ``matplotlib`` will handle masked arrays and remove the
     out-of-range data from the plot.  Importantly, the
     ``transform`` method *must* return an array that is the
     same shape as the input array, since these values need to
     remain synchronized with values in the other dimension.
     """
     masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
     if masked.mask.any():
         return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
     else:
         return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
Exemplo n.º 8
0
 def calc_PA(self) :
     """Calculates the telescope PA. requires LST to be either a field or 
     previously calculated array
     Outputs an  array of PA values for each time in radians.
     This requires the fields Ra = 'CRVAL2', Dec = 'CRVAL3' and 'DATE-OBS'
     to be set.
     """
     
     self.PA = sp.zeros(self.dims[0])
     for ii in range(self.dims[0]) :
         RA = self.field['CRVAL2'][ii]
         DEC = self.field['CRVAL3'][ii]
         LST = utils.LSTatGBT(self.field['DATE-OBS'][ii])
         H = LST-RA
         Latit = 38.0+26.0/60
         tanPA = ma.sin(H*sp.pi/180)/(ma.cos(DEC*sp.pi/180)*ma.tan(Latit*sp.pi/180)-ma.sin(DEC*sp.pi/180)*ma.cos(H*sp.pi/180))
         self.PA[ii] = ma.arctan(tanPA)
Exemplo n.º 9
0
 def transform(self, a):
     """
     This transform takes an Nx1 ``numpy`` array and returns a
     transformed copy.  Since the range of the Mercator scale
     is limited by the user-specified threshold, the input
     array must be masked to contain only valid values.
     ``matplotlib`` will handle masked arrays and remove the
     out-of-range data from the plot.  Importantly, the
     ``transform`` method *must* return an array that is the
     same shape as the input array, since these values need to
     remain synchronized with values in the other dimension.
     """
     masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
     if masked.mask.any():
         return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
     else:
         return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
Exemplo n.º 10
0
    def calc_PA(self):
        """Calculates the telescope PA. requires LST to be either a field or 
        previously calculated array
        Outputs an  array of PA values for each time in radians.
        This requires the fields Ra = 'CRVAL2', Dec = 'CRVAL3' and 'DATE-OBS'
        to be set.
        """

        self.PA = sp.zeros(self.dims[0])
        for ii in range(self.dims[0]):
            RA = self.field['CRVAL2'][ii]
            DEC = self.field['CRVAL3'][ii]
            LST = utils.LSTatGBT(self.field['DATE-OBS'][ii])
            H = LST - RA
            Latit = 38.0 + 26.0 / 60
            tanPA = ma.sin(H * sp.pi / 180) / (
                ma.cos(DEC * sp.pi / 180) * ma.tan(Latit * sp.pi / 180) -
                ma.sin(DEC * sp.pi / 180) * ma.cos(H * sp.pi / 180))
            self.PA[ii] = ma.arctan(tanPA)
Exemplo n.º 11
0
def func(x):
    return (1 - sec(x)) / (tan(x)**2)
Exemplo n.º 12
0
 def transform_non_affine(self, a):
     masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
     if masked.mask.any():
         return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
     else:
         return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))