Пример #1
0
def SVGTransforms(s,pts):
    pts = [ np.reshape(p+[1],(3,1)) for p in pts ]
    transforms = re.findall("[a-zA-Z]+\([^\)]+\)",s.get('transform') or '')
    # reverse order because SVG transforms apply right-to-left
    transforms.reverse()
    mat = np.identity(3)
    for t in transforms:
        if t.startswith("matrix"):
            t = re.sub("[a-zA-Z]+\(([^\)]+)\)","\\1",t)
            mat = matrixTransform( [ float(n) for n in re.split("[ ,]",t) ], mat )
        # TODO: translate, skewX, skewY transforms
        elif t.startswith("translate"):
            pass
        elif t.startswith("skew"):
            pass
        elif t.startswith("scale"):
            t = re.sub("[a-zA-Z]+\(([^\)]+)\)","\\1",t)
            n = re.split("[ ,]",t)
            sx = float(n[0])
            sy = float(n[1]) if len(n)>1 else sx # y scale is optional
            mat = matrixTransform( [ sx,0,0,sy,0,0 ], mat )
        elif t.startswith("rotate"):
            # TODO: rotate about a given point using translate() and this code
            t = re.sub("[a-zA-Z]+\(([^\)]+)\)","\\1",t)
            n = re.split("[ ,]",t)
            a = float(n[0])
            x = float(n[1]) if len(n)>1 else None
            y = float(n[2]) if len(n)>1 else None
            mat = matrixTransform( [ np.cosd(a), np.sind(a), -np.sind(a), np.cosd(a) ], mat )
    # this is gross
    return [ np.dot(mat,p)[0:2].transpose().tolist()[0] for p in pts ]
Пример #2
0
def SVGTransforms(s, pts):
    pts = [np.reshape(p + [1], (3, 1)) for p in pts]
    transforms = re.findall("[a-zA-Z]+\([^\)]+\)", s.get('transform') or '')
    # reverse order because SVG transforms apply right-to-left
    transforms.reverse()
    mat = np.identity(3)
    for t in transforms:
        if t.startswith("matrix"):
            t = re.sub("[a-zA-Z]+\(([^\)]+)\)", "\\1", t)
            mat = matrixTransform([float(n) for n in re.split("[ ,]", t)], mat)
        # TODO: translate, skewX, skewY transforms
        elif t.startswith("translate"):
            pass
        elif t.startswith("skew"):
            pass
        elif t.startswith("scale"):
            t = re.sub("[a-zA-Z]+\(([^\)]+)\)", "\\1", t)
            n = re.split("[ ,]", t)
            sx = float(n[0])
            sy = float(n[1]) if len(n) > 1 else sx  # y scale is optional
            mat = matrixTransform([sx, 0, 0, sy, 0, 0], mat)
        elif t.startswith("rotate"):
            # TODO: rotate about a given point using translate() and this code
            t = re.sub("[a-zA-Z]+\(([^\)]+)\)", "\\1", t)
            n = re.split("[ ,]", t)
            a = float(n[0])
            x = float(n[1]) if len(n) > 1 else None
            y = float(n[2]) if len(n) > 1 else None
            mat = matrixTransform(
                [np.cosd(a), np.sind(a), -np.sind(a),
                 np.cosd(a)], mat)
    # this is gross
    return [np.dot(mat, p)[0:2].transpose().tolist()[0] for p in pts]
Пример #3
0
    def BuildSphericallyRectSource(ds, a, b, Rs, R):
        """
        Implements a spherical curved rectangular acoustic source pattern

        ds: numeric stepsize
        a:  width of the rect
        b:  height of the rect
        Rs: radius of the source
        r:  radius of the curvature
        Plot: Plotting source distribution

        """

        alpha = np.arcsin(Rs / R) * 180 / np.pi
        L = np.pi * R / 180.0 * alpha

        H = R - np.sqrt(R**2 - Rs**2)
        S = 2 * np.pi * R * H
        l0 = ds * .5
        r0, h0, s0, ll0 = GPSS.SphereSegment(R, l0)

        Xs = Ys = Zs = np.array([])

        nRings = int(np.ceil((L - l0) / ds))

        dRings = L / nRings
        l = l0
        sprev = s0
        nSource = 0

        for iRing in range(1, nRings):
            l += dRings
            r, h, s, ll = GPSS.SphereSegment(R, l)
            sRing = s - sprev
            sprev = s

            nPieces = int(np.ceil(ll / ds))
            dBeta = 360 / nPieces
            nSource += nPieces

            rh, hh, sh, llh = GPSS.SphereSegment(R, l + dRings * .5)

            for iPiece in range(0, nPieces):
                beta = iPiece * dBeta
                if ((np.abs(rh * np.cosd(beta)) < .5 * a) &
                    (np.abs(rh * np.sind(beta)) < .5 * b)):
                    Xs = np.append(Xs, rh * np.sind(beta))
                    Ys = np.append(Ys, rh * np.cosd(beta))
                    Zs = np.append(Zs, hh)

        return Xs, Ys, Zs
