wavespectra.SpecDataset.to_swan#

SpecDataset.to_swan(filename, append=False, id='Created by wavespectra', ntime=None, lons=None, lats=None, compresslevel=6)#

Write spectra in SWAN ASCII format.

Args:
  • filename (str): str, name for output SWAN ASCII file.

  • append (bool): if True append to existing filename.

  • id (str): used for header in output file.

  • ntime (int, None): number of times to load into memory before dumping output file if full dataset does not fit into memory, choose None to load all times.

  • lons: (np.array, None): longitudes to use for each site, if None use.

  • lats: (np.array, None): latitudes to use for each site, if None use.

  • compresslevel (int): compression level for gzip compression (1-9).

Note:
  • Output files are gzipped if filename ends with .gz.

  • lons/lats parameters may be prescribed to set site locations if lon/lat are not variables in the dataset (their sizes must match the number of sites).

  • If lons/lats are not specified and the dataset does not have lon/lat coords, all coordinates default to zero.

  • Extra dimensions other than time, site, lon, lat, freq, dim not yet supported.

  • Only 2D spectra E(f,d) are currently supported.

  • ntime=None optimises speed as the dataset is loaded into memory however the dataset may not fit into memory in which case a smaller number of times may be prescribed.