core.netcdf_dictionary¶
Provides classes for saving and loading NetCDF files from and to appropriate Python dictionaries, allowing NetCDF4 compression methods.
- class pyunicorn.core.netcdf_dictionary.NetCDFDictionary(data_dict=None, silence_level=0)[source]¶
Bases:
object
Encapsulates appropriate dictionary following NetCDF conventions.
Also contains methods to load data from NetCDF and NetCDF4 files.
- __init__(data_dict=None, silence_level=0)[source]¶
Return a NetCDF object containing an appropriately structured dictionary.
If no data_dict is given, a default quasi-empty dictionary is created.
- Parameters:
data_dict (dictionary) – Contains data in a structure following NetCDF conventions: {“global_attributes”: {}, “dimensions”: {}, “variables”: {“obs”: {“array”: (), “dims”: (), “attributes”: ()}}}
silence_level (int >= 0) – The higher, the less progress info is output.
- __weakref__¶
list of weak references to the object
- static from_file(file_name, with_array='all')[source]¶
Load NetCDF4 file into a dictionary.
- Supported file types
file_type
are: “NetCDF”
“NetCDF4”
- Parameters:
file_name (str) – The name of the data file.
with_array ([str]) – Names of data arrays to be loaded completely.
- Return type:
NetCDF instance
- Supported file types
- silence_level¶
(int >= 0) The higher, the less progress info is output.
- to_file(file_name, compress=False, comp_level=6, least_significant_digit=10)[source]¶
Write NetCDF4 file by using appropriate dictionary.
- Parameters:
file_name (str) – The name of the data file.
compress (bool) – Determines whether the data should be compressed.
comp_level (int) – Level of compression, between 0 (no compression, fastest) and 9 (strongest compression, slowest).
least_significant_digit (int) – Last precise digit.