def calc_LRT_reflectance(lrt_radf, solar_interp, phase):
    mu = np.cosd(38.5) if phase == 'Liquid Water' else np.cosd(56)
    refl_lrt = [
        np.pi / mu * lrt_radf.values[w] / solar_interp.values[w]
        for w in np.arange(0, len(lrt_radf.wavelength))
    ]

    refl_lrt = xr.DataArray(refl_lrt,
                            dims=['wavelength'],
                            name='lrt reflectances',
                            coords={'wavelength': lrt_radf.wavelength})
    refl_lrt.attrs['COT'] = lrt_radf.attrs['COT']
    refl_lrt.attrs['r_eff'] = lrt_radf.attrs['r_eff']
    return refl_lrt
def psn_bow(lon_now, lat_now, ant2bow, co):  # 경도, 위도, 안테나로부터 선수bow까지 거리(m), 침로
    ant2bow = ant2bow / (1852 * 60)  # meter로 입력받은 길이(m)를 도(deg) 단위로 변환
    lon_psn_bow = lon_now + ant2bow * numpy.cosd(
        gyro2deg(co))  # 선수위치 보정 경도.  도(deg) 단위
    lat_psn_bow = lat_now + ant2bow * numpy.sind(
        gyro2deg(co))  # 선수위치 보정 위도.  도(deg) 단위
    return lon_psn_bow, lat_psn_bow
def psn_eca(lon_bow, lat_bow, co, spd,
            eca_time):  # 선수위치 경도, 선수위치 위도, 침로, 선속, eca시간
    eca_lon = lon_bow + spd / (60 * 60 * 60) * numpy.cosd(
        gyro2deg(co)) * eca_time  # 몇 초뒤 선수위치 경도. 도(deg)단위
    eca_lat = lat_bow + spd / (60 * 60 * 60) * numpy.sind(
        gyro2deg(co)) * eca_time  # 몇 초뒤 선수위치 위도. 도(deg)단위
    return eca_lon, eca_lat
Пример #7
0
def d_sec(co, spd):
    # 첫번째 60 : mile/hr를 deg/hr로 변환.
    # 두번째 60 : deg/hr를 deg/min로 변환.
    # 세번쨰 60 : deg/min를 deg/sec로 변환.
    lon_d_sec=spd/(60*60*60)*numpy.cosd(gyro2deg(co))   #초당 경도 이동거리 (도, deg)
    lat_d_sec=spd/(60*60*60)*numpy.sind(gyro2deg(co))   #초당 위도 이동거리 (도, deg)
    return lon_d_sec, lat_d_sec
def calc_HySICS_reflectance(datacube, solar_interp, phase, x, y):
    f = interp1d(datacube.wavelength,
                 datacube.values[x, y, :],
                 fill_value='NaN')
    hy_new = f(solar_interp.wavelength)

    mu = np.cosd(38.5) if phase == 'Liquid Water' else np.cosd(56)
    refl_HySICS = [
        np.pi / mu * hy_new[w] / solar_interp.values[w]
        for w in np.arange(0, len(solar_interp.wavelength))
    ]

    refl_hysics_pixel = xr.DataArray(
        refl_HySICS,
        dims=['wavelength'],
        name='HySICS reflectance',
        coords={'wavelength': solar_interp.wavelength})
    return refl_hysics_pixel
Пример #9
0
# propiedades del material
E = 2040   # ton/cm^2
k = E*A/L  # rigidez de cada barra

# %% se separa la memoria antes de los cálculos
K   = np.zeros((8,8))
T   = 5*[None]        # MATLAB = cell(5,1) -> separo memoria
idx = 5*[None]

