Example #1
0
 def test_default_projection_and_extent(self):
     self.assertEqual(iplt.default_projection(self.cube),
                      ccrs.PlateCarree())
     np_testing.assert_array_almost_equal(
         iplt.default_projection_extent(self.cube),
         [0., 360., -89.99995422, 89.99998474])
     np_testing.assert_array_almost_equal(
         iplt.default_projection_extent(self.cube,
                                        mode=iris.coords.BOUND_MODE),
         [-1.875046, 358.124954, -90, 90])
Example #2
0
 def test_default_projection_and_extent(self):
     self.assertEqual(iplt.default_projection(self.cube),
                      ccrs.PlateCarree())
     np_testing.assert_array_almost_equal(
         iplt.default_projection_extent(self.cube),
         [0., 360., -89.99995422, 89.99998474])
     np_testing.assert_array_almost_equal(
         iplt.default_projection_extent(
             self.cube, mode=iris.coords.BOUND_MODE),
         [-1.875046, 358.124954, -91.24995422, 91.24998474])
Example #3
0
 def test_default_projection_and_extent(self):
     self.assertEqual(
         iplt.default_projection(self.cube),
         ccrs.PlateCarree(globe=self.cube.coord_system(
             "CoordSystem").as_cartopy_globe()),
     )
     np_testing.assert_array_almost_equal(
         iplt.default_projection_extent(self.cube),
         [0.0, 360.0, -89.99995422, 89.99998474],
     )
     np_testing.assert_array_almost_equal(
         iplt.default_projection_extent(self.cube,
                                        mode=iris.coords.BOUND_MODE),
         [-1.875046, 358.124954, -90, 90],
     )
Example #4
0
    def test_default_projection_and_extent(self):
        self.assertEqual(iplt.default_projection(self.cube),
                         ccrs.RotatedPole(357.5 - 180, 37.5))

        np_testing.assert_array_almost_equal(
            iplt.default_projection_extent(self.cube),
            (313.01998901, 391.11999512, -22.48999977, 24.80999947))
Example #5
0
    def _goplot(self, sender):
        """Create the cube_browser.Plot2D and cube_browser.Browser"""
        IPython.display.clear_output()
        fig = plt.figure(figsize=(16, 7))
        sub_plots = 110
        if self._subplots.value == 2:
            sub_plots = 120

        confs = []
        for spl, pc in enumerate(self.plot_controls):
            spl += 1
            cube = None
            if pc.cube_picker.value is not None:
                cube = self.cubes[pc.cube_picker.value]
            if cube and spl <= self._subplots.value:
                pc_x_name = pc.x_coord.value
                pc_y_name = pc.y_coord.value
                x_coords = cube.coords(axis='X', dim_coords=True)
                if len(x_coords) == 1:
                    x_name = x_coords[0].name()
                else:
                    x_name = None
                y_coords = cube.coords(axis='Y', dim_coords=True)
                if len(y_coords) == 1:
                    y_name = y_coords[0].name()
                else:
                    y_name = None
                if x_name == pc_x_name and y_name == pc_y_name:
                    proj = iplt.default_projection(cube) or ccrs.PlateCarree()
                    ax = fig.add_subplot(sub_plots + spl, projection=proj)
                    # If the spatial extent is small, use high-res coastlines
                    extent = iplt.default_projection_extent(cube)
                    x0, y0 = ccrs.PlateCarree().transform_point(extent[0],
                                                                extent[2],
                                                                proj)
                    x1, y1 = ccrs.PlateCarree().transform_point(extent[1],
                                                                extent[3],
                                                                proj)
                    if x1-x0 < 20 and y1-y0 < 20:
                        ax.coastlines(resolution='10m')
                    elif x1-x0 < 180 and y1-y0 < 90:
                        ax.coastlines(resolution='50m')
                    else:
                        ax.coastlines()
                else:
                    ax = plt.gca()
                    ax = fig.add_subplot(sub_plots+spl)
                plot_type = pc.plot_type
                coords = [pc_x_name, pc_y_name]
                confs.append(plot_type.value(cube, ax, coords=coords,
                                             **pc.mpl_kwargs))
                title = cube.name().replace('_', ' ').capitalize()
                ax.set_title(title)
        self.browser = cube_browser.Browser(confs)
        self.browser.on_change(None)
        # For each PlotControl, assign the plot's mpl_kwargs back to
        # that PlotControl.
        for pc, plot in zip(self.plot_controls, confs):
            pc.mpl_kwargs = plot.kwargs
        self._plot_container.children = [self.browser.form]
Example #6
0
    def test_default_projection_and_extent(self):
        self.assertEqual(iplt.default_projection(self.cube),
                         ccrs.RotatedPole(357.5 - 180, 37.5,
                                          globe=_DEFAULT_GLOBE))

        np_testing.assert_array_almost_equal(
            iplt.default_projection_extent(self.cube),
            (313.01998901, 391.11999512, -22.48999977, 24.80999947))
Example #7
0
    def test_default_projection_and_extent(self):
        self.assertEqual(iplt.default_projection(self.cube),
                         ccrs.RotatedPole(357.5 - 180, 37.5))

        np_testing.assert_array_almost_equal(
            iplt.default_projection_extent(self.cube),
            (3.59579163e+02, 3.59669159e+02, -1.28250003e-01, -3.82499993e-02),
            decimal=3)
Example #8
0
    def test_default_projection_and_extent(self):
        self.assertEqual(iplt.default_projection(self.cube),
                         ccrs.RotatedPole(357.5 - 180, 37.5,
                                          globe=_DEFAULT_GLOBE))

        np_testing.assert_array_almost_equal(
            iplt.default_projection_extent(self.cube),
            (3.59579163e+02, 3.59669159e+02, -1.28250003e-01, -3.82499993e-02),
            decimal=3)