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
ce3f9443
Commit
ce3f9443
authored
11 months ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
4cbd18d4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/contrail/util.py
+10
-19
10 additions, 19 deletions
modules/contrail/util.py
with
10 additions
and
19 deletions
modules/contrail/util.py
+
10
−
19
View file @
ce3f9443
...
...
@@ -70,20 +70,6 @@ def extract(mask_image, image_ts, clavrx_path):
for
bin_num
in
np
.
unique
(
binned_indexes
):
bins_dict
[
bin_num
]
=
np
.
where
(
binned_indexes
==
bin_num
)[
0
]
# # This does point by point computation of model parameters for each contrail pixel
# voxel_dict = {key: [] for key in bins_dict.keys()}
# for key in bins_dict.keys():
# print('working on pressure level: ', bins[key])
# for c_idx in bins_dict[key]:
# lon = contrail_lons[c_idx]
# lat = contrail_lats[c_idx]
# press = contrail_press[c_idx]
#
# wind_3d = get_voxel_s(xr_dataset, ['u-wind','v-wind'], lon, lat, press)
# if wind_3d is not None:
# voxel_dict[key].append(wind_3d)
# ------------------------------------------------------------------------------------
# This section will compute model parameters in bulk for the region then pull for each contrail pixel
lon_range
=
[
np
.
min
(
contrail_lons
),
np
.
max
(
contrail_lons
)]
lat_range
=
[
np
.
min
(
contrail_lats
),
np
.
max
(
contrail_lats
)]
...
...
@@ -124,22 +110,28 @@ def extract(mask_image, image_ts, clavrx_path):
static_value
=
static_3d
.
interp
(
Pressure
=
press
,
Longitude
=
lon
,
Latitude
=
lat
,
method
=
'
nearest
'
).
item
(
0
)
horz_wind_spd_value
=
horz_wind_spd_3d
.
interp
(
Pressure
=
press
,
Longitude
=
lon
,
Latitude
=
lat
,
method
=
'
nearest
'
).
item
(
0
)
vert_shear_value
=
vert_shear_3d
.
interp
(
Pressure
=
press
,
Longitude
=
lon
,
Latitude
=
lat
,
method
=
'
nearest
'
).
item
(
0
)
temp_value
=
temp_3d
.
interp
(
Pressure
=
press
,
Longitude
=
lon
,
Latitude
=
lat
,
method
=
'
nearest
'
).
item
(
0
)
rh_value
=
rh_3d
.
interp
(
Pressure
=
press
,
Longitude
=
lon
,
Latitude
=
lat
,
method
=
'
nearest
'
).
item
(
0
)
# tmp = horz_shear_3d.sel(Pressure=press, method='nearest')
# tmp = tmp.sel(Longitude=lon, Latitude=lat, method='nearest')
voxel_dict
[
key
].
append
((
press_level
,
press
,
lat
,
lon
,
horz_shear_value
,
static_value
,
horz_wind_spd_value
,
vert_shear_value
))
all_list
.
append
((
press_level
,
press
,
lat
,
lon
,
horz_shear_value
,
static_value
,
horz_wind_spd_value
,
vert_shear_value
))
voxel_dict
[
key
].
append
((
press_level
,
press
,
lat
,
lon
,
temp_value
,
rh_value
,
horz_shear_value
,
static_value
,
horz_wind_spd_value
,
vert_shear_value
))
all_list
.
append
((
press_level
,
press
,
lat
,
lon
,
temp_value
,
rh_value
,
horz_shear_value
,
static_value
,
horz_wind_spd_value
,
vert_shear_value
))
# Create pandas DataFrame for each list of tuples in voxel_dict
voxel_dict_df
=
{}
for
k
,
v
in
voxel_dict
.
items
():
print
(
k
,
len
(
v
))
df
=
pd
.
DataFrame
(
v
,
columns
=
[
"
pressure_level
"
,
"
pressure
"
,
"
lat
"
,
"
lon
"
,
"
horz_shear_deform
"
,
"
static_stability
"
,
"
horz_wind_speed
"
,
"
vert_wind_shear
"
])
df
=
pd
.
DataFrame
(
v
,
columns
=
[
"
pressure_level
"
,
"
pressure
"
,
"
lat
"
,
"
lon
"
,
"
temperature
"
,
"
relative_humidity
"
,
"
horz_shear_deform
"
,
"
static_stability
"
,
"
horz_wind_speed
"
,
"
vert_wind_shear
"
])
voxel_dict_df
[
k
]
=
df
# Create a DataFrame for all tuples
all_df
=
pd
.
DataFrame
(
all_list
,
columns
=
[
"
pressure_level
"
,
"
pressure
"
,
"
lat
"
,
"
lon
"
,
"
horz_shear_deform
"
,
"
static_stability
"
,
"
horz_wind_speed
"
,
"
vert_wind_shear
"
])
all_df
=
pd
.
DataFrame
(
all_list
,
columns
=
[
"
pressure_level
"
,
"
pressure
"
,
"
lat
"
,
"
lon
"
,
"
temperature
"
,
"
relative_humidity
"
,
"
horz_shear_deform
"
,
"
static_stability
"
,
"
horz_wind_speed
"
,
"
vert_wind_shear
"
])
xr_dataset
.
close
()
...
...
@@ -148,7 +140,6 @@ def extract(mask_image, image_ts, clavrx_path):
def
analyze
(
dataFrame
,
column
,
value
):
result_df
=
dataFrame
[
dataFrame
[
column
]
==
value
]
# get rows where column has a certain value
print
(
result_df
.
head
())
mean
=
result_df
.
mean
()
# calculate mean for other columns
stddev
=
result_df
.
std
()
# calculate standard deviation for other columns
...
...
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