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
4a568887
Commit
4a568887
authored
2 years ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
initial template for testing read_data
parent
d29519e7
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ancillary.pyx
+11
-11
11 additions, 11 deletions
ancillary.pyx
pyproject.toml
+4
-0
4 additions, 0 deletions
pyproject.toml
read_data.py
+7
-7
7 additions, 7 deletions
read_data.py
tests/test_read_data.py
+18
-6
18 additions, 6 deletions
tests/test_read_data.py
with
40 additions
and
24 deletions
ancillary.pyx
+
11
−
11
View file @
4a568887
...
...
@@ -21,7 +21,7 @@ cimport numpy as np
np
.
import_array
()
ctypedef
np
.
float_t
DTYPE_t
DTYPE
=
np
.
float
DTYPE
=
np
.
float
32
@cython.boundscheck
(
False
)
@cython.wraparound
(
False
)
...
...
@@ -87,21 +87,21 @@ def py_get_GEOS(np.ndarray[float, ndim=1] lat, np.ndarray[float, ndim=1] lon, in
geos_data
[
v
]
=
np
.
ascontiguousarray
(
geos_data
[
v
])
cdef
float
[::
1
]
tpw_mv
=
geos_data
[
'
tpw
'
]
cdef
float
[::
1
]
snowfr_mv
=
geos_data
[
'
snowfr
'
]
cdef
float
[::
1
]
icefr_mv
=
geos_data
[
'
icefr
'
]
cdef
float
[::
1
]
ocnfr_mv
=
geos_data
[
'
oc
nfr
'
]
cdef
float
[::
1
]
landicefr_mv
=
geos_data
[
'
landicefr
'
]
cdef
float
[::
1
]
sfct_mv
=
geos_data
[
'
s
fct
'
]
cdef
float
[::
1
]
snowfr_mv
=
geos_data
[
'
snow
_
fr
action
'
]
cdef
float
[::
1
]
icefr_mv
=
geos_data
[
'
ice
_
fr
action
'
]
cdef
float
[::
1
]
ocnfr_mv
=
geos_data
[
'
oc
ean_fraction
'
]
cdef
float
[::
1
]
landicefr_mv
=
geos_data
[
'
land
_
ice
_
fr
action
'
]
cdef
float
[::
1
]
sfct_mv
=
geos_data
[
'
s
urface_temperature
'
]
get_GEOS
(
&
lat
[
0
],
&
lon
[
0
],
res
,
startTime
,
anc_dir
,
geos1
,
geos2
,
geos_lnd
,
geos_ocn
,
geos_cnst
,
&
tpw_mv
[
0
],
&
snowfr_mv
[
0
],
&
icefr_mv
[
0
],
&
ocnfr_mv
[
0
],
&
landicefr_mv
[
0
],
&
sfct_mv
[
0
])
geos_dict
=
{
'
tpw
'
:
geos_data
[
'
tpw
'
],
'
snowfr
'
:
geos_data
[
'
snowfr
'
],
'
icefr
'
:
geos_data
[
'
icefr
'
],
'
oc
nfr
'
:
geos_data
[
'
oc
nfr
'
],
'
landicefr
'
:
geos_data
[
'
landicefr
'
],
'
s
fct
'
:
geos_data
[
'
sfct
'
]
'
snow
_
fr
action
'
:
geos_data
[
'
snow
_
fr
action
'
],
'
ice
_
fr
action
'
:
geos_data
[
'
ice
_
fr
action
'
],
'
oc
ean_fraction
'
:
geos_data
[
'
oc
ean_fraction
'
],
'
land
_
ice
_
fr
action
'
:
geos_data
[
'
land
_
ice
_
fr
action
'
],
'
s
urface_temperature
'
:
geos_data
[
'
surface_temperature
'
]
}
return
geos_dict
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
4
−
0
View file @
4a568887
...
...
@@ -18,3 +18,7 @@ classifiers = ['Programming Language :: Python :: 3',
[project.urls]
'Homepage'
=
'https://gitlab.ssec.wisc.edu/pveglio/mvcm'
[tool.pytest.ini_options]
addopts
=
[
'--import-mode
=
importlib
',
]
This diff is collapsed.
Click to expand it.
read_data.py
+
7
−
7
View file @
4a568887
...
...
@@ -13,7 +13,7 @@ from attrs import define, field, validators, Factory
_DTR
=
np
.
pi
/
180.
_RTD
=
180.
/
np
.
pi
_bad_data
=
-
999.0
_datapath
=
'
/ships19/hercules/pveglio/mvcm_
viirs_hires
'
_datapath
=
'
/ships19/hercules/pveglio/mvcm_
test_data
'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
'
%(name)s - %(levelname)s - %(message)s
'
)
# logging.basicConfig(level=logging.INFO, filename='logfile.log', 'filemode='w',
...
...
@@ -60,7 +60,7 @@ class CollectInputs(object):
validator
=
[
validators
.
instance_of
(
str
),
])
eco_file
:
str
=
field
(
default
=
'
goge1_2_img.v1
'
,
validator
=
[
validators
.
instance_of
(
str
),
])
ndvi_file
:
str
=
field
(
default
=
'
NDVI.FM.c004.v2.0.WS.00-04
-
177.hdf
'
,
ndvi_file
:
str
=
field
(
default
=
'
NDVI.FM.c004.v2.0.WS.00-04
.
177.hdf
'
,
validator
=
[
validators
.
instance_of
(
str
),
])
geos_file_1
:
str
=
field
(
default
=
'
GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1200.V01.nc4
'
,
validator
=
[
validators
.
instance_of
(
str
),
])
...
...
@@ -402,15 +402,15 @@ class ReadAncillary(CollectInputs):
geos_data: Dict
dictionary containing all quantities required by MVCM (see geos_variables here below)
"""
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
,
self
.
geos_file_1
)):
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
_dir
,
self
.
geos_file_1
)):
logging
.
error
(
'
GEOS-5 file 1 not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
,
self
.
geos_file_2
)):
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
_dir
,
self
.
geos_file_2
)):
logging
.
error
(
'
GEOS-5 file 2 not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
,
self
.
geos_land
_file
)):
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
_dir
,
self
.
geos_land
)):
logging
.
error
(
'
GEOS-5 land file not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
,
self
.
geos_ocean
_file
)):
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
_dir
,
self
.
geos_ocean
)):
logging
.
error
(
'
GEOS-5 ocean file not found
'
)
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
,
self
.
geos_constants
_file
)):
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
ancillary
_dir
,
self
.
geos_constants
)):
logging
.
error
(
'
GEOS-5 constants file not found
'
)
geos_variables
=
[
'
tpw
'
,
'
snow_fraction
'
,
'
ice_fraction
'
,
'
ocean_fraction
'
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_read_data.py
+
18
−
6
View file @
4a568887
...
...
@@ -12,14 +12,14 @@ def fixturepath():
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
fixtures
'
)
#
@pytest.fixture
()
#
def l1b_file(
fixturepath
):
#
return
os.path.join(fixturepath, '')
@pytest.fixture
def
l1b_file
():
return
'
VNP02MOD.A2022173.1312.001.2022174011547.uwssec.nc
'
#
@pytest.fixture
()
#
def geo_file(
fixturepath
):
#
return
os.path.join(fixturepath, '')
@pytest.fixture
def
geo_file
():
return
'
VNP03MOD.A2022173.1312.001.2022174012746.uwssec.nc
'
# @pytest.fixture
...
...
@@ -67,6 +67,18 @@ def ref_file(fixturepath):
return
os
.
path
.
join
(
fixturepath
,
'
ref_ancillary.nc
'
)
# this is only temporary. At some point I'll write a better test
def
test_l1b
(
fixturepath
,
l1b_file
,
geo_file
):
viirs
=
rd
.
ReadData
(
satellite
=
'
snpp
'
,
sensor
=
'
viirs
'
,
file_name_l1b
=
l1b_file
,
file_name_geo
=
geo_file
)
geo
=
viirs
.
read_viirs_geo
()
l1b
=
viirs
.
read_l1b
(
geo
.
solar_zenith
.
values
)
assert
'
M11
'
in
l1b
.
data_vars
def
test_sst
(
fixturepath
,
sst_file
,
ref_file
):
viirs
=
rd
.
ReadData
(
satellite
=
'
snpp
'
,
sensor
=
'
viirs
'
)
...
...
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