Exemplo n.º 1
0
    def _spherical_to_cartesian(self, lon, lat, i, j):
        """Takes latitude, longitude arrays and returns cartesian unit vector.

        Latitude and longitude must be in degrees and must have already been 
        shifted .5 pixels as calculated from corners keyword of heliographic
        function. i and j represent the shift and thus corner.
        i, j
        0, 0: top-left
        1, 0: bottom-left
        1, 1: bottom-right
        0, 1: top-right
        """
        coslat = M.cos(lat)
        coslon = M.cos(lon)
        sinlat = M.sin(lat)
        sinlon = M.sin(lon)
        l = len(lat)
        Xar = coslat[i:l - 1 + i, j:l - 1 + j]*coslon[i:l - 1 + i, j:l - 1 + j]
        Yar = coslat[i:l - 1 + i, j:l - 1 + j]*sinlon[i:l - 1 + i, j:l - 1 + j]
        Zar = sinlat[i:l - 1 + i, j:l - 1 + j]
        r = np.ndarray(shape=(3,), dtype=np.object)
        r[0] = Xar
        r[1] = Yar
        r[2] = Zar
        return r
Exemplo n.º 2
0
    def _hpc_hcc(self, x, y):
        """Converts hpc coordinates to hcc coordinates. 

        x -- x coordinate in arcseconds
        y -- y coordinate in arcseconds
        Calculations taken and shortened from sunpy.wcs.
        """
        x *= np.deg2rad(1)/3600.0
        y *= np.deg2rad(1)/3600.0

        q = self.dsun * M.cos(y) * M.cos(x)
        distance = q**2 - self.dsun**2 + self.RSUN_METERS**2
        distance = q - M.sqrt(distance)
        
        rx = distance * M.cos(y) * M.sin(x)
        ry = distance * M.sin(y)
        rz = M.sqrt(self.RSUN_METERS**2 - rx**2 - ry**2)

        return rx, ry, rz
Exemplo n.º 3
0
    def los_corr(self, *args, array=True):
        """Takes in coordinates and returns corrected magnetic field.

        Applies the dot product between the observers unit vector and
        the heliographic radial vector to get the true magnitude of 
        the magnetic field vector. See geometric projection for
        calulations.
        """

        print("Correcting line of sight magnetic field.")
        if array:
            try:
                lonh, lath = M.deg2rad(self.lonh), M.deg2rad(self.lath)
            except AttributeError:
                self.heliographic()
                lonh, lath = M.deg2rad(self.lonh), M.deg2rad(self.lath)
        else:
            lonh, lath = M.deg2rad(self.heliographic(args[0], args[1]))

        B0 = M.deg2rad(self.B0)
        L0 = M.deg2rad(self.L0)

        Xobs = M.cos(B0)*M.cos(L0)
        Yobs = M.cos(B0)*M.sin(L0)
        Zobs = M.sin(B0)

        corr_factor = (M.cos(lath)*M.cos(lonh)*Xobs
                + M.cos(lath)*M.sin(lonh)*Yobs
                + M.sin(lath)*Zobs)

        if array:
            self.im_corr = self.im_raw_u/corr_factor
            bad_ind = np.where(self.rg > self.rsun*np.sin(75.0*np.pi/180))
            self.im_corr[bad_ind] = np.nan
            return
        else:
            return self.im_raw.data[args[0], args[1]]/corr_factor
Exemplo n.º 4
0
    def _hcc_hg(self, x, y, z):
        """Converts hcc coordinates to Stonyhurst heliographic. 

        x - x coordinate in meters
        y - y coordinate in meters 
        z - z coordinate in meters
        Calculations taken and shortened
        from sunpy.wcs.
        """
        cosb = M.cos(M.deg2rad(self.B0))
        sinb = M.sin(M.deg2rad(self.B0))

        hecr = M.sqrt(x**2 + y**2 + z**2)
        hgln = M.arctan2(x, z*cosb - y*sinb) \
                + M.deg2rad(self.L0)
        hglt = M.arcsin((y * cosb + z * sinb)/hecr)

        return hgln*180/np.pi, hglt*180/np.pi