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
1a25b13d
Commit
1a25b13d
authored
1 year ago
by
Simon Grasse
Browse files
Options
Downloads
Patches
Plain Diff
fix usage/implementation
parent
da16bf39
No related branches found
No related tags found
1 merge request
!11
Creation of first beta release version
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
toargridding/grids.py
+4
-8
4 additions, 8 deletions
toargridding/grids.py
toargridding/metadata.py
+4
-4
4 additions, 4 deletions
toargridding/metadata.py
with
8 additions
and
12 deletions
toargridding/grids.py
+
4
−
8
View file @
1a25b13d
...
@@ -13,10 +13,7 @@ from toargridding.toar_rest_client import (
...
@@ -13,10 +13,7 @@ from toargridding.toar_rest_client import (
)
)
from
toargridding.metadata
import
(
from
toargridding.metadata
import
(
Variables
,
Variables
,
DataVariables
,
Variable
,
Coordinate
,
Coordinate
,
DataVariable
,
get_variable_attributes
,
get_variable_attributes
,
get_global_attributes
,
get_global_attributes
,
)
)
...
@@ -82,6 +79,7 @@ class RegularGrid(GridDefinition):
...
@@ -82,6 +79,7 @@ class RegularGrid(GridDefinition):
datasets
[
statistic
]
=
self
.
create_dataset
(
cell_statistics
,
metadata
)
datasets
[
statistic
]
=
self
.
create_dataset
(
cell_statistics
,
metadata
)
return
datasets
return
datasets
print
(
cls
)
def
clean_coords
(
self
,
coords
:
pd
.
DataFrame
):
def
clean_coords
(
self
,
coords
:
pd
.
DataFrame
):
valid_coords
=
coords
.
notna
().
all
(
axis
=
1
)
valid_coords
=
coords
.
notna
().
all
(
axis
=
1
)
...
@@ -131,7 +129,7 @@ class RegularGrid(GridDefinition):
...
@@ -131,7 +129,7 @@ class RegularGrid(GridDefinition):
self
,
gridded_ds
:
xr
.
Dataset
,
cell_statistic
,
grouped_timeseries
,
time
self
,
gridded_ds
:
xr
.
Dataset
,
cell_statistic
,
grouped_timeseries
,
time
):
):
values
=
self
.
create_gridded_statistics
(
time
,
grouped_timeseries
)
values
=
self
.
create_gridded_statistics
(
time
,
grouped_timeseries
)
print
(
values
.
shape
)
gridded_ds
=
gridded_ds
.
assign
(
# maybe better all in one ? (memory)
gridded_ds
=
gridded_ds
.
assign
(
# maybe better all in one ? (memory)
{
{
cell_statistic
:
(
cell_statistic
:
(
...
@@ -177,13 +175,11 @@ class RegularGrid(GridDefinition):
...
@@ -177,13 +175,11 @@ class RegularGrid(GridDefinition):
self
,
time
:
pd
.
DatetimeIndex
,
metadata
:
pd
.
DataFrame
self
,
time
:
pd
.
DatetimeIndex
,
metadata
:
pd
.
DataFrame
)
->
xr
.
Dataset
:
# TODO make CF-compliant => docs
)
->
xr
.
Dataset
:
# TODO make CF-compliant => docs
coords
=
{
coords
=
{
Variables
.
longitude
.
name
:
self
.
lon
,
Variables
.
longitude
.
name
:
self
.
lon
.
as_data_array
(
dims
=
self
.
lon
.
name
)
,
Variables
.
latitude
.
name
:
self
.
lat
,
Variables
.
latitude
.
name
:
self
.
lat
.
as_data_array
(
dims
=
self
.
lat
.
name
)
,
Variables
.
time
.
name
:
time
,
Variables
.
time
.
name
:
time
,
}
}
ds
=
xr
.
Dataset
(
coords
=
coords
,
attrs
=
get_global_attributes
(
metadata
))
ds
=
xr
.
Dataset
(
coords
=
coords
,
attrs
=
get_global_attributes
(
metadata
))
ds
.
longitude
.
attrs
=
get_variable_attributes
(
Variables
.
longitude
)
ds
.
latitude
.
attrs
=
get_variable_attributes
(
Variables
.
latitude
)
return
ds
return
ds
This diff is collapsed.
Click to expand it.
toargridding/metadata.py
+
4
−
4
View file @
1a25b13d
...
@@ -30,8 +30,8 @@ class Variable:
...
@@ -30,8 +30,8 @@ class Variable:
def
get_metadata
(
variable
:
Variables
):
def
get_metadata
(
variable
:
Variables
):
return
VARIABLE_METADATA
[
variable
]
return
VARIABLE_METADATA
[
variable
]
def
as_data_array
(
self
,
name
,
dims
):
def
as_data_array
(
self
,
dims
):
return
xr
.
DataArray
(
self
.
data
,
name
=
name
,
dims
=
dims
,
attrs
=
self
.
attributes
)
return
xr
.
DataArray
(
self
.
data
,
name
=
self
.
name
,
dims
=
dims
,
attrs
=
self
.
attributes
)
@property
@property
def
size
(
self
):
def
size
(
self
):
...
@@ -46,7 +46,7 @@ class Variable:
...
@@ -46,7 +46,7 @@ class Variable:
return
self
.
data
.
max
()
return
self
.
data
.
max
()
@dataclass
class
Coordinate
(
Variable
):
class
Coordinate
(
Variable
):
resolution
:
float
resolution
:
float
...
@@ -58,7 +58,7 @@ class Coordinate(Variable):
...
@@ -58,7 +58,7 @@ class Coordinate(Variable):
n
=
int
(
span
/
resolution
)
# raise error if invalid inputs ?
n
=
int
(
span
/
resolution
)
# raise error if invalid inputs ?
data
=
np
.
linspace
(
min
,
max
,
n
+
1
)
data
=
np
.
linspace
(
min
,
max
,
n
+
1
)
cls
.
from_data
(
data
,
variable
,
resolution
=
resolution
)
return
cls
.
from_data
(
data
,
variable
,
resolution
=
resolution
)
def
get_global_attributes
(
metadata
):
def
get_global_attributes
(
metadata
):
...
...
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