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)
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)
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()
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'))
def test_swan_files(self): for swanfile in SWAN_TEST_FILES: print("Reading %s" % swanfile) self.s = read_swan(swanfile) self._test_netcdf(swanfile)
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"))
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)
def dset(): filename = os.path.join(FILES_DIR, "swanfile.spec") _dset = read_swan(filename) yield _dset
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