#%% ensamblo la matriz de rigidez global
for e in range(5):  # para cada barra
    # saco los 4 gdls de la barra
    idx[e] = np.r_[gdl[LaG[e,NL1],:], gdl[LaG[e,NL2],:]]

    # matriz de transformacion de coordenadas para la barra e
    c = np.cosd(theta[e]); s = np.sind(theta[e]) # sin y cos de la inclinación
    T[e] = np.array([[ c,  s,  0,  0],           
                     [-s,  c,  0,  0],           
                     [ 0,  0,  c,  s],
                     [ 0,  0, -s,  c]])

    # matriz de rigidez local expresada en el sistema de coordenadas locales 
    # para la barra e
    Kloc = np.array([[ k[e],  0, -k[e],  0],    
                     [ 0,     0,  0,     0],    
                     [-k[e],  0,  k[e],  0],    
                     [ 0,     0,  0,     0]])

    # se ensambla la matriz de rigidez local Ke en la matriz de rigidez global K
    K[np.ix_(idx[e],idx[e])] += T[e].T@Kloc@T[e]
Пример #10
0
    def computeRotWorld(self):
        ##
        Facc_calibNoOut, facc_out = rmo.rmoutliers_percentiles(
            self.Facc_Zero, 1.645, 1.645)
        Macc_calibNoOut, macc_out = rmo.rmoutliers_percentiles(
            self.Macc_Zero, 1.645, 1.645)
        Fgyr_calibNoOut, fgyr_out = rmo.rmoutliers_percentiles(
            self.Fgyr_Zero, 1.645, 1.645)
        Mgyr_calibNoOut, mgyr_out = rmo.rmoutliers_percentiles(
            self.Mgyr_Zero, 1.645, 1.645)

        # Localiser axe gravit� (approx)
        Facc_mean = np.mean(Facc_calibNoOut, axis=1)
        Macc_mean = np.mean(Macc_calibNoOut, axis=1)

        def normVec(V):
            v_norm = V / np.linalg.norm(V)  #np.sqrt(np.dot(V,V))
            return v_norm

        Fgref = normVec(Facc_mean)  #Facc_mean / np.dot(Facc_mean,Facc_mean)
        Mgref = normVec(Macc_mean)  #Macc_mean / np.dot(Macc_mean,Macc_mean)

        # KL - 06nov: ajustement ax gravit�
        Facc_offset = np.mean(Facc_calibNoOut, axis=1) - Fgref
        Macc_offset = np.mean(Macc_calibNoOut, axis=1) - Mgref
        Fgyr_offset = np.mean(Fgyr_calibNoOut, axis=1)
        Mgyr_offset = np.mean(Mgyr_calibNoOut, axis=1)

        # Remarque 1: ***Consid�rer le filtrage?***
        # Remarque 2: En calibrant comme �a, on assume que c'est du bruit de
        # capteur et que ce n'est pas une erreur d'alignement interne... mais
        # bon... on va tenter de palier � tout cela en faisant une certaine
        # it�ration...

        Macc_offset2 = [0, 0, 0]
        Mgyr_offset2 = [0, 0, 0]

        ##
        np.cosd = lambda x: np.cos(np.deg2rad(x))
        np.sind = lambda x: np.sin(np.deg2rad(x))

        ## création de Cterrain
        Cterrain = []
        angTerrain = [0, 0, 0]
        CterrainX = np.matrix(
            [[1, 0, 0], [0, np.cosd(angTerrain[0]), -np.sind(angTerrain[0])],
             [0, np.sind(angTerrain[0]),
              np.cosd(angTerrain[0])]])
        CterrainY = np.matrix(
            [[np.cosd(angTerrain[1]), 0,
              np.sind(angTerrain[1])], [0, 1, 0],
             [-np.sind(angTerrain[1]), 0,
              np.cosd(angTerrain[1])]])
        CterrainZ = np.matrix(
            [[np.cosd(angTerrain[0]), -np.sind(angTerrain[0]), 0],
             [np.sind(angTerrain[0]),
              np.cosd(angTerrain[0]), 0], [0, 0, 1]])

        Cterrain = CterrainX * CterrainY * CterrainZ

        ## search offsets
        Cmobile = []

        for icalib in range(20):
            Macc_offset = Macc_offset + Macc_offset2
            Mgyr_offset = Mgyr_offset + Mgyr_offset2

            ## Cr�ation de vecteurs de l'essai
            Facc_Zero = (Cterrain * self.Facc_Zero).T - Facc_offset
            Macc_Zero = (Cterrain * self.Macc_Zero).T - Macc_offset

            # Fgyr_Zero = self.Fgyr_Zero.T - Fgyr_offset
            # Mgyr_Zero = self.Mgyr_Zero.T - Mgyr_offset

            # Facc_Inclined = (Cterrain * self.Facc_Inclined).T - Facc_offset
            Macc_Inclined = (Cterrain * self.Macc_Inclined).T - Macc_offset

            # Fgyr_Inclined = self.Fgyr_Inclined.T - Fgyr_offset
            Mgyr_Inclined = self.Mgyr_Inclined.T - Mgyr_offset

            ## CALIBRATION POSITIONNEMENT STATIQUE

            # (1) Mesure statique

            # Facc_stat = np.mean(Facc_Zero, axis=0)
            Macc_stat = np.mean(Macc_Zero, axis=0)

            # (2) Inclinaison initiale des IMUs:
            # ** IMU mobile **
            vecG = np.array([0, 0, 1])
            Macc_stat_norm = normVec(np.array(Macc_stat)[0])
            u = normVec(np.cross(vecG, Macc_stat_norm))

            def angRot2Vec(vector_1, vector_2):
                unit_vector_1 = vector_1 / np.linalg.norm(vector_1)
                unit_vector_2 = vector_2 / np.linalg.norm(vector_2)
                dot_product = np.dot(unit_vector_1, unit_vector_2)
                angle = np.arccos(dot_product)
                return angle

            angRot = angRot2Vec(vecG, Macc_stat_norm)

            c = np.cos(angRot)
            s = np.sin(angRot)

            C1_mobile = np.linalg.inv(
                np.matrix([[
                    u[0]**2 + (1 - u[0]**2) * c,
                    u[0] * u[1] * (1 - c) - u[2] * s,
                    u[0] * u[2] * (1 - c) + u[1] * s
                ],
                           [
                               u[0] * u[1] * (1 - c) + u[2] * s,
                               u[1]**2 + (1 - u[1]**2) * c,
                               u[1] * u[2] * (1 - c) - u[0] * s
                           ],
                           [
                               u[0] * u[2] * (1 - c) - u[1] * s,
                               u[1] * u[2] * (1 - c) + u[0] * s,
                               u[2]**2 + (1 - u[2]**2) * c
                           ]]))

            # Correction capteurs dans IMU mobile
            # Macc_cor = (C1_mobile*Macc.T).T
            # Mgyr_cor = (C1_mobile*Mgyr.T).T

            Macc_Zero_cor = (C1_mobile * Macc_Zero.T).T
            # Mgyr_Zero_cor = (C1_mobile * Mgyr_Zero.T).T

            Macc_Inclined_cor = (C1_mobile * Macc_Inclined.T).T
            Mgyr_Inclined_cor = (C1_mobile * Mgyr_Inclined.T).T

            # (3) Axe de rotation (IMU mobile) pendant la bascule

            # Remarque: Trouver de fa�on autonome la p�riode de bascule...
            Macc_Zero_Dir = np.mean(Macc_Zero_cor, axis=0)
            Macc_Inclined_Dir = np.mean(Macc_Inclined_cor, axis=0)

            def vecBasc(Macc_Zero_Dir, Macc_Inclined_Dir):
                vector_1 = np.array([
                    Macc_Zero_Dir[0, 0], Macc_Zero_Dir[0, 1], Macc_Zero_Dir[0,
                                                                            2]
                ])
                vector_2 = np.array([
                    Macc_Inclined_Dir[0, 0], Macc_Inclined_Dir[0, 1],
                    Macc_Inclined_Dir[0, 2]
                ])

                vecRot = np.cross(vector_1, vector_2)
                unit_vecRot = vecRot / np.linalg.norm(vecRot)
                return np.matrix(unit_vecRot)

            vecRot = vecBasc(Macc_Zero_Dir, Macc_Inclined_Dir)

            # La bonne nouvelle c'est que la composante en z est presque nulle...
            # donc l'alignement avec acc�l�ro tiens la route... la petite
            # composante est soit un r�siduel de l'alignement vs offset initial,
            # soit la vibration carr�ment... pour l'instant, je mets de c�t�.

            # Trouvons l'angle de rotation autour de z qui permettra d'avoir une
            # bascule purement en "y".
            ang_Rotz = math.atan2(vecRot[0, 0], vecRot[0, 1])
            Mat_Rotz = np.matrix([[np.cos(ang_Rotz), -np.sin(ang_Rotz), 0],
                                  [np.sin(ang_Rotz),
                                   np.cos(ang_Rotz), 0], [0, 0, 1]])

            # v�rification axe bascule:
            # test = Mat_Rotz * vecRot.T
            # print(test)
            # OK... pas mal �a... reste la petite composante en z mais...

            # Matrice alignement principale (mobile)
            Cmobile = Mat_Rotz * C1_mobile

            # On va essayer d'optimiser un peu en validant pour 3 vecteurs...
            # (i) vecteur statique initial, normalis�...
            vecIni = np.mean(Macc_Zero, axis=0)
            # vecIni = vecIni / sqrt(vecIni*vecIni')
            vecIni_al = Cmobile * vecIni.T
            # (iii) Vecteur de bascule
            vecBascule = vecRot
            vecBascule_al = Cmobile * vecBascule.T

            # Avecteur devrait s'approcher de Adesire
            Avecteur = np.concatenate((vecIni_al.T, vecBascule_al.T))
            Adesire = np.matrix([[0, 0, 1], [0, 1, 0]])

            Macc_offset2 = Avecteur[0, :] - Adesire[0, :]
            Mgyr_offset2 = Avecteur[1, :] - Adesire[1, :]

        ## (4) Optimisation du d�couplage correction angulaire vs offset pour le
        #    IMU fixe
        Fgyr_offset2 = [0, 0, 0]
        Facc_offset2 = [0, 0, 0]

        # # ORIGINAL
        # Facc_offset = np.mean(self.Facc_Zero, axis=1) - [0, 0, 1]
        # Fgyr_offset = np.mean(self.Fgyr_Zero, axis=1)

        # Filtre pour gyro
        # [B,A] = butter(3,0.3/0.5,"low") #a optimiser
        w = 0.3 / 0.5  # Normalize the frequency
        b, a = signal.butter(3, w, 'low')
        ntaps = max(len(a), len(b))

        Facc = (Cterrain * self.Facc_Inclined).T - Facc_offset

        signalToFilter = (Cterrain * self.Fgyr_Inclined)
        if signalToFilter.shape[1] > ntaps:
            Fgyr = signal.filtfilt(a, b, signalToFilter).T - Fgyr_offset
        else:
            Fgyr = signalToFilter.T - Fgyr_offset

        # Macc = (Cterrain * self.Macc_Inclined).T - Macc_offset

        # signalToFilter = (Cterrain * self.Mgyr_Inclined)
        # if signalToFilter.shape[1] > ntaps:
        #     Mgyr = signal.filtfilt(a, b, signalToFilter).T - Mgyr_offset
        # else:
        #     Mgyr = signalToFilter.T - Mgyr_offset

        ##
        Cfixe = []
        for j in range(20):
            # Fgyr_offset = Fgyr_offset + Fgyr_offset2
            Facc_offset = Facc_offset + Facc_offset2

            ## Cr�ation de vecteurs de l'essai
            Facc_Zero = (Cterrain * self.Facc_Zero).T - Facc_offset
            # Fgyr_Zero = self.Fgyr_Zero.T - Fgyr_offset

            # Inclinaison IMU fixe
            Facc_stat = np.mean(Facc_Zero, axis=0)

            vecG = np.array([0, 0, 1])
            Facc_stat_norm = normVec(np.array(Facc_stat)[0])
            u = normVec(np.cross(vecG, Macc_stat_norm))

            def angRot2Vec(vector_1, vector_2):
                unit_vector_1 = vector_1 / np.linalg.norm(vector_1)
                unit_vector_2 = vector_2 / np.linalg.norm(vector_2)
                dot_product = np.dot(unit_vector_1, unit_vector_2)
                angle = np.arccos(dot_product)
                return angle

            angRot = angRot2Vec(vecG, Facc_stat_norm)

            c = np.cos(angRot)
            s = np.sin(angRot)

            C1_fixe = np.linalg.inv(
                np.matrix([[
                    u[0]**2 + (1 - u[0]**2) * c,
                    u[0] * u[1] * (1 - c) - u[2] * s,
                    u[0] * u[2] * (1 - c) + u[1] * s
                ],
                           [
                               u[0] * u[1] * (1 - c) + u[2] * s,
                               u[1]**2 + (1 - u[1]**2) * c,
                               u[1] * u[2] * (1 - c) - u[0] * s
                           ],
                           [
                               u[0] * u[2] * (1 - c) - u[1] * s,
                               u[1] * u[2] * (1 - c) + u[0] * s,
                               u[2]**2 + (1 - u[2]**2) * c
                           ]]))

            # Correction capteurs dans IMU fixe
            Facc_cor = (C1_fixe * Facc_Zero.T).T
            # Fgyr_cor = (C1_fixe * Fgyr_Zero.T).T

            Facc_offset2 = np.mean(Facc_cor, axis=0) - [0, 0, 1]
            # Fgyr_offset2 = np.mean(Fgyr_cor, axis=0)
            Cfixe = C1_fixe

        self.Cterrain = Cterrain
        self.Facc_offset = Facc_offset
        self.Fgyr_offset = Fgyr_offset
        self.Macc_offset = Macc_offset
        self.Mgyr_offset = Mgyr_offset

        self.Cfixe = Cfixe
        self.Cmobile = Cmobile

        self.isRotWorld = True
        print(self.getRotWorld())
        self.saveToJson()

        self.computeAngle(self.Facc_Zero, self.Fgyr_Zero, self.Macc_Zero,
                          self.Mgyr_Zero)

        self.computeAngle(self.Facc_Inclined, self.Fgyr_Inclined,
                          self.Macc_Inclined, self.Mgyr_Inclined)
