コード例 #1
0
ファイル: test_compress.py プロジェクト: akleeman/slocum
 def test_version_assert(self):
     # create a forecast that looks like its from a newer version
     # and make sure an assertion is raised.
     ds = create_data()
     original_version = compress._VERSION
     compress._VERSION = np.array(compress._VERSION + 1, dtype=np.uint8)
     beaufort = compress.compress_dataset(ds)
     compress._VERSION = original_version
     self.assertRaises(ValueError,
                       lambda: compress.decompress_dataset(beaufort))
コード例 #2
0
ファイル: test_interactive.py プロジェクト: akleeman/slocum
def main():
    fcst = test_data()
    fcst = compress.decompress_dataset(compress.compress_dataset(fcst))

    for vn in ['current', 'wind']:
        variable = query_utils.get_variable(vn)
        if isinstance(variable, schemes.VelocityVariable):
            interactive.InteractiveVelocity(fcst, variable)

    plt.show()
コード例 #3
0
ファイル: request.py プロジェクト: akleeman/slocum
def process_query(query, url=None):
    """
    Takes a query and returns the corresponding tiny forecast.
    """
    # log the query so debugging others request failures will be easier.
    logging.debug(json.dumps(query))
    # Acquires a forecast corresponding to a query
    fcst = get_forecast(query, url=url)
    compressed_forecast = compress.compress_dataset(fcst)
    logging.debug("Compressed Size: %d" % len(compressed_forecast))
    return compressed_forecast
コード例 #4
0
ファイル: test_compress.py プロジェクト: akleeman/slocum
    def test_compress_dataset(self):
        ds = create_data()
        compressed = compress.compress_dataset(ds)
        actual = compress.decompress_dataset(compressed)

        np.testing.assert_allclose(actual['x_wind'].values, ds['x_wind'].values,
                                   atol=1e-4, rtol=1e-4)
        np.testing.assert_allclose(actual['y_wind'].values, ds['y_wind'].values,
                                   atol=1e-4, rtol=1e-4)
        np.testing.assert_allclose(actual['air_pressure_at_sea_level'].values,
                                   ds['air_pressure_at_sea_level'].values,
                                   atol=1e-4, rtol=1e-4)
        # pass it through the system again, it should be idempotent.
        compressed = compress.compress_dataset(ds)
        actual = compress.decompress_dataset(compressed)
        np.testing.assert_allclose(actual['x_wind'].values, ds['x_wind'].values,
                                   atol=1e-4, rtol=1e-4)
        np.testing.assert_allclose(actual['y_wind'].values, ds['y_wind'].values,
                                   atol=1e-4, rtol=1e-4)
        np.testing.assert_allclose(actual['air_pressure_at_sea_level'].values,
                                   ds['air_pressure_at_sea_level'].values,
                                   atol=1e-4, rtol=1e-4)