Ejemplo n.º 1
0
 def test_check_standard_model(self):
     """Test that standard model outputs nothing if there are no changes to
        the standard model
     """
     model = sami2py.Model(tag='test', lon=256, year=1999, day=256,
                           test=True)
     keys = model.check_standard_model()
     assert keys == list()
Ejemplo n.º 2
0
 def test_model_repr(self):
     """Test that __repr__ returns a string of information."""
     model = sami2py.Model(tag='test',
                           lon=self.lon,
                           year=self.year,
                           day=self.day,
                           test=True)
     repr_str = model.__repr__()
     assert type(repr_str) is str
Ejemplo n.º 3
0
 def test_model_instantiation(self):
     """Test that model object is instantiated as a sami2py_model
     """
     model = sami2py.Model(tag='test',
                           lon=self.lon,
                           year=self.year,
                           day=self.day,
                           test=True,
                           outn=True)
     assert isinstance(model, sami2py.Model)
Ejemplo n.º 4
0
    def test_to_netcdf(self):
        """Test that output file is correctly generated"""
        model = sami2py.Model(tag='test',
                              lon=self.lon,
                              year=self.year,
                              day=self.day,
                              test=True,
                              outn=True)
        model.to_netcdf()
        path = 'sami2py_output.nc'
        savedat = xr.load_dataset(path)
        os.remove(path)

        assert model.data == savedat
Ejemplo n.º 5
0
    def test_to_netcdf_w_path(self):
        """Test that output file is correctly generated"""
        model = sami2py.Model(tag='test',
                              lon=self.lon,
                              year=self.year,
                              day=self.day,
                              test=True,
                              outn=True)
        path = 'custom_filename.nc'
        model.to_netcdf(path=path)
        savedat = xr.load_dataset('custom_filename.nc')
        os.remove(path)

        assert model.data == savedat
Ejemplo n.º 6
0
    def test_check_standard_model(self):
        """Test that standard model outputs nothing if there are no changes to
           the standard model / changes to EUV in unformatted version
        """
        model = sami2py.Model(tag='test',
                              lon=self.lon,
                              year=self.year,
                              day=self.day,
                              test=True)
        keys = model.check_standard_model()

        if self.day == 256:
            assert keys == list()
        else:
            assert 'EUV Multiplier' in keys
Ejemplo n.º 7
0
 def test_model_plot(self):
     """Basic test that a reasonable plot has been created by testing the
        resulting axis limits
     """
     import matplotlib
     matplotlib.use('Agg')
     import matplotlib.pyplot as plt
     model = sami2py.Model(tag='test', lon=256, year=1999, day=256,
                           test=True)
     model.plot_lat_alt()
     fig = plt.gcf()
     xlims = fig.axes[0].get_xlim()
     ylims = fig.axes[0].get_ylim()
     assert xlims == (-36.3329, 19.37387)
     assert ylims == (84.98926, 1999.998)
     plt.close()
Ejemplo n.º 8
0
    def test_model_plot(self):
        """Basic test that a reasonable plot has been created by testing the
           resulting axis limits
        """
        import matplotlib

        model = sami2py.Model(tag='test',
                              lon=self.lon,
                              year=self.year,
                              day=self.day,
                              test=True)
        fig = model.plot_lat_alt()
        assert isinstance(fig, matplotlib.figure.Figure)

        tol = 1.e-4
        xlims = fig.axes[0].get_xlim()
        ylims = fig.axes[0].get_ylim()
        assert abs(xlims[0] + 36.3329) < tol
        assert abs(xlims[1] - 19.37387) < tol
        assert abs(ylims[0] - 84.98926) < tol
        assert abs(ylims[1] - 1999.998) < tol
        matplotlib.pyplot.close(fig)
Ejemplo n.º 9
0
 def test_model_input_exception(self):
     """File not found error should be produced if the file does not exist
     """
     with pytest.raises(IOError):
         sami2py.Model(tag='none', lon=428, day=428, year=1969)
Ejemplo n.º 10
0
 def test_model_instantiation_with_unformatted_files_and_mods(self):
     """Test that model object is instantiated as a sami2py_model
     """
     model = sami2py.Model(tag='test', lon=256, year=1999, day=257,
                           test=True)
     assert isinstance(model, sami2py.Model)
Ejemplo n.º 11
0
 def test_model_instantiation(self):
     """Test that model object is instantiated as a sami2py_model
     """
     model = sami2py.Model(tag='test', lon=256, year=1999, day=256,
                           test=True)
     assert isinstance(model, sami2py.Model)