Пример #11
0
os_lat_now=[os_lat+i*d_sec(os_co,os_spd)[1] for i in range(0,time_limit)] # 출발지를 기준으로 매초 안테나 위치 위도
os_lon_bow=psn_bow(os_lon_now,os_lat_now,os_ant2bow,os_co)[0]  # 각 시점의 선수위치 경도
os_lat_bow=psn_bow(os_lon_now,os_lat_now,os_ant2bow,os_co)[1]  # 각 시점의 선수위치 경도

# 타선데이터
ts_lon_now=[ts_lon+i*d_sec(ts_co,ts_spd)[0] for i in range(0,time_limit)] # 출발지를 기준으로 매초 안테나 위치 경도
ts_lat_now=[ts_lat+i*d_sec(ts_co,ts_spd)[1] for i in range(0,time_limit)] # 출발지를 기준으로 매초 안테나 위치 위도
ts_lon_bow=psn_bow(ts_lon_now,ts_lat_now,ts_ant2bow,ts_co)[0]   # 각 시점의 선수위치 경도
ts_lat_bow=psn_bow(ts_lon_now,ts_lat_now,ts_ant2bow,ts_co)[1]   # 각 시점의 선수위치 위도
ts_lon_eca=psn_eca(ts_lon_bow,ts_lat_bow,ts_co,ts_spd,eca_time)[0]   # 각 시점에서 eca_time(sec)가 지난 후 선수위치 경도
ts_lat_eca=psn_eca(ts_lon_bow,ts_lat_bow,ts_co,ts_spd,eca_time)[1]   # 각 시점에서 eca_time(sec)가 지난 후 선수위치 위도


