Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
# coding:utf-8
import sys
import os
sys.path.insert(0, os.path.abspath('..'))
import re
from pathlib import Path
from pprint import pprint
from sen2chain import xmlparser, L1cProduct
tile = "40KCB"
#mtd = Path("data/S2A_USER_MTD_SAFL2A_PDMC_20160119T023918_R134_V20160118T063524_20160118T063524.xml")
mtd = Path("data/S2A_OPER_MTD_SAFL1C_PDMC_20151201T164959_R134_V20151129T063527_20151129T063527.xml")
#parser = xmlparser.MetadataParser(mtd, tile)
p = L1cProduct("S2A_MSIL1C_20161213T063502_N0204_R134_T40KCB_20161213T063504.SAFE", path=Path()/"data")
print(p._update_metadata_parser())
#def test_xmlparser_get_granule():
#print(parser._psd_version)
#print(parser._root)
#schema_location = parser._root.attrib["{http://www.w3.org/2001/XMLSchema-instance}schemaLocation"]
#version = re.findall("https://psd-([0-9]{2}).sentinel2.eo.esa.int", schema_location)[0]
#print(parser._psd_version)
#pprint(parser.__dict__)
#pprint([g.attrib['granuleIdentifier'] for g in parser._root.findall('.//Granules') if tile in g.attrib["granuleIdentifier"]][0])
#print(parser._granule)
#granules = [g.attrib["granuleIdentifier"] for g in parser._root.findall('.//Granule')]
#print(parser._granule_string)
#print(parser.get_band_path("B04"))
#parser._root.findall(".//[@granuleIdentifier={}]"
#print(
#[f.text + ".jp2"
#for f in parser._root.findall(".//{}[@granuleIdentifier='{}']/{}".format(parser._granule_string, parser._granule, parser._image_string))
#if "B04" in f.text][0]
#)
#print(granules)
#for child in granules[0]:
#print(child.text)