Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toargridding
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
esde
toar-public
toargridding
Commits
ebd4443d
Commit
ebd4443d
authored
1 year ago
by
Simon Grasse
Browse files
Options
Downloads
Patches
Plain Diff
refactor dataset writing
parent
b70136d6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
Creation of first beta release version
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
toargridding/grids.py
+26
-8
26 additions, 8 deletions
toargridding/grids.py
with
26 additions
and
8 deletions
toargridding/grids.py
+
26
−
8
View file @
ebd4443d
...
@@ -14,7 +14,7 @@ from toargridding.toar_rest_client import (
...
@@ -14,7 +14,7 @@ from toargridding.toar_rest_client import (
STATION_LON
,
STATION_LON
,
COORDS
,
COORDS
,
)
)
from
toargridding.metadata
import
GLOBAL
,
LATITUDE
,
LONGITUDE
from
toargridding.metadata
import
GLOBAL
,
LATITUDE
,
LONGITUDE
,
get_variable_attributes
GridType
=
Enum
(
"
GridType
"
,
[
"
regular
"
])
GridType
=
Enum
(
"
GridType
"
,
[
"
regular
"
])
...
@@ -116,18 +116,36 @@ class RegularGrid(GridDefinition):
...
@@ -116,18 +116,36 @@ class RegularGrid(GridDefinition):
gridded_ds
=
self
.
get_empty_grid
(
time
,
metadata
)
gridded_ds
=
self
.
get_empty_grid
(
time
,
metadata
)
for
cell_statistic
,
grouped_timeseries
in
cell_statistics
.
items
():
for
cell_statistic
,
grouped_timeseries
in
cell_statistics
.
items
():
values
=
np
.
empty
((
self
.
lat
.
size
,
self
.
lon
.
size
,
time
.
size
))
gridded_ds
=
self
.
assign_statistic_to_grid
(
index
=
self
.
_as_xy_index
[
grouped_timeseries
.
index
]
gridded_ds
,
cell_statistic
,
grouped_timeseries
,
time
values
[
index
.
T
[
0
],
index
.
T
[
1
]]
=
grouped_timeseries
.
values
.
reshape
(
-
1
,
time
.
size
)
)
gridded_ds
=
gridded_ds
.
assign
(
# maybe better all in one ? (memory)
return
gridded_ds
{
cell_statistic
:
([
"
latitude
"
,
"
longitude
"
,
"
time
"
],
values
)}
)
def
assign_statistic_to_grid
(
self
,
gridded_ds
:
xr
.
Dataset
,
cell_statistic
,
grouped_timeseries
,
time
):
values
=
self
.
create_gridded_statistics
(
time
,
grouped_timeseries
)
metadata
=
get_variable_attributes
(
cell_statistic
)
print
(
cell_statistic
)
gridded_ds
=
gridded_ds
.
assign
(
# maybe better all in one ? (memory)
{
cell_statistic
:
([
"
latitude
"
,
"
longitude
"
,
"
time
"
],
values
)}
)
return
gridded_ds
return
gridded_ds
def
create_gridded_statistics
(
self
,
time
,
grouped_timeseries
):
values
=
np
.
empty
((
self
.
lat
.
size
,
self
.
lon
.
size
,
time
.
size
))
index
=
self
.
_as_xy_index
[
grouped_timeseries
.
index
]
values
[
index
.
T
[
0
],
index
.
T
[
1
]]
=
grouped_timeseries
.
values
.
reshape
(
-
1
,
time
.
size
)
return
values
def
as_cell_index
(
self
,
coords
):
def
as_cell_index
(
self
,
coords
):
id_x
=
self
.
coord_to_index
(
id_x
=
self
.
coord_to_index
(
coords
[
STATION_LAT
],
self
.
lat
.
min
(),
self
.
lat_resolution
coords
[
STATION_LAT
],
self
.
lat
.
min
(),
self
.
lat_resolution
...
...
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