' ECA_TIME뒤 본선과 상대선의 선수위치 시계열데이터 '
ts_lon_eca=ts_lon_bow+ts_spd/(60*60*60)*numpy.sind(ts_co)*eca_time # 타선의 eca_time(sec) 뒤 경도
ts_lat_eca=ts_lat_bow+ts_spd/(60*60*60)*numpy.cosd(ts_co)*eca_time # 타선의 eca_time(sec) 뒤 위도

import math
' 두 점의 상대방위를 구하는 함수  '
def rel_brg(pointA,pointB):
    pointA=tuple(pointA)
    pointB=tuple(pointB)

    lat1 = math.radians(pointA[1])
    lat2 = math.radians(pointB[1])
    diffLong = math.radians(pointB[0] - pointA[0])

    x = math.sin(diffLong) * math.cos(lat2)
    y = math.cos(lat1) * math.sin(lat2) - (math.sin(lat1)
        * math.cos(lat2) * math.cos(diffLong))
Пример #12
0
    ts_lat + i * d_sec(ts_co, ts_spd)[1] for i in range(0, time_limit)
]  # 출발지를 기준으로 매초 안테나 위치 위도
ts_lon_bow = psn_bow(ts_lon_now, ts_lat_now, ts_ant2bow,
                     ts_co)[0]  # 각 시점의 선수위치 경도
