Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
yori
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
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
Paolo Veglio
yori
Commits
495676c3
Commit
495676c3
authored
3 years ago
by
Paolo Veglio
Browse files
Options
Downloads
Patches
Plain Diff
changes to account for day-night split and CLD vs CLDPCL data for GEWEX
parent
58deb9f5
No related branches found
Branches containing commit
Tags
1.6.5
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
yori/aggrtools.py
+95
-38
95 additions, 38 deletions
yori/aggrtools.py
yori/yori_aggregate.py
+20
-7
20 additions, 7 deletions
yori/yori_aggregate.py
with
115 additions
and
45 deletions
yori/aggrtools.py
+
95
−
38
View file @
495676c3
...
...
@@ -7,6 +7,11 @@
NC_FILL_DOUBLE
=
-
9999.
VERSION
=
get_distribution
(
'
yori
'
).
version
_cae
=
[
'
CAE_Day
'
,
'
CAEH_Day
'
,
'
CAEM_Day
'
,
'
CAEL_Day
'
,
'
CAEW_Day
'
,
'
CAEI_Day
'
,
'
CAEIH_Day
'
,
'
CAE_Night
'
,
'
CAEH_Night
'
,
'
CAEM_Night
'
,
'
CAEL_Night
'
,
'
CAEW_Night
'
,
'
CAEI_Night
'
,
'
CAEIH_Night
'
]
_wp
=
[
'
ALWP
'
,
'
AIWP
'
,
'
AIWPH
'
,
'
ALWP_CLDPCL
'
,
'
AIWP_CLDPCL
'
,
'
AIWPH_CLDPCL
'
]
def
daily_mask
(
satellite
,
daily
,
flist
,
gridsize
):
...
...
@@ -59,11 +64,9 @@ def prepare_vars(var_add, group_batch, ncfile, granule_edges, gewex=False):
# for nonzero entries
# if 'min_pixel_counts' in grp:
# var_add[grp]['min_pixel_counts'] = ncfile[grp]['min_pixel_counts']
_cae
=
[
'
CAE
'
,
'
CAEH
'
,
'
CAEM
'
,
'
CAEL
'
,
'
CAEW
'
,
'
CAEI
'
,
'
CAEIH
'
]
_wp
=
[
'
ALWP
'
,
'
AIWP
'
,
'
AIWPH
'
]
if
grp
in
_cae
:
if
'
Pixel_Counts
'
in
ncfile
[
'
CA
'
].
variables
:
cnt
=
ncfile
[
'
CA/Pixel_Counts
'
][:]
if
'
Pixel_Counts
'
in
ncfile
[
'
CA
_Day
'
].
variables
:
cnt
=
ncfile
[
'
CA
_Day
/Pixel_Counts
'
][:]
x
,
y
=
cnt
.
nonzero
()
if
len
(
x
)
==
0
:
del
var_add
[
grp
]
...
...
@@ -81,8 +84,8 @@ def prepare_vars(var_add, group_batch, ncfile, granule_edges, gewex=False):
y_slice
=
slice
(
None
)
elif
grp
in
_wp
:
if
'
Pixel_Counts
'
in
ncfile
[
'
C
LWP
'
].
variables
:
cnt
=
ncfile
[
'
C
LWP
/Pixel_Counts
'
][:]
if
'
Pixel_Counts
'
in
ncfile
[
'
C
loud_Water_Path_CLD_Liquid
'
].
variables
:
cnt
=
ncfile
[
'
C
loud_Water_Path_CLD_Liquid
/Pixel_Counts
'
][:]
x
,
y
=
cnt
.
nonzero
()
if
len
(
x
)
==
0
:
del
var_add
[
grp
]
...
...
@@ -119,29 +122,83 @@ def prepare_vars(var_add, group_batch, ncfile, granule_edges, gewex=False):
y_slice
=
slice
(
None
)
if
grp
in
_cae
:
for
w
in
ncfile
[
'
CA
'
].
variables
:
suffix
=
grp
.
replace
(
'
CAE
'
,
''
)
daynight
=
grp
.
split
(
'
_
'
)[
-
1
]
for
w
in
ncfile
[
f
'
CA_
{
daynight
}
'
].
variables
:
suffix
=
grp
.
split
(
'
_
'
)[
0
].
replace
(
'
CAE
'
,
''
)
if
w
!=
[
'
Pixel_Counts
'
,
'
min_pixel_counts
'
,
'
min_valid_days
'
]:
var_add
[
f
'
CAE
{
suffix
}
'
][
w
]
=
ncfile
[
f
'
CEM
{
suffix
}
'
][
w
][
x_slice
,
y_slice
]
var_add
[
f
'
CAE
{
suffix
}
'
][
'
Sum_Mean
'
]
=
(
ncfile
[
f
'
CA
{
suffix
}
'
][
'
Mean
'
][
x_slice
,
y_slice
]
*
ncfile
[
f
'
CEM
{
suffix
}
'
][
'
Mean
'
][
x_slice
,
y_slice
])
var_add
[
f
'
CAE
{
suffix
}
'
][
'
Sum_Squares_Mean
'
]
=
(
ncfile
[
f
'
CA
{
suffix
}
'
][
'
Mean
'
][
x_slice
,
y_slice
]
*
ncfile
[
f
'
CEM
{
suffix
}
'
][
'
Mean
'
][
x_slice
,
y_slice
])
**
2
var_add
[
f
'
CAE
{
suffix
}
_
{
daynight
}
'
][
w
]
=
ncfile
[
f
'
CEM
{
suffix
}
_
{
daynight
}
'
][
w
][
x_slice
,
y_slice
]
var_add
[
f
'
CAE
{
suffix
}
_
{
daynight
}
'
][
'
Sum_Mean
'
]
=
(
ncfile
[
f
'
CA
{
suffix
}
_
{
daynight
}
'
][
'
Mean
'
][
x_slice
,
y_slice
]
*
ncfile
[
f
'
CEM
{
suffix
}
_
{
daynight
}
'
][
'
Mean
'
][
x_slice
,
y_slice
])
var_add
[
f
'
CAE
{
suffix
}
_
{
daynight
}
'
][
'
Sum_Squares_Mean
'
]
=
(
ncfile
[
f
'
CA
{
suffix
}
_
{
daynight
}
'
][
'
Mean
'
][
x_slice
,
y_slice
]
*
ncfile
[
f
'
CEM
{
suffix
}
_
{
daynight
}
'
][
'
Mean
'
][
x_slice
,
y_slice
])
**
2
elif
grp
in
_wp
:
wp_dic
=
{
'
ALWP
'
:
'
CAL
'
,
'
AIWP
'
:
'
CAI
'
,
'
AIWPH
'
:
'
CAIH
'
}
for
w
in
ncfile
[
'
CLWP
'
].
variables
:
suffix
=
grp
.
replace
(
'
A
'
,
'
C
'
)
wp_dic
=
{
'
ALWP
'
:
'
CAL_Day
'
,
'
AIWP
'
:
'
CAI_Day
'
,
'
AIWPH
'
:
'
CAIH_Day
'
,
'
ALWP_CLDPCL
'
:
'
CAL_Day
'
,
'
AIWP_CLDPCL
'
:
'
CAI_Day
'
,
'
AIWPH_CLDPCL
'
:
'
CAIH_Day
'
}
wp_match
=
{
'
ALWP
'
:
'
Cloud_Water_Path_CLD_Liquid
'
,
'
AIWP
'
:
'
Cloud_Water_Path_CLD_Ice
'
,
'
AIWPH
'
:
'
Cloud_Water_Path_CLD_Ice_High
'
,
'
ALWP_CLDPCL
'
:
'
Cloud_Water_Path_CLDPCL_Liquid
'
,
'
AIWP_CLDPCL
'
:
'
Cloud_Water_Path_CLDPCL_Ice
'
,
'
AIWPH_CLDPCL
'
:
'
Cloud_Water_Path_CLDPCL_Ice_High
'
}
for
w
in
ncfile
[
'
Cloud_Water_Path_CLD_Liquid
'
].
variables
:
# suffix = grp.replace('A', 'C')
suffix
=
wp_match
[
grp
]
ca_name
=
wp_dic
[
grp
]
wgt_dict
=
{}
'''
cloudy = np.squeeze(ncfile[
'
COP_Phase_Cloudy
'
][x_slice, y_slice])
liquid = np.squeeze(ncfile[
'
COP_Phase_Cloudy
'
][x_slice, y_slice, 0])
pcl = np.squeeze(ncfile[
'
COP_Phase_Partly_Cloudy
'
][x_slice, y_slice])
ice = np.squeeze(ncfile[
'
COP_Phase_Cloudy
'
][x_slice, y_slice, 1])
ice_high = 0
liquid_pcl = np.squeeze(ncfile[
'
COP_Phase_Partly_Cloudy
'
][x_slice, y_slice, 0])
ice_pcl = np.squeeze(ncfile[
'
COP_Phase_Partly_Cloudy
'
][x_slice, y_slice, 1])
ice_high_pcl = 0
clear = np.squeeze(ncfile[
'
COP_Phase_CloudMaskClear
'
][x_slice, y_slice])
restclear = np.squeeze(ncfile[
'
COP_Phase_RestoredToClear
'
][x_slice, y_slice])
wgt_liquid = liquid/(cloudy + pcl + clear + restclear)
wgt_ice = ice/(cloudy + pcl + clear + restclear)
wgt_ice_high = ice_high/(cloudy + pcl + clear + restclear)
wgt_liquid_pcl = (liquid_pcl + liquid)/(cloudy + pcl + clear + restclear)
wgt_ice_pcl = (ice_pcl + ice)/(cloudy + pcl + clear + restclear)
wgt_ice_high_pcl = (ice_high + ice_high_pcl)/(cloudy + pcl + clear + restclear)
wgt_dict = {
'
ALWP
'
: wgt_liquid,
'
AIWP
'
: wgt_ice,
'
AIWPH
'
: wgt_ice_high,
'
ALWP_CLDPCL
'
: wgt_liquid_pcl,
'
AIWP_CLDPCL
'
: wgt_ice_pcl,
'
AIWPH_CLDPCL
'
: wgt_ice_high_pcl}
'''
wgt_dict
=
{
'
ALWP
'
:
'
Cloud_Retrieval_Fraction_CLD_Liquid
'
,
'
AIWP
'
:
'
Cloud_Retrieval_Fraction_CLD_Ice
'
,
'
AIWPH
'
:
'
Cloud_Retrieval_Fraction_CLD_Ice_High
'
,
'
ALWP_CLDPCL
'
:
'
Cloud_Retrieval_Fraction_CLDPCL_Liquid
'
,
'
AIWP_CLDPCL
'
:
'
Cloud_Retrieval_Fraction_CLDPCL_Ice
'
,
'
AIWPH_CLDPCL
'
:
'
Cloud_Retrieval_Fraction_CLDPCL_Ice_High
'
}
wgtname
=
wgt_dict
[
grp
]
#
# if CLDPCL
# weight = (cloudy + pcl)/(cloudy + pcl + clear + restclear)
# wgt_liquid = (liquid_cpl + liquid)/(cloudy + pcl + clear + restclear)
# wgt_ice = (ice_pcl + ice)/(cloudy + pcl + clear + restclear)
# wgt_ice_high = ()/(cloudy + pcl + clear + restclear)
# else # only CLD
# weight = cloudy/(cloudy + pcl + clear + restclear)
# wgt_liquid = liquid/(cloudy + pcl + clear + restclear)
# wgt_ice = ice/(cloudy + pcl + clear + restclear)
# wgt_ice_high = ()/(cloudy + pcl + clear + restclear)
#
if
w
!=
[
'
Pixel_Counts
'
,
'
min_pixel_counts
'
,
'
min_valid_days
'
]:
var_add
[
grp
][
w
]
=
ncfile
[
suffix
][
w
][
x_slice
,
y_slice
]
var_add
[
f
'
{
grp
}
'
][
'
Sum_Mean
'
]
=
(
ncfile
[
f
'
{
suffix
}
/Mean
'
][
x_slice
,
y_slice
]
*
ncfile
[
f
'
{
ca_
name
}
/Mean
'
][
x_slice
,
y_slice
])
ncfile
[
f
'
{
wgt
name
}
/Mean
'
][
x_slice
,
y_slice
])
var_add
[
f
'
{
grp
}
'
][
'
Sum_Squares_Mean
'
]
=
(
ncfile
[
f
'
{
suffix
}
/Mean
'
][
x_slice
,
y_slice
]
*
ncfile
[
f
'
{
ca_
name
}
/Mean
'
][
x_slice
,
y_slice
])
**
2
ncfile
[
f
'
{
wgt
name
}
/Mean
'
][
x_slice
,
y_slice
])
**
2
else
:
for
w
in
ncfile
[
grp
].
variables
:
if
w
!=
[
'
Pixel_Counts
'
,
'
min_pixel_counts
'
,
'
min_valid_days
'
]:
...
...
@@ -158,28 +215,28 @@ def initialize_arrays(group_batch, ncfile, latkey, lonkey, fv, gewex=False):
for
grp
in
group_batch
:
if
grp
==
latkey
or
grp
==
lonkey
:
pass
elif
grp
in
[
'
CAE
'
,
'
CAEH
'
,
'
CAEM
'
,
'
CAEL
'
,
'
CAEW
'
,
'
CAEI
'
,
'
CAEIH
'
]:
elif
grp
in
_cae
:
#
['CAE', 'CAEH', 'CAEM', 'CAEL', 'CAEW', 'CAEI', 'CAEIH']:
var_in
[
grp
]
=
{}
var_in
[
grp
][
'
Mean
'
]
=
ncfile
[
f
'
CA/Mean
'
][:]
*
0
var_in
[
grp
][
'
Standard_Deviation
'
]
=
ncfile
[
f
'
CA/Standard_Deviation
'
][:]
*
0
var_in
[
grp
][
'
Pixel_Counts
'
]
=
ncfile
[
f
'
CA/Pixel_Counts
'
][:]
*
0
var_in
[
grp
][
'
Sum
'
]
=
ncfile
[
f
'
CA/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares
'
]
=
ncfile
[
f
'
CA/Sum_Squares
'
][:]
*
0
var_in
[
grp
][
'
Mean
'
]
=
ncfile
[
f
'
CA
_Day
/Mean
'
][:]
*
0
var_in
[
grp
][
'
Standard_Deviation
'
]
=
ncfile
[
f
'
CA
_Day
/Standard_Deviation
'
][:]
*
0
var_in
[
grp
][
'
Pixel_Counts
'
]
=
ncfile
[
f
'
CA
_Day
/Pixel_Counts
'
][:]
*
0
var_in
[
grp
][
'
Sum
'
]
=
ncfile
[
f
'
CA
_Day
/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares
'
]
=
ncfile
[
f
'
CA
_Day
/Sum_Squares
'
][:]
*
0
# var_in[grp]['Histogram_Counts'] = ncfile[f'CA/Histogram_Counts'][:]*0
var_in
[
grp
][
'
Sum_Mean
'
]
=
ncfile
[
f
'
CA/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares_Mean
'
]
=
ncfile
[
f
'
CA/Sum_Squares
'
][:]
*
0
var_in
[
grp
][
'
Num_Days
'
]
=
ncfile
[
f
'
CA/Sum
'
][:]
*
0
elif
grp
in
[
'
ALWP
'
,
'
AIWP
'
,
'
AIWPH
'
]:
var_in
[
grp
][
'
Sum_Mean
'
]
=
ncfile
[
f
'
CA
_Day
/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares_Mean
'
]
=
ncfile
[
f
'
CA
_Day
/Sum_Squares
'
][:]
*
0
var_in
[
grp
][
'
Num_Days
'
]
=
ncfile
[
f
'
CA
_Day
/Sum
'
][:]
*
0
elif
grp
in
_wp
:
#
['ALWP', 'AIWP', 'AIWPH']:
var_in
[
grp
]
=
{}
var_in
[
grp
][
'
Mean
'
]
=
ncfile
[
f
'
C
LWP
/Mean
'
][:]
*
0
var_in
[
grp
][
'
Standard_Deviation
'
]
=
ncfile
[
f
'
C
LWP
/Standard_Deviation
'
][:]
*
0
var_in
[
grp
][
'
Pixel_Counts
'
]
=
ncfile
[
f
'
C
LWP
/Pixel_Counts
'
][:]
*
0
var_in
[
grp
][
'
Sum
'
]
=
ncfile
[
f
'
C
LWP
/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares
'
]
=
ncfile
[
f
'
C
LWP
/Sum_Squares
'
][:]
*
0
var_in
[
grp
][
'
Mean
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Mean
'
][:]
*
0
var_in
[
grp
][
'
Standard_Deviation
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Standard_Deviation
'
][:]
*
0
var_in
[
grp
][
'
Pixel_Counts
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Pixel_Counts
'
][:]
*
0
var_in
[
grp
][
'
Sum
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Sum_Squares
'
][:]
*
0
# var_in[grp]['Histogram_Counts'] = ncfile[f'CA/Histogram_Counts'][:]*0
var_in
[
grp
][
'
Sum_Mean
'
]
=
ncfile
[
f
'
C
LWP
/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares_Mean
'
]
=
ncfile
[
f
'
C
LWP
/Sum_Squares
'
][:]
*
0
var_in
[
grp
][
'
Num_Days
'
]
=
ncfile
[
f
'
C
LWP
/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Mean
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Sum
'
][:]
*
0
var_in
[
grp
][
'
Sum_Squares_Mean
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Sum_Squares
'
][:]
*
0
var_in
[
grp
][
'
Num_Days
'
]
=
ncfile
[
f
'
C
loud_Water_Path_CLD_Liquid
/Sum
'
][:]
*
0
else
:
var_in
[
grp
]
=
{}
if
hasattr
(
ncfile
[
grp
],
'
min_pixel_counts
'
):
...
...
This diff is collapsed.
Click to expand it.
yori/yori_aggregate.py
+
20
−
7
View file @
495676c3
...
...
@@ -30,17 +30,30 @@ def aggregate(flist, fname_out, satellite='', daily='',
f0
=
nc
.
Dataset
(
flist
[
0
])
group_list
=
list
(
f0
.
groups
)
if
gewex
is
True
:
group_list
.
append
(
'
CAE
'
)
group_list
.
append
(
'
CAEH
'
)
group_list
.
append
(
'
CAEM
'
)
group_list
.
append
(
'
CAEL
'
)
group_list
.
append
(
'
CAEW
'
)
group_list
.
append
(
'
CAEI
'
)
group_list
.
append
(
'
CAEIH
'
)
group_list
.
append
(
'
CAE_Day
'
)
group_list
.
append
(
'
CAEH_Day
'
)
group_list
.
append
(
'
CAEM_Day
'
)
group_list
.
append
(
'
CAEL_Day
'
)
group_list
.
append
(
'
CAEW_Day
'
)
group_list
.
append
(
'
CAEI_Day
'
)
group_list
.
append
(
'
CAEIH_Day
'
)
group_list
.
append
(
'
CAE_Night
'
)
group_list
.
append
(
'
CAEH_Night
'
)
group_list
.
append
(
'
CAEM_Night
'
)
group_list
.
append
(
'
CAEL_Night
'
)
group_list
.
append
(
'
CAEW_Night
'
)
group_list
.
append
(
'
CAEI_Night
'
)
group_list
.
append
(
'
CAEIH_Night
'
)
group_list
.
append
(
'
ALWP
'
)
group_list
.
append
(
'
AIWP
'
)
group_list
.
append
(
'
AIWPH
'
)
group_list
.
append
(
'
ALWP_CLDPCL
'
)
group_list
.
append
(
'
AIWP_CLDPCL
'
)
group_list
.
append
(
'
AIWPH_CLDPCL
'
)
latdim
=
f0
.
dimensions
[
'
latitude
'
].
size
londim
=
f0
.
dimensions
[
'
longitude
'
].
size
...
...
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