wavespectra.input.swan.read_swans#

wavespectra.input.swan.read_swans(fileglob, ndays=None, int_freq=True, int_dir=False, dirorder=True, ntimes=None)[source]#

Read multiple SWAN ASCII files into single Dataset.

Parameters:
  • fileglob (-) – glob pattern specifying files to read.

  • ndays (-) – number of days to keep from the start of each file, choose None to keep the entire period. Useful for constructing continuous timeseries from files of overlapping forecast cycles. Reading stops once the period is read and an exception is raised if a file does not span the requested period.

  • int_freq (-) –

    frequency array for interpolating onto:

    • ndarray: 1d array specifying frequencies to interpolate onto.

    • True: logarithm array is constructed such that fmin=0.0418 Hz, fmax=0.71856 Hz, df=0.1f.

    • False: No interpolation performed in frequency space.

  • int_dir (-) –

    direction array for interpolating onto:

    • ndarray: 1d array specifying directions to interpolate onto.

    • True: circular array is constructed such that dd=10 degrees.

    • False: No interpolation performed in direction space.

  • dirorder (-) – if True ensures directions are sorted.

  • ntimes (-) – number of times to read from the start of each file, choose None to read all times. Reading stops early once the records are read which makes it useful for quickly inspecting the first few records of large files. Can be combined with ndays, whichever limit is reached first stops the reading.

Returns:

spectra dataset object read from file with

different sites and cycles concatenated along the ‘site’ and ‘time’ dimensions.

Return type:

  • dset (SpecDataset)

Note

  • If multiple cycles are provided, ‘time’ coordinate is replaced by ‘cycletime’ multi-index coordinate.

  • If more than one cycle is prescribed from fileglob, each cycle must have same number of sites.

  • Either all or none of the spectra in fileglob must have tabfile associated to provide wind/depth data.

  • Winds and depth from tab files are sliced at the times actually read when the ndays or ntimes options are used.

  • Concatenation is done with numpy arrays for efficiency.