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
18b28d38
Commit
18b28d38
authored
3 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
40b376e2
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/icing/pirep_goes.py
+24
-17
24 additions, 17 deletions
modules/icing/pirep_goes.py
with
24 additions
and
17 deletions
modules/icing/pirep_goes.py
+
24
−
17
View file @
18b28d38
...
@@ -831,7 +831,7 @@ def apply_qc_no_icing_pireps(icing_alt, cld_top_hgt, cld_phase, cld_opd, cld_mas
...
@@ -831,7 +831,7 @@ def apply_qc_no_icing_pireps(icing_alt, cld_top_hgt, cld_phase, cld_opd, cld_mas
return
mask
,
idxs
,
num_tested
return
mask
,
idxs
,
num_tested
def
fov_extract
(
outfile
=
'
/home/rink/fovs_l1b_out.h5
'
,
train_params
=
l1b_ds_list
,
ds_types
=
l1b_ds_types
):
def
fov_extract
(
outfile
=
'
/home/rink/fovs_l1b_out.h5
'
,
L1B_or_L2
=
'
L1B
'
):
ice_times
=
[]
ice_times
=
[]
icing_int_s
=
[]
icing_int_s
=
[]
ice_lons
=
[]
ice_lons
=
[]
...
@@ -844,8 +844,15 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -844,8 +844,15 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
h5_s_icing
=
[]
h5_s_icing
=
[]
h5_s_no_icing
=
[]
h5_s_no_icing
=
[]
icing_data_dct
=
{
ds
:
[]
for
ds
in
train_params
}
if
L1B_or_L2
==
'
L1B
'
:
no_icing_data_dct
=
{
ds
:
[]
for
ds
in
train_params
}
params
=
l1b_ds_list
param_types
=
l1b_ds_types
elif
L1B_or_L2
==
'
L2
'
:
params
=
ds_list
param_types
=
ds_types
icing_data_dct
=
{
ds
:
[]
for
ds
in
params
}
no_icing_data_dct
=
{
ds
:
[]
for
ds
in
params
}
sub_indexes
=
np
.
arange
(
400
)
sub_indexes
=
np
.
arange
(
400
)
...
@@ -881,7 +888,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -881,7 +888,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
k_idxs
=
k_idxs
[
0
:
len
(
k_idxs
)]
k_idxs
=
k_idxs
[
0
:
len
(
k_idxs
)]
num_ice
+=
len
(
k_idxs
)
num_ice
+=
len
(
k_idxs
)
for
ds_name
in
train_
params
:
for
ds_name
in
params
:
dat
=
f
[
ds_name
][
i
,
10
:
30
,
10
:
30
].
flatten
()
dat
=
f
[
ds_name
][
i
,
10
:
30
,
10
:
30
].
flatten
()
icing_data_dct
[
ds_name
].
append
(
dat
[
k_idxs
])
icing_data_dct
[
ds_name
].
append
(
dat
[
k_idxs
])
...
@@ -892,7 +899,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -892,7 +899,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
print
(
fname
)
print
(
fname
)
for
ds_name
in
train_
params
:
for
ds_name
in
params
:
lst
=
icing_data_dct
[
ds_name
]
lst
=
icing_data_dct
[
ds_name
]
icing_data_dct
[
ds_name
]
=
np
.
concatenate
(
lst
)
icing_data_dct
[
ds_name
]
=
np
.
concatenate
(
lst
)
...
@@ -934,13 +941,13 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -934,13 +941,13 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
no_ice_lons
.
append
(
np
.
full
(
len
(
k_idxs
),
lons
[
i
]))
no_ice_lons
.
append
(
np
.
full
(
len
(
k_idxs
),
lons
[
i
]))
no_ice_lats
.
append
(
np
.
full
(
len
(
k_idxs
),
lats
[
i
]))
no_ice_lats
.
append
(
np
.
full
(
len
(
k_idxs
),
lats
[
i
]))
for
ds_name
in
train_
params
:
for
ds_name
in
params
:
dat
=
f
[
ds_name
][
i
,
10
:
30
,
10
:
30
].
flatten
()
dat
=
f
[
ds_name
][
i
,
10
:
30
,
10
:
30
].
flatten
()
no_icing_data_dct
[
ds_name
].
append
(
dat
[
k_idxs
])
no_icing_data_dct
[
ds_name
].
append
(
dat
[
k_idxs
])
print
(
fname
)
print
(
fname
)
for
ds_name
in
train_
params
:
for
ds_name
in
params
:
lst
=
no_icing_data_dct
[
ds_name
]
lst
=
no_icing_data_dct
[
ds_name
]
no_icing_data_dct
[
ds_name
]
=
np
.
concatenate
(
lst
)
no_icing_data_dct
[
ds_name
]
=
np
.
concatenate
(
lst
)
no_icing_int_s
=
np
.
full
(
num_no_ice
,
-
1
)
no_icing_int_s
=
np
.
full
(
num_no_ice
,
-
1
)
...
@@ -954,7 +961,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -954,7 +961,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
icing_lats
=
np
.
concatenate
([
ice_lats
,
no_ice_lats
])
icing_lats
=
np
.
concatenate
([
ice_lats
,
no_ice_lats
])
data_dct
=
{}
data_dct
=
{}
for
ds_name
in
train_
params
:
for
ds_name
in
params
:
data_dct
[
ds_name
]
=
np
.
concatenate
([
icing_data_dct
[
ds_name
],
no_icing_data_dct
[
ds_name
]])
data_dct
[
ds_name
]
=
np
.
concatenate
([
icing_data_dct
[
ds_name
],
no_icing_data_dct
[
ds_name
]])
# apply shuffle indexes
# apply shuffle indexes
...
@@ -970,7 +977,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -970,7 +977,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
# do sort
# do sort
ds_indexes
=
np
.
argsort
(
icing_times
)
ds_indexes
=
np
.
argsort
(
icing_times
)
for
ds_name
in
train_
params
:
for
ds_name
in
params
:
data_dct
[
ds_name
]
=
data_dct
[
ds_name
][
ds_indexes
]
data_dct
[
ds_name
]
=
data_dct
[
ds_name
][
ds_indexes
]
icing_intensity
=
icing_intensity
[
ds_indexes
]
icing_intensity
=
icing_intensity
[
ds_indexes
]
icing_times
=
icing_times
[
ds_indexes
]
icing_times
=
icing_times
[
ds_indexes
]
...
@@ -980,8 +987,8 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -980,8 +987,8 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
h5f_expl
=
h5py
.
File
(
a_clvr_file
,
'
r
'
)
h5f_expl
=
h5py
.
File
(
a_clvr_file
,
'
r
'
)
h5f_out
=
h5py
.
File
(
outfile
,
'
w
'
)
h5f_out
=
h5py
.
File
(
outfile
,
'
w
'
)
for
idx
,
ds_name
in
enumerate
(
train_
params
):
for
idx
,
ds_name
in
enumerate
(
params
):
dt
=
ds
_types
[
ds_list
.
index
(
ds_name
)]
dt
=
param
_types
[
params
.
index
(
ds_name
)]
data
=
data_dct
[
ds_name
]
data
=
data_dct
[
ds_name
]
h5f_out
.
create_dataset
(
ds_name
,
data
=
data
,
dtype
=
dt
)
h5f_out
.
create_dataset
(
ds_name
,
data
=
data
,
dtype
=
dt
)
...
@@ -1001,7 +1008,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -1001,7 +1008,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
lat_ds
.
attrs
.
create
(
'
long_name
'
,
data
=
'
PIREP latitude
'
)
lat_ds
.
attrs
.
create
(
'
long_name
'
,
data
=
'
PIREP latitude
'
)
# copy relevant attributes
# copy relevant attributes
for
ds_name
in
train_
params
:
for
ds_name
in
params
:
h5f_ds
=
h5f_out
[
ds_name
]
h5f_ds
=
h5f_out
[
ds_name
]
h5f_ds
.
attrs
.
create
(
'
standard_name
'
,
data
=
h5f_expl
[
ds_name
].
attrs
.
get
(
'
standard_name
'
))
h5f_ds
.
attrs
.
create
(
'
standard_name
'
,
data
=
h5f_expl
[
ds_name
].
attrs
.
get
(
'
standard_name
'
))
h5f_ds
.
attrs
.
create
(
'
long_name
'
,
data
=
h5f_expl
[
ds_name
].
attrs
.
get
(
'
long_name
'
))
h5f_ds
.
attrs
.
create
(
'
long_name
'
,
data
=
h5f_expl
[
ds_name
].
attrs
.
get
(
'
long_name
'
))
...
@@ -1024,7 +1031,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
...
@@ -1024,7 +1031,7 @@ def fov_extract(outfile='/home/rink/fovs_l1b_out.h5', train_params=l1b_ds_list,
h5f_expl
.
close
()
h5f_expl
.
close
()
def
tile_extract
(
trnfile
=
'
/home/rink/tiles_l1b_train.h5
'
,
tstfile
=
'
/home/rink/tiles_l1b_test.h5
'
,
l
1B_or_
l
2
=
'
L1B
'
,
def
tile_extract
(
trnfile
=
'
/home/rink/tiles_l1b_train.h5
'
,
tstfile
=
'
/home/rink/tiles_l1b_test.h5
'
,
L
1B_or_
L
2
=
'
L1B
'
,
cld_mask_name
=
'
cloud_mask
'
,
augment
=
False
,
split
=
0.2
):
cld_mask_name
=
'
cloud_mask
'
,
augment
=
False
,
split
=
0.2
):
icing_int_s
=
[]
icing_int_s
=
[]
ice_time_s
=
[]
ice_time_s
=
[]
...
@@ -1037,10 +1044,10 @@ def tile_extract(trnfile='/home/rink/tiles_l1b_train.h5', tstfile='/home/rink/ti
...
@@ -1037,10 +1044,10 @@ def tile_extract(trnfile='/home/rink/tiles_l1b_train.h5', tstfile='/home/rink/ti
h5_s_icing
=
[]
h5_s_icing
=
[]
h5_s_no_icing
=
[]
h5_s_no_icing
=
[]
if
l
1B_or_
l
2
==
'
L1B
'
:
if
L
1B_or_
L
2
==
'
L1B
'
:
params
=
l1b_ds_list
params
=
l1b_ds_list
param_types
=
l1b_ds_types
param_types
=
l1b_ds_types
elif
l
1B_or_
l
2
==
'
L2
'
:
elif
L
1B_or_
L
2
==
'
L2
'
:
params
=
ds_list
params
=
ds_list
param_types
=
ds_types
param_types
=
ds_types
...
@@ -1063,7 +1070,7 @@ def tile_extract(trnfile='/home/rink/tiles_l1b_train.h5', tstfile='/home/rink/ti
...
@@ -1063,7 +1070,7 @@ def tile_extract(trnfile='/home/rink/tiles_l1b_train.h5', tstfile='/home/rink/ti
cld_msk
=
f
[
cld_mask_name
][
i
,
12
:
28
,
12
:
28
]
cld_msk
=
f
[
cld_mask_name
][
i
,
12
:
28
,
12
:
28
]
for
ds_name
in
params
:
for
ds_name
in
params
:
dat
=
f
[
ds_name
][
i
,
12
:
28
,
12
:
28
]
dat
=
f
[
ds_name
][
i
,
12
:
28
,
12
:
28
]
if
l
1B_or_
l
2
==
'
L2
'
:
if
L
1B_or_
L
2
==
'
L2
'
:
keep
=
np
.
logical_or
(
cld_msk
==
2
,
cld_msk
==
3
)
# cloudy
keep
=
np
.
logical_or
(
cld_msk
==
2
,
cld_msk
==
3
)
# cloudy
np
.
where
(
keep
,
dat
,
np
.
nan
)
np
.
where
(
keep
,
dat
,
np
.
nan
)
icing_data_dct
[
ds_name
].
append
(
dat
)
icing_data_dct
[
ds_name
].
append
(
dat
)
...
@@ -1100,7 +1107,7 @@ def tile_extract(trnfile='/home/rink/tiles_l1b_train.h5', tstfile='/home/rink/ti
...
@@ -1100,7 +1107,7 @@ def tile_extract(trnfile='/home/rink/tiles_l1b_train.h5', tstfile='/home/rink/ti
cld_msk
=
f
[
cld_mask_name
][
i
,
12
:
28
,
12
:
28
]
cld_msk
=
f
[
cld_mask_name
][
i
,
12
:
28
,
12
:
28
]
for
ds_name
in
params
:
for
ds_name
in
params
:
dat
=
f
[
ds_name
][
i
,
12
:
28
,
12
:
28
]
dat
=
f
[
ds_name
][
i
,
12
:
28
,
12
:
28
]
if
l
1B_or_
l
2
==
'
L2
'
:
if
L
1B_or_
L
2
==
'
L2
'
:
keep
=
np
.
logical_or
(
cld_msk
==
2
,
cld_msk
==
3
)
# cloudy
keep
=
np
.
logical_or
(
cld_msk
==
2
,
cld_msk
==
3
)
# cloudy
np
.
where
(
keep
,
dat
,
np
.
nan
)
np
.
where
(
keep
,
dat
,
np
.
nan
)
no_icing_data_dct
[
ds_name
].
append
(
dat
)
no_icing_data_dct
[
ds_name
].
append
(
dat
)
...
...
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