Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MVCM
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Paolo Veglio
MVCM
Commits
1e5beacd
Commit
1e5beacd
authored
6 months ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
still working on the scene refactoring
parent
6f5161ef
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#54786
failed with stages
Stage: .pre
Stage: test
in 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mvcm/constants.py
+8
-0
8 additions, 0 deletions
mvcm/constants.py
mvcm/scene.py
+78
-29
78 additions, 29 deletions
mvcm/scene.py
with
86 additions
and
29 deletions
mvcm/constants.py
+
8
−
0
View file @
1e5beacd
...
...
@@ -34,6 +34,14 @@ class SceneConstants:
POLAR_LATITUDES
=
60.0
POLAR_COAST_LATITUDES
=
64.0
ARCTIC_LAT
=
67.5
GREENLAND_BB_W_LON
=
-
40.0
GREENLAND_BB_E_LON
=
-
30.0
SIBERIA_BB_W_LON
=
-
12.5
CANADA_BB_W_LON
=
-
168.5
VIS_RATIO
=
0.9
SCENE_LIST
=
(
"
Ocean_Day
"
,
"
Ocean_Night
"
,
...
...
This diff is collapsed.
Click to expand it.
mvcm/scene.py
+
78
−
29
View file @
1e5beacd
...
...
@@ -139,8 +139,8 @@ def test_scene():
"""
def
compute_
ref
_angle
(
vza
,
sza
,
raz
):
"""
Compute
ref
angle.
"""
def
compute_
glint
_angle
(
vza
,
sza
,
raz
):
"""
Compute
glint
angle.
"""
cos_refang
=
np
.
sin
(
vza
*
Constants
.
DTR
)
*
np
.
sin
(
sza
*
Constants
.
DTR
)
*
np
.
cos
(
raz
*
Constants
.
DTR
)
+
np
.
cos
(
vza
*
Constants
.
DTR
)
*
np
.
cos
(
sza
*
Constants
.
DTR
)
...
...
@@ -158,7 +158,7 @@ class Scene:
ref_ang
:
np
.
ndarray
=
field
(
init
=
False
,
default
=
Factory
(
lambda
self
:
compute_
ref
_angle
(
lambda
self
:
compute_
glint
_angle
(
self
.
data
.
sensor_zenith
.
values
,
self
.
data
.
solar_zenith
.
values
,
self
.
data
.
relative_azimuth
.
values
,
...
...
@@ -354,10 +354,27 @@ def find_scene(
&
(
data
.
land_water_mask
!=
land_water_flags
[
"
ephemeral
"
]),
1
,
scene_flag
[
"
land
"
],
)
scene_flag
[
"
land
"
]
=
xr
.
where
(
(
data
.
land_water_mask
==
SceneConstants
.
COASTLINE
)
|
(
data
.
land_water_mask
==
SceneConstants
.
SHALLOW_INLAND
),
1
,
scene_flag
[
"
land
"
],
)
scene_flag
[
"
land
"
]
=
xr
.
where
(
(
data
.
land_water_mask
==
SceneConstants
.
NO_DATA
)
&
(
data
.
M07
!=
Constants
.
BAD_DATA
)
&
(
data
.
M05
!=
Constants
.
BAD_DATA
)
&
(
data
.
M07
/
data
.
M05
>
SceneConstants
.
VIS_RATIO
),
1
,
0
,
).
values
# idx = np.nonzero(((lsf == 1) | (lsf == 4)) & (eco == 14) & (lat < 64.0))
# scene_flag["coast"][idx] = 1
# Coast for everything not in polar regiones
scene_flag
[
"
coast
"
]
=
xr
.
where
(
(
(
data
.
land_water_mask
==
land_water_flags
[
"
land
"
])
...
...
@@ -373,37 +390,69 @@ def find_scene(
# (eco == 14) & ((lsf == 1) | (lsf == 4)) & ((lat >= 67.5) & (lon < -40.0) & (lon > -168.6))
# )
# scene_flag["coast"][idx] = 1
# idx = np.nonzero((eco == 14) & ((lsf == 1) | (lsf == 4)) & ((lat >= 67.5) & (lon > -12.5)))
# scene_flag["coast"][idx] = 1
# idx = np.nonzero(
# (eco == 14)
# & ((lsf == 1) | (lsf == 4))
# & ((lat >= 64.0) & (lat < 67.5) & (lon < -40.0) & (lon > -168.5))
# )
# scene_flag["coast"][idx] = 1
# idx = np.nonzero(
# (eco == 14) & ((lsf == 1) | (lsf == 4)) & ((lat >= 64.0) & (lat < 67.5) & (lon > -30.0))
# )
# scene_flag["coast"][idx] = 1
# The colors in the comments below refer to the highlighted areas as shown in the map provided
# in the documentation (figures/coast_areas_scene_selection_mvcm). The figure is used to
# remember the logic of this block that otherwise is rather confusing
scene_flag
[
"
coast
"
]
=
xr
.
where
(
(
(
data
.
ecosystem
==
ecosystem_flags
[
"
water
"
])
&
(
data
.
land_water_mask
==
land_water_flags
[
"
land
"
])
|
(
data
.
land_water_mask
==
land_water_flags
[
"
ephemeral
"
])
(
data
.
ecosystem
==
SceneConstants
.
ECO_FLAG_WATER
)
&
(
data
.
land_water_mask
==
SceneConstants
.
LAND
)
|
(
data
.
land_water_mask
==
SceneConstants
.
EPHEMERAL
)
)
&
(
# GREEN
(
data
.
latitude
>=
SceneConstants
.
ARCTIC_LAT
)
&
(
(
data
.
longitude
<
SceneConstants
.
GREENLAND_BB_W_LON
)
&
(
data
.
longitude
>
SceneConstants
.
CANADA_BB_W_LON
)
)
|
(
data
.
longitude
>
SceneConstants
.
SIBERIA_BB_W_LON
)
)
&
((
data
.
latitude
>=
67.5
)
&
(
data
.
longitude
<
-
40.0
)
&
(
data
.
longitude
>
-
168.6
)),
|
(
# YELLOW
(
data
.
latitude
>=
SceneConstants
.
POLAR_COAST_LATITUDES
)
&
(
data
.
latitude
<
SceneConstants
.
ARCTIC_LAT
)
&
(
# RED
(
data
.
longitude
<
SceneConstants
.
GREENLAND_BB_W_LON
)
&
(
data
.
longitude
>
SceneConstants
.
CANADA_BB_W_LON
)
|
(
data
.
longitude
>
SceneConstants
.
GREENLAND_BB_E_LON
)
)
),
1
,
scene_flag
[
"
coast
"
],
)
scene_flag
[
"
coast
"
]
=
xr
.
where
(
(
data
.
land_water_mask
==
SceneConstants
.
COASTLINE
)
|
((
data
.
land_water_mask
==
SceneConstants
.
SHALLOW_INLAND
)
&
(
scene_flag
[
"
day
"
]
==
1
)),
1
,
scene_flag
[
"
coast
"
],
).
values
idx
=
np
.
nonzero
((
eco
==
14
)
&
((
lsf
==
1
)
|
(
lsf
==
4
))
&
((
lat
>=
67.5
)
&
(
lon
>
-
12.5
)))
scene_flag
[
"
coast
"
][
idx
]
=
1
# ARCTIC_LAT = 67.5
# GREENLAND_BB_W_LON = -40.0
# GREENLAND_BB_E_LON = -30.0
# SIBERIA_BB_W_LON = -12.5
# CANADA_BB_W_LON = -168.5
idx
=
np
.
nonzero
(
(
eco
==
14
)
&
((
lsf
==
1
)
|
(
lsf
==
4
))
&
((
lat
>=
64.0
)
&
(
lat
<
67.5
)
&
(
lon
<
-
40.0
)
&
(
lon
>
-
168.5
))
)
scene_flag
[
"
coast
"
][
idx
]
=
1
idx
=
np
.
nonzero
(
(
eco
==
14
)
&
((
lsf
==
1
)
|
(
lsf
==
4
))
&
((
lat
>=
64.0
)
&
(
lat
<
67.5
)
&
(
lon
>
-
30.0
))
)
scene_flag
[
"
coast
"
][
idx
]
=
1
idx
=
np
.
nonzero
(
lsf
==
2
)
scene_flag
[
"
coast
"
][
idx
]
=
1
scene_flag
[
"
land
"
][
idx
]
=
1
# idx = np.nonzero(lsf == 2)
# scene_flag["coast"][idx] = 1
# scene_flag["land"][idx] = 1
idx
=
np
.
nonzero
(
lsf
==
3
)
scene_flag
[
"
land
"
][
idx
]
=
1
#
scene_flag["land"][idx] = 1
scene_flag
[
"
sh_lake
"
][
idx
]
=
1
idx
=
np
.
nonzero
((
lsf
==
0
)
|
((
lsf
>=
5
)
&
(
lsf
<=
7
)))
...
...
@@ -413,18 +462,18 @@ def find_scene(
scene_flag
[
"
sh_ocean
"
][
lsf
==
0
]
=
1
# Need shallow lakes to be processed as "coast" for day, but not night
idx
=
np
.
nonzero
((
lsf
==
3
)
&
(
day
==
1
))
scene_flag
[
"
coast
"
][
idx
]
=
1
#
idx = np.nonzero((lsf == 3) & (day == 1))
#
scene_flag["coast"][idx] = 1
# if land/sea flag is missing, then calculate visible ratio
# to determine if land or water.
idx
=
np
.
nonzero
((
lsf
==
255
)
&
(
b065
!=
_bad_data
)
&
(
b086
!=
_bad_data
)
&
(
b086
/
b065
>
0.9
))
scene_flag
[
"
land
"
][
idx
]
=
1
#
idx = np.nonzero((lsf == 255) & (b065 != _bad_data) & (b086 != _bad_data) & (b086 / b065 > 0.9))
#
scene_flag["land"][idx] = 1
idx
=
np
.
nonzero
(
(
lsf
==
255
)
&
(
b065
!=
_bad_data
)
&
(
b086
!=
_bad_data
)
&
(
b086
/
b065
<=
0.9
)
)
scene_flag
[
"
land
"
][
idx
]
=
0
#
scene_flag["land"][idx] = 0
# I implemented this, but not the water part
scene_flag
[
"
water
"
][
idx
]
=
1
# Check surface elevation
...
...
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