parseo 0.4.4__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.
Files changed (70) hide show
  1. parseo/__init__.py +53 -0
  2. parseo/_epsg_lookup.py +145 -0
  3. parseo/_field_mappings.py +219 -0
  4. parseo/_json.py +14 -0
  5. parseo/_tile_systems.py +51 -0
  6. parseo/assembler.py +225 -0
  7. parseo/cli.py +383 -0
  8. parseo/parser.py +784 -0
  9. parseo/schema_registry.py +246 -0
  10. parseo/schemas/copernicus/clms/clc/clc_filename_v1_0_0.json +48 -0
  11. parseo/schemas/copernicus/clms/clc/clc_filename_v1_1_0.json +65 -0
  12. parseo/schemas/copernicus/clms/clcplus/ras/clcplus_filename_v0_0_0.json +90 -0
  13. parseo/schemas/copernicus/clms/clcplus/ras/clcplus_filename_v0_0_1.json +80 -0
  14. parseo/schemas/copernicus/clms/egms/egms_gnss_model_filename_v0_0_0.json +46 -0
  15. parseo/schemas/copernicus/clms/egms/egms_l2a_product_filename_v0_0_0.json +71 -0
  16. parseo/schemas/copernicus/clms/egms/egms_l3_velocity_grid_filename_v0_0_0.json +64 -0
  17. parseo/schemas/copernicus/clms/euhydro/euhydro_filename_v0_0_0.json +115 -0
  18. parseo/schemas/copernicus/clms/euhydro/euhydro_filename_v0_0_1.json +103 -0
  19. parseo/schemas/copernicus/clms/hr-vpp/st_filename_v0_0_0.json +82 -0
  20. parseo/schemas/copernicus/clms/hr-vpp/vi_filename_v0_0_0.json +89 -0
  21. parseo/schemas/copernicus/clms/hr-vpp/vpp_filename_v0_0_0.json +109 -0
  22. parseo/schemas/copernicus/clms/hr-wsi/cc_filename_v0_0_0.json +84 -0
  23. parseo/schemas/copernicus/clms/hr-wsi/fsc_filename_v0_0_0.json +88 -0
  24. parseo/schemas/copernicus/clms/hr-wsi/gfsc_filename_v0_0_0.json +83 -0
  25. parseo/schemas/copernicus/clms/hr-wsi/icd_filename_v0_0_0.json +96 -0
  26. parseo/schemas/copernicus/clms/hr-wsi/sp_filename_v0_0_0.json +177 -0
  27. parseo/schemas/copernicus/clms/hr-wsi/sws_filename_v0_0_0.json +83 -0
  28. parseo/schemas/copernicus/clms/hr-wsi/wcd_filename_v0_0_0.json +96 -0
  29. parseo/schemas/copernicus/clms/hr-wsi/wds_filename_v0_0_0.json +83 -0
  30. parseo/schemas/copernicus/clms/hr-wsi/wic_comb_filename_v0_0_0.json +82 -0
  31. parseo/schemas/copernicus/clms/hr-wsi/wic_filename_v0_0_0.json +90 -0
  32. parseo/schemas/copernicus/clms/hrl/fty_filename_v0_0_0.json +48 -0
  33. parseo/schemas/copernicus/clms/hrl/gra_filename_v0_0_0.json +48 -0
  34. parseo/schemas/copernicus/clms/hrl/ibu_filename_v0_0_0.json +57 -0
  35. parseo/schemas/copernicus/clms/hrl/imp_filename_v0_0_0.json +48 -0
  36. parseo/schemas/copernicus/clms/hrl/nvlcc_filename_v0_0_0.json +73 -0
  37. parseo/schemas/copernicus/clms/hrl/nvlcc_filename_v0_0_1.json +89 -0
  38. parseo/schemas/copernicus/clms/hrl/nvlcc_filename_v0_0_2.json +89 -0
  39. parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_0.json +48 -0
  40. parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_1.json +49 -0
  41. parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_2.json +93 -0
  42. parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_3.json +99 -0
  43. parseo/schemas/copernicus/clms/hrl/tcd_filename_v0_0_0.json +48 -0
  44. parseo/schemas/copernicus/clms/hrl/vlcc_filename_v0_0_0.json +105 -0
  45. parseo/schemas/copernicus/clms/hrl/waw_filename_v0_0_0.json +48 -0
  46. parseo/schemas/copernicus/clms/n2k/n2k_filename_v1_0_0.json +43 -0
  47. parseo/schemas/copernicus/clms/pa/pa_filename_v1_0_0.json +99 -0
  48. parseo/schemas/copernicus/clms/riparian-zones/rpz_filename_v0_0_0.json +50 -0
  49. parseo/schemas/copernicus/clms/urban-atlas/ua_dhm_filename_v0_0_0.json +53 -0
  50. parseo/schemas/copernicus/clms/urban-atlas/ua_filename_v0_0_0.json +105 -0
  51. parseo/schemas/copernicus/clms/urban-atlas/ua_stl_filename_v0_0_0.json +89 -0
  52. parseo/schemas/copernicus/sentinel/s1_filename_v1_0_0.json +78 -0
  53. parseo/schemas/copernicus/sentinel/s2_filename_v1_0_0.json +62 -0
  54. parseo/schemas/copernicus/sentinel/s3_filename_v1_0_0.json +22 -0
  55. parseo/schemas/copernicus/sentinel/s4_filename_v1_0_0.json +21 -0
  56. parseo/schemas/copernicus/sentinel/s5p_filename_v1_0_0.json +21 -0
  57. parseo/schemas/copernicus/sentinel/s6_filename_v1_0_0.json +23 -0
  58. parseo/schemas/eumetsat/metop_filename_v1_0_0.json +68 -0
  59. parseo/schemas/eumetsat/mtg_filename_v1_0_0.json +65 -0
  60. parseo/schemas/nasa/modis_filename_v1_0_0.json +54 -0
  61. parseo/schemas/usgs/landsat/landsat_filename_v1_0_0.json +50 -0
  62. parseo/stac_http.py +267 -0
  63. parseo/stac_scraper.py +115 -0
  64. parseo/template.py +78 -0
  65. parseo-0.4.4.dist-info/METADATA +402 -0
  66. parseo-0.4.4.dist-info/RECORD +70 -0
  67. parseo-0.4.4.dist-info/WHEEL +5 -0
  68. parseo-0.4.4.dist-info/entry_points.txt +2 -0
  69. parseo-0.4.4.dist-info/licenses/LICENSE.txt +287 -0
  70. parseo-0.4.4.dist-info/top_level.txt +1 -0
