API Reference
cli
Command line interface.
Provides access to basic functionality in the API from the command line.
main()
Entry point for the CLI.
This is called from project.scripts in pyproject.toml
Source code in caroline_download/cli.py
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 |
|
parse_args()
Parse command line arguments.
Returns:
Type | Description |
---|---|
Namespace
|
the parsed arguments |
Source code in caroline_download/cli.py
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 |
|
setup_logging(log_config)
Set up logging.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_config
|
logging configuration object |
required |
Source code in caroline_download/cli.py
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 |
|
config
Handle configuration for the CLI.
Implementation based on suggestions from: https://tech.preferred.jp/en/blog/working-with-configuration-in-python/
Config(download, geo_search, product_search, logging=Logging())
dataclass
Main configuration data class.
ConsoleLog(enable=True, level=LogLevel[DEFAULT_LOG_LEVEL], format=DEFAULT_LOG_FORMAT)
dataclass
Data class for console log handler configuration.
Download(base_directory, force=False, dry_run=False, verify=True)
dataclass
Data class for download configuration.
FileLog(file, level=LogLevel[DEFAULT_LOG_LEVEL], format=DEFAULT_LOG_FORMAT)
dataclass
Data class for file log handler configuration.
GeoSearch(dataset, start, end, roi_wkt_file, relative_orbits, product_type)
dataclass
Data class for search configuration.
LogLevel
Bases: Enum
Enum for logging levels.
Logger(level=LogLevel[DEFAULT_LOG_LEVEL])
dataclass
Data class for logger configuration.
Logging(console_log=ConsoleLog(enable=True, level=LogLevel[DEFAULT_LOG_LEVEL], format=DEFAULT_LOG_FORMAT), file_log=FileLog(file=None, level=LogLevel[DEFAULT_LOG_LEVEL], format=DEFAULT_LOG_FORMAT), root_logger=Logger(level=LogLevel['WARNING']), cli_logger=Logger(level=LogLevel[DEFAULT_LOG_LEVEL]), download_logger=Logger(level=LogLevel[DEFAULT_LOG_LEVEL]), asf_logger=Logger(level=LogLevel['WARNING']))
dataclass
Data class for logging configuration.
get_config(args)
Get configuration.
Get configuration from files, arguments and defaults.
Source code in caroline_download/config.py
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 217 218 219 220 |
|
parse_datetime(datetime)
Parse time(range) specifications.
Allows parsing of human formatted time(range) specifications such as 'one month ago' to a datetime
Source code in caroline_download/config.py
117 118 119 120 121 122 123 |
|
download
Download.
compose_product_download_path(base_directory, file_name, relative_orbit, orbit_direction, polarization)
Compose product download path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_directory
|
The base download directory |
required | |
file_name
|
The name of the file to download |
required | |
relative_orbit
|
The relative orbit of the product |
required | |
orbit_direction
|
The orbit direction of the product |
required | |
polarization
|
The polarization of the product |
required |
Returns:
Type | Description |
---|---|
str
|
A string representation of the composed path |
Source code in caroline_download/download.py
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 |
|
download(download_config, geo_search=None, product_search=None)
Download.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
download_config
|
download configuration |
required | |
geo_search
|
search configuration |
None
|
|
product_search
|
product name |
None
|
Source code in caroline_download/download.py
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 |
|
download_product(download_config, product)
Download a product.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
download_config
|
download configuration |
required | |
product
|
the product to download |
required |
Source code in caroline_download/download.py
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 217 218 219 220 221 222 223 |
|
download_products(download_config, result)
Download products from a result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
download_config
|
download configuration |
required | |
result
|
query result |
required |
Source code in caroline_download/download.py
147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
split_into_monthly_intervals(start_datetime, end_datetime)
Split interval into monthly intervals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_datetime
|
start of the interval |
required | |
end_datetime
|
end of the interval |
required |
Returns:
Type | Description |
---|---|
list
|
A list of intervals |
Notes
Intervals are split on the end of the month, so even if the interval is smaller than one month but the interval includes the end of a month two intervals are returned.
Source code in caroline_download/download.py
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 |
|
verify_checksum(file, checksum)
Verify checksum of a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
The file to verify the checksum of |
required | |
checksum
|
str
|
The checksum to compare against |
required |
Returns:
Type | Description |
---|---|
bool
|
True if checksum matches, False if it doesn't |
Source code in caroline_download/download.py
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 |
|