56
56
57
57
@dataclass
58
58
class _ChunkInfo :
59
- """Class for keeping track of an chunked processing.
60
-
61
- Parameters
62
- ----------
63
- n_data : int
64
- number of data points
65
- n_chunks : int
66
- number of chunks
67
-
68
- Attributes
69
- ----------
70
- n_data : int
71
- number of data points
72
- n_chunks : int
73
- number of chunks
74
- chunk_size : int
75
- number of data points per chunk
76
-
77
- Methods
78
- -------
79
- stop(start)
80
- Return the stop index for a chunk
81
- chunk_end(start)
82
- Return the end index for a chunk
83
- from_dfs(dfs, item_numbers, buffer_size)
84
- Calculate chunk info based on # of elements in dfs file and selected buffer size
85
-
86
- """
87
-
88
59
def __init__ (self , n_data : int , n_chunks : int ):
89
60
self .n_data = n_data
90
61
self .n_chunks = n_chunks
@@ -94,15 +65,12 @@ def __repr__(self) -> str:
94
65
95
66
@property
96
67
def chunk_size (self ) -> int :
97
- """number of data points per chunk."""
98
68
return math .ceil (self .n_data / self .n_chunks )
99
69
100
70
def stop (self , start : int ) -> int :
101
- """Return the stop index for a chunk."""
102
71
return min (start + self .chunk_size , self .n_data )
103
72
104
73
def chunk_end (self , start : int ) -> int :
105
- """Return the end index for a chunk."""
106
74
e2 = self .stop (start )
107
75
return self .chunk_size - ((start + self .chunk_size ) - e2 )
108
76
@@ -127,29 +95,6 @@ def _clone(
127
95
timestep : float | None = None ,
128
96
items : Sequence [int | DfsDynamicItemInfo ] | None = None ,
129
97
) -> DfsFile :
130
- """Clone a dfs file.
131
-
132
- Parameters
133
- ----------
134
- infilename : str | pathlib.Path
135
- input filename
136
- outfilename : str | pathlib.Path
137
- output filename
138
- start_time : datetime, optional
139
- new start time for the new file, by default None
140
- timestep : float, optional
141
- new timestep (in seconds) for the new file, by default None
142
- items : list(int,eum.ItemInfo), optional
143
- list of items for new file, either as a list of
144
- ItemInfo or a list of str/int referring to original file,
145
- default: all items from original file
146
-
147
- Returns
148
- -------
149
- DfsFile
150
- MIKE generic dfs file object
151
-
152
- """
153
98
source = DfsFileFactory .DfsGenericOpen (str (infilename ))
154
99
fi = source .FileInfo
155
100
@@ -943,23 +888,6 @@ def quantile(
943
888
944
889
945
890
def _read_item (dfs : DfsFile , item : int , timestep : int ) -> np .ndarray :
946
- """Read item data from dfs file.
947
-
948
- Parameters
949
- ----------
950
- dfs : DfsFile
951
- dfs file
952
- item : int
953
- item number
954
- timestep : int
955
- timestep number
956
-
957
- Returns
958
- -------
959
- np.ndarray
960
- item data
961
-
962
- """
963
891
indatatime = dfs .ReadItemTimeStep (item + 1 , timestepIndex = timestep )
964
892
indata = indatatime .Data
965
893
has_value = indata != dfs .FileInfo .DeleteValueFloat
@@ -971,21 +899,6 @@ def _read_item(dfs: DfsFile, item: int, timestep: int) -> np.ndarray:
971
899
def _get_repeated_items (
972
900
items_in : list [DfsDynamicItemInfo ], prefixes : list [str ]
973
901
) -> list [ItemInfo ]:
974
- """Create new items by repeating the items in items_in with the prefixes.
975
-
976
- Parameters
977
- ----------
978
- items_in : list[DfsDynamicItemInfo]
979
- List of items to be repeated
980
- prefixes : list[str]
981
- List of prefixes to be added to the items
982
-
983
- Returns
984
- -------
985
- list[ItemInfo]
986
- List of new items
987
-
988
- """
989
902
item_numbers = _valid_item_numbers (items_in )
990
903
items_in = _get_item_info (items_in )
991
904
0 commit comments