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
dbc38c68
Commit
dbc38c68
authored
2 years ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
fixed imports to account for new repo structure
parent
6afb4379
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mvcm/preprocess_thresholds.py
+1
-1
1 addition, 1 deletion
mvcm/preprocess_thresholds.py
mvcm/read_data.py
+22
-21
22 additions, 21 deletions
mvcm/read_data.py
mvcm/scene.py
+1
-1
1 addition, 1 deletion
mvcm/scene.py
with
24 additions
and
23 deletions
mvcm/preprocess_thresholds.py
+
1
−
1
View file @
dbc38c68
...
...
@@ -2,7 +2,7 @@ import numpy as np
import
xarray
as
xr
import
ancillary_data
as
anc
import
utils
import
mvcm.utils
as
utils
from
numpy.lib.stride_tricks
import
sliding_window_view
from
typing
import
Dict
...
...
This diff is collapsed.
Click to expand it.
mvcm/read_data.py
+
22
−
21
View file @
dbc38c68
...
...
@@ -15,7 +15,8 @@ _RTD = 180./np.pi
_bad_data
=
-
999.0
_datapath
=
'
/ships19/hercules/pveglio/mvcm_test_data
'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
'
%(name)s - %(levelname)s - %(message)s
'
)
logger
=
logging
.
getLogger
(
'
__name__
'
)
# logging.basicConfig(level=logging.INFO, format='%(name)s - %(levelname)s - %(message)s')
# logging.basicConfig(level=logging.INFO, filename='logfile.log', 'filemode='w',
# format='%(name)s %(levelname)s %(message)s')
...
...
@@ -93,7 +94,7 @@ class ReadData(CollectInputs):
sensor
:
str
=
field
(
validator
=
[
validators
.
instance_of
(
str
),
validators
.
in_
([
'
viirs
'
])])
logg
ing
.
debug
(
'
Instance of ReadData created
'
)
logg
er
.
debug
(
'
Instance of ReadData created
'
)
def
read_viirs_geo
(
self
)
->
xr
.
Dataset
:
"""
Read VIIRS geolocation data and generate additional angles
...
...
@@ -108,7 +109,7 @@ class ReadData(CollectInputs):
geo_data xarray.Dataset
dataset containing all geolocation data
"""
logg
ing
.
debug
(
f
'
Reading
{
self
.
file_name_geo
}
'
)
logg
er
.
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
)
...
...
@@ -120,7 +121,7 @@ class ReadData(CollectInputs):
geo_data
[
'
sunglint_angle
'
]
=
(
self
.
dims
,
sunglint
)
geo_data
[
'
scattering_angle
'
]
=
(
self
.
dims
,
scatt_angle
)
logg
ing
.
debug
(
'
Geolocation file read correctly
'
)
logg
er
.
debug
(
'
Geolocation file read correctly
'
)
return
geo_data
...
...
@@ -135,7 +136,7 @@ class ReadData(CollectInputs):
solar_zenith: np.ndarray
solar zenith angle derived from the geolocation file
"""
logg
ing
.
debug
(
f
'
Reading
{
self
.
file_name_l1b
}
'
)
logg
er
.
debug
(
f
'
Reading
{
self
.
file_name_l1b
}
'
)
l1b_data
=
xr
.
open_dataset
(
self
.
file_name_l1b
,
group
=
'
observation_data
'
,
decode_cf
=
False
)
rad_data
=
xr
.
Dataset
()
...
...
@@ -154,7 +155,7 @@ class ReadData(CollectInputs):
else
:
pass
logg
ing
.
debug
(
'
L1b file read correctly
'
)
logg
er
.
debug
(
'
L1b file read correctly
'
)
return
rad_data
...
...
@@ -227,7 +228,7 @@ class ReadData(CollectInputs):
viirs
.
update
(
geo_data
)
viirs
=
viirs
.
set_coords
([
'
latitude
'
,
'
longitude
'
])
logg
ing
.
debug
(
'
Viirs preprocessing completed successfully.
'
)
logg
er
.
debug
(
'
Viirs preprocessing completed successfully.
'
)
return
viirs
def
relative_azimuth_angle
(
self
,
...
...
@@ -248,7 +249,7 @@ class ReadData(CollectInputs):
"""
rel_azimuth
=
np
.
abs
(
180.
-
np
.
abs
(
sensor_azimuth
-
solar_azimuth
))
logg
ing
.
debug
(
'
Relative azimuth calculated successfully.
'
)
logg
er
.
debug
(
'
Relative azimuth calculated successfully.
'
)
return
rel_azimuth
...
...
@@ -276,7 +277,7 @@ class ReadData(CollectInputs):
cossna
[
cossna
>
1
]
=
1
sunglint_angle
=
np
.
arccos
(
cossna
)
*
_RTD
logg
ing
.
debug
(
'
Sunglint generated
'
)
logg
er
.
debug
(
'
Sunglint generated
'
)
return
sunglint_angle
...
...
@@ -305,7 +306,7 @@ class ReadData(CollectInputs):
scatt_angle
=
np
.
arccos
(
cos_scatt_angle
)
*
_RTD
logg
ing
.
debug
(
'
Scattering angle calculated successfully
'
)
logg
er
.
debug
(
'
Scattering angle calculated successfully
'
)
return
scatt_angle
...
...
@@ -348,11 +349,11 @@ class ReadAncillary(CollectInputs):
array containing the Reynolds SST interpolated at the sensor
'
s resolution
"""
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary_dir
,
self
.
sst_file
)):
logg
ing
.
error
(
'
SST file not found
'
)
logg
er
.
error
(
'
SST file not found
'
)
sst
=
np
.
empty
(
self
.
out_shape
,
dtype
=
np
.
float32
).
ravel
()
sst
=
anc
.
py_get_Reynolds_SST
(
self
.
latitude
.
ravel
(),
self
.
longitude
.
ravel
(),
self
.
resolution
,
self
.
ancillary_dir
,
self
.
sst_file
,
sst
)
logg
ing
.
debug
(
'
SST file read successfully
'
)
logg
er
.
debug
(
'
SST file read successfully
'
)
return
sst
.
reshape
(
self
.
out_shape
)
def
get_ndvi
(
self
)
->
npt
.
NDArray
[
float
]:
...
...
@@ -367,11 +368,11 @@ class ReadAncillary(CollectInputs):
NDVI interpolated at the sensor
'
s resolution
"""
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary_dir
,
self
.
ndvi_file
)):
logg
ing
.
error
(
'
NDVI file not found
'
)
logg
er
.
error
(
'
NDVI file not found
'
)
ndvi
=
np
.
empty
(
self
.
out_shape
,
dtype
=
np
.
float32
).
ravel
()
ndvi
=
anc
.
py_get_NDVI_background
(
self
.
latitude
.
ravel
(),
self
.
longitude
.
ravel
(),
self
.
resolution
,
self
.
ancillary_dir
,
self
.
ndvi_file
,
ndvi
)
logg
ing
.
debug
(
'
NDVI file read successfully
'
)
logg
er
.
debug
(
'
NDVI file read successfully
'
)
return
ndvi
.
reshape
(
self
.
out_shape
)
def
get_eco
(
self
)
->
npt
.
NDArray
[
float
]:
...
...
@@ -388,7 +389,7 @@ class ReadAncillary(CollectInputs):
eco
=
np
.
empty
(
self
.
out_shape
,
dtype
=
np
.
ubyte
).
ravel
()
eco
=
anc
.
py_get_Olson_eco
(
self
.
latitude
.
ravel
(),
self
.
longitude
.
ravel
(),
self
.
resolution
,
self
.
ancillary_dir
,
eco
)
logg
ing
.
debug
(
'
Olson ecosystem file read successfully
'
)
logg
er
.
debug
(
'
Olson ecosystem file read successfully
'
)
return
eco
.
reshape
(
self
.
out_shape
)
def
get_geos
(
self
)
->
Dict
:
...
...
@@ -403,15 +404,15 @@ class ReadAncillary(CollectInputs):
dictionary containing all quantities required by MVCM (see geos_variables here below)
"""
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary_dir
,
self
.
geos_file_1
)):
logg
ing
.
error
(
'
GEOS-5 file 1 not found
'
)
logg
er
.
error
(
'
GEOS-5 file 1 not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary_dir
,
self
.
geos_file_2
)):
logg
ing
.
error
(
'
GEOS-5 file 2 not found
'
)
logg
er
.
error
(
'
GEOS-5 file 2 not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary_dir
,
self
.
geos_land
)):
logg
ing
.
error
(
'
GEOS-5 land file not found
'
)
logg
er
.
error
(
'
GEOS-5 land file not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary_dir
,
self
.
geos_ocean
)):
logg
ing
.
error
(
'
GEOS-5 ocean file not found
'
)
logg
er
.
error
(
'
GEOS-5 ocean file not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary_dir
,
self
.
geos_constants
)):
logg
ing
.
error
(
'
GEOS-5 constants file not found
'
)
logg
er
.
error
(
'
GEOS-5 constants file not found
'
)
geos_variables
=
[
'
tpw
'
,
'
snow_fraction
'
,
'
ice_fraction
'
,
'
ocean_fraction
'
,
'
land_ice_fraction
'
,
'
surface_temperature
'
]
...
...
@@ -425,7 +426,7 @@ class ReadAncillary(CollectInputs):
for
var
in
list
(
geos_variables
):
geos_data
[
var
]
=
geos_data
[
var
].
reshape
(
self
.
out_shape
)
logg
ing
.
debug
(
'
GEOS data read successfully
'
)
logg
er
.
debug
(
'
GEOS data read successfully
'
)
return
geos_data
def
pack_data
(
self
)
->
xr
.
Dataset
:
...
...
This diff is collapsed.
Click to expand it.
mvcm/scene.py
+
1
−
1
View file @
dbc38c68
...
...
@@ -6,7 +6,7 @@ except ImportError:
# from glob import glob
import
read_data
as
rd
import
mvcm.
read_data
as
rd
import
ancillary_data
as
anc
# lsf: land sea flag
...
...
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