effluent.io¶
The package contains functions and classes for reading and writing simulation data.
Classes¶
Data about the ambient ocean. |
|
Data about the ambient ocean, from ROMS. |
|
Data about the ambient ocean, from in-memory dataset. |
|
Class for writing simulation output to disk |
|
Class for writing simulation output to CSV file. |
|
Class for writing simulation output to netCDF file. |
|
Data about the pipe and the effluent release. |
Functions¶
|
Append data from an xarray.Dataset to a netCDF4.Dataset |
|
Convert an xarray date variable to a CF-style date variable |
|
Read csv file, and return a pandas.DataFrame |
|
Write data from a netCDF4.Dataset to a an xarray.Dataset |
|
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:
- 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,vanddens, all indexed by the coordinatedepth.- Return type:
- class effluent.io.AmbientRoms(file, latitude, longitude, azimuth)¶
Bases:
AmbientData 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,vanddens, all indexed by the coordinatedepth.- Return type:
- class effluent.io.AmbientXarray(dset)¶
Bases:
AmbientData 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,vanddens, all indexed by the coordinatesdepthandtime.- 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,vanddens, all indexed by the coordinatedepth.- Return type:
- 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:
- abstract write(time, result)¶
Write simulation results to disk
- Parameters:
time – Discharge time, as numpy.datetime64 object
result – Simulation result, as returned by
effluent.solver.Solver.solve()
- class effluent.io.OutputCSV(file, variables=None, float_format='%.10g', separator=',')¶
Bases:
OutputClass 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:
- write(time, result)¶
Write simulation results to disk
- Parameters:
time – Discharge time, as numpy.datetime64 object
result – Simulation result, as returned by
effluent.solver.Solver.solve()
- class effluent.io.OutputNC(file, variables)¶
Bases:
OutputClass 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:
- write(time, result)¶
Write simulation results to disk
- Parameters:
time – Discharge time, as numpy.datetime64 object
result – Simulation result, as returned by
effluent.solver.Solver.solve()
- 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,densanddiam, all indexed by the coordinatetime.
- static from_config(conf)¶
Initialize using configuration parameters
- Parameters:
conf – A dict of configuration parameters
- Returns:
An initialized object
- Return type:
- 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,densanddiam.- Return type:
- 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:
xr_dset (xarray.Dataset) – Input dataset
nc_dset (netCDF4.Dataset) – Output dataset
- 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:
- effluent.io.read_csv(file)¶
Read csv file, and return a pandas.DataFrame
- Parameters:
file – File name
- Returns:
A pandas.DataFrame object
- Return type:
- effluent.io.write_nc_to_xr(nc_dset, xr_dset)¶
Write data from a netCDF4.Dataset to a an xarray.Dataset
- Parameters:
nc_dset (netCDF4.Dataset) – Input dataset
xr_dset (xarray.Dataset) – Output dataset
- effluent.io.write_xr_to_nc(xr_dset, nc_dset)¶
Write data from an xarray.Dataset to a netCDF4.Dataset
- Parameters:
xr_dset (xarray.Dataset) – Input dataset
nc_dset (netCDF4.Dataset) – Output dataset