ts_lat_bow = psn_bow(ts_lon_now, ts_lat_now, ts_ant2bow,
                     ts_co)[1]  # 각 시점의 선수위치 위도
ts_lon_eca = psn_eca(ts_lon_bow, ts_lat_bow, ts_co, ts_spd,
                     eca_time)[0]  # 각 시점에서 eca_time(sec)가 지난 후 선수위치 경도
ts_lat_eca = psn_eca(ts_lon_bow, ts_lat_bow, ts_co, ts_spd,
                     eca_time)[1]  # 각 시점에서 eca_time(sec)가 지난 후 선수위치 위도

' 타선의 몇 분뒤 선수위치 시계열데이터 '
ts_lon_eca = ts_lon_bow + ts_spd / (
    60 * 60 * 60) * numpy.sind(ts_co) * eca_time  # 타선의 eca_time(sec) 뒤 경도
ts_lat_eca = ts_lat_bow + ts_spd / (
    60 * 60 * 60) * numpy.cosd(ts_co) * eca_time  # 타선의 eca_time(sec) 뒤 위도

' 본선의 현재 선수위치와 상대선의 몇초뒤 선수위치 간의 상대방위 계산 예) 앞 0 뒤 180 좌 270 우 90 '
rel_brg = [
    rel_brg([os_lon_bow[i], os_lat_bow[i]], [ts_lon_eca[i], ts_lat_eca[i]])
    for i in range(0, time_limit)
]

