Exemplo n.º 1
0
    def _draw_grid(self, fig, axes, grid_spacing=20):
        """Draws a grid over the surface of the Sun"""
        # define the number of points for each latitude or longitude line
        num_points = 20
        hg_longitude_deg = np.linspace(-90, 90, num=num_points)
        hg_latitude_deg = np.arange(-90, 90, grid_spacing)

        # draw the latitude lines
        for lat in hg_latitude_deg:
            hg_latitude_deg_mesh, hg_longitude_deg_mesh = np.meshgrid(
                lat * np.ones(num_points), hg_longitude_deg)
            x, y = wcs.convert_hg_hpc(self.rsun_meters,
                                      self.dsun, self.heliographic_latitude,
                                      self.heliographic_longitude,
                                      hg_longitude_deg_mesh,
                                      hg_latitude_deg_mesh, units='arcsec')
            axes.plot(x, y, color='white', linestyle='dotted')

        hg_longitude_deg = np.arange(-90, 90, grid_spacing)
        hg_latitude_deg = np.linspace(-90, 90, num=num_points)

        # draw the longitude lines
        for lon in hg_longitude_deg:
            hg_longitude_deg_mesh, hg_latitude_deg_mesh = np.meshgrid(
                lon * np.ones(num_points), hg_latitude_deg)
            x, y = wcs.convert_hg_hpc(self.rsun_meters,
                                      self.dsun, self.heliographic_latitude,
                                      self.heliographic_longitude,
                                      hg_longitude_deg_mesh,
                                      hg_latitude_deg_mesh, units='arcsec')
            axes.plot(x, y, color='white', linestyle='dotted')

        return fig, axes
Exemplo n.º 2
0
def test_conv_hg_hpc():
    coord = [34.0, 96.0]
    result = wcs.convert_hg_hpc(img.rsun_arcseconds, img.dsun, 
                                img.heliographic_latitude,
                                img.heliographic_longitude,
                                coord[0], coord[1])
    assert_array_almost_equal(result, [0.096365756, 0.22138465], decimal=2)
Exemplo n.º 3
0
def test_conv_hg_hpc():
    coord = [34.0, 45.0]
    result = wcs.convert_hg_hpc(img.rsun_meters, img.dsun, 
                                img.heliographic_latitude,
                                img.heliographic_longitude,
                                coord[0], coord[1])
    known_answer = [0.10603822, 0.20752017]
    magnitude = np.floor(np.log10(known_answer))
    assert_array_almost_equal(result*10**(-magnitude), 
                              known_answer*10**(-magnitude), decimal=2)
Exemplo n.º 4
0
def test_conv_hg_hpc():
    coord = [34.0, 45.0]
    result = wcs.convert_hg_hpc(img.rsun_meters, img.dsun,
                                img.heliographic_latitude,
                                img.heliographic_longitude, coord[0], coord[1])
    known_answer = [0.10603822, 0.20752017]
    magnitude = np.floor(np.log10(known_answer))
    assert_array_almost_equal(result * 10**(-magnitude),
                              known_answer * 10**(-magnitude),
                              decimal=2)
Exemplo n.º 5
0
    def _draw_grid(self, fig, axes, grid_spacing=20):
        """Draws a grid over the surface of the Sun"""
        # define the number of points for each latitude or longitude line
        num_points = 20
        hg_longitude_deg = np.linspace(-90, 90, num=num_points)
        hg_latitude_deg = np.arange(-90, 90, grid_spacing)

        # draw the latitude lines
        for lat in hg_latitude_deg:
            hg_latitude_deg_mesh, hg_longitude_deg_mesh = np.meshgrid(lat * np.ones(num_points), hg_longitude_deg)
            x, y = wcs.convert_hg_hpc(self.header, hg_longitude_deg_mesh, hg_latitude_deg_mesh, units="arcsec")
            axes.plot(x, y, color="white", linestyle="dotted")

        hg_longitude_deg = np.arange(-90, 90, grid_spacing)
        hg_latitude_deg = np.linspace(-90, 90, num=num_points)

        # draw the longitude lines
        for lon in hg_longitude_deg:
            hg_longitude_deg_mesh, hg_latitude_deg_mesh = np.meshgrid(lon * np.ones(num_points), hg_latitude_deg)
            x, y = wcs.convert_hg_hpc(self.header, hg_longitude_deg_mesh, hg_latitude_deg_mesh, units="arcsec")
            axes.plot(x, y, color="white", linestyle="dotted")

        return fig, axes
Exemplo n.º 6
0
    def _draw_grid(self, fig, axes, grid_spacing=20):
        """Draws a grid over the surface of the Sun"""
        # define the number of points for each latitude or longitude line
        num_points = 20
        hg_longitude_deg = np.linspace(-90, 90, num=num_points)
        hg_latitude_deg = np.arange(-90, 90, grid_spacing)

        # draw the latitude lines
        for lat in hg_latitude_deg:
            hg_latitude_deg_mesh, hg_longitude_deg_mesh = np.meshgrid(
                lat * np.ones(num_points), hg_longitude_deg)
            x, y = wcs.convert_hg_hpc(self.rsun_meters,
                                      self.dsun,
                                      self.heliographic_latitude,
                                      self.heliographic_longitude,
                                      hg_longitude_deg_mesh,
                                      hg_latitude_deg_mesh,
                                      units='arcsec')
            axes.plot(x, y, color='white', linestyle='dotted')

        hg_longitude_deg = np.arange(-90, 90, grid_spacing)
        hg_latitude_deg = np.linspace(-90, 90, num=num_points)

        # draw the longitude lines
        for lon in hg_longitude_deg:
            hg_longitude_deg_mesh, hg_latitude_deg_mesh = np.meshgrid(
                lon * np.ones(num_points), hg_latitude_deg)
            x, y = wcs.convert_hg_hpc(self.rsun_meters,
                                      self.dsun,
                                      self.heliographic_latitude,
                                      self.heliographic_longitude,
                                      hg_longitude_deg_mesh,
                                      hg_latitude_deg_mesh,
                                      units='arcsec')
            axes.plot(x, y, color='white', linestyle='dotted')

        return fig, axes
