cf.close_one_file

cf.close_one_file(file_format=None)[source]

Close an arbitrary open file containing a sub-array of a data array.

By default a file of arbitrary format is closed, but the choice may be restricted to files of a particular format.

Note that the closed file will be automatically reopened if subsequently needed by a variable to access the sub-array.

If there are no appropriate open files then no action is taken.

Parameters:
file_format : str, optional

Only close a file of the given format. Recognised formats are 'netCDF' and 'PP'. By default a file of any format is closed.

Returns:

None

Examples:
>>> cf.close_one_file()
>>> cf.close_one_file('netCDF')
>>> cf.close_one_file('PP')
>>> cf.open_files()
{'netCDF': {'file1.nc': <netCDF4.Dataset at 0x181bcd0>,
            'file2.nc': <netCDF4.Dataset at 0x1e42350>,
            'file3.nc': <netCDF4.Dataset at 0x1d185e9>}}
>>> cf.close_one_file()
>>> cf.open_files()
{'netCDF': {'file1.nc': <netCDF4.Dataset at 0x181bcd0>,
            'file3.nc': <netCDF4.Dataset at 0x1d185e9>}}