netcdf4_interface#

ioapps.netcdf4_interface.nccheck(ncfile, ncfrmt=None)[source]#

DESCRIPTION:

This function checks whether a given file path is a netCDF-formatted file and returns a boolean valued variable specifying such.

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file to be read.

Returns:
is_ncfile: bool

A Python boolean valued variable specifying whether the specified input file is a netCDF-formatted file.

Return type:

bool

ioapps.netcdf4_interface.ncconcat(ncfilelist, ncfile, ncdim, ncfrmt=None)[source]#

DESCRIPTION:

This function concatenates a list of netCDF-formatted files, provided in ncfilelist, into a single file (ncfile); the concatenation is performed along a single specified dimension (ncdim); optional arguments enable the format of the concatenated file to be specified.

Parameters:
ncfilelist: List

A Python string containing the list of netCDF files to be concatenated.

ncfile: str

A Python string specifying the netCDF file(to be created) containing the concatenated values collected from each of the files to be concatenated.

ncdim: str

A Python string specifying the netCDF variable dimension along which to concatenated the respective netCDF files list.

Return type:

None

ioapps.netcdf4_interface.nccopy(ncfilein, ncfileout, ncfrmtout, ncfrmtin=None, ncvarlist=None, ncunlimval=None, use_nccopy=False)[source]#

DESCRIPTION:

This function performs a direct copy of an input netCDF-formattedfile to a specified output netCDF-formatted file of a specified format.

Parameters:
ncfilein: str

A Python string specifying the input netCDF-formatted file to be copied.

ncfileout: str

A Python string specifying the netCDF file(to be created) containing the contents of the input netCDF file.

ncfrmtout: str

A Python string specifying the format of the netCDF file to be created; available options are NETCDF4, NETCDF4_CLASSIC, NETCDF3_CLASSIC, NETCDF3_64BIT_OFFSET, or NETCDF3_64BIT_DATA.

Raises:
NetCDF4InterfaceError:
  • raised if the netCDF nccopy application output file form is not supported.

Return type:

None

ioapps.netcdf4_interface.nccopyvar(ncfilein, ncfileout, ncvarname, ncvar, ncout_mode, ncfrmtin=None, ncfrmtout=None)[source]#

DESCRIPTION:

This function performs a direct copy of a specified variable from a specified input file to a specified output file.

Parameters:
ncfilein: str

A Python string specifying the input(source) netCDF-formatted file.

ncfileout: str

A Python string specifying the output(destination) netCDF-formatted file.

ncvarname: str

A Python string specifying the netCDF variable to be copied.

ncvar: numpy.array

A Python array containing the values for the respective netCDF variable.

ncout_mode: str

A Python string specifying the write-mode for the output netCDF-formatted file; this should typically be either ‘w’ for a new netCDF-formatted file write(this will clobber any previous existence of ncfileout) or ‘a’ to append to an existing netCDF-formatted file.

Return type:

None

ioapps.netcdf4_interface.ncnumvar(ncfile, ncfrmt=None)[source]#

DESCRIPTION:

This function parses a netCDF-formatted file to determine the total number of variable arrays within the respective file.

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file to be read.

Returns:
numvar: int

A Python integer specifying the total number of variable arrays within the respective netCDF-formatted input file.

Return type:

int

ioapps.netcdf4_interface.ncreaddim(ncfile, ncdimname, ncfrmt=None)[source]#

DESCRIPTION:

This function parses a netCDF-formatted file to collect and return the dimension size for the specified dimension variable name.

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file to be read.

ncdimname: str

A Python string specifying the netCDF dimension to be retrieved and returned.

Returns:
ncdim: int

A Python integer specifying the value for the specified dimension variable.

Return type:

int

ioapps.netcdf4_interface.ncreadattr(ncfile, ncattrname, ncvarname=None, ncfrmt=None)[source]#

DESCRIPTION:

This function parses a netCDF-formatted file to collect the specified netCDF attribute value(s)

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file to be read.

ncattrname: str

A Python string specifying the netCDF attribute to collect and return.

Returns:
ncattr: Union[str, float, int, Tuple]

A Python type containing the value(s) for the specified netCDF attribute.

Return type:

Union[str, float, int, Tuple]

ioapps.netcdf4_interface.ncvarexist(ncfile, ncvarname, ncfrmt=None)[source]#

DESCRIPTION:

This function reads a netCDF-formatted file and queries the variable list for the existence of a specified variable name (ncvarname); it returns a boolean values indicating whether the variable name has been found.

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file to be read.

ncvarname: str

A Python string specifying the netCDF variable to be queried.

Returns:
ncvarexist: bool

A Python boolean variable indicating whether the queried variable exists within the respective netCDF file.

Return type:

bool

ioapps.netcdf4_interface.ncvarlist(ncfile, ncfrmt=None)[source]#

DESCRIPTION:

This function reads and returns a list of variables within the netCDF-formatted file specified upon entry.

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file to be read.

Returns:
varlist: List

A Python list of variables within the netCDF-formatted file specified upon entry.

Return type:

List

ioapps.netcdf4_interface.ncwrite(ncfile, ncdim_obj, ncvar_obj, ncfrmt=None, glbattrs_dict=None)[source]#

DESCRIPTION:

This function writes a netCDF-formatted file, containing the specified dimensions, variables, and (optional) attributes.

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file (to be created).

ncdim_obj: object

A Python object containing the dimension variable attributes for the netCDF-formatted file (to be created).

ncvar_obj: object

A Python object containing the variable attributes for the netCDF-formatted file (to be created).

Return type:

None

ioapps.netcdf4_interface.ncwritevar(ncfile, ncvarname, ncvar, ncfrmt=None)[source]#

DESCRIPTION:

This function opens a netCDF-formatted file and writes the array (ncvar) values for the specified variable to the respective (open) netCDF-formatted file.

Parameters:
ncfile: str

A Python string specifying the netCDF-formatted file to be written to.

ncvarname: str

A Python string specifying the netCDF variable to be written/updated.

ncvar: numpy.array

A Python array containing the values for the specified netCDF variable.

Return type:

None