Exemple #1
0
def test_corner_to_point():
    corner = (36.5, -97.5)
    point = (36.4, -97.6)
    with warnings.catch_warnings():  # invalid divide is handled by code
        warnings.simplefilter("ignore", category=DeprecationWarning)
        x, y = transforms.corner_to_point(corner, point)
    assert round(x) == -8950.
    assert round(y) == -11119.0
Exemple #2
0
def test_corner_to_point():
    corner = (36.5, -97.5)
    point = (36.4, -97.6)
    with warnings.catch_warnings():  # invalid divide is handled by code
        warnings.simplefilter("ignore", category=DeprecationWarning)
        x, y = transforms.corner_to_point(corner, point)
    assert round(x) == -8950.
    assert round(y) == -11119.0
def test_corner_to_point():
    corner = (36.5, -97.5)
    point = (36.4, -97.6)
    x, y = transforms.corner_to_point(corner, point)
    assert round(x) == -8950.
    assert round(y) == -11119.0
    def __init__(self, size=(800, 800), name="Radar Loop",
                 timer_interval=1.0,
                 num_radars=1,
                 radar_filenames=None,
                 radar_latlons=None,
                 radar_fields=None,
                 time_start=None, time_end=None,
                 loop_step=10, image_duration=10):

        '''
        Parameters
        ----------
        size : 2-tuple int
            (x, y) size in pixels of window.
        name : str
            Name to use in window label.
        timer_interval : float
            Interval at which to update data in window.
        num_radars : int
            The number of radars to display.
        radar_filenames : list
            List of radar filenames to process. This can be a list of lists
            if multiple radars are desired. num_radars must be > 1.
        radar_latlons : list of tuples
            List of (latitude, longitude) coordinates. This can be a list
            the same length as radar_filenames. num_radars must be > 1.
        time_start : datetime instance
            Start time to use for subset.
        time_end : datetime instance
            End time to use for subset.
        loop_step : float
            Seconds between image update in frame.
        image_duration : float
            Seconds that each image will last in frame.
        '''
        # self.vb = scene.widgets.ViewBox(parent=self.scene, border_color='b')
        # vb.camera.rect = 0, 0, 1, 1

        # self.rotation = MatrixTransform()

        # Perform a couple of checks
        if radar_filenames is None:
            print("Must provide a list of filenames!")
            return
        if (num_radars > 1) & (len(radar_filenames) != num_radars) & (len(radar_latlons) != num_radars):
            print("ERROR: Must provide filenames and lat-lons for each radar!")
            return

        # Prepare some variables if two radars are chosen
        self.radar_filenames = radar_filenames
        self.t_start = time_start
        self.t_end = time_end
        self.rnum = num_radars
        self.loop_dt = np.timedelta64(loop_step * 1000000000, 'ns')
        self.loop_duration = np.timedelta64(image_duration * 1000000000, 'ns')

        # Read in the radar files into a collection
        self.rfc = []
        self.rfc = []
        for ii in range(self.rnum):
            self.rfc.append(RadarFileCollection(self.radar_filenames[ii]))

##        self.rfc = RadarFileCollection(filenames)
        self.rfc_88d = RadarFileCollection(filenames_88d)

        # Initialize variables for later use
        self.dx, self.dy = [], []
        if radar_fields is None:
            self.radar_fields = ['reflectivity']
        else:
            self.radar_fields = [radar_fields[0]]

        # Find corner points if required
        if len(radar_latlons) > 1:
            for num in range(1, len(radar_latlons)):
                dx_tmp, dy_tmp = corner_to_point(radar_latlons[num], radar_latlons[num-1]) #meters
                self.dx.append(dx_tmp)
                self.dy.append(dy_tmp)
                try:
                    self.radar_fields.append(radar_fields[num])
                except:
                    self.radar_fields.append('reflectivity')

        # Generate dummy data to initialize the Mesh instance
        x, y, z, d = radar_example_data()
        # print x.shape, y.shape, z.shape
        # print d.shape, d.min(), d.max()
        mesh = self._init_mesh(x, y, z, d)
        mesh_88d = self._init_mesh(x, y, z, d)

        # Use colormapping class from matplotlib
        self.DZcm = ScalarMappable(norm=Normalize(-25,80), cmap='gist_ncar')
        self.VRcm = ScalarMappable(norm=Normalize(-32,32), cmap='PuOr_r')
        self.SWcm = ScalarMappable(norm=Normalize(0.0,5.0), cmap='cubehelix_r')

        self.radar_mesh = mesh
        self.mesh_88d = mesh_88d
        self.meshes = (mesh, mesh_88d)

        self.rot_view = None

        vispy.scene.SceneCanvas.__init__(self, keys='interactive',
                                         title=name, size=size, show=True)

        view = self.central_widget.add_view()
        view.camera = 'turntable'
        view.camera.mode = 'ortho'
        view.camera.up = 'z'
        view.camera.distance = 20
        self.rot_view = view

        for a_mesh in self.meshes:
            self.rot_view.add(a_mesh)

        self.unfreeze() # allow addition of new attributes to the canvas
        self.t1 = Text('Time', parent=self.scene, color='white')
        self.t1.font_size = 18
        self.t1.pos = self.size[0] // 2, self.size[1] // 10

        self.loop_reset()
        self.timer = vispy.app.Timer(connect=self.loop_radar)
        self.timer.start(timer_interval)
Exemple #5
0
def test_corner_to_point():
    corner = (36.5, -97.5)
    point = (36.4, -97.6)
    x, y = transforms.corner_to_point(corner, point)
    assert round(x) == -8950.
    assert round(y) == -11119.0