ceos-capabilities 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ceos_capabilities/__init__.py +12 -0
- ceos_capabilities/client.py +471 -0
- ceos_capabilities/data/manifest.json +20 -0
- ceos_capabilities/data/snapshot.json.gz +0 -0
- ceos_capabilities-0.1.0.dist-info/METADATA +96 -0
- ceos_capabilities-0.1.0.dist-info/RECORD +10 -0
- ceos_capabilities-0.1.0.dist-info/WHEEL +5 -0
- ceos_capabilities-0.1.0.dist-info/licenses/LICENSE +202 -0
- ceos_capabilities-0.1.0.dist-info/licenses/NOTICE +12 -0
- ceos_capabilities-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""ceos-capabilities: a small client for the CEOS MIM Database.
|
|
2
|
+
|
|
3
|
+
from ceos_capabilities import Client
|
|
4
|
+
db = Client() # offline: the snapshot shipped with this package
|
|
5
|
+
db = Client(mode="api") # live: https://ceos-capabilities.org/api
|
|
6
|
+
|
|
7
|
+
Both modes answer the same calls with the same shapes.
|
|
8
|
+
"""
|
|
9
|
+
from .client import Client, Edition, Records, SnapshotError, NotFound, SUPPORTED_SHAPES
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
__all__ = ["Client", "Edition", "Records", "SnapshotError", "NotFound", "SUPPORTED_SHAPES", "__version__"]
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
"""The client. Standard library only; pandas is optional (Records.to_pandas)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import copy
|
|
5
|
+
import gzip
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import tempfile
|
|
11
|
+
import time
|
|
12
|
+
import urllib.error
|
|
13
|
+
import urllib.parse
|
|
14
|
+
import urllib.request
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any, Optional
|
|
18
|
+
|
|
19
|
+
DEFAULT_API = "https://ceos-capabilities.org/api"
|
|
20
|
+
# Shape versions of the published snapshot this client can read. Adding a
|
|
21
|
+
# field or a collection is not a new shape; renaming, removing or restructuring is.
|
|
22
|
+
SUPPORTED_SHAPES = (1,)
|
|
23
|
+
_BUNDLED = Path(__file__).parent / "data" / "snapshot.json.gz"
|
|
24
|
+
_USER_AGENT = "ceos-capabilities-python/0.1.0"
|
|
25
|
+
|
|
26
|
+
# Detail route name -> entity type in the identifier registry, for resolving a
|
|
27
|
+
# slug or alternate name to an id in offline mode. (The live API resolves these itself.)
|
|
28
|
+
_ENTITY = {
|
|
29
|
+
"mission": "mission", "instrument": "instrument", "measurement": "measurement",
|
|
30
|
+
"series": "series", "constellation": "constellation", "programme": "programme",
|
|
31
|
+
"provider": "agency", "horizon": "horizon",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# "575", "+575", "0575", and "575.0" (an id that passed through a float column).
|
|
36
|
+
# Longer digit runs are not ids: they are looked up as names and not found.
|
|
37
|
+
_INT = re.compile(r"^[+-]?\d{1,18}(\.0+)?$")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _as_int(text: str) -> int:
|
|
41
|
+
return int(re.sub(r"\.0+$", "", text))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _KeyStaysHome(urllib.request.HTTPRedirectHandler):
|
|
45
|
+
"""Follow redirects, but never carry the API key to another host or scheme."""
|
|
46
|
+
|
|
47
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
48
|
+
new = super().redirect_request(req, fp, code, msg, headers, newurl)
|
|
49
|
+
if new is not None:
|
|
50
|
+
a, b = urllib.parse.urlsplit(req.full_url), urllib.parse.urlsplit(new.full_url)
|
|
51
|
+
if (a.scheme, a.netloc) != (b.scheme, b.netloc):
|
|
52
|
+
new.headers = {k: v for k, v in new.headers.items() if k.lower() != "x-api-key"}
|
|
53
|
+
return new
|
|
54
|
+
_DATE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
|
|
55
|
+
_EDITION = re.compile(r"^[0-9A-Za-z][0-9A-Za-z._-]{0,63}$")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _slugify(name: str) -> str:
|
|
59
|
+
"""The API's slug rule (eogos-api identifiers.slugify)."""
|
|
60
|
+
return re.sub(r"[^A-Za-z0-9]+", "-", name.lower()).strip("-")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class SnapshotError(RuntimeError):
|
|
64
|
+
"""The snapshot is missing, damaged, or in a shape this client cannot read."""
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class NotFound(LookupError):
|
|
68
|
+
"""No such record (HTTP 404 in live mode; no stored response offline)."""
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class Records(list):
|
|
72
|
+
"""A list of records (plain dicts) with a pandas convenience."""
|
|
73
|
+
|
|
74
|
+
def to_pandas(self):
|
|
75
|
+
try:
|
|
76
|
+
import pandas as pd
|
|
77
|
+
except ImportError as e: # pragma: no cover - depends on the environment
|
|
78
|
+
raise ImportError("to_pandas() needs pandas: pip install pandas") from e
|
|
79
|
+
return pd.DataFrame(list(self))
|
|
80
|
+
|
|
81
|
+
# A slice, a copy or a sum of records is still records.
|
|
82
|
+
def __getitem__(self, item):
|
|
83
|
+
got = super().__getitem__(item)
|
|
84
|
+
return Records(got) if isinstance(item, slice) else got
|
|
85
|
+
|
|
86
|
+
def __add__(self, other):
|
|
87
|
+
return Records(list(self) + list(other))
|
|
88
|
+
|
|
89
|
+
def copy(self):
|
|
90
|
+
return Records(self)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass(frozen=True)
|
|
94
|
+
class Edition:
|
|
95
|
+
"""Which data a client is reading."""
|
|
96
|
+
edition: Optional[str] # identifier-registry edition, e.g. "e574f0c2"
|
|
97
|
+
as_of: Optional[str] # date the data was extracted from the database
|
|
98
|
+
api_version: Optional[str] # API version that served or produced it
|
|
99
|
+
mode: str # "snapshot" or "api"
|
|
100
|
+
source: str # where it came from (file path or URL)
|
|
101
|
+
shape_version: Optional[int] = None # snapshot only
|
|
102
|
+
|
|
103
|
+
def __str__(self) -> str:
|
|
104
|
+
# The file name only: a full path would put a local user name into notebook output.
|
|
105
|
+
where = self.source if self.mode == "api" else os.path.basename(self.source)
|
|
106
|
+
return f"CEOS MIM Database, edition {self.edition}, data as of {self.as_of} ({self.mode}: {where})"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class Client:
|
|
110
|
+
"""Read the CEOS MIM Database, offline from a snapshot or live from the API.
|
|
111
|
+
|
|
112
|
+
mode "snapshot" (default) or "api". The environment variable
|
|
113
|
+
CEOS_CAPABILITIES_MODE sets the default.
|
|
114
|
+
snapshot path to a snapshot.json.gz to use instead of the bundled one
|
|
115
|
+
(or CEOS_CAPABILITIES_SNAPSHOT). Offline mode makes no network call.
|
|
116
|
+
base_url the API to call in "api" mode.
|
|
117
|
+
api_key optional API key for "api" mode (or CEOS_CAPABILITIES_API_KEY).
|
|
118
|
+
Keys are personal: keep them out of shared notebooks.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
def __init__(self, mode: Optional[str] = None, *, snapshot: Optional[os.PathLike] = None,
|
|
122
|
+
base_url: str = DEFAULT_API, api_key: Optional[str] = None, timeout: float = 30.0):
|
|
123
|
+
self.mode = (mode or os.environ.get("CEOS_CAPABILITIES_MODE") or "snapshot").lower()
|
|
124
|
+
if self.mode not in ("snapshot", "api"):
|
|
125
|
+
raise ValueError('mode must be "snapshot" or "api"')
|
|
126
|
+
self.base_url = base_url.rstrip("/")
|
|
127
|
+
self._api_key = api_key or os.environ.get("CEOS_CAPABILITIES_API_KEY")
|
|
128
|
+
if self._api_key and self.mode == "api":
|
|
129
|
+
where = urllib.parse.urlsplit(self.base_url)
|
|
130
|
+
if where.scheme != "https" and where.hostname not in ("localhost", "127.0.0.1", "::1"):
|
|
131
|
+
raise ValueError("an API key is only sent over https (or to localhost)")
|
|
132
|
+
self._opener = urllib.request.build_opener(_KeyStaysHome())
|
|
133
|
+
self._timeout = timeout
|
|
134
|
+
self._responses: Optional[dict] = None
|
|
135
|
+
self._manifest: Optional[dict] = None
|
|
136
|
+
self._slugs: Optional[dict] = None
|
|
137
|
+
self._path = Path(snapshot or os.environ.get("CEOS_CAPABILITIES_SNAPSHOT") or _BUNDLED)
|
|
138
|
+
if self.mode == "snapshot":
|
|
139
|
+
self._load_snapshot(self._path)
|
|
140
|
+
|
|
141
|
+
# ------------------------------------------------------------------ snapshot
|
|
142
|
+
|
|
143
|
+
def _load_snapshot(self, path: Path) -> None:
|
|
144
|
+
try:
|
|
145
|
+
with gzip.open(path, "rt", encoding="utf-8") as f:
|
|
146
|
+
doc = json.load(f)
|
|
147
|
+
manifest, responses = doc["manifest"], doc["responses"]
|
|
148
|
+
if not isinstance(manifest, dict) or not isinstance(responses, dict):
|
|
149
|
+
raise TypeError("manifest and responses must be objects")
|
|
150
|
+
except FileNotFoundError as e:
|
|
151
|
+
raise SnapshotError(f"no snapshot at {path}") from e
|
|
152
|
+
except (OSError, EOFError, ValueError, KeyError, TypeError) as e:
|
|
153
|
+
# EOFError: a truncated file, the commonest damage (a partial copy or download).
|
|
154
|
+
raise SnapshotError(f"{path} is not a readable snapshot: {e}") from e
|
|
155
|
+
shape = manifest.get("shape_version")
|
|
156
|
+
if shape not in SUPPORTED_SHAPES:
|
|
157
|
+
raise SnapshotError(
|
|
158
|
+
f"{path} has shape version {shape}; this version of ceos-capabilities reads "
|
|
159
|
+
f"{', '.join(map(str, SUPPORTED_SHAPES))}. Upgrade the package: pip install -U ceos-capabilities")
|
|
160
|
+
licence = manifest.get("licence")
|
|
161
|
+
if not isinstance(licence, dict) or not licence.get("attribution") or not licence.get("url"):
|
|
162
|
+
raise SnapshotError(f"{path} carries no licence and attribution; refusing to use it")
|
|
163
|
+
self._manifest, self._responses, self._path, self._slugs = manifest, responses, Path(path), None
|
|
164
|
+
|
|
165
|
+
def _resolve(self, kind: str, ref: Any) -> Any:
|
|
166
|
+
"""Offline: turn an id, slug, name or alternate name into the record's id,
|
|
167
|
+
by the API's rules: an integer is an id; anything else is reduced to slug
|
|
168
|
+
form (lower case, every run of other characters to one hyphen) and looked
|
|
169
|
+
up in the identifier registry, a canonical slug winning over an alternate
|
|
170
|
+
name and the lowest id winning a tie."""
|
|
171
|
+
text = str(ref).strip()
|
|
172
|
+
if _INT.match(text):
|
|
173
|
+
return _as_int(text)
|
|
174
|
+
if kind not in _ENTITY:
|
|
175
|
+
return text
|
|
176
|
+
if self._slugs is None:
|
|
177
|
+
# The API's index (eogos-api identifiers.Identifiers): canonical slug rows
|
|
178
|
+
# first; then alternate-name rows by their slug and hierarchical-id rows by
|
|
179
|
+
# the slug form of their value, the lowest id winning a shared alias.
|
|
180
|
+
try:
|
|
181
|
+
rows = self._responses["/identifiers"]["identifiers"]
|
|
182
|
+
canonical: dict = {}
|
|
183
|
+
alias: dict = {}
|
|
184
|
+
for row in rows:
|
|
185
|
+
key, kind_of = (row["entity_type"], row["entity_id"]), row.get("kind")
|
|
186
|
+
if kind_of == "slug" and row.get("is_canonical"):
|
|
187
|
+
canonical[(key[0], row["slug"])] = key[1]
|
|
188
|
+
elif kind_of == "aka" and row.get("slug"):
|
|
189
|
+
slot = (key[0], row["slug"])
|
|
190
|
+
alias[slot] = min(alias.get(slot, key[1]), key[1])
|
|
191
|
+
elif kind_of == "hierarchical_id" and _slugify(str(row.get("value") or "")):
|
|
192
|
+
slot = (key[0], _slugify(str(row["value"])))
|
|
193
|
+
alias[slot] = min(alias.get(slot, key[1]), key[1])
|
|
194
|
+
except (KeyError, TypeError) as e:
|
|
195
|
+
raise SnapshotError("this snapshot has no usable identifier registry, "
|
|
196
|
+
"so names cannot be resolved; use ids") from e
|
|
197
|
+
self._slugs = {**alias, **canonical}
|
|
198
|
+
found = self._slugs.get((_ENTITY[kind], _slugify(text)))
|
|
199
|
+
if found is None:
|
|
200
|
+
raise NotFound(f"no {kind} called {ref!r} in edition {self.edition.edition}")
|
|
201
|
+
return found
|
|
202
|
+
|
|
203
|
+
# ------------------------------------------------------------------ requests
|
|
204
|
+
|
|
205
|
+
def get(self, path: str, **params: Any) -> Any:
|
|
206
|
+
"""Return the API's response for a read path, e.g. get("/mission/575").
|
|
207
|
+
|
|
208
|
+
Offline, this is the stored response for that path. Query parameters are
|
|
209
|
+
a live-mode feature: offline, a call with parameters raises, because a
|
|
210
|
+
stored response cannot be filtered the way the service filters it.
|
|
211
|
+
|
|
212
|
+
As in the API, a name or slug is accepted on a record's own route
|
|
213
|
+
("/mission/sentinel-1-a"); the routes beneath a record take its id
|
|
214
|
+
("/mission/575/instruments"). The named methods accept either everywhere.
|
|
215
|
+
"""
|
|
216
|
+
if "?" in path or "#" in path:
|
|
217
|
+
raise ValueError("pass query parameters as keyword arguments, not in the path")
|
|
218
|
+
# One spelling for both modes: each segment is taken as text, encoded or not.
|
|
219
|
+
parts = [urllib.parse.unquote(s) for s in path.strip("/").split("/")]
|
|
220
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
221
|
+
if self.mode == "api":
|
|
222
|
+
return self._http("/" + "/".join(urllib.parse.quote(s, safe="") for s in parts), params)
|
|
223
|
+
if params:
|
|
224
|
+
raise ValueError("query parameters need mode=\"api\"; offline responses are stored as served by default")
|
|
225
|
+
if len(parts) == 2 and parts[0] in _ENTITY:
|
|
226
|
+
parts[1] = str(self._resolve(parts[0], parts[1]))
|
|
227
|
+
elif len(parts) > 2 and parts[0] in _ENTITY and _INT.match(parts[1].strip()):
|
|
228
|
+
parts[1] = str(_as_int(parts[1].strip()))
|
|
229
|
+
return self._stored("/" + "/".join(parts))
|
|
230
|
+
|
|
231
|
+
def _stored(self, path: str) -> Any:
|
|
232
|
+
try:
|
|
233
|
+
# A copy, as a live call returns a fresh object: changing a result
|
|
234
|
+
# must not change what the next call returns.
|
|
235
|
+
return copy.deepcopy(self._responses[path])
|
|
236
|
+
except KeyError:
|
|
237
|
+
raise NotFound(f"{path} is not in edition {self.edition.edition}") from None
|
|
238
|
+
|
|
239
|
+
def _http(self, path: str, params: dict) -> Any:
|
|
240
|
+
# `path` arrives already percent-encoded, segment by segment.
|
|
241
|
+
url = self.base_url + path + ("?" + urllib.parse.urlencode(params) if params else "")
|
|
242
|
+
headers = {"User-Agent": _USER_AGENT, "Accept": "application/json"}
|
|
243
|
+
if self._api_key:
|
|
244
|
+
headers["X-API-Key"] = self._api_key
|
|
245
|
+
for attempt in range(4):
|
|
246
|
+
try:
|
|
247
|
+
with self._opener.open(urllib.request.Request(url, headers=headers), timeout=self._timeout) as r:
|
|
248
|
+
return json.loads(r.read().decode("utf-8"))
|
|
249
|
+
except urllib.error.HTTPError as e:
|
|
250
|
+
if e.code == 404:
|
|
251
|
+
raise NotFound(f"{path} not found") from None
|
|
252
|
+
if e.code == 429 and attempt < 3:
|
|
253
|
+
retry_after = e.headers.get("Retry-After", "")
|
|
254
|
+
time.sleep(min(float(retry_after) if retry_after.isdigit() else 2.0 ** attempt, 30.0))
|
|
255
|
+
continue
|
|
256
|
+
raise
|
|
257
|
+
raise RuntimeError("unreachable") # pragma: no cover
|
|
258
|
+
|
|
259
|
+
# ------------------------------------------------------------------ provenance
|
|
260
|
+
|
|
261
|
+
def _get_meta(self) -> dict:
|
|
262
|
+
# Not cached: a long-lived live client must not cite an edition the API has moved on from.
|
|
263
|
+
return self._http("/meta", {})
|
|
264
|
+
|
|
265
|
+
def _one(self, kind: str, ref: Any, suffix: str = "") -> Any:
|
|
266
|
+
"""A record (or a sub-resource of it) by id, slug, name or alternate name.
|
|
267
|
+
|
|
268
|
+
The reference is one name, whatever characters it holds: "C/NOFS" is a
|
|
269
|
+
mission, not a path. Offline it is resolved to an id here; live, a name
|
|
270
|
+
is sent in slug form, which is what the API reduces it to anyway.
|
|
271
|
+
"""
|
|
272
|
+
if self.mode == "snapshot":
|
|
273
|
+
return self._stored(f"/{kind}/{self._resolve(kind, ref)}{suffix}")
|
|
274
|
+
text = str(ref).strip()
|
|
275
|
+
token = str(_as_int(text)) if _INT.match(text) else _slugify(text)
|
|
276
|
+
if not token:
|
|
277
|
+
raise NotFound(f"no {kind} called {ref!r}")
|
|
278
|
+
return self._http(f"/{kind}/{token}{suffix}", {})
|
|
279
|
+
|
|
280
|
+
@property
|
|
281
|
+
def edition(self) -> Edition:
|
|
282
|
+
if self.mode == "snapshot":
|
|
283
|
+
return self._edition_of(self._manifest)
|
|
284
|
+
return self._edition_of(self._get_meta())
|
|
285
|
+
|
|
286
|
+
def _edition_of(self, m: dict) -> Edition:
|
|
287
|
+
if self.mode == "snapshot":
|
|
288
|
+
return Edition(m.get("edition"), m.get("as_of"), m.get("api_version"), "snapshot",
|
|
289
|
+
str(self._path), m.get("shape_version"))
|
|
290
|
+
return Edition(m.get("registry_edition"), m.get("as_of"), m.get("api_version"), "api", self.base_url)
|
|
291
|
+
|
|
292
|
+
@property
|
|
293
|
+
def licence(self) -> dict:
|
|
294
|
+
"""Licence of the data: name, long_name, url, attribution."""
|
|
295
|
+
return dict((self._manifest if self.mode == "snapshot" else self._get_meta())["licence"])
|
|
296
|
+
|
|
297
|
+
def citation(self) -> str:
|
|
298
|
+
"""A line to cite the data used, with its edition and licence."""
|
|
299
|
+
m = self._manifest if self.mode == "snapshot" else self._get_meta() # one read, so the parts agree
|
|
300
|
+
e, lic = self._edition_of(m), m["licence"]
|
|
301
|
+
return (f"{lic['attribution']}. Edition {e.edition}, data as of {e.as_of}. "
|
|
302
|
+
f"Licensed under {lic['name']} ({lic['url']}).")
|
|
303
|
+
|
|
304
|
+
# ------------------------------------------------------------------ refresh
|
|
305
|
+
|
|
306
|
+
def refresh(self, manifest_url: Optional[str] = None, *, cache_dir: Optional[os.PathLike] = None,
|
|
307
|
+
allow_older: bool = False) -> Edition:
|
|
308
|
+
"""Fetch a newer published edition, verify it, and switch to it.
|
|
309
|
+
|
|
310
|
+
Never called automatically. `manifest_url` (or CEOS_CAPABILITIES_MANIFEST_URL)
|
|
311
|
+
points at a published manifest.json; the snapshot file is fetched from
|
|
312
|
+
beside it, checked against the manifest's SHA-256 and shape version, and
|
|
313
|
+
kept in `cache_dir` (or CEOS_CAPABILITIES_CACHE, default
|
|
314
|
+
~/.cache/ceos-capabilities). An edition older than the one in use is
|
|
315
|
+
refused unless allow_older is set.
|
|
316
|
+
|
|
317
|
+
The switch lasts for this client. A new Client() starts from the
|
|
318
|
+
bundled edition again; to keep using a refreshed one, pass its path
|
|
319
|
+
(`db.edition.source`) as Client(snapshot=...) or in
|
|
320
|
+
CEOS_CAPABILITIES_SNAPSHOT. Proof of concept: no editions are published
|
|
321
|
+
yet, so there is no default address.
|
|
322
|
+
"""
|
|
323
|
+
if self.mode != "snapshot":
|
|
324
|
+
raise RuntimeError("refresh() applies to snapshot mode; api mode is always current")
|
|
325
|
+
url = manifest_url or os.environ.get("CEOS_CAPABILITIES_MANIFEST_URL")
|
|
326
|
+
if not url:
|
|
327
|
+
raise RuntimeError("no published editions to refresh from yet: pass manifest_url, "
|
|
328
|
+
"or use the snapshot shipped with the package")
|
|
329
|
+
with urllib.request.urlopen(urllib.request.Request(url, headers={"User-Agent": _USER_AGENT}),
|
|
330
|
+
timeout=self._timeout) as r:
|
|
331
|
+
raw = r.read()
|
|
332
|
+
try:
|
|
333
|
+
manifest = json.loads(raw.decode("utf-8"))
|
|
334
|
+
except ValueError as e:
|
|
335
|
+
raise SnapshotError(f"{url} is not a snapshot manifest") from e
|
|
336
|
+
if not isinstance(manifest, dict):
|
|
337
|
+
raise SnapshotError(f"{url} is not a snapshot manifest")
|
|
338
|
+
if manifest.get("shape_version") not in SUPPORTED_SHAPES:
|
|
339
|
+
raise SnapshotError(f"the published edition has shape version {manifest.get('shape_version')}; "
|
|
340
|
+
"upgrade the package to read it: pip install -U ceos-capabilities")
|
|
341
|
+
edition, as_of = manifest.get("edition"), manifest.get("as_of")
|
|
342
|
+
if not isinstance(edition, str) or not _EDITION.match(edition):
|
|
343
|
+
raise SnapshotError("the published manifest has no usable edition id")
|
|
344
|
+
if not isinstance(as_of, str) or not _DATE.match(as_of):
|
|
345
|
+
raise SnapshotError("the published manifest has no usable extract date")
|
|
346
|
+
# A snapshot is identified by its extract date AND its edition: the edition
|
|
347
|
+
# is the identifier registry's, and the data can change while it stays the same.
|
|
348
|
+
if (edition, as_of) == (self._manifest.get("edition"), self._manifest.get("as_of")):
|
|
349
|
+
return self.edition
|
|
350
|
+
# Never go backwards by accident: extract dates are ISO dates, so text order is date order.
|
|
351
|
+
if not allow_older and as_of < str(self._manifest.get("as_of") or ""):
|
|
352
|
+
raise SnapshotError(f"the published edition ({edition}, {manifest.get('as_of')}) is older than the one "
|
|
353
|
+
f"in use ({self._manifest.get('edition')}, {self._manifest.get('as_of')}); "
|
|
354
|
+
"pass allow_older=True to use it anyway")
|
|
355
|
+
name = manifest.get("file") or "snapshot.json.gz"
|
|
356
|
+
if not isinstance(name, str) or not re.match(r"^[0-9A-Za-z][0-9A-Za-z._-]*$", name):
|
|
357
|
+
raise SnapshotError("the manifest names a file outside its own directory")
|
|
358
|
+
with urllib.request.urlopen(urllib.request.Request(urllib.parse.urljoin(url, name),
|
|
359
|
+
headers={"User-Agent": _USER_AGENT}), timeout=self._timeout) as r:
|
|
360
|
+
blob = r.read()
|
|
361
|
+
if hashlib.sha256(blob).hexdigest() != manifest.get("sha256"):
|
|
362
|
+
raise SnapshotError("the downloaded snapshot does not match the manifest's checksum; not using it")
|
|
363
|
+
cache = Path(cache_dir or os.environ.get("CEOS_CAPABILITIES_CACHE")
|
|
364
|
+
or Path.home() / ".cache" / "ceos-capabilities")
|
|
365
|
+
cache.mkdir(parents=True, exist_ok=True)
|
|
366
|
+
target = cache / f"snapshot-{as_of}-{edition}.json.gz"
|
|
367
|
+
# A name of its own, so two processes refreshing into one cache do not collide.
|
|
368
|
+
handle, tmp_name = tempfile.mkstemp(dir=cache, prefix=target.name + ".", suffix=".part")
|
|
369
|
+
os.close(handle)
|
|
370
|
+
tmp = Path(tmp_name)
|
|
371
|
+
# One transaction: write, load, verify and move into place. Any failure, including
|
|
372
|
+
# the final move, leaves this client on the snapshot it had and removes the part file.
|
|
373
|
+
previous = (self._manifest, self._responses, self._path, self._slugs)
|
|
374
|
+
try:
|
|
375
|
+
tmp.write_bytes(blob)
|
|
376
|
+
self._load_snapshot(tmp)
|
|
377
|
+
if (self._manifest.get("edition"), self._manifest.get("as_of")) != (edition, as_of):
|
|
378
|
+
raise SnapshotError("the downloaded snapshot is not the edition its manifest announced; not using it")
|
|
379
|
+
tmp.replace(target)
|
|
380
|
+
self._path = target
|
|
381
|
+
except BaseException:
|
|
382
|
+
self._manifest, self._responses, self._path, self._slugs = previous
|
|
383
|
+
try:
|
|
384
|
+
tmp.unlink()
|
|
385
|
+
except OSError:
|
|
386
|
+
pass
|
|
387
|
+
raise
|
|
388
|
+
return self.edition
|
|
389
|
+
|
|
390
|
+
# ------------------------------------------------------------------ collections
|
|
391
|
+
|
|
392
|
+
def _list(self, path: str, key: str) -> Records:
|
|
393
|
+
return Records(self.get(path)[key])
|
|
394
|
+
|
|
395
|
+
def missions(self) -> Records:
|
|
396
|
+
return self._list("/missions", "missions")
|
|
397
|
+
|
|
398
|
+
def mission(self, ref) -> dict:
|
|
399
|
+
"""One mission by id, slug ("sentinel-1-a") or alternate name ("S1A")."""
|
|
400
|
+
return self._one("mission", ref)
|
|
401
|
+
|
|
402
|
+
def mission_instruments(self, mission_id) -> Any:
|
|
403
|
+
return self.get(f"/mission/{self._id('mission', mission_id)}/instruments")
|
|
404
|
+
|
|
405
|
+
def instruments(self) -> Records:
|
|
406
|
+
return self._list("/instruments", "instruments")
|
|
407
|
+
|
|
408
|
+
def instrument(self, ref) -> dict:
|
|
409
|
+
return self._one("instrument", ref)
|
|
410
|
+
|
|
411
|
+
def sar_parameters(self, instrument_id) -> dict:
|
|
412
|
+
return self.get(f"/instrument/{self._id('instrument', instrument_id)}/sar-parameters")
|
|
413
|
+
|
|
414
|
+
def measurements(self) -> Records:
|
|
415
|
+
return self._list("/measurements", "measurements")
|
|
416
|
+
|
|
417
|
+
def measurement(self, ref) -> dict:
|
|
418
|
+
return self._one("measurement", ref)
|
|
419
|
+
|
|
420
|
+
def series(self) -> Records:
|
|
421
|
+
return self._list("/series", "series")
|
|
422
|
+
|
|
423
|
+
def series_detail(self, ref) -> dict:
|
|
424
|
+
return self._one("series", ref)
|
|
425
|
+
|
|
426
|
+
def constellations(self) -> Records:
|
|
427
|
+
return self._list("/constellations", "constellations")
|
|
428
|
+
|
|
429
|
+
def constellation(self, ref) -> dict:
|
|
430
|
+
return self._one("constellation", ref)
|
|
431
|
+
|
|
432
|
+
def constellation_units(self, constellation_id) -> Any:
|
|
433
|
+
return self.get(f"/constellation/{self._id('constellation', constellation_id)}/units")
|
|
434
|
+
|
|
435
|
+
def timelines(self) -> Records:
|
|
436
|
+
return self._list("/timelines", "timelines")
|
|
437
|
+
|
|
438
|
+
def timeline(self, timeline_id) -> dict:
|
|
439
|
+
return self.get(f"/timelines/{timeline_id}")
|
|
440
|
+
|
|
441
|
+
def products(self) -> Records:
|
|
442
|
+
return self._list("/products", "products")
|
|
443
|
+
|
|
444
|
+
def providers(self) -> Records:
|
|
445
|
+
return self._list("/providers", "providers")
|
|
446
|
+
|
|
447
|
+
def provider(self, ref) -> dict:
|
|
448
|
+
return self._one("provider", ref)
|
|
449
|
+
|
|
450
|
+
def wavebands(self) -> Records:
|
|
451
|
+
return self._list("/wavebands", "wavebands")
|
|
452
|
+
|
|
453
|
+
def identifiers(self) -> Records:
|
|
454
|
+
"""The identifier registry: every canonical slug and alternate name."""
|
|
455
|
+
return self._list("/identifiers", "identifiers")
|
|
456
|
+
|
|
457
|
+
def _id(self, kind: str, ref) -> Any:
|
|
458
|
+
"""Routes that take an id only: resolve a slug first, in either mode."""
|
|
459
|
+
text = str(ref).strip()
|
|
460
|
+
if _INT.match(text):
|
|
461
|
+
return _as_int(text)
|
|
462
|
+
if self.mode == "snapshot":
|
|
463
|
+
return self._resolve(kind, ref)
|
|
464
|
+
key = {"mission": "mission_id", "instrument": "instrument_id", "constellation": "constellation_id"}[kind]
|
|
465
|
+
return self._one(kind, ref)[key]
|
|
466
|
+
|
|
467
|
+
def __repr__(self) -> str:
|
|
468
|
+
# No network call from a repr: in api mode the edition is not looked up here.
|
|
469
|
+
if self.mode == "api":
|
|
470
|
+
return f"<ceos_capabilities.Client api: {self.base_url}>"
|
|
471
|
+
return f"<ceos_capabilities.Client {self.edition}>"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"shape_version": 1,
|
|
3
|
+
"edition": "e574f0c2",
|
|
4
|
+
"as_of": "2026-10-23",
|
|
5
|
+
"api_version": "0.4.4",
|
|
6
|
+
"derived_as_of_year": 2026,
|
|
7
|
+
"source": "CEOS MIM Database, as served by the CEOS Capabilities API",
|
|
8
|
+
"licence": {
|
|
9
|
+
"name": "CC BY 4.0",
|
|
10
|
+
"long_name": "Creative Commons Attribution 4.0 International",
|
|
11
|
+
"url": "https://creativecommons.org/licenses/by/4.0/",
|
|
12
|
+
"attribution": "CEOS MIM Database, https://database.eohandbook.com",
|
|
13
|
+
"effective_from": "2026-09-07"
|
|
14
|
+
},
|
|
15
|
+
"responses": 8244,
|
|
16
|
+
"absent_subresources": 0,
|
|
17
|
+
"sha256": "70e09e4159a4754c7e7ff2a1f70b84aeb6a45120d4e871ed687ed5a4217f02dc",
|
|
18
|
+
"bytes": 2088075,
|
|
19
|
+
"file": "snapshot.json.gz"
|
|
20
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ceos-capabilities
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Client for the CEOS MIM Database: an offline snapshot or the live CEOS Capabilities API, same interface
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://ceos-capabilities.org
|
|
7
|
+
Project-URL: Examples, https://github.com/ceos-capabilities/examples
|
|
8
|
+
Keywords: earth observation,CEOS,satellite missions,instruments,MIM Database
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: NOTICE
|
|
17
|
+
Provides-Extra: pandas
|
|
18
|
+
Requires-Dist: pandas; extra == "pandas"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# ceos-capabilities
|
|
22
|
+
|
|
23
|
+
A small Python client for the CEOS MIM Database, the data behind the
|
|
24
|
+
[EO Capabilities Explorer](https://ceos-capabilities.org).
|
|
25
|
+
|
|
26
|
+
**Status: early release.** A proof of concept from Phase 1 of the CEOS MIM+ pilot. The interface
|
|
27
|
+
may change before 1.0.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install ceos-capabilities # standard library only
|
|
31
|
+
pip install "ceos-capabilities[pandas]" # adds .to_pandas()
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Needs Python 3.9 or later.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from ceos_capabilities import Client
|
|
38
|
+
|
|
39
|
+
db = Client() # offline: the snapshot shipped in the package; no network
|
|
40
|
+
db = Client(mode="api") # live: https://ceos-capabilities.org/api
|
|
41
|
+
|
|
42
|
+
db.missions().to_pandas() # every list is a list of dicts; to_pandas() if pandas is installed
|
|
43
|
+
db.mission("sentinel-1-a") # by id, slug or alternate name ("S1A")
|
|
44
|
+
db.sar_parameters(1589) # extended parameters and imaging modes
|
|
45
|
+
db.edition # which data this is: edition, extract date, source
|
|
46
|
+
db.citation() # a line to cite it, with the licence
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Both modes answer the same calls with the same shapes, so code written against one runs
|
|
50
|
+
against the other.
|
|
51
|
+
|
|
52
|
+
## Two ways to read the data
|
|
53
|
+
|
|
54
|
+
| | Offline (default) | Live (`mode="api"`) |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| Network | none | needed |
|
|
57
|
+
| Data | the edition in the package, or one you supply or refresh to | current |
|
|
58
|
+
| Rate limits | none | the API's (a free key raises them) |
|
|
59
|
+
| Suits | pipelines, containers, reproducible analysis | interactive work, the newest data |
|
|
60
|
+
|
|
61
|
+
The offline snapshot is a capture of the API's own responses, taken when an edition is
|
|
62
|
+
published. It therefore holds exactly what the API serves, in the API's shapes.
|
|
63
|
+
|
|
64
|
+
## Editions, shapes and refresh
|
|
65
|
+
|
|
66
|
+
- An **edition** is a published extract of the database. `db.edition` names the one in use.
|
|
67
|
+
- A **shape version** changes only when existing fields are renamed, removed or restructured. A
|
|
68
|
+
client refuses a snapshot in a shape it does not understand and says to upgrade. New fields are
|
|
69
|
+
not a new shape.
|
|
70
|
+
- `db.refresh(manifest_url)` fetches a newer edition, checks its SHA-256 and shape, caches it and
|
|
71
|
+
switches to it. It is never called automatically. **No editions are published yet**, so there is
|
|
72
|
+
no default address.
|
|
73
|
+
- `Client(snapshot="/path/snapshot.json.gz")` uses a file you supply (air-gapped sites; images
|
|
74
|
+
that bake the data in).
|
|
75
|
+
|
|
76
|
+
Environment variables: `CEOS_CAPABILITIES_MODE`, `CEOS_CAPABILITIES_SNAPSHOT`,
|
|
77
|
+
`CEOS_CAPABILITIES_API_KEY`, `CEOS_CAPABILITIES_MANIFEST_URL`, `CEOS_CAPABILITIES_CACHE`.
|
|
78
|
+
|
|
79
|
+
## Limits of this proof of concept
|
|
80
|
+
|
|
81
|
+
- Query parameters and the analysis endpoints work in live mode only.
|
|
82
|
+
- The snapshot holds the missions the API lists by default (Earth observation missions).
|
|
83
|
+
- `refresh()` is tested against local files only. It lasts for the client it is called on: a new `Client()` starts from the bundled edition unless given the refreshed file (`db.edition.source`).
|
|
84
|
+
- Offline holds the routes the builder names: lists, details, measurement variables, the identifier registry and combinations. The per-record `/identifiers` routes are not stored (the registry is).
|
|
85
|
+
- A few fields are worked out by the API from the calendar year, such as the `phase` of each mission under a measurement variable. Offline they are as worked out in the year the snapshot was built (`derived_as_of_year` in its manifest), so they can differ from live once the year turns.
|
|
86
|
+
- `get()` accepts a name or slug on a record's own route (`/mission/sentinel-1-a`) and an id on the routes beneath it (`/mission/575/instruments`), as the API does. The named methods accept either everywhere.
|
|
87
|
+
- An API key is sent only over https, or to localhost, and is dropped if the API redirects to another host.
|
|
88
|
+
- No write path of any kind.
|
|
89
|
+
|
|
90
|
+
## Licence
|
|
91
|
+
|
|
92
|
+
Code: [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0), the CEOS standard licence for software. Data: CEOS MIM Database,
|
|
93
|
+
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); cite it with `db.citation()`.
|
|
94
|
+
|
|
95
|
+
Worked examples for the API and this client are collected at
|
|
96
|
+
https://github.com/ceos-capabilities/examples.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
ceos_capabilities/__init__.py,sha256=MGnK9qiN3kPCSHsTW313yeHjnSAKyd0et4rK8IRQ7IM,536
|
|
2
|
+
ceos_capabilities/client.py,sha256=dseXqhHkx8h9b_COm7YYDplkGPCqG6rO7aP_mKwfNls,23220
|
|
3
|
+
ceos_capabilities/data/manifest.json,sha256=HLccilygKtHlz8SfGo1vQl45-ywM7b4-nQ7MgfbJjrs,662
|
|
4
|
+
ceos_capabilities/data/snapshot.json.gz,sha256=cOCeQVmkdUx-f_Kh9wuErrakUSDU6HHtaH7VpCF_Atw,2088075
|
|
5
|
+
ceos_capabilities-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
6
|
+
ceos_capabilities-0.1.0.dist-info/licenses/NOTICE,sha256=jQORam9N-WIvw2DqjCYfe9RGMrZMLpgeEidgPDncEJQ,584
|
|
7
|
+
ceos_capabilities-0.1.0.dist-info/METADATA,sha256=uT97Fot_zajmlw4GrIkry6Q-gYIE_37bIbgMSo07tDM,4887
|
|
8
|
+
ceos_capabilities-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
9
|
+
ceos_capabilities-0.1.0.dist-info/top_level.txt,sha256=P75WQjnKHWnd8PdMirUNtr-_-5GustzhVnxlfkmX-mg,18
|
|
10
|
+
ceos_capabilities-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
ceos-capabilities
|
|
2
|
+
Python client for the CEOS MIM Database and the CEOS Capabilities API.
|
|
3
|
+
|
|
4
|
+
The code in this package is licensed under the Apache License, Version 2.0
|
|
5
|
+
(see LICENSE), the CEOS standard licence for software.
|
|
6
|
+
|
|
7
|
+
The data bundled with this package (src/ceos_capabilities/data/) is content of
|
|
8
|
+
the CEOS MIM Database and is licensed separately under Creative Commons
|
|
9
|
+
Attribution 4.0 International (CC BY 4.0):
|
|
10
|
+
https://creativecommons.org/licenses/by/4.0/
|
|
11
|
+
Each snapshot carries its licence, attribution text, edition and extract date;
|
|
12
|
+
Client.citation() returns a line to cite it.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ceos_capabilities
|