Skip to content
Snippets Groups Projects
dev_xmlparser.py 1.54 KiB
Newer Older
Jeremy Commins's avatar
Jeremy Commins committed
# 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)