effluent.io

The package contains functions and classes for reading and writing simulation data.

Classes

Ambient

Data about the ambient ocean.

AmbientRoms

Data about the ambient ocean, from ROMS.

AmbientXarray

Data about the ambient ocean, from in-memory dataset.

Output

Class for writing simulation output to disk

OutputCSV

Class for writing simulation output to CSV file.

OutputNC

Class for writing simulation output to netCDF file.

Pipe

Data about the pipe and the effluent release.

Functions

append_xr_to_nc(xr_dset, nc_dset)

Append data from an xarray.Dataset to a netCDF4.Dataset

convert_to_nc_date(xr_var[, units, calendar, dtype])

Convert an xarray date variable to a CF-style date variable

read_csv(file)

Read csv file, and return a pandas.DataFrame

write_nc_to_xr(nc_dset, xr_dset)

Write data from a netCDF4.Dataset to a an xarray.Dataset

write_xr_to_nc(xr_dset, nc_dset)

Write data from an xarray.Dataset to a netCDF4.Dataset

Module Contents

class effluent.io.Ambient

Data about the ambient ocean.

This is an abstract base class with no explicit constructor. To initialize an instance of the class, use the factory method.

close()

Close the underlying data source

static from_config(conf)

Initialize using configuration parameters

Parameters:

conf – A dict of configuration parameters

Returns:

An initialized object

Return type:

Ambient

abstract select(time)

Compute the ambient conditions at a specific time.

Parameters:

time – A numpy.datetime64 object

Returns:

An xarray.Dataset object with variables u, v and dens, all indexed by the coordinate depth.

Return type:

xarray.Dataset

class effluent.io.AmbientRoms(file, latitude, longitude, azimuth)

Bases: Ambient

Data about the ambient ocean, from ROMS.

This subclass is using ROMS output files as its data source. The constructor also needs the pipe position and azimuth, as described in the documentation of the configuration file.

The class lazily opens the underlying data source the first time it’s needed.

Parameters:
  • file – A set of ROMS files, specified with a wildcard string

  • latitude – The pipe latitude

  • longitude – The pipe longitude

  • azimuth – The pipe azimuth (north = 0, east = 90)

close()

Close the underlying data source

select(time)

Compute the ambient conditions at a specific time.

Parameters:

time – A numpy.datetime64 object

Returns:

An xarray.Dataset object with variables u, v and dens, all indexed by the coordinate depth.

Return type:

xarray.Dataset

class effluent.io.AmbientXarray(dset)

Bases: Ambient

Data about the ambient ocean, from in-memory dataset.

This subclass is using an xarray.Dataset object as its data source. The dataset should have variables u, v and dens, all indexed by the coordinates depth and time.

Parameters:

dset – An xarray.Dataset object

select(time)

Compute the ambient conditions at a specific time.

Parameters:

time – A numpy.datetime64 object

Returns:

An xarray.Dataset object with variables u, v and dens, all indexed by the coordinate depth.

Return type:

xarray.Dataset

class effluent.io.Output

Class for writing simulation output to disk

This is an abstract base class with no explicit constructor. To initialize an instance of the class, use the factory method.

close()

Close the underlying data stream

static from_config(conf)

Initialize using configuration parameters

Parameters:

conf – A dict of configuration parameters

Returns:

An initialized object

Return type:

Output

abstract write(time, result)

Write simulation results to disk

Parameters:
class effluent.io.OutputCSV(file, variables=None, float_format='%.10g', separator=',')

Bases: Output

Class for writing simulation output to CSV file.

The output file is created lazily upon the first write statement.

Parameters:
  • file – Name of output file

  • variables – A list of variable names to include

  • float_format – Output format for float numbers

  • separator – Symbol used as data separator

close()

Close the underlying data stream

static from_config(conf)

Initialize using configuration parameters

Parameters:

conf – A dict of configuration parameters

Returns:

An initialized object

Return type:

OutputCSV

write(time, result)

Write simulation results to disk

Parameters:
class effluent.io.OutputNC(file, variables)

Bases: Output

Class for writing simulation output to netCDF file.

The output file is created lazily upon the first write statement.

Parameters:
  • file – Name of output file

  • variables – A list of variable names to include

close()

Close the underlying data stream

static from_config(conf)

Initialize using configuration parameters

Parameters:

conf – A dict of configuration parameters

Returns:

An initialized object

Return type:

OutputNC

write(time, result)

Write simulation results to disk

Parameters:
class effluent.io.Pipe(dset)

Data about the pipe and the effluent release.

The constructor takes an xarray.Dataset object as input. If the source data is in the form of a data file, the factory method should be used instead.

Parameters:

dset – An xarray.Dataset object with variables depth, u, w, dens and diam, all indexed by the coordinate time.

static from_config(conf)

Initialize using configuration parameters

Parameters:

conf – A dict of configuration parameters

Returns:

An initialized object

Return type:

Pipe

select(time)

Interpolate pipe parameters to a specific point in time

Parameters:

time – A time in numpy.datetime64 format

Returns:

An xarray.Dataset object with variables depth, u, w, dens and diam.

Return type:

xarray.Dataset

effluent.io.append_xr_to_nc(xr_dset, nc_dset)

Append data from an xarray.Dataset to a netCDF4.Dataset

This method does not create new variables in the destination dataset, but only appends to the existing variables.

Parameters:
effluent.io.convert_to_nc_date(xr_var, units='seconds since 1970-01-01', calendar='proleptic_gregorian', dtype='i8')

Convert an xarray date variable to a CF-style date variable

On default, the xarray date will be converted to seconds (int64) since the unix epoch (1970-01-01) using the proleptic gregorian calendar.

Parameters:
  • xr_var (xarray.Variable) – Input variable, with values of type numpy.datetime64

  • units (str) – Output units, as defined by CF conventions

  • calendar (str) – Output calendar, as defined by CF conventions

  • dtype – Output data type, as defined by numpy conventions

Returns:

Output variable, with values converted to seconds since epoch

Return type:

xarray.Variable

effluent.io.read_csv(file)

Read csv file, and return a pandas.DataFrame

Parameters:

file – File name

Returns:

A pandas.DataFrame object

Return type:

pandas.DataFrame

effluent.io.write_nc_to_xr(nc_dset, xr_dset)

Write data from a netCDF4.Dataset to a an xarray.Dataset

Parameters:
effluent.io.write_xr_to_nc(xr_dset, nc_dset)

Write data from an xarray.Dataset to a netCDF4.Dataset

Parameters: