loader
aiice.loader
Loader
Dataset Loader with a Hugging Face dataset client.
Downloading a large number of files in parallel may lead to request timeouts or temporary server-side errors from Hugging Face. If this happens, reduce the number of threads or split the download into smaller date ranges.
Source code in src/aiice/loader.py
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
seas
property
seas: tuple[str, ...]
Return available seas.
shape
property
shape: tuple[int, ...]
Return shape of a single dataset sample.
dataset_start
property
dataset_start: date
Return earliest available date in the dataset.
dataset_end
property
dataset_end: date
Return latest available date in the dataset.
info
info(per_year: bool = False) -> dict[str, any]
Collect dataset statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
per_year
|
bool
|
If True, include per-year statistics. |
False
|
Source code in src/aiice/loader.py
81 82 83 84 85 86 87 88 | |
download
download(local_dir: str, start: date | str | None = None, end: date | str | None = None, step: int | str | None = None, threads: int = 16) -> list[str | None]
Download dataset files to a local directory in parallel. Raw numpy matrices in the dataset have range values from 0 to 100.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_dir
|
`str`
|
Directory to save downloaded files. |
required |
start
|
`date` or `str`
|
Start date for files. Defaults to earliest dataset date. |
None
|
end
|
`date` or `str`
|
End date for files. Defaults to latest dataset date. |
None
|
step
|
`int` or `str`
|
Step between files. If |
None
|
threads
|
`int`
|
Number of parallel download threads. Defaults to 24. |
16
|
Source code in src/aiice/loader.py
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 123 | |
get
get(start: date | str | None = None, end: date | str | None = None, step: int | str | None = None, sea: str | None = None, tensor_out: bool = False, idx_out: bool = False, threads: int = 16, processes: int | None = None) -> np.ndarray | torch.Tensor | NpWithIdx | TorchWithIdx
Load dataset files into memory as numpy arrays or torch tensors. Loaded matrices are normalized to float values in the range 0 to 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
`date` or `str`
|
Start date for files. Defaults to earliest dataset date. |
None
|
end
|
`date` or `str`
|
End date for files. Defaults to latest dataset date. |
None
|
step
|
`int` or `str`
|
Step between files. If |
None
|
sea
|
`str`
|
Name of the sea (e.g., "Barents Sea"). Check |
None
|
tensor_out
|
`bool`
|
If True, returns a torch.Tensor instead of numpy array. Defaults to False. |
False
|
idx_out
|
`bool`
|
If True, returns a tuple of (date indexes, matrices). Defaults to False. |
False
|
threads
|
`int`
|
Number of parallel download threads. Defaults to 16. |
16
|
processes
|
`int`
|
Number of worker processes for decoding raw bytes. Defaults to CPU core count. |
None
|
Source code in src/aiice/loader.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |