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
69674809
Commit
69674809
authored
10 months ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
2a63cf40
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/util/gfs_reader.py
+21
-8
21 additions, 8 deletions
modules/util/gfs_reader.py
with
21 additions
and
8 deletions
modules/util/gfs_reader.py
+
21
−
8
View file @
69674809
...
@@ -232,7 +232,7 @@ def get_vert_profile_s(xr_dataset, fld_name_s, lons, lats, method='linear'):
...
@@ -232,7 +232,7 @@ def get_vert_profile_s(xr_dataset, fld_name_s, lons, lats, method='linear'):
return
intrp_fld
return
intrp_fld
def
get_point
(
xr_dataset
,
fld_name
,
lons
,
lats
,
method
=
'
nearest
'
):
def
get_point
(
xr_dataset
,
fld_name
,
lons
,
lats
,
pres_s
=
None
,
method
=
'
nearest
'
):
if
lon360
:
# convert -180/+180 to 0,360
if
lon360
:
# convert -180/+180 to 0,360
lons
=
np
.
where
(
lons
<
0
,
lons
+
360
,
lons
)
# convert -180,180 to 0,360
lons
=
np
.
where
(
lons
<
0
,
lons
+
360
,
lons
)
# convert -180,180 to 0,360
...
@@ -240,17 +240,24 @@ def get_point(xr_dataset, fld_name, lons, lats, method='nearest'):
...
@@ -240,17 +240,24 @@ def get_point(xr_dataset, fld_name, lons, lats, method='nearest'):
lon_coords
=
np
.
linspace
(
0
,
359.5
,
xr_dataset
.
fakeDim2
.
size
)
lon_coords
=
np
.
linspace
(
0
,
359.5
,
xr_dataset
.
fakeDim2
.
size
)
fld
=
xr_dataset
[
fld_name
]
fld
=
xr_dataset
[
fld_name
]
fld
=
fld
.
assign_coords
(
fakeDim2
=
lon_coords
,
fakeDim1
=
lat_coords
)
if
pres_s
is
not
None
:
fld
=
fld
.
assign_coords
(
fakeDim2
=
lon_coords
,
fakeDim1
=
lat_coords
,
fakeDim0
=
plevs
)
else
:
fld
=
fld
.
assign_coords
(
fakeDim2
=
lon_coords
,
fakeDim1
=
lat_coords
)
dim1
=
xr
.
DataArray
(
lats
,
dims
=
'
k
'
)
dim1
=
xr
.
DataArray
(
lats
,
dims
=
'
k
'
)
dim2
=
xr
.
DataArray
(
lons
,
dims
=
'
k
'
)
dim2
=
xr
.
DataArray
(
lons
,
dims
=
'
k
'
)
if
pres_s
is
not
None
:
intrp_fld
=
fld
.
interp
(
fakeDim1
=
dim1
,
fakeDim2
=
dim2
,
method
=
method
)
dim0
=
xr
.
DataArray
(
pres_s
,
dims
=
'
k
'
)
intrp_fld
=
fld
.
interp
(
fakeDim0
=
dim0
,
fakeDim1
=
dim1
,
fakeDim2
=
dim2
,
method
=
method
)
else
:
intrp_fld
=
fld
.
interp
(
fakeDim1
=
dim1
,
fakeDim2
=
dim2
,
method
=
method
)
return
intrp_fld
return
intrp_fld
def
get_point_s
(
xr_dataset
,
fld_name_s
,
lons
,
lats
,
method
=
'
nearest
'
):
def
get_point_s
(
xr_dataset
,
fld_name_s
,
lons
,
lats
,
pres_s
=
None
,
method
=
'
nearest
'
):
if
lon360
:
# convert -180/+180 to 0,360
if
lon360
:
# convert -180/+180 to 0,360
lons
=
np
.
where
(
lons
<
0
,
lons
+
360
,
lons
)
# convert -180,180 to 0,360
lons
=
np
.
where
(
lons
<
0
,
lons
+
360
,
lons
)
# convert -180,180 to 0,360
...
@@ -260,14 +267,20 @@ def get_point_s(xr_dataset, fld_name_s, lons, lats, method='nearest'):
...
@@ -260,14 +267,20 @@ def get_point_s(xr_dataset, fld_name_s, lons, lats, method='nearest'):
fld_s
=
[]
fld_s
=
[]
for
fld_name
in
fld_name_s
:
for
fld_name
in
fld_name_s
:
fld
=
xr_dataset
[
fld_name
]
fld
=
xr_dataset
[
fld_name
]
fld
=
fld
.
assign_coords
(
fakeDim2
=
lon_coords
,
fakeDim1
=
lat_coords
)
if
pres_s
is
not
None
:
fld
=
fld
.
assign_coords
(
fakeDim2
=
lon_coords
,
fakeDim1
=
lat_coords
,
fakeDim0
=
plevs
)
else
:
fld
=
fld
.
assign_coords
(
fakeDim2
=
lon_coords
,
fakeDim1
=
lat_coords
)
fld_s
.
append
(
fld
)
fld_s
.
append
(
fld
)
fld
=
xr
.
concat
(
fld_s
,
'
fld_dim
'
)
fld
=
xr
.
concat
(
fld_s
,
'
fld_dim
'
)
dim1
=
xr
.
DataArray
(
lats
,
dims
=
'
k
'
)
dim1
=
xr
.
DataArray
(
lats
,
dims
=
'
k
'
)
dim2
=
xr
.
DataArray
(
lons
,
dims
=
'
k
'
)
dim2
=
xr
.
DataArray
(
lons
,
dims
=
'
k
'
)
if
pres_s
is
not
None
:
intrp_fld
=
fld
.
interp
(
fakeDim1
=
dim1
,
fakeDim2
=
dim2
,
method
=
method
)
dim0
=
xr
.
DataArray
(
pres_s
,
dims
=
'
k
'
)
intrp_fld
=
fld
.
interp
(
fakeDim0
=
dim0
,
fakeDim1
=
dim1
,
fakeDim2
=
dim2
,
method
=
method
)
else
:
intrp_fld
=
fld
.
interp
(
fakeDim1
=
dim1
,
fakeDim2
=
dim2
,
method
=
method
)
return
intrp_fld
return
intrp_fld
...
...
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