' 본선의 현재 선수위치와 상대선의 몇초뒤 선수위치 간의 거리 계산 '
dist_eca = [
    math.sqrt((os_lon_bow[i] - ts_lon_eca[i])**2 +
              (os_lat_bow[i] - ts_lat_eca[i])**2)
    for i in range(0, time_limit)
]  # deg 단위

' TCPA, DCPA 계산 알고리즘 - 한국해양대 제공본 수정 ----------------------------'
Пример #13
0
def vecX(xdeg):  # For positive xdeg=cwRoll: +y=>+z; +z=>-y.
    c = np.cosd(xdeg)
    s = np.sind(xdeg)
    return np.array([[1, 0, 0], [0, c, -s], [0, +s, c]])
Пример #14
0
    def ejecutar_trigo(self, funcion):
        if funcion.funcion == 'acos':
            try:

                return np.acos(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en acos ')
                return 0
        elif funcion.funcion == 'acosd':
            try:
                return np.acosd(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en acosd ')
                return 0
        elif funcion.funcion == 'asin':
            try:
                return np.asin(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en asin ')
                return 0
        elif funcion.funcion == 'asind':
            try:
                return np.asind(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en asind ')
                return 0
        elif funcion.funcion == 'atan':
            try:
                return np.atan(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores ')
                return 0
        elif funcion.funcion == 'atand':
            try:
                return np.atand(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores atand ')
                return 0
        elif funcion.funcion == 'atan2':
            try:
                return np.atan2(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en atan2 ')
                return 0
        elif funcion.funcion == 'cos':
            try:
                return np.cos(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en cos ')
                return 0
        elif funcion.funcion == 'cosd':
            try:
                return np.cosd(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores cosd cosd')
                return 0
        elif funcion.funcion == 'cot':
            try:
                return np.cot(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores cot')
                return 0
        elif funcion.funcion == 'cotd':
            try:
                return np.cotd(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en cotd ')
                return 0
        elif funcion.funcion == 'sin':
            try:
                return np.sin(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en sin ')
                return 0
        elif funcion.funcion == 'sind':
            try:
                return np.sind(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en sind ')
                return 0
        elif funcion.funcion == 'tan':
            try:
                return np.tan(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en tan ')
                return 0
        elif funcion.funcion == 'tand':
            try:
                return np.tand(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en tand')
                return 0
        elif funcion.funcion == 'sinh':
            try:
                return np.sinh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en sinh')
                return 0
        elif funcion.funcion == 'cosh':
            try:
                return np.cosh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en cosh ')
                return 0
        elif funcion.funcion == 'tanh':
            try:
                return np.tanh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en tanh ')
                return 0
        elif funcion.funcion == 'asinh':
            try:
                return np.asinh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en asinh')
                return 0
        elif funcion.funcion == 'acosh':
            try:
                return np.acosh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en acosh ')
                return 0
        elif funcion.funcion == 'atanh':
            try:
                return np.atanh(self.aritexc.ejecutar_operacion(funcion.op1))
            except:
                errorsem.append('error al convertir valores en atanh ')
                return 0
Пример #15
0
def vecY(ydeg):  # For positive ydeg=-elev: +z=>+x; +x=>-z.
    # do not overlook this minus sign: positive ydeg pitches downward.
    c = np.cosd(ydeg)
    s = np.sind(ydeg)
    return np.array([[c, 0, +s], [0, 1, 0], [-s, 0, c]])
Пример #16
0
def vecZ(zdeg):  # For positive zdeg=+az: +x=>+y; +y=>-x.
    c = np.cosd(zdeg)
    s = np.sind(zdeg)
    return np.array([[c, -s, 0], [+s, c, 0], [0, 0, 1]])
Пример #17
0
    ts_lat + i * d_sec(ts_co, ts_spd)[1] for i in range(0, time_limit)
]  # 출발지를 기준으로 매초 안테나 위치 위도
ts_lon_bow = psn_bow(ts_lon_now, ts_lat_now, ts_ant2bow,
                     ts_co)[0]  # 각 시점의 선수위치 경도
ts_lat_bow = psn_bow(ts_lon_now, ts_lat_now, ts_ant2bow,
                     ts_co)[1]  # 각 시점의 선수위치 위도
ts_lon_eca = psn_eca(ts_lon_bow, ts_lat_bow, ts_co, ts_spd,
                     eca_time)[0]  # 각 시점에서 eca_time(sec)가 지난 후 선수위치 경도
ts_lat_eca = psn_eca(ts_lon_bow, ts_lat_bow, ts_co, ts_spd,
                     eca_time)[1]  # 각 시점에서 eca_time(sec)가 지난 후 선수위치 위도

' ECA_TIME뒤 본선과 상대선의 선수위치 시계열데이터 '
ts_lon_eca = ts_lon_bow + ts_spd / (
    60 * 60 * 60) * numpy.sind(ts_co) * eca_time  # 타선의 eca_time(sec) 뒤 경도
ts_lat_eca = ts_lat_bow + ts_spd / (
    60 * 60 * 60) * numpy.cosd(ts_co) * eca_time  # 타선의 eca_time(sec) 뒤 위도

import math
' 두 점의 상대방위를 구하는 함수  '


def rel_brg(pointA, pointB):
    pointA = tuple(pointA)
    pointB = tuple(pointB)

    lat1 = math.radians(pointA[1])
    lat2 = math.radians(pointB[1])
    diffLong = math.radians(pointB[0] - pointA[0])

    x = math.sin(diffLong) * math.cos(lat2)
    y = math.cos(lat1) * math.sin(lat2) - (math.sin(lat1) * math.cos(lat2) *
Пример #18
0
fe = [np.array(v) for v in fe]  # convierto todas esas listas a arrays de NumPy

# %% separo la memoria
K = np.zeros((ngdl, ngdl))  # matriz de rigidez global
f = np.zeros(ngdl)  # vector de fuerzas nodales equivalentes global
Ke = nb * [None]  # matriz de rigidez local en coordenadas globales
T = nb * [None]  # matriz de transfor(mación de coordenadas
idx = np.zeros((nb, 6), dtype=int)  # almacena los 6 gdls de las barras

# %% ensamblo la matriz de rigidez global (K) y vector de fuerzas global (f)
for e in range(nb):  # para cada barra
    # saco los 6 gdls de la barra e
    idx[e] = np.r_[gdl[LaG[e, NL1], :], gdl[LaG[e, NL2], :]]

    # matriz de transformaciÓn de coordenadas para la barra e
    c = np.cosd(theta[e])
    s = np.sind(theta[e])
    T[e] = np.array([[c, s, 0, 0, 0, 0], [-s, c, 0, 0, 0,
                                          0], [0, 0, 1, 0, 0, 0],
                     [0, 0, 0, c, s, 0], [0, 0, 0, -s, c, 0],
                     [0, 0, 0, 0, 0, 1]])

    # matriz de rigidez local expresada en el sistema de coordenadas locales
    # para la barra e
    AE = A[e] * E
    EI = E * I[e]
    L = long[e]
    L2 = long[e]**2
    L3 = long[e]**3
    Kloc = np.array(
        [[AE / L, 0, 0, -AE / L, 0, 0],