/
count.py
122 lines (93 loc) · 3.14 KB
/
count.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from . import core, mixin
class Count(
mixin.NetCDFVariable,
mixin.NetCDFDimension,
mixin.NetCDFSampleDimension,
mixin.PropertiesData,
mixin.Files,
core.abstract.PropertiesData,
):
"""A count variable required to uncompress a ragged array.
A collection of features stored using a contiguous ragged array
combines all features along a single dimension (the sample
dimension) such that each feature in the collection occupies a
contiguous block.
The information needed to uncompress the data is stored in a count
variable that gives the size of each block.
**NetCDF interface**
{{netCDF variable}}
The name of the netCDF dimension spanned by the count variable's
data may be accessed with the `nc_set_dimension`,
`nc_get_dimension`, `nc_del_dimension` and `nc_has_dimension`
methods.
The name of the netCDF sample dimension spanned by the compressed
data (that is stored in the "sample_dimension" netCDF attribute
and which does not correspond to a domain axis construct) may be
accessed with the `nc_set_sample_dimension`,
`nc_get_sample_dimension`, `nc_del_sample_dimension` and
`nc_has_sample_dimension` methods.
.. versionadded:: (cfdm) 1.7.0
"""
def __init__(
self,
properties=None,
data=None,
source=None,
copy=True,
_use_data=True,
):
"""**Initialisation**
:Parameters:
{{init properties: `dict`, optional}}
*Parameter example:*
``properties={'long_name': 'number of obs'}``
{{init data: data_like, optional}}
{{data_like}}
{{init source: optional}}
{{init copy: `bool`, optional}}
"""
super().__init__(
properties=properties,
data=data,
source=source,
copy=copy,
_use_data=_use_data,
)
self._initialise_netcdf(source)
self._initialise_original_filenames(source)
def dump(
self,
display=True,
_key=None,
_title=None,
_create_title=True,
_prefix="",
_level=0,
_omit_properties=None,
_axes=None,
_axis_names=None,
):
"""A full description of the count variable.
Returns a description of all properties, including those of
components, and provides selected values of all data arrays.
.. versionadded:: (cfdm) 1.7.0
:Parameters:
display: `bool`, optional
If False then return the description as a string. By
default the description is printed.
:Returns:
{{returns dump}}
"""
if _create_title and _title is None:
_title = "Count: " + self.identity(default="")
return super().dump(
display=display,
_key=_key,
_omit_properties=_omit_properties,
_prefix=_prefix,
_level=_level,
_title=_title,
_create_title=_create_title,
_axes=_axes,
_axis_names=_axis_names,
)