API reference
earthcarekit.utils
Collection of basic utility functions.
Notes
This module depends on other internal modules:
get_config
Returns the default or a given earthcarekit config object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | ECKConfig | None
|
A path to a config file (.toml) or None. If None, returns the default config. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ECKConfig |
ECKConfig
|
A config object. |
Source code in earthcarekit/utils/_config.py
get_file_info_from_str
get_file_info_from_str(s: str) -> dict
Extract meta data from a EarthCARE product/file name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
The input string. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the pattern of |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
File meta data as a dict with the following keys:
|
Source code in earthcarekit/utils/parse/filename.py
get_maap_access_token
Retrieves MAAP access token from generated offline token
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
A temporary/offline ESA MAAP access token (to generate it visit: https://portal.maap.eo.esa.int/ini/services/auth/token/). Defaults to None. |
None
|
config
|
str | ECKConfig | None
|
A path to a config file (.toml) or None. If None, returns the default config. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Long-lasting ESA MAAP access token. |
Source code in earthcarekit/utils/maap.py
has_param
read_config
Reads and return earthcare-kit configurations.
Source code in earthcarekit/utils/_config.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
search_files_by_regex
Recursively searches for files in a directory that match a given regex pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dirpath
|
str
|
The root directory to start the search from. |
required |
regex_pattern
|
str
|
A regular expression pattern to match file names against. |
required |
Return
list[str]: A list of absolute file paths that point to files with matching names.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the root directory does not exist. |
error
|
If the given pattern is not a valid regular expression. |
Source code in earthcarekit/utils/path.py
set_config
Creates or updates the default earthcarekit configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | ECKConfig
|
Filepath to a configuration file (.toml) or configuration object. |
required |
verbose
|
bool
|
If True, prints a message to the console. Defaults to True. |
True
|
Source code in earthcarekit/utils/_config.py
set_config_maap_token
Updates the ESA MAAP access token in the default earthcarekit configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
A temporary ESA MAAP access token (to generate it visit: https://portal.maap.eo.esa.int/ini/services/auth/token/). |
required |
Source code in earthcarekit/utils/_config.py
set_config_to_maap
Sets the download backend to the ESA MAAP system in the default earthcarekit configuration file.
Source code in earthcarekit/utils/_config.py
set_config_to_oads
Sets the download backend to OADS in the default earthcarekit configuration file.