Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySegCNN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
earth_observation_public
PySegCNN
Commits
a8b6557d
Commit
a8b6557d
authored
4 years ago
by
Frisinghelli Daniel
Browse files
Options
Downloads
Patches
Plain Diff
Improved Sentinel 2 product name parsing.
parent
4898f218
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pysegcnn/core/utils.py
+36
-8
36 additions, 8 deletions
pysegcnn/core/utils.py
with
36 additions
and
8 deletions
pysegcnn/core/utils.py
+
36
−
8
View file @
a8b6557d
...
@@ -599,12 +599,20 @@ def parse_sentinel2_scene(scene_id):
...
@@ -599,12 +599,20 @@ def parse_sentinel2_scene(scene_id):
# Sentinel 2 Level-1C products naming convention before 6th December 2016
# Sentinel 2 Level-1C products naming convention before 6th December 2016
file_class
=
'
[A-Z]{4}_
'
file_class
=
'
[A-Z]{4}_
'
file_category
=
'
[A-Z]{3}_
'
file_category
=
'
[A-Z]{3}_
'
file_semantic
=
'
L[0-1]([ABC]|_)
_[A-Z]{2}
_
'
file_semantic
=
'
(MSI(
L[0-1]([ABC
P
]|_)
|CTI)|USER2A)
_
'
site
=
'
[A-Z_]{4}_
'
site
=
'
[A-Z_]{4}_
'
aorbit
=
'
A[0-9]{6}_
'
S2_L1C_Old
=
re
.
compile
(
mission
+
file_class
+
file_category
+
S2_L1C_Old
=
re
.
compile
(
mission
+
file_class
+
file_category
+
file_semantic
+
site
+
'
V
'
+
date
+
time
+
aorbit
+
file_semantic
+
site
+
date
+
time
+
orbit
+
'
V
'
+
tile
.
replace
(
'
_
'
,
''
))
date
+
time
+
date
+
time
.
replace
(
'
_
'
,
''
))
# Sentinel 2 granule naming convention before 6th December 2016
granule_semantic
=
'
L[0-1][ABC_]_(GR|DS|TL|TC|CO)_
'
det_or_tile
=
'
(D[0-1][1-2]|T[0-9]{2}[A-Z]{3})(_)?
'
aorbit
=
'
(A[0-9]{6}_
'
+
'
{}
'
.
format
(
'
|S
'
+
date
+
time
+
'
)
'
)
baseline
=
'
(N[0-9]{2})?
'
S2_L1C_Granule
=
re
.
compile
(
mission
+
file_class
+
file_category
+
granule_semantic
+
site
+
'
V
'
+
date
+
time
+
aorbit
+
det_or_tile
+
baseline
)
# ProSnow project naming convention
# ProSnow project naming convention
ProSnow
=
re
.
compile
(
tile
+
date
+
time
.
replace
(
'
_
'
,
''
))
ProSnow
=
re
.
compile
(
tile
+
date
+
time
.
replace
(
'
_
'
,
''
))
...
@@ -624,12 +632,12 @@ def parse_sentinel2_scene(scene_id):
...
@@ -624,12 +632,12 @@ def parse_sentinel2_scene(scene_id):
scene
[
'
satellite
'
]
=
parts
[
0
]
scene
[
'
satellite
'
]
=
parts
[
0
]
scene
[
'
file class
'
]
=
parts
[
1
]
scene
[
'
file class
'
]
=
parts
[
1
]
scene
[
'
file category
'
]
=
parts
[
2
]
scene
[
'
file category
'
]
=
parts
[
2
]
scene
[
'
file semantic
'
]
=
'
_
'
.
join
([
parts
[
3
],
parts
[
4
]])
scene
[
'
file semantic
'
]
=
parts
[
3
]
scene
[
'
site
'
]
=
parts
[
5
]
scene
[
'
site
'
]
=
parts
[
4
]
scene
[
'
orbit
'
]
=
parts
[
8
]
scene
[
'
orbit
'
]
=
parts
[
6
]
scene
[
'
date
'
]
=
datetime
.
datetime
.
strptime
(
scene
[
'
date
'
]
=
datetime
.
datetime
.
strptime
(
parts
[
7
].
split
(
'
T
'
)[
0
].
replace
(
'
V
'
,
''
),
'
%Y%m%d
'
)
parts
[
7
].
split
(
'
T
'
)[
0
].
replace
(
'
V
'
,
''
),
'
%Y%m%d
'
)
scene
[
'
tile
'
]
=
parts
[
9
]
scene
[
'
tile
'
]
=
None
elif
S2_L1C_New
.
search
(
scene_id
):
elif
S2_L1C_New
.
search
(
scene_id
):
...
@@ -649,6 +657,26 @@ def parse_sentinel2_scene(scene_id):
...
@@ -649,6 +657,26 @@ def parse_sentinel2_scene(scene_id):
scene
[
'
orbit
'
]
=
parts
[
4
]
scene
[
'
orbit
'
]
=
parts
[
4
]
scene
[
'
tile
'
]
=
parts
[
5
]
scene
[
'
tile
'
]
=
parts
[
5
]
elif
S2_L1C_Granule
.
search
(
scene_id
):
# the match of the regular expression
match
=
S2_L1C_Granule
.
search
(
scene_id
)[
0
]
# split scene into respective parts
parts
=
match
.
split
(
'
_
'
)
# the metadata of the scene identifier
scene
[
'
id
'
]
=
match
scene
[
'
satellite
'
]
=
parts
[
0
]
scene
[
'
file class
'
]
=
parts
[
1
]
scene
[
'
file category
'
]
=
parts
[
2
]
scene
[
'
file semantic
'
]
=
parts
[
3
]
+
parts
[
4
]
scene
[
'
site
'
]
=
parts
[
5
]
scene
[
'
orbit
'
]
=
parts
[
8
]
scene
[
'
date
'
]
=
datetime
.
datetime
.
strptime
(
parts
[
7
].
split
(
'
T
'
)[
0
].
replace
(
'
V
'
,
''
),
'
%Y%m%d
'
)
scene
[
'
tile
'
]
=
parts
[
9
]
elif
ProSnow
.
search
(
scene_id
):
elif
ProSnow
.
search
(
scene_id
):
# the match of the regular expression
# the match of the regular expression
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment