Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
intercal
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
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
Fazlul Shahriar
intercal
Commits
ca0a32c1
Commit
ca0a32c1
authored
10 years ago
by
Greg Quinn
Browse files
Options
Downloads
Patches
Plain Diff
Add multi-granule support
parent
4bbed994
No related branches found
Tags
v3-master
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
intercal/modis.py
+21
-8
21 additions, 8 deletions
intercal/modis.py
intercal/test/e2e/test.py
+4
-3
4 additions, 3 deletions
intercal/test/e2e/test.py
with
25 additions
and
11 deletions
intercal/modis.py
+
21
−
8
View file @
ca0a32c1
...
...
@@ -5,16 +5,17 @@ import pyhdf.SD
import
pyhdf.VS
from
intercal.util
import
great_circle_dist
def
sno_stats
(
mod03_file
,
mod021km_
file
,
sno_lat
,
sno_lon
,
sno_radius
,
output_file
):
def
modis_to_iasi
(
file
s
,
sno_lat
,
sno_lon
,
sno_radius
,
output_file
):
reader
=
ModisReader
(
mod03_file
,
mod021km_file
)
mask
=
(
great_circle_dist
(
reader
.
latitude
,
reader
.
longitude
,
sno_lat
,
sno_lon
)
<=
sno_radius
)
radiance
=
reader
.
radiance
[:,
mask
]
output_shape
=
[
16
]
num_invalid_fov
=
np
.
zeros
(
output_shape
,
np
.
int32
)
num_fov
=
np
.
zeros
(
output_shape
,
np
.
int32
)
sum_radiance
=
np
.
zeros
(
output_shape
,
np
.
float64
)
sum_radiance_squared
=
np
.
zeros
(
output_shape
,
np
.
float64
)
num_invalid_fov
=
np
.
ma
.
count_masked
(
radiance
,
axis
=-
1
)
num_fov
=
radiance
.
shape
[
-
1
]
-
num_invalid_fov
sum_radiance
=
radiance
.
sum
(
axis
=-
1
)
sum_radiance_squared
=
(
radiance
**
2
).
sum
(
axis
=-
1
)
for
mod03_file
,
mod021km_file
in
files
:
sno_stats
(
mod03_file
,
mod021km_file
,
sno_lat
,
sno_lon
,
sno_radius
,
num_invalid_fov
,
num_fov
,
sum_radiance
,
sum_radiance_squared
)
sd
=
pyhdf
.
SD
.
SD
(
output_file
,
pyhdf
.
SD
.
SDC
.
WRITE
|
pyhdf
.
SD
.
SDC
.
CREATE
|
pyhdf
.
SD
.
SDC
.
TRUNC
)
write_hdf_sds
(
sd
,
'
Num_Invalid_FOV
'
,
num_invalid_fov
,
dims
=
[
'
Channel
'
])
...
...
@@ -22,6 +23,18 @@ def sno_stats(mod03_file, mod021km_file, sno_lat, sno_lon, sno_radius, output_fi
write_hdf_sds
(
sd
,
'
Sum_Radiance
'
,
sum_radiance
,
dims
=
[
'
Channel
'
])
write_hdf_sds
(
sd
,
'
Sum_Radiance_Squared
'
,
sum_radiance_squared
,
dims
=
[
'
Channel
'
])
def
sno_stats
(
mod03_file
,
mod021km_file
,
sno_lat
,
sno_lon
,
sno_radius
,
num_invalid_fov
,
num_fov
,
sum_radiance
,
sum_radiance_squared
):
reader
=
ModisReader
(
mod03_file
,
mod021km_file
)
mask
=
(
great_circle_dist
(
reader
.
latitude
,
reader
.
longitude
,
sno_lat
,
sno_lon
)
<=
sno_radius
)
radiance
=
reader
.
radiance
[:,
mask
]
num_invalid_fov
+=
np
.
ma
.
count_masked
(
radiance
,
axis
=-
1
)
num_fov
+=
radiance
.
shape
[
-
1
]
-
num_invalid_fov
sum_radiance
+=
radiance
.
sum
(
axis
=-
1
)
sum_radiance_squared
+=
(
radiance
**
2
).
sum
(
axis
=-
1
)
def
write_hdf_sds
(
sd
,
name
,
data
,
dims
):
hdf_type
,
np_type
=
{
'
i
'
:
(
pyhdf
.
SD
.
SDC
.
INT32
,
np
.
int32
),
...
...
This diff is collapsed.
Click to expand it.
intercal/test/e2e/test.py
+
4
−
3
View file @
ca0a32c1
...
...
@@ -2,15 +2,16 @@
import
os
from
unittest
import
TestCase
import
pyhdf.SD
from
intercal.modis
import
sno_stats
from
intercal.modis
import
modis_to_iasi
class
SnoStats
Test
(
TestCase
):
class
ModisToIasi
Test
(
TestCase
):
@classmethod
def
setUpClass
(
cls
):
output_file
=
os
.
path
.
join
(
'
local/test
'
,
output_file_name
)
sno_stats
(
mod03_file
,
mod021km_file
,
sno_lat
,
sno_lon
,
distance_threshold
,
output_file
)
modis_to_iasi
([(
mod03_file
,
mod021km_file
)],
sno_lat
,
sno_lon
,
distance_threshold
,
output_file
)
cls
.
output_sd
=
pyhdf
.
SD
.
SD
(
output_file
)
def
test_counts_number_of_pixels_within_threshold_distance_of_sno
(
self
):
...
...
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