Ejemplo n.º 1
0
 def _test_swan(self, testfile):
     print("Reading %s" % testfile)
     self.s = read_swan(testfile)
     fileout = os.path.join(TMP_DIR, 'test.spec')
     print("Writing %s" % fileout)
     self.s.spec.to_swan(fileout)
     print("Verifying %s" % fileout)
     tmpspec = read_swan(fileout)
     check_equal(self.s, tmpspec)
Ejemplo n.º 2
0
 def test_swan(self):
     for testfile in SWAN_TEST_FILES:
         print("Reading %s" % testfile)
         self.s = read_swan(testfile)
         fileout = os.path.join(TMP_DIR,
                                os.path.basename(testfile) + '.json')
         print("Writing %s" % fileout)
         self.s.spec.to_json(fileout)
Ejemplo n.º 3
0
            y = _infer_interval_breaks(y, check_monotonic=True)
        else:
            # we have to infer the intervals on both axes
            y = _infer_interval_breaks(y, axis=1)
            y = _infer_interval_breaks(y, axis=0)

    primitive = ax.pcolormesh(x, y, z, **kwargs)

    # by default, pcolormesh picks "round" values for bounds
    # this results in ugly looking plots with lots of surrounding whitespace
    if not hasattr(ax, "projection") and x.ndim == 1 and y.ndim == 1:
        # not a cartopy geoaxis
        ax.set_xlim(x[0], x[-1])
        ax.set_ylim(y[0], y[-1])

    if clean_radius:
        ax.set_rticks([])
    if clean_sector:
        ax.set_xticks([])

    return primitive


if __name__ == "__main__":
    import matplotlib.pyplot as plt
    from wavespectra import read_swan

    dset = read_swan("../tests/sample_files/swanfile.spec", as_site=True)
    dset.isel(site=0).efth.spec.plot(col="time", col_wrap=3)
    plt.show()
"""
Spectrum as contourf
====================

Contourf type plot of wave spectrum

"""
import matplotlib.pyplot as plt
from wavespectra import read_swan

dset = read_swan("../_static/swanfile.spec", as_site=True)
ds = dset.isel(site=0, time=0)
fig = plt.figure(figsize=(6, 4))
p = ds.spec.plot.contourf()
Ejemplo n.º 5
0
 def setup_class(self):
     """Read test spectra from file."""
     here = os.path.dirname(os.path.abspath(__file__))
     self.swanspec = read_swan(os.path.join(FILES_DIR, 'swanfile.spec'))
Ejemplo n.º 6
0
 def test_swan_files(self):
     for swanfile in SWAN_TEST_FILES:
         print("Reading %s" % swanfile)
         self.s = read_swan(swanfile)
         self._test_netcdf(swanfile)
Ejemplo n.º 7
0
    def setup_class(self):
        """Read test spectra and pre-calculated stats from file."""

        self.control = pd.read_csv(os.path.join(FILES_DIR, "swanfile.txt"),
                                   sep="\t")
        self.swanspec = read_swan(os.path.join(FILES_DIR, "swanfile.spec"))
Ejemplo n.º 8
0
 def setup_class(self):
     """Read test spectra and pre-calculated stats from file."""
     self.swanspec = read_swan(os.path.join(FILES_DIR, "swanfile.spec"))
     self.wshed = self.swanspec.spec.partition(self.swanspec.wspd,
                                               self.swanspec.wdir,
                                               self.swanspec.dpt)
Ejemplo n.º 9
0
def dset():
    filename = os.path.join(FILES_DIR, "swanfile.spec")
    _dset = read_swan(filename)
    yield _dset
Ejemplo n.º 10
0
def load_specdataset():
    """Load SpecDset but skip test if matplotlib is not installed."""
    pytest.importorskip("matplotlib")
    dset = read_swan(os.path.join(FILES_DIR, "swanfile.spec"), as_site=True)
    return dset