Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MVCM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
bbd9e5f7
Commit
bbd9e5f7
authored
1 year ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
fixed debug option not including certain variables
parent
71587a3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#47481
failed
1 year ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mvcm/cli_mvcm.py
+3
-0
3 additions, 0 deletions
mvcm/cli_mvcm.py
mvcm/main.py
+6
-2
6 additions, 2 deletions
mvcm/main.py
mvcm/read_data.py
+28
-11
28 additions, 11 deletions
mvcm/read_data.py
with
37 additions
and
13 deletions
mvcm/cli_mvcm.py
+
3
−
0
View file @
bbd9e5f7
...
...
@@ -82,6 +82,7 @@ def mvcm():
default
=
1
,
help
=
"
print verbose information. Argument can be used multiple times.
"
,
)
parser
.
add_argument
(
"
-d
"
,
"
--debug
"
,
action
=
"
store_true
"
,
help
=
"
activate debug mode
"
)
args
=
parser
.
parse_args
()
...
...
@@ -103,6 +104,7 @@ def mvcm():
eco_file
=
args
.
eco
or
_eco_file
out_file
=
args
.
out
or
"
test_out.nc
"
verbose
=
args
.
verbose
debug
=
args
.
debug
main
(
satellite
=
satellite
,
...
...
@@ -123,4 +125,5 @@ def mvcm():
eco_file
=
eco_file
,
out_file
=
out_file
,
verbose
=
verbose
,
debug
=
debug
,
)
This diff is collapsed.
Click to expand it.
mvcm/main.py
+
6
−
2
View file @
bbd9e5f7
...
...
@@ -214,6 +214,8 @@ def main(
# logging.info(f"Band {b} not found in file. No output will be written.")
# return
logging
.
info
(
f
"
Reading VNP02:
{
file_names
[
'
MOD02
'
]
}
"
)
viirs_data
=
rd
.
get_data
(
satellite
,
sensor
,
file_names
,
hires
=
use_hires
)
sunglint_angle
=
thresholds
[
"
Sun_Glint
"
][
"
bounds
"
][
3
]
...
...
@@ -553,9 +555,11 @@ def main(
}
if
debug
is
True
:
d
.
update
(
d_debug
)
sf
=
{
k
:
{
"
dims
"
:
(
"
x
"
,
"
y
"
),
"
data
"
:
scene_flags
[
k
]}
for
k
in
scene_flags
}
out_dict
=
d
|
sf
else
:
out_dict
=
d
sf
=
{
k
:
{
"
dims
"
:
(
"
x
"
,
"
y
"
),
"
data
"
:
scene_flags
[
k
]}
for
k
in
scene_flags
}
out_dict
=
d
|
sf
ds_out
=
xr
.
Dataset
.
from_dict
(
out_dict
)
comp
=
dict
(
zlib
=
True
,
complevel
=
5
)
...
...
This diff is collapsed.
Click to expand it.
mvcm/read_data.py
+
28
−
11
View file @
bbd9e5f7
...
...
@@ -237,9 +237,15 @@ class ReadData(CollectInputs):
logger
.
debug
(
f
"
Reading
{
self
.
file_name_geo
}
"
)
geo_data
=
xr
.
open_dataset
(
self
.
file_name_geo
,
group
=
"
geolocation_data
"
)
relazi
=
self
.
relative_azimuth_angle
(
geo_data
.
sensor_azimuth
.
values
,
geo_data
.
solar_azimuth
.
values
)
sunglint
=
self
.
sun_glint_angle
(
geo_data
.
sensor_zenith
.
values
,
geo_data
.
solar_zenith
.
values
,
relazi
)
scatt_angle
=
self
.
scattering_angle
(
geo_data
.
solar_zenith
.
values
,
geo_data
.
sensor_zenith
.
values
,
relazi
)
relazi
=
self
.
relative_azimuth_angle
(
geo_data
.
sensor_azimuth
.
values
,
geo_data
.
solar_azimuth
.
values
)
sunglint
=
self
.
sun_glint_angle
(
geo_data
.
sensor_zenith
.
values
,
geo_data
.
solar_zenith
.
values
,
relazi
)
scatt_angle
=
self
.
scattering_angle
(
geo_data
.
solar_zenith
.
values
,
geo_data
.
sensor_zenith
.
values
,
relazi
)
geo_data
[
"
relative_azimuth
"
]
=
(
self
.
dims
,
relazi
)
geo_data
[
"
sunglint_angle
"
]
=
(
self
.
dims
,
sunglint
)
...
...
@@ -287,7 +293,9 @@ class ReadData(CollectInputs):
return
rad_data
def
preprocess_viirs
(
self
,
geo_data
:
xr
.
Dataset
,
viirs
:
xr
.
Dataset
,
hires_data
:
xr
.
Dataset
=
None
)
->
xr
.
Dataset
:
def
preprocess_viirs
(
self
,
geo_data
:
xr
.
Dataset
,
viirs
:
xr
.
Dataset
,
hires_data
:
xr
.
Dataset
=
None
)
->
xr
.
Dataset
:
"""
Create band combinations that are used by some spectral tests.
Parameters
...
...
@@ -428,7 +436,9 @@ class ReadData(CollectInputs):
logger
.
debug
(
"
Viirs preprocessing completed successfully.
"
)
return
viirs_out
def
relative_azimuth_angle
(
self
,
sensor_azimuth
:
npt
.
NDArray
,
solar_azimuth
:
npt
.
NDArray
)
->
npt
.
NDArray
:
def
relative_azimuth_angle
(
self
,
sensor_azimuth
:
npt
.
NDArray
,
solar_azimuth
:
npt
.
NDArray
)
->
npt
.
NDArray
:
"""
Compute relative azimuth angle.
Parameters
...
...
@@ -469,9 +479,9 @@ class ReadData(CollectInputs):
-------
sunglint_angle: np.ndarray
"""
cossna
=
np
.
sin
(
sensor_zenith
*
_DTR
)
*
np
.
sin
(
solar_zenith
*
_DTR
)
*
np
.
cos
(
rel_azimuth
*
_DTR
)
+
np
.
cos
(
sensor_zeni
th
*
_DTR
)
*
np
.
cos
(
solar_zenith
*
_DTR
)
cossna
=
np
.
sin
(
sensor_zenith
*
_DTR
)
*
np
.
sin
(
solar_zenith
*
_DTR
)
*
np
.
cos
(
rel_azimu
th
*
_DTR
)
+
np
.
cos
(
sensor_zenith
*
_DTR
)
*
np
.
cos
(
solar_zenith
*
_DTR
)
cossna
[
cossna
>
1
]
=
1
sunglint_angle
=
np
.
arccos
(
cossna
)
*
_RTD
...
...
@@ -502,7 +512,9 @@ class ReadData(CollectInputs):
"""
cos_scatt_angle
=
-
1.0
*
(
np
.
cos
(
solar_zenith
*
_DTR
)
*
np
.
cos
(
sensor_zenith
*
_DTR
)
-
np
.
sin
(
solar_zenith
*
_DTR
)
*
np
.
sin
(
sensor_zenith
*
_DTR
)
*
np
.
cos
(
relative_azimuth
*
_DTR
)
-
np
.
sin
(
solar_zenith
*
_DTR
)
*
np
.
sin
(
sensor_zenith
*
_DTR
)
*
np
.
cos
(
relative_azimuth
*
_DTR
)
)
scatt_angle
=
np
.
arccos
(
cos_scatt_angle
)
*
_RTD
...
...
@@ -543,7 +555,9 @@ class ReadAncillary(CollectInputs):
]
)
out_shape
:
tuple
=
field
(
init
=
False
,
default
=
Factory
(
lambda
self
:
self
.
latitude
.
shape
,
takes_self
=
True
))
out_shape
:
tuple
=
field
(
init
=
False
,
default
=
Factory
(
lambda
self
:
self
.
latitude
.
shape
,
takes_self
=
True
)
)
def
get_granule_time
(
self
):
"""
Get granule timestamp and format it for MVCM.
"""
...
...
@@ -657,7 +671,9 @@ class ReadAncillary(CollectInputs):
"
land_ice_fraction
"
,
"
surface_temperature
"
,
]
geos_data
=
{
var
:
np
.
empty
(
self
.
out_shape
,
dtype
=
np
.
float32
).
ravel
()
for
var
in
geos_variables
}
geos_data
=
{
var
:
np
.
empty
(
self
.
out_shape
,
dtype
=
np
.
float32
).
ravel
()
for
var
in
geos_variables
}
geos_data
=
anc
.
py_get_GEOS
(
self
.
latitude
.
ravel
(),
...
...
@@ -750,6 +766,7 @@ def get_data(satellite: str, sensor: str, file_names: Dict, hires: bool = False)
res
=
1
Ancillary
=
ReadAncillary
(
file_name_l1b
=
file_names
[
"
MOD02
"
],
latitude
=
geo_data
.
latitude
.
values
,
longitude
=
geo_data
.
longitude
.
values
,
resolution
=
res
,
...
...
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