src.netcdf_helper module¶
-
class
src.netcdf_helper.NetcdfHelper[source]¶ Bases:
object-
classmethod
nc_crop_time_axis(time_var_name, date_range, in_file=None, out_file=None, cwd=None, dry_run=False)[source]¶
-
classmethod
-
src.netcdf_helper._nco_outfile_decorator(function)[source]¶ Wrapper handling cleanup for NCO operations that modify files. NB must come between classmethod and base function definition. See https://stackoverflow.com/a/18732038.
-
class
src.netcdf_helper.NcoNetcdfHelper[source]¶ Bases:
src.netcdf_helper.NetcdfHelper-
static
_run_command(command, env=None, cwd=None, timeout=0, dry_run=False)¶ Subprocess wrapper to facilitate running single command without starting a shell.
Note
We hope to save some process overhead by not running the command in a shell, but this means the command can’t use piping, quoting, environment variables, or filename globbing etc.
See documentation for the Python2 subprocess module.
- Parameters
command (list of
str) – List of commands to executeenv (
dict, optional) – environment variables to set, passed to Popen, default None.cwd (
str, optional) – child processes’ working directory, passed to Popen. Default is None, which uses parent processes’ directory.timeout (
int, optional) – Optionally, kill the command’s subprocess and raise a CalledProcessError if the command doesn’t finish in timeout seconds.
- Returns
listofstrcontaining output that was written to stdout by each command. Note: this is split on newlines after the fact.- Raises
CalledProcessError – If any commands return with nonzero exit code. Stderr for that command is stored in output attribute.
-
static