Other pnetcdf class methods

PnetCDF class methods listed below are not associated with particular instances of File or Variable.

pnetcdf.libver()[source]
Returns:

The PnetCDF-Python version string, for example “1.0.0”.

Return type:

str

pnetcdf.strerror(err_code)

Method to return an error message string corresponding to an integer netCDF error code or to a system error number, presumably returned by a call to a PnetCDF method.

Parameters:

err_code (int) – An error code returned from a call to a PnetCDF method.

Returns:

error message

Return type:

str

pnetcdf.strerrno(err_code)

Method to return a character string containing the name of the NC error code. For instance, ncmpi_strerrno(NC_EBADID) returns string “NC_EBADID”.

Parameters:

err_code (int) – An error code returned from a call to a PnetCDF method.

Returns:

name of the NC error code.

Return type:

str

pnetcdf.chartostring(src, encoding='utf-8')

Convert a character array to a string array with one less dimension.

Parameters:
  • src (numpy.ndarray) – Input character array (numpy datatype ‘S1’ or ‘U1’). Will be converted to a array of strings, where each string has a fixed length of src.shape[-1] characters.

  • encoding (str) – [Optional] Can be used to specify character encoding (default utf-8). If encoding is ‘none’ or ‘bytes’, a np.string_ btye array is returned.

Returns:

A numpy string array with datatype ‘UN’ (or ‘SN’) and shape src.shape[:-1] where where N=src.shape[-1].

Return type:

numpy.ndarray

pnetcdf.stringtochar(src, encoding='utf-8')

Convert a string array to a character array with one extra dimension.

Parameters:
  • src – Input numpy string array with numpy datatype ‘SN’ or ‘UN’, where N is the number of characters in each string. Will be converted to an array of characters (datatype ‘S1’ or ‘U1’) of shape src.shape + (N,).

  • encoding (str) – [Optional] Can be used to specify character encoding (default utf-8). If encoding is ‘none’ or ‘bytes’, a numpy.string_ the input array is treated a raw byte strings (numpy.string_).

Returns:

A numpy character array with datatype ‘S1’ or ‘U1’ and shape src.shape + (N,), where N is the length of each string in src.

Return type:

numpy.ndarray

pnetcdf.set_default_format(int new_format)

Method to change the default format of the netCDF file to be created in the successive file creations when no file format is explicitly passed as a parameter.

Parameters:

new_format

  • pnetcdf.NC_FORMAT_CLASSIC (the default setting),

  • pnetcdf.NC_FORMAT_CDF2 (pnetcdf.NC_FORMAT_64BIT), or

  • pnetcdf.NC_FORMAT_CDF5 (pnetcdf.NC_FORMAT_64BIT_DATA).

Return type:

int

Returns:

The current default format before this call of setting a new default format.

Operational mode:

This method can be called in either collective or independent I/O mode, but is expected to be called by all processes.

pnetcdf.inq_default_format()

Method to return the current setting for default file format, one of the PnetCDF constants shown below.

  • pnetcdf.NC_FORMAT_CLASSIC (the default setting),

  • pnetcdf.NC_FORMAT_CDF2 (pnetcdf.NC_FORMAT_64BIT), or

  • pnetcdf.NC_FORMAT_CDF5 (pnetcdf.NC_FORMAT_64BIT_DATA).

Return type:

int

Operational mode:

This method is an independent subroutine.

pnetcdf.inq_file_format(str file_name)

Method to return the current setting for default file format, one of the PnetCDF constants shown below.

  • pnetcdf.NC_FORMAT_CLASSIC (the default setting),

  • pnetcdf.NC_FORMAT_CDF2 (pnetcdf.NC_FORMAT_64BIT), or

  • pnetcdf.NC_FORMAT_CDF5 (pnetcdf.NC_FORMAT_64BIT_DATA).

Return type:

int

Operational mode:

This method is an independent subroutine.

pnetcdf.inq_clibvers()

Method to return a string describing the version of the PnetCDF-C library used to build this PnetCDF-Python module, and when the PnetCDF-C library was built.

Returns:

A string about PnetCDF-C library, for example, “1.13.0 of March 29, 2024”.

Return type:

str