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
abd2c65f
Commit
abd2c65f
authored
9 months ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
4a623f26
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/contrail/util.py
+10
-2
10 additions, 2 deletions
modules/contrail/util.py
with
10 additions
and
2 deletions
modules/contrail/util.py
+
10
−
2
View file @
abd2c65f
...
...
@@ -4,6 +4,7 @@ from datetime import timezone
import
numpy
as
np
import
xarray
as
xr
import
pandas
as
pd
import
rasterio
from
PIL
import
Image
import
matplotlib.pyplot
as
plt
...
...
@@ -108,8 +109,10 @@ def extract(mask_image, image_ts, clavrx_path):
horz_shear_3d
=
shearing_deformation
(
uwind_3d
,
vwind_3d
)
static_3d
=
static_stability
(
temp_3d
.
coords
[
'
Pressure
'
]
*
units
.
hPa
,
temp_3d
)
horz_wind_spd_3d
=
wind_speed
(
uwind_3d
,
vwind_3d
)
# This one's a bit more work: `first_derivative` only returns a ndarray with no units, so we use the
# helper function to create a DataArray and units via metpy's pint support
vert_shear_3d
=
first_derivative
(
horz_wind_spd_3d
,
axis
=
0
,
x
=
temp_3d
.
coords
[
'
Pressure
'
])
print
(
horz_wind_spd_3d
.
shape
,
vert_shear_3d
.
shape
)
vert_shear_3d
=
volume_np_to_xr
(
vert_shear_3d
,
[
'
Pressure
'
,
'
Latitude
'
,
'
Longitude
'
],
lon_range
=
[
lon_range
[
0
],
lon_range
[
1
]],
lat_range
=
[
lat_range
[
0
],
lat_range
[
1
]])
vert_shear_3d
=
vert_shear_3d
*
units
.
meter
/
(
units
.
second
*
units
.
hPa
)
...
...
@@ -126,7 +129,12 @@ def extract(mask_image, image_ts, clavrx_path):
horz_wind_spd_value
=
horz_wind_spd_3d
.
interp
(
Pressure
=
press
,
Longitude
=
lon
,
Latitude
=
lat
,
method
=
'
nearest
'
)
vert_shear_value
=
vert_shear_3d
.
interp
(
Pressure
=
press
,
Longitude
=
lon
,
Latitude
=
lat
,
method
=
'
nearest
'
)
voxel_dict
[
key
].
append
((
horz_shear_value
,
static_value
,
horz_wind_spd_value
,
vert_shear_value
))
voxel_dict
[
key
].
append
((
press
,
lat
,
lon
,
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
():
voxel_dict_df
[
k
]
=
pd
.
DataFrame
(
v
,
columns
=
[
"
press
"
,
"
lat
"
,
"
lon
"
,
"
horz_shear_value
"
,
"
static_value
"
,
"
horz_wind_spd_value
"
,
"
vert_shear_value
"
])
xr_dataset
.
close
()
...
...
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