Ejemplo n.º 1
0
def test_rotation_matrix_within_GGS_class_var_size():
    '''Checks compartibility of variable sizes'''
    d1 = np.empty(5)
    d2 = np.empty(4)
    raises(AssertionError, GGS().rotation_matrix, d1, d2)
    
    d1 = np.empty(4)
    d2 = np.empty(5)
    raises(AssertionError, GGS().rotation_matrix, d1, d2)
Ejemplo n.º 2
0
    def continuation(self, *args):
        r'''Continuates the harmonic field to specified observation points.
        input >
        args:                 tuple     -> (obs_lon, obs_lat, obs_height, laydepth, param)
        Each args variable within the parenthesis is related to the observables.
        OBS: All variables inside the tuple args are required! They represent:

            obs_lon, obs_lat: 1D arrays -> horizontal coordinates of the continued field
            obs_height:       float     -> altitude of the continued field (must be positive)
            laydepth:         float     -> depth of point-masses (must be negative)
            param:            1D arrays -> equivalent layer coefficients
        '''
        lon = np.asarray(args[0])
        lat = np.asarray(args[1])
        # h = np.zeros_like(lon) + args[2]
        x, y, z = GGS().geodetic2cartesian(lon, lat,
                                           np.zeros_like(lon) + args[2])
        R = GGS().rotation_matrix(lon, lat)
        # xlay, ylay, zlay = func2(lon,lat,np.zeros_like(lon)+args[3])
        Layer = EqLayer(self.lon, self.lat, np.zeros_like(self.lon) + args[3])
        xlay, ylay, zlay = GGS().geodetic2cartesian(self.lon,self.lat, \
            np.zeros_like(self.lon)+args[3])
        lay = Layer.build_layer(xlay, ylay, zlay)
        T = Layer.designMat(x, y, z, R, lay)

        if args[2] < 0.:
            print('The transformation is a downward continuation')
        else:
            print('The transformation is an upward continuation')
        continued_data = np.dot(T, np.asarray(args[4]))
        return continued_data


# 1 element for each variable
# longitude = -55.
# latitude = -25.
# height = 1000.
# 3 element for each variable making vectors
# longitude = np.asarray([x for x in xrange(-55,-49,2)])
# latitude = np.asarray([x for x in xrange(-25,-19,2)])
# height = np.zeros_like(longitude) + 1000.

# Observation points object
# observ = GGS()
# x, y, z = observ.geodetic2cartesian(longitude,latitude,height)

# Equivalent layer object
# Lay = EqLayer(longitude,latitude,height)
# xlay, ylay, zlay = Lay.geodetic2cartesian(longitude,latitude,np.zeros_like(longitude)-5000.)
# layer = Lay.build_layer(xlay, ylay, zlay)

# H = Lay.designMat(x, y, z, observ.rotation_matrix(longitude, latitude), layer)
# print H
# print Lay.continuation(10.)
Ejemplo n.º 3
0
def test_geodetic2cartesian_within_GGS_class_var_size():
    '''Checks compartibility of variable sizes'''
    d1 = np.empty(5)
    d2 = np.empty(4)
    d3 = np.empty(4)
    raises(AssertionError, GGS().geodetic2cartesian, d1, d2, d3)
    
    d1 = np.empty(4)
    d2 = np.empty(5)
    raises(AssertionError, GGS().geodetic2cartesian, d1, d2, d3)
    
    d2 = np.empty(4)
    d3 = np.empty(5)
    raises(AssertionError, GGS().geodetic2cartesian, d1, d2, d3)
Ejemplo n.º 4
0
 def __init__(self, longitude, latitude, height):
     # super().__init__(self)
     GGS.__init__(self)
     self.lon = np.asarray(longitude)
     self.lat = np.asarray(latitude)
     self.height = np.asarray(height)
     assert type(self.lon) == type(self.lat) == type(self.height), \
         'Input coordinate variables do not have the same type!'
     assert self.lon.size == self.lat.size == self.height.size, \
         'Input coordinate variables do not have the same size!'
     if self.lon.size == 1 or self.lat.size == 1 or self.height.size == 1:
         self.radius = np.asarray(self.radius)
     elif self.lon.size > 1 or self.lat.size > 1 or self.height.size > 1:
         self.radius = np.zeros_like(self.lon) + np.asarray(self.radius)
     else:
         self.radius = np.asarray(self.radius)
Ejemplo n.º 5
0
def test_designMat_within_EqLayer_class_check_value():
    '''Checks compartibility of calculated and given
    design matrices'''

    # Creating Observation points
    lon = np.array([-60., -50., -40.])
    lat = np.array([-30., -25., -20.])
    h = np.zeros_like(lon) + 3000.
    x, y, z = GGS().geodetic2cartesian(lon, lat, h)

    Lay = EqLayer(lon, lat, np.zeros_like(lon) - 200.)

    # Applying build_layer function
    d1 = np.empty(5)
    d2 = np.empty(4)
    d3 = np.empty(4)
    raises(AssertionError, Lay.build_layer, d1, d2, d3)

    d1 = np.empty(4)
    d2 = np.empty(5)
    raises(AssertionError, Lay.build_layer, d1, d2, d3)

    d2 = np.empty(4)
    d3 = np.empty(5)
    raises(AssertionError, Lay.build_layer, d1, d2, d3)
Ejemplo n.º 6
0
def test_rotation_matrix_within_GGS_class_value_check2():
    '''Checks compartibility of between given and calculated
    rotation matrix when lat and lon are equal to 90'''
    lat = 90.
    lon = 90.
    R_calc = GGS().rotation_matrix(lon,lat)
    R_obs = [0., 0., 1., 0., -1., 0., -1., 0.]
    npt.assert_almost_equal(R_calc,R_obs,decimal=15)