parseo/template.py ADDED
@@ -0,0 +1,78 @@
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ from typing import Dict
5
+ from typing import List
6
+ from typing import Tuple
7
+ from typing import Union
8
+
9
+ def _field_regex(spec: Union[Dict, None]) -> str:
10
+ """Return a regex for a field spec.
11
+
12
+ If *spec* is missing or empty, a permissive pattern ``.+`` is used.
13
+ Anchors in patterns are stripped so they integrate into larger regexes.
14
+ """
15
+ if not spec:
16
+ return ".+"
17
+ if "enum" in spec:
18
+ return "(?:" + "|".join(re.escape(v) for v in spec["enum"]) + ")"
19
+ if "oneOf" in spec:
20
+ options = [
21
+ _field_regex(option)
22
+ for option in spec["oneOf"]
23
+ if option is not None
24
+ ]
25
+ if not options:
26
+ return ".+"
27
+ return "(?:" + "|".join(f"(?:{option})" for option in options) + ")"
28
+ pattern = spec.get("pattern")
29
+ if pattern is None:
30
+ raise KeyError("Field spec missing 'pattern' or 'enum'")
31
+ if pattern.startswith("^"):
32
+ pattern = pattern[1:]
33
+ if pattern.endswith("$"):
34
+ pattern = pattern[:-1]
35
+ return pattern
36
+
37
+ def compile_template(template: str, fields: Dict[str, Dict]) -> Tuple[str, List[str]]:
38
+ """Compile *template* into a regex pattern and extract field order.
39
+
40
+ ``{field}`` placeholders are replaced using patterns or enums from
41
+ *fields*. Optional segments can be denoted with ``[ ... ]`` and will be
42
+ converted into non-capturing optional groups. The returned pattern is
43
+ anchored with ``^`` and ``$``.
44
+ """
45
+ order: List[str] = []
46
+
47
+ def _compile(segment: str) -> str:
48
+ result = ""
49
+ i = 0
50
+ while i < len(segment):
51
+ ch = segment[i]
52
+ if ch == "{":
53
+ j = segment.index("}", i)
54
+ name = segment[i + 1 : j]
55
+ if name not in order:
56
+ order.append(name)
57
+ regex = _field_regex(fields.get(name))
58
+ result += f"(?P<{name}>{regex})"
59
+ i = j + 1
60
+ elif ch == "[":
61
+ depth = 1
62
+ j = i + 1
63
+ while j < len(segment) and depth:
64
+ if segment[j] == "[":
65
+ depth += 1
66
+ elif segment[j] == "]":
67
+ depth -= 1
68
+ j += 1
69
+ inner = segment[i + 1 : j - 1]
70
+ result += f"(?:{_compile(inner)})?"
71
+ i = j
72
+ else:
73
+ result += re.escape(ch)
74
+ i += 1
75
+ return result
76
+
77
+ pattern = "^" + _compile(template) + "$"
78
+ return pattern, order
@@ -0,0 +1,402 @@
1
+ Metadata-Version: 2.4
2
+ Name: parseo
3
+ Version: 0.4.4
4
+ Summary: Filename parser/assembler for satellite data
5
+ Author-email: Matteo Mattiuzzi <matteo@mattiuzzi.com>
6
+ License: EUPL-1.2
7
+ Project-URL: Homepage, https://github.com/copernicus-land/parsEO
8
+ Project-URL: Repository, https://github.com/copernicus-land/parsEO.git
9
+ Project-URL: Issues, https://github.com/copernicus-land/parsEO/issues
10
+ Project-URL: Changelog, https://github.com/copernicus-land/parsEO/releases
11
+ Keywords: satellite,remote-sensing,filenames,sentinel,parsing
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Topic :: Scientific/Engineering :: GIS
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE.txt
25
+ Requires-Dist: build>=1.4.4
26
+ Provides-Extra: dev
27
+ Requires-Dist: build; extra == "dev"
28
+ Requires-Dist: twine; extra == "dev"
29
+ Requires-Dist: ruff; extra == "dev"
30
+ Requires-Dist: mypy; extra == "dev"
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
33
+ Provides-Extra: web
34
+ Requires-Dist: fastapi; extra == "web"
35
+ Requires-Dist: uvicorn; extra == "web"
36
+ Dynamic: license-file
37
+
38
+ ::: {align="center"}
39
+ # parsEO
40
+
41
+ **parsEO** is a Python toolkit that parses existing Earth Observation filenames into structured metadata and assembles new filenames from validated fields. Filename rules live in JSON schemas, turning the repository into a single source of truth for product nomenclature.
42
+ :::
43
+
44
+ ## Why parsEO?
45
+
46
+ - **Bidirectional workflows** – convert filenames to Python dictionaries and rebuild filenames from the same fields.
47
+ - **Schema-driven** – JSON schemas define every product token, validation rule, and STAC link. Drop in a new schema file and it is discovered automatically.
48
+ - **Extensible** – contributions focus on data, not glue code. Adding support for a new mission only requires a schema.
49
+
50
+ ## Supported product families
51
+
52
+ - **Sentinel missions** – S1, S2, S3, S4, S5P, S6
53
+ - **Landsat** – LT04, LT05, LE07, LC08, LC09
54
+ - **NASA MODIS** – Terra and Aqua MODIS products
55
+ - **EUMETSAT missions** – MTG, Metop
56
+ - **Copernicus Land Monitoring Service (CLMS)**
57
+ - Corine Land Cover (CLC) and CLC+ Raster
58
+ - European Ground Motion Service (EGMS) Level 2 basic/calibrated products, Level 3 velocity grid, and GNSS model
59
+ - Urban Atlas Land Cover / Land Use
60
+ - High Resolution Vegetation Phenology & Productivity (HR-VPP): Seasonal Trajectories (PPI) and Vegetation Indices (FAPAR, LAI, NDVI, PPI, FCOVER, DMP)
61
+ - High Resolution Water & Snow / Ice (HR-WSI): CC, FSC, GFSC, ICD, SWS, WDS, WIC, WIC-COMB, SP_S2, SP_COMB
62
+ - High Resolution Layers (HRL): Forest Type, Grassland, Imperviousness, Non-Vegetated Land Cover Characteristics, Tree Cover Density, Water & Wetness, Small Woody Features
63
+
64
+ ## Installation
65
+
66
+ ``` bash
67
+ pip install parseo
68
+ ```
69
+
70
+ For development installs:
71
+
72
+ ``` bash
73
+ git clone https://github.com/copernicus-land/parsEO.git
74
+ cd parsEO
75
+ pip install -e .
76
+ ```
77
+
78
+ Confirm the CLI is available:
79
+
80
+ ``` bash
81
+ parseo --version
82
+ ```
83
+
84
+ ## Quick start
85
+
86
+ ### Parse a filename
87
+
88
+ ``` python
89
+ from parseo import parse_auto
90
+
91
+ name = "S2B_MSIL2A_20241123T224759_N0511_R101_T03VUL_20241123T230829.SAFE"
92
+ result = parse_auto(name)
93
+
94
+ print(result.valid) # True
95
+ print(result.fields) # structured dict of extracted fields
96
+ ```
97
+
98
+ Another example using a MODIS filename:
99
+
100
+ ``` python
101
+ from parseo import parse_auto
102
+
103
+ name = "MOD09GA.A2021123.h18v04.006.2021132234506.hdf"
104
+ result = parse_auto(name)
105
+
106
+ print(result.fields["platform"]) # MOD
107
+ print(result.fields["product"]) # 09
108
+ print(result.fields["variant"]) # GA
109
+ ```
110
+
111
+ The MODIS schema advertises the Processing, Sat, Raster, and Electro-Optical STAC extensions, enabling automated STAC metadata generation (`processing`, `sat`, `raster`, `eo`).
112
+
113
+ ### Assemble a filename
114
+
115
+ ``` python
116
+ from parseo import assemble, assemble_auto
117
+
118
+ fields = {
119
+ "platform": "S2B",
120
+ "instrument": "MSI",
121
+ "processing_level": "L2A",
122
+ "sensing_datetime": "20241123T224759",
123
+ "processing_baseline": "N0511",
124
+ "relative_orbit": "R101",
125
+ "tile_id": "T03VUL", # MGRS tile (TxxYYY, e.g. T32TNS)
126
+ "generation_datetime": "20241123T230829",
127
+ "extension": "SAFE",
128
+ }
129
+
130
+ assemble_auto(fields)
131
+ # 'S2B_MSIL2A_20241123T224759_N0511_R101_T03VUL_20241123T230829.SAFE'
132
+
133
+ assemble(fields, family="S2")
134
+ # Uses the default (current) Sentinel-2 schema for quicker resolution.
135
+
136
+ assemble(fields, family="S2", version="1.0.0")
137
+ # Lock both family and schema version explicitly.
138
+ ```
139
+
140
+ To force a specific schema file:
141
+
142
+ ``` python
143
+ from pathlib import Path
144
+ from parseo import assemble
145
+
146
+ schema_path = Path("src/parseo/schemas/copernicus/sentinel/s2/s2_filename_v1_0_0.json")
147
+ filename = assemble(fields, schema_path=schema_path)
148
+ ```
149
+
150
+ `parse_auto` reports the schema version and lifecycle status that were used:
151
+
152
+ ``` python
153
+ from parseo import parse_auto
154
+
155
+ result = parse_auto("S2B_MSIL2A_20241123T224759_N0511_R101_T03VUL_20241123T230829.SAFE")
156
+ print(result.version) # '1.0.0'
157
+ print(result.status) # 'current'
158
+ ```
159
+
160
+ ### Command-line interface
161
+
162
+ The same functionality is exposed through the CLI.
163
+
164
+ ``` bash
165
+ # Parse a filename
166
+ parseo parse S2B_MSIL2A_20241123T224759_N0511_R101_T03VUL_20241123T230829.SAFE
167
+
168
+ # Parse a Copernicus Land Monitoring Service (CLMS) filename
169
+ parseo parse ST_20240101T123045_S2_E15N45-03035-010m_V100_PPI.tif
170
+
171
+ # Parse and write the JSON response to a file
172
+ parseo parse ST_20240101T123045_S2_E15N45-03035-010m_V100_PPI.tif --output result.json
173
+
174
+ # Assemble from the saved JSON document. The CLI automatically
175
+ # extracts the `fields` entry produced by `parseo parse`.
176
+ cat result.json | parseo assemble --family copernicus:clms:hr-vpp:st --fields-json -
177
+
178
+ # Pipe the parse result directly into assemble
179
+ parseo parse ST_20240101T123045_S2_E15N45-03035-010m_V100_PPI.tif \
180
+ | parseo assemble --family copernicus:clms:hr-vpp:st
181
+
182
+ # Assemble the same CLMS filename from key=value pairs
183
+ parseo assemble
184
+ product=ST
185
+ timestamp=20240101T123045
186
+ sensor=S2
187
+ tile_id=E15N45
188
+ epsg_code=03035
189
+ resolution=010m
190
+ version=V100
191
+ variable=PPI
192
+ extension=tif
193
+ ```
194
+
195
+ ### Discover available schemas
196
+
197
+ List every schema that ships with parsEO, including its fully qualified `schema_id`, semantic version, lifecycle status, and file location:
198
+
199
+ ``` bash
200
+ parseo list-schemas
201
+ ```
202
+
203
+ The command prints a table summarizing all discovered schemas, making it easy to confirm which versions are available before parsing or assembling filenames. The first column shows the complete namespace (for example `copernicus:clms:hrl:vlcc`), so you can see exactly where a product sits inside the Copernicus hierarchy.
204
+
205
+ List only the schemas that are marked as `current` with the built-in filter (works on every platform):
206
+
207
+ ``` bash
208
+ parseo list-schemas --status current
209
+ ```
210
+
211
+ To inspect a single family in the summary table, provide the short family name explicitly. You can also pass a namespace prefix to see every schema beneath it:
212
+
213
+ ``` bash
214
+ parseo list-schemas --family S2
215
+ parseo list-schemas --family copernicus
216
+ parseo list-schemas --family copernicus:clms:hrl
217
+ ```
218
+
219
+ For the full schema metadata (fields, examples, etc.), use `schema-info`:
220
+
221
+ ``` bash
222
+ parseo schema-info S2
223
+ ```
224
+
225
+ The JSON response includes the schema's semantic version and lifecycle status so
226
+ you can immediately tell which release you are viewing. To inspect an archived
227
+ version, provide the version number explicitly:
228
+
229
+ ``` bash
230
+ parseo schema-info --version 1.0.0 CLC
231
+ ```
232
+
233
+ ### Working with specific schema versions
234
+
235
+ When multiple schema versions are present, parsEO chooses the one whose `status` is `"current"`. If none are marked current, the highest `schema_version` wins. You can inspect historical schemas with `parseo schema-info --version <x.y.z> <family>` and you can always pin a schema by passing `schema_path` to `assemble` or `parse`.
236
+
237
+ ## Authoring new Schema
238
+
239
+ Adding a schema requires only a JSON document under `src/parseo/schemas/`. Start from an existing product schema or the skeleton in `template/`.
240
+
241
+ - **Create the product directory** – `src/parseo/schemas/<family>/<mission>/<product>/` (only the family level is mandatory).
242
+
243
+ - **Write the versioned schema file** – `<product>_filename_vX_Y_Z.json` with required metadata (`schema_id`, `schema_version`, `status`, optional `stac_version`, `stac_extensions`, and `description`).
244
+
245
+ - **Maintain versions** — mark the latest schema as `"current"` and move older ones to `"deprecated"` (or similar). parsEO uses these flags to pick defaults.
246
+
247
+ **Schema versioning policy:** Schemas at version `0.0.0` are provisional — their patterns and field definitions may change without notice. Once a product's naming convention is finalised (typically when it reaches CDSE production), the schema should be promoted to `1.0.0` to signal a stable, supported contract.
248
+
249
+ ### Container Object `fields`
250
+
251
+ **`fields`** is a container object to define filename tokens and translation mechanisms from/to STAC. Each `property` combines JSON Schema keywords (`type`, `pattern`, `enum`, …) and optional documentation. The `property name` is the variable name used by the `template` container and unless a `stac_map` is applied also what is retrieved by `parseo parse` or fed into `parseo assemble`.
252
+
253
+ ``` json
254
+ "fields": {
255
+ "property-1": {
256
+ "type": "string",
257
+ "enum": ["A","B"],
258
+ "description": "descripton of property 1"
259
+ },
260
+ "property-2": {
261
+ "type": "string",
262
+ "pattern": "^(\d{8}T\d{6})$",
263
+ "description": "descripton of property 2"
264
+ },
265
+ ...
266
+ }
267
+ ```
268
+
269
+ #### `type`
270
+
271
+ The keyword `type` is currently set to "string" by default, and used as best practice.
272
+
273
+ #### `enum` or `pattern`
274
+
275
+ - Use `enum` for short, controlled vocabularies such as file extensions or processing modes (`["A","B"]`). It keeps validation strict and self-documenting.
276
+ - Use `pattern` for structured tokens like timestamps (`^\d{8}T\d{6}$`), version identifiers (`^V\d{3}$`), or grid identifiers (`^h\d{2}v\d{2}$`).
277
+
278
+ #### `oneOf`
279
+
280
+ Use `oneOf` to express mutually exclusive validation branches for a single field. Each branch can provide its own JSON Schema keywords, enabling concise modelling of tokens that admit multiple formats. For example, a `variant` token may allow either a fixed set of legacy values or a future-proof pattern:
281
+
282
+ ``` json
283
+ "variant": {
284
+ "type": "string",
285
+ "oneOf": [
286
+ {"enum": ["A", "B", "C"]},
287
+ {"pattern": "^X\d{2}$"},
288
+ {"pattern": "^z\d{4}$"}
289
+ ],
290
+ "description": "Legacy letters or experimental codes"
291
+ }
292
+ ```
293
+
294
+ When `parseo parse` runs, the value is checked against each branch in order until one succeeds. `parseo assemble` accepts any value satisfying at least one branch, allowing schemas to stay expressive without duplicating fields.
295
+
296
+ #### `stac_map`
297
+
298
+ Functionality to connect filename tokens to STAC properties in case of incompatibility. In the following example `parseo parse` matches the filename field `prefix` but returns the STAC compliant `platform` and `instrument`. `parseo assemble` must be provided with `platform` and `instrument` and converts it to the correct `prefix` as defined by the filename `template`.
299
+
300
+ ``` json
301
+ "prefix": {
302
+ "type": "string",
303
+ "pattern": "^(MOD|MYD|MCD)$",
304
+ "stac_map": {
305
+ "MOD": {
306
+ "platform": "Terra",
307
+ "instrument": "MODIS"
308
+ },
309
+ "MYD": {
310
+ "platform": "Aqua",
311
+ "instrument": "MODIS"
312
+ },
313
+ "MCD": {
314
+ "platform": "Combined",
315
+ "instrument": "MODIS"
316
+ }
317
+ }
318
+ }
319
+ ```
320
+
321
+
322
+ #### Container Object `template`
323
+ A filename is assembled/parsed based on the definition put into `template` container object. E.g.:
324
+
325
+ ``` json
326
+ "template": "{variable}-C{reference_year}_R{resolution}_{tile_id}{epsg_code}_{version}[.{extension}]"
327
+ ```
328
+
329
+ `fields` are added to the `template` using the `{property name}`. The template further decides for the fields are arranged and how they are separated from each other. Further it is possible to ad permanent elements as well, e.g. adding a prefix `C` to the `{reference_year} = C{reference_year}` to match e.g. 'C2012'. This can be particularly useful if you are interested in only parts of the field, e.g. by doping `EPSG{epsg_code}` you fetch only the code itself. This can also be a regex, e.g. `..._(S|C){reference_year}_...`.
330
+
331
+ Optional filenames must be encapsulated in `[]`. E.g. `[.{extension}]`
332
+
333
+ #### Container Object `examples`
334
+
335
+ Populate `"examples"` with valid filenames covering typical combinations of optional tokens. Test routines will run the examples to assess the proper functioning.
336
+
337
+ ### Test round-trips
338
+
339
+ run `parseo parse <filename>` and `parseo assemble --schema <schema_path>` to confirm the schema behaves as expected.
340
+
341
+ ### Run unit tests
342
+
343
+ Install the pytest python package.
344
+
345
+ from the top-level directory, run `pytest` to launch all tests, or e.g `pytest tests/test_schema_examples_round_trip.py`
346
+
347
+ ### Run as API
348
+
349
+ parsEO functions can be exposed through a web service. The example below uses [FastAPI](https://fastapi.tiangolo.com), which provides an automatic Swagger UI for trying out the endpoints.
350
+
351
+ ``` python
352
+ # Safe to file: main.py
353
+ from fastapi import FastAPI
354
+ from parseo import assemble, parse_auto
355
+
356
+ app = FastAPI()
357
+
358
+ @app.get("/parse")
359
+ def parse_endpoint(name: str):
360
+ res = parse_auto(name)
361
+ return res
362
+
363
+ @app.post("/assemble")
364
+ def assemble_endpoint(schema: str, fields: dict):
365
+ filename = assemble(fields, schema_path=schema)
366
+ return {"filename": filename}
367
+ ```
368
+
369
+ Install fastapi and uvicorn (in a python virtual environment):
370
+
371
+ ``` bash
372
+ python3 -m venv .venv
373
+ source .venv/bin/activate
374
+ ```
375
+
376
+ Install the required dependencies (fastapi and uvicorn):
377
+
378
+ ``` bash
379
+ (.venv) pip install fastapi uvicorn[standard]
380
+ ```
381
+
382
+ from the console inside the same directory start the app:
383
+
384
+ ``` bash
385
+ (.venv) python -m uvicorn main:app --reload
386
+ ```
387
+
388
+ Open <http://127.0.0.1:8000/docs> to access Swagger UI:
389
+
390
+ The interactive page lets you call `/parse` and `/assemble` directly from the browser to verify the API.
391
+
392
+
393
+ ## Contributing
394
+
395
+ - Place new schemas under `src/parseo/schemas/<product_family>/`.
396
+ - Include at least one positive example in each schema file.
397
+ - Run the test-suite with `pytest` (and `ruff check .` for linting) before opening a pull request.
398
+ - Submit a pull request describing the new products or fixes.
399
+
400
+ ## License
401
+
402
+ This project is licensed under the [European Union Public Licence v1.2](LICENSE.txt).
@@ -0,0 +1,70 @@
1
+ parseo/__init__.py,sha256=opqEAAFoBmJEhJxgbab41_V0GVMeu1A3RMya6jFHJQA,1414
2
+ parseo/_epsg_lookup.py,sha256=2x5iWe362V18-9yvs1ZMmrpNTXFtHUinPYFWh36m6SQ,3519
3
+ parseo/_field_mappings.py,sha256=aL921FsdmwedkZtKR44Di1f6YtRsdw6s31gvgRKIEJQ,6899
4
+ parseo/_json.py,sha256=jsooZYiYg3DTte971JuBgUWehJwxmq-LA6CvG5Dft9I,353
5
+ parseo/_tile_systems.py,sha256=nuE-TPMBrKXE60cwHoNWHasM2fc_mc1n5zrFpiTV5Xw,1134
6
+ parseo/assembler.py,sha256=c45_0JkSQjfEA3GKq_TeEMDwdEkdlXvyvk0H_I6r2L4,7396
7
+ parseo/cli.py,sha256=2hhbQnD76v5yTyaJ9_zrOoqKa_J7gyoxK6FigEEUGk4,13228
8
+ parseo/parser.py,sha256=H_E-k-QO49oX70A5m0NIJlEKFzOPTxd2DSAYPvqDLlE,26377
9
+ parseo/schema_registry.py,sha256=m9QG8kOvwnSuVsrrBFxJRNOM2BjkjyWWixj4nVBLE2A,7434
10
+ parseo/stac_http.py,sha256=XNIrA1MKBfY3f_YbtWRqfdn8P1Nk5d5A3AwpqiGtH9o,10086
11
+ parseo/stac_scraper.py,sha256=Tn-YxBPcsQwieU6VeEvroLRp8stQXT0TX0onC64C6A4,4130
12
+ parseo/template.py,sha256=5D01EIwyvZk4OnWtV5iPiKWA4BCeoIuC1yMnb8nC5R4,2588
13
+ parseo/schemas/copernicus/clms/clc/clc_filename_v1_0_0.json,sha256=Wx1E7V6sG-0R4QCBi8dUBs4DRKudMIMvMT5-rgEKtuM,1273
14
+ parseo/schemas/copernicus/clms/clc/clc_filename_v1_1_0.json,sha256=3WiWVch82ecdljEwlVAt7-a7EGo4H4Xfu-HoL66EB2A,2037
15
+ parseo/schemas/copernicus/clms/clcplus/ras/clcplus_filename_v0_0_0.json,sha256=QcymUmO-RHKEFyaHJlitNseDYB9ZHID3hiuda74fINw,2541
16
+ parseo/schemas/copernicus/clms/clcplus/ras/clcplus_filename_v0_0_1.json,sha256=s82NXdbbuaY7qPUA0DG-IagTN6-i3ce87k2DqjfxW88,2139
17
+ parseo/schemas/copernicus/clms/egms/egms_gnss_model_filename_v0_0_0.json,sha256=ujNKUCflE1gcSIR8mglaKdQTb-0cHmgYYwIXVtyEhV0,1115
18
+ parseo/schemas/copernicus/clms/egms/egms_l2a_product_filename_v0_0_0.json,sha256=LOj-EksLnJ7sLTJJJPnUMKHJCqn6JxLq_j1HFoL97xs,1988
19
+ parseo/schemas/copernicus/clms/egms/egms_l3_velocity_grid_filename_v0_0_0.json,sha256=DRHAcDS1UwW6-_MD2bMbFzzFLkU1-GTX40wU-L6LYPk,1761
20
+ parseo/schemas/copernicus/clms/euhydro/euhydro_filename_v0_0_0.json,sha256=3kfZaa9pZD-IDcHimKqyg8ptWcmWOLTHBHZp83OJdGw,3346
21
+ parseo/schemas/copernicus/clms/euhydro/euhydro_filename_v0_0_1.json,sha256=nobaYHLlQWF1tZR44GViKNn4ZF7ud3L2SNq6WDLrQm4,2744
22
+ parseo/schemas/copernicus/clms/hr-vpp/st_filename_v0_0_0.json,sha256=kjTBUsAjOkSzthGPQiclHWDGqBY-qLBZuCTSBFxLOCQ,2336
23
+ parseo/schemas/copernicus/clms/hr-vpp/vi_filename_v0_0_0.json,sha256=n8XfkmmlYQE1-9rZ2ZizSgFPPHjwH-UuQ2LX01bq9Wk,2357
24
+ parseo/schemas/copernicus/clms/hr-vpp/vpp_filename_v0_0_0.json,sha256=KXFv16cnn6y4LM7-H-eKmzPhQkom1GW1_ENvlPMreL8,2944
25
+ parseo/schemas/copernicus/clms/hr-wsi/cc_filename_v0_0_0.json,sha256=iyIhJGHmGN4h-83h9SfyGXQ2CR5cp9m9I_dHdiD6w7I,1950
26
+ parseo/schemas/copernicus/clms/hr-wsi/fsc_filename_v0_0_0.json,sha256=0GqCGw--v3cE1CjoN8cxTsw1RtwQwIDqzMsMDzV-Mqk,2042
27
+ parseo/schemas/copernicus/clms/hr-wsi/gfsc_filename_v0_0_0.json,sha256=i-UbTKBs0rEYZyaZIl1ORieveWKNWA-EOrP7xOglQ7s,1936
28
+ parseo/schemas/copernicus/clms/hr-wsi/icd_filename_v0_0_0.json,sha256=xDeNbL1OHzz68kJa8NpsbsQrOVLQO0VA7b2reDBd7ms,2389
29
+ parseo/schemas/copernicus/clms/hr-wsi/sp_filename_v0_0_0.json,sha256=XnyC6JI4U2iEWZQnTyCu4j6EYimVbhNRkq2Av6v8Ctk,3824
30
+ parseo/schemas/copernicus/clms/hr-wsi/sws_filename_v0_0_0.json,sha256=_2qzZt-psb5ebVULllmM6lsSYenyyetTv3bbD-my43I,1945
31
+ parseo/schemas/copernicus/clms/hr-wsi/wcd_filename_v0_0_0.json,sha256=jdHLFmv_XZVmWKO2hkSvDvO5yRqqS7F0ty28RXGu73s,2445
32
+ parseo/schemas/copernicus/clms/hr-wsi/wds_filename_v0_0_0.json,sha256=Sogqu4pK2XHsq6aC3uIfMbV13gP_Rz5DK6cDD_M6RVk,1966
33
+ parseo/schemas/copernicus/clms/hr-wsi/wic_comb_filename_v0_0_0.json,sha256=zqnJdTWbNzbREucSIXI9jwI16tqLaMHcsxtb2IBsetg,1959
34
+ parseo/schemas/copernicus/clms/hr-wsi/wic_filename_v0_0_0.json,sha256=pGIqjEZnnC9rBV_KjlahE4ZBybobF3sbAWi1a_hLhPk,2134
35
+ parseo/schemas/copernicus/clms/hrl/fty_filename_v0_0_0.json,sha256=mTaX9mL1vSnPuqTa6hg6UDzjvbQ7vNgQjWF0c--osm8,1299
36
+ parseo/schemas/copernicus/clms/hrl/gra_filename_v0_0_0.json,sha256=PCYQMwSAU2UQY05RXp1DMEDB5ga4xs6Axw244n5yOZg,1295
37
+ parseo/schemas/copernicus/clms/hrl/ibu_filename_v0_0_0.json,sha256=JD04nSYB4Si4By4IXbknvfTh_raEARXsvL4YPTQATjA,1644
38
+ parseo/schemas/copernicus/clms/hrl/imp_filename_v0_0_0.json,sha256=oH2SVF1Kv7_lKOQmf-JdAVV7IQ65_f4IDTr9XmalKvw,1294
39
+ parseo/schemas/copernicus/clms/hrl/nvlcc_filename_v0_0_0.json,sha256=kcKPmjJA4Vs4YRKmCqMGhSEkzHPU5hrAUcdHp0JZSp4,2290
40
+ parseo/schemas/copernicus/clms/hrl/nvlcc_filename_v0_0_1.json,sha256=O9Y5i2kqMISkgVS3nhaOmlCazW2ygcvwgoyYEVq-Z38,2839
41
+ parseo/schemas/copernicus/clms/hrl/nvlcc_filename_v0_0_2.json,sha256=JdGPDIJ8YDLifhHJYYSXn5jw_KKt6741mHBMQoJFQl4,2833
42
+ parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_0.json,sha256=FRnwSvfPQSt5DLT_Z50eQ-v-nEDie8Xnu8zz47n_w_g,1303
43
+ parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_1.json,sha256=jkoHU1n46aXKGOgVmgRnj7-k2C2kvjcT57Zj2JZJb84,1361
44
+ parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_2.json,sha256=5GpHfvTbr-dceFZi2tbIba9WBatUpTzYYKQCv7yW6iI,3054
45
+ parseo/schemas/copernicus/clms/hrl/swf_filename_v0_0_3.json,sha256=O3w1EUb-o7AR5473ra_0tlgwEw8X71fNK9LJnS6UuuY,3327
46
+ parseo/schemas/copernicus/clms/hrl/tcd_filename_v0_0_0.json,sha256=Mfu9qcOOuyo6BVNN4XoY7bhXo0xWJiPTzszWog81Mrk,1298
47
+ parseo/schemas/copernicus/clms/hrl/vlcc_filename_v0_0_0.json,sha256=BywmPoNQcokP2aIQm6ifCZ_Fxn7nPcBD_QrWGBZ7kvo,3796
48
+ parseo/schemas/copernicus/clms/hrl/waw_filename_v0_0_0.json,sha256=W0FFsTE7d1MgPnXQox807-VqvoVWPcKsNNi0YOPy-6c,1295
49
+ parseo/schemas/copernicus/clms/n2k/n2k_filename_v1_0_0.json,sha256=T2to8-0jV-NAB4HwZdtbsZgEIKsoS47LWXE9J-9ZG3o,1146
50
+ parseo/schemas/copernicus/clms/pa/pa_filename_v1_0_0.json,sha256=fpJjEkDlKa-LaIKFcagKr4ELpZALsR97_VQkhpFcWGk,2728
51
+ parseo/schemas/copernicus/clms/riparian-zones/rpz_filename_v0_0_0.json,sha256=gOnLwQb8YIfSOKnNBVn0I2QZaMX2Z-vLr0R8NVZd_B0,1271
52
+ parseo/schemas/copernicus/clms/urban-atlas/ua_dhm_filename_v0_0_0.json,sha256=qoOwRTAurcN4tTxHPiR8X_PS00NzQrvxDA6s3P5W44E,1456
53
+ parseo/schemas/copernicus/clms/urban-atlas/ua_filename_v0_0_0.json,sha256=CeeJ5F15r4450OVwQ5U1U3BL1Fqhxm1aeATVpr6bZEg,3083
54
+ parseo/schemas/copernicus/clms/urban-atlas/ua_stl_filename_v0_0_0.json,sha256=74tKrcVhM3DvFKBvGrs5fWVLhqhQgvSH8vlNGgE0668,2485
55
+ parseo/schemas/copernicus/sentinel/s1_filename_v1_0_0.json,sha256=B05ONYUgPJXWf22A94nwO9Sedrna_KfNiS6J6FkFJZk,2676
56
+ parseo/schemas/copernicus/sentinel/s2_filename_v1_0_0.json,sha256=HaZsgJWM61A519SwozvUDNfSWSnQDih20RQy061gyz0,1982
57
+ parseo/schemas/copernicus/sentinel/s3_filename_v1_0_0.json,sha256=pl3Z7RMh8xSBJKBLVy3mtriPxVYKfxHmb7DB__tjxAw,1353
58
+ parseo/schemas/copernicus/sentinel/s4_filename_v1_0_0.json,sha256=HUltPy_dzGpzY-VhI672X7-KbwTsvOACFOnJ5Tprc_c,902
59
+ parseo/schemas/copernicus/sentinel/s5p_filename_v1_0_0.json,sha256=tymR-OaPA1M8XJ269NRDo6qBUZBr7YqxrxeN5F2nYPg,924
60
+ parseo/schemas/copernicus/sentinel/s6_filename_v1_0_0.json,sha256=Zos88LqbeUwE4WD4Lmh0O7v5qpcNXP7xx7P8qc86ATg,1075
61
+ parseo/schemas/eumetsat/metop_filename_v1_0_0.json,sha256=D9na0QufeUI8BtqBdNY7p6mvWA8Qle8AmhBCmhrHdS8,1689
62
+ parseo/schemas/eumetsat/mtg_filename_v1_0_0.json,sha256=xCcdYQXyOlYMUG6O5KulqddUj-Jb3xT7h5a2baQaDiU,1596
63
+ parseo/schemas/nasa/modis_filename_v1_0_0.json,sha256=mlS0PHaEX8IZYAOmXO-JIbDP5tQ-P7XCP-lXeV4ZIYo,1921
64
+ parseo/schemas/usgs/landsat/landsat_filename_v1_0_0.json,sha256=Hjh_PrnyNUX4hmFT9vSDFtogiTDDHGr-EwStY1OkFZs,1986
65
+ parseo-0.4.4.dist-info/licenses/LICENSE.txt,sha256=b8nnCcy_4Nd_v_okJ6mDKCvi64jkexzbSfIag7TR5mU,13827
66
+ parseo-0.4.4.dist-info/METADATA,sha256=VbRbzoczGk4f-2a-ngGh1oWMn-md28RwOk0KwCFfTi4,15097
67
+ parseo-0.4.4.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
68
+ parseo-0.4.4.dist-info/entry_points.txt,sha256=dFGisbioM3P8UeYD0WYQYrNcxdc4RSsCMb7N2PgdLXE,43
69
+ parseo-0.4.4.dist-info/top_level.txt,sha256=yxQJTOitKnP3h7Ji6r0G0SuCcJIRGzsr4qu0VCWBrXA,7
70
+ parseo-0.4.4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ parseo = parseo.cli:main