Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
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
Tom Rink
python
Commits
a1953aff
Commit
a1953aff
authored
2 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
minor
parent
a89b297d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/util/viirs_l1b_l2.py
+29
-29
29 additions, 29 deletions
modules/util/viirs_l1b_l2.py
with
29 additions
and
29 deletions
modules/util/viirs_l1b_l2.py
+
29
−
29
View file @
a1953aff
...
...
@@ -20,8 +20,8 @@ def run_all(directory):
if
not
p
.
is_dir
():
continue
#
l1b
_files = glob.glob(directory + p.name+'/'+'clavrx_snpp_viirs*.uwssec*.nc')
l1b
_files
=
glob
.
glob
(
directory
+
p
.
name
+
'
/
'
+
'
VNP02MOD*.uwssec.nc
'
)
#
data
_files = glob.glob(directory + p.name+'/'+'clavrx_snpp_viirs*.uwssec*.nc')
data
_files
=
glob
.
glob
(
directory
+
p
.
name
+
'
/
'
+
'
VNP02MOD*.uwssec.nc
'
)
label_valid_tiles
=
[]
label_train_tiles
=
[]
...
...
@@ -29,47 +29,47 @@ def run_all(directory):
data_train_tiles
=
[]
f_cnt
=
0
for
idx
,
l1b
_f
in
enumerate
(
l1b
_files
):
for
idx
,
data
_f
in
enumerate
(
data
_files
):
# if idx % 8 == 0: # if we want to skip some files
if
True
:
w_o_ext
,
ext
=
os
.
path
.
splitext
(
l1b
_f
)
l
2
_f
=
w_o_ext
+
'
.highres
'
+
ext
if
not
os
.
path
.
exists
(
l
2
_f
):
w_o_ext
,
ext
=
os
.
path
.
splitext
(
data
_f
)
l
abel
_f
=
w_o_ext
+
'
.highres
'
+
ext
if
not
os
.
path
.
exists
(
l
abel
_f
):
continue
print
(
l1b
_f
)
print
(
data
_f
)
try
:
l1b
_h5f
=
h5py
.
File
(
l1b
_f
,
'
r
'
)
data
_h5f
=
h5py
.
File
(
data
_f
,
'
r
'
)
except
:
print
(
'
cant open file:
'
,
l1b
_f
)
print
(
'
cant open file:
'
,
data
_f
)
continue
try
:
l
2
_h5f
=
h5py
.
File
(
l
2
_f
,
'
r
'
)
l
abel
_h5f
=
h5py
.
File
(
l
abel
_f
,
'
r
'
)
except
:
print
(
'
cant open file:
'
,
l
2
_f
)
l1b
_h5f
.
close
()
print
(
'
cant open file:
'
,
l
abel
_f
)
data
_h5f
.
close
()
continue
data_tiles
=
[]
label_tiles
=
[]
try
:
run
(
l1b
_h5f
,
l
2
_h5f
,
data_tiles
,
label_tiles
,
factor
=
2
)
run
(
data
_h5f
,
l
abel
_h5f
,
data_tiles
,
label_tiles
,
factor
=
2
)
except
Exception
as
e
:
print
(
e
)
l1b
_h5f
.
close
()
l
2
_h5f
.
close
()
data
_h5f
.
close
()
l
abel
_h5f
.
close
()
continue
l1b
_h5f
.
close
()
l
2
_h5f
.
close
()
data
_h5f
.
close
()
l
abel
_h5f
.
close
()
if
len
(
data_tiles
)
==
0
or
len
(
label_tiles
)
==
0
:
continue
if
len
(
data_tiles
)
!=
len
(
label_tiles
):
print
(
'
weirdness:
'
,
l1b
_f
)
print
(
'
weirdness:
'
,
data
_f
)
continue
num
=
len
(
data_tiles
)
...
...
@@ -119,9 +119,9 @@ def run_all(directory):
np
.
save
(
'
/data/Personal/rink/viirs/label_valid_
'
+
str
(
cnt
),
label_valid
)
def
run
(
l1b
_h5f
,
l
2
_h5f
,
l1b
_tiles
,
l
2
_tiles
,
factor
=
2
):
if
l
2
_h5f
is
None
:
l
2
_h5f
=
l1b
_h5f
def
run
(
data
_h5f
,
l
abel
_h5f
,
data
_tiles
,
l
abel
_tiles
,
factor
=
2
):
if
l
abel
_h5f
is
None
:
l
abel
_h5f
=
data
_h5f
l1b_param_name
=
data_params
[
0
]
l2_param_name
=
label_params
[
0
]
...
...
@@ -129,11 +129,11 @@ def run(l1b_h5f, l2_h5f, l1b_tiles, l2_tiles, factor=2):
mod_tile_width
=
64
img_tile_width
=
mod_tile_width
*
factor
mod_num_lines
=
l1b
_h5f
[
l1b_param_name
].
shape
[
0
]
mod_num_pixels
=
l1b
_h5f
[
l1b_param_name
].
shape
[
1
]
mod_num_lines
=
data
_h5f
[
l1b_param_name
].
shape
[
0
]
mod_num_pixels
=
data
_h5f
[
l1b_param_name
].
shape
[
1
]
img_num_lines
=
l
2
_h5f
[
l2_param_name
].
shape
[
0
]
img_num_pixels
=
l
2
_h5f
[
l2_param_name
].
shape
[
1
]
img_num_lines
=
l
abel
_h5f
[
l2_param_name
].
shape
[
0
]
img_num_pixels
=
l
abel
_h5f
[
l2_param_name
].
shape
[
1
]
mod_num_y_tiles
=
int
(
mod_num_lines
/
mod_tile_width
)
mod_num_x_tiles
=
int
(
mod_num_pixels
/
mod_tile_width
)
...
...
@@ -143,14 +143,14 @@ def run(l1b_h5f, l2_h5f, l1b_tiles, l2_tiles, factor=2):
for
param
in
data_params
:
try
:
grd
=
get_grid_values
(
l1b
_h5f
,
param
,
0
,
0
,
None
,
mod_num_lines
,
mod_num_pixels
,
range_name
=
None
)
grd
=
get_grid_values
(
data
_h5f
,
param
,
0
,
0
,
None
,
mod_num_lines
,
mod_num_pixels
,
range_name
=
None
)
l1b_grd_s
.
append
(
grd
)
except
:
return
for
param
in
label_params
:
try
:
grd
=
get_grid_values
(
l
2
_h5f
,
param
,
0
,
0
,
None
,
img_num_lines
,
img_num_pixels
,
range_name
=
None
)
grd
=
get_grid_values
(
l
abel
_h5f
,
param
,
0
,
0
,
None
,
img_num_lines
,
img_num_pixels
,
range_name
=
None
)
l2_grd_s
.
append
(
grd
)
except
:
return
...
...
@@ -175,10 +175,10 @@ def run(l1b_h5f, l2_h5f, l1b_tiles, l2_tiles, factor=2):
i_i
=
i_m
*
factor
nda
=
mod_data
[:,
j_m
:
j_m
+
mod_tile_width
,
i_m
:
i_m
+
mod_tile_width
]
l1b
_tiles
.
append
(
nda
)
data
_tiles
.
append
(
nda
)
nda
=
img_data
[:,
j_i
:
j_i
+
img_tile_width
,
i_i
:
i_i
+
img_tile_width
]
l
2
_tiles
.
append
(
nda
)
l
abel
_tiles
.
append
(
nda
)
# def run_mean_std(directory):
...
...
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