Exemplo n.º 7
0
Arquivo: map.py Projeto: hbain/sunpy
    def draw_grid(self, axes=None, grid_spacing=20):
        """Draws a grid over the surface of the Sun
        
        Parameters
        ----------
        axes: matplotlib.axes object or None
        Axes to plot limb on or None to use current axes.
        
        grid_spacing: float
            Spacing (in degrees) for longitude and latitude grid.
        
        Returns
        -------
        matplotlib.axes object
        """

        if not axes:
            axes = plt.gca()

        x, y = self.pixel_to_data()
        rsun = self.rsun_meters
        dsun = self.dsun

        b0 = self.heliographic_latitude
        l0 = self.heliographic_longitude
        units = [self.units.get('x'), self.units.get('y')]

        #TODO: This function could be optimized. Does not need to convert the entire image
        # coordinates
        lon_self, lat_self = wcs.convert_hpc_hg(rsun, dsun, units[0], units[1], b0, l0, x, y)
        # define the number of points for each latitude or longitude line
        num_points = 20
        
        #TODO: The following code is ugly. Fix it.
        lon_range = [lon_self.min(), lon_self.max()]
        lat_range = [lat_self.min(), lat_self.max()]
        if np.isfinite(lon_range[0]) == False: 
            lon_range[0] = -90 + self.heliographic_longitude
        if np.isfinite(lon_range[1]) == False: 
            lon_range[1] = 90 + self.heliographic_longitude
        if np.isfinite(lat_range[0]) == False: 
            lat_range[0] = -90 + self.heliographic_latitude
        if np.isfinite(lat_range[1]) == False: 
            lat_range[1] = 90 + self.heliographic_latitude

        hg_longitude_deg = np.linspace(lon_range[0], lon_range[1], num=num_points)
        hg_latitude_deg = np.arange(lat_range[0], lat_range[1]+grid_spacing, grid_spacing)

        # draw the latitude lines
        for lat in hg_latitude_deg:
            hg_latitude_deg_mesh, hg_longitude_deg_mesh = np.meshgrid(
                lat * np.ones(num_points), hg_longitude_deg)
            x, y = wcs.convert_hg_hpc(self.rsun_meters,
                                      self.dsun, self.heliographic_latitude,
                                      self.heliographic_longitude,
                                      hg_longitude_deg_mesh,
                                      hg_latitude_deg_mesh, units='arcsec')
            axes.plot(x, y, color='white', linestyle='dotted')
            
        hg_longitude_deg = np.arange(lon_range[0], lon_range[1]+grid_spacing, grid_spacing)
        hg_latitude_deg = np.linspace(lat_range[0], lat_range[1], num=num_points)

        # draw the longitude lines
        for lon in hg_longitude_deg:
            hg_longitude_deg_mesh, hg_latitude_deg_mesh = np.meshgrid(
                lon * np.ones(num_points), hg_latitude_deg)
            x, y = wcs.convert_hg_hpc(self.rsun_meters,
                                      self.dsun, self.heliographic_latitude,
                                      self.heliographic_longitude,
                                      hg_longitude_deg_mesh,
                                      hg_latitude_deg_mesh, units='arcsec')
            axes.plot(x, y, color='white', linestyle='dotted')
            
        axes.set_ylim(self.yrange)
        axes.set_xlim(self.xrange)

        return axes
Exemplo n.º 8
0
def test_conv_hg_hpc():
    coord = [34.0, 96.0]
    result = wcs.convert_hg_hpc(header, coord[0], coord[1])
    assert_array_almost_equal(result, [0.096365756, 0.22138465], decimal=2)
Exemplo n.º 9
0
i0 = smap.Map('./ssw_cutout_20110607_063514_AIA_211_.fts')
if i0.shape[0] > 2048:
    i0 = i0.resample((2048,2048))
x = -320
y = -364
step = 0.1
times = 720 # around focus
velocity = 700 # km/s
cadence = 200 # sec
lonlat = wcs.convert_hpc_hg(x, y, dsun_meters = i0.meta['dsun_obs'])
start_point_xyz = greatcircle.lonlatr2GCircleStart(lonlat[0], lonlat[1])
lonlatgc = greatcircle.GCircle2lonlatr(greatcircle.GreatCircle(start_point_xyz, step = step, times = times))

xycoord = [wcs.convert_hg_hpc(line[0] , line[1], 
                              dsun_meters = i0.meta['dsun_obs'], 
                              occultation = True) for line in lonlatgc]

pxcoord = [np.array(np.round(np.nan_to_num(wcs.convert_data_to_pixel(line[0], line[1], 
                                                                     i0.scale.values(), i0.reference_pixel.values(), 
                                                                     [0,0]))), #i0.reference_coordinate.values()))),
                    dtype = np.int) for line in xycoord]
pxcoord_arr = np.array(pxcoord) # shape for default -> (360,2,180)
# Convert the values from physical to pixel values
deltaX = wcs.rsun_meters * np.deg2rad(step) / 1e3 # km
velocity_px = velocity / deltaX
deltaT = 1 / velocity_px # sec
cadencewave = int(cadence / deltaT)
front = int(150e3 / deltaX)
# Create the wave 
wavearr, tsteps = wave.wave(len(line[0]), velocity = velocity_px, cadence = cadencewave,