jacobbieker
commited on
Commit
•
4c9706a
1
Parent(s):
db8068a
Add raw observation Features
Browse files- gfs-reforecast.py +20 -13
gfs-reforecast.py
CHANGED
@@ -73,10 +73,10 @@ class GFEReforecastDataset(datasets.GeneratorBasedBuilder):
|
|
73 |
DEFAULT_CONFIG_NAME = "gfs_v16" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
74 |
|
75 |
def _info(self):
|
|
|
76 |
if "v16" in self.config.name:
|
77 |
# TODO Add the variables one with all 696 variables, potentially combined by level
|
78 |
-
features =
|
79 |
-
{
|
80 |
"current_state": datasets.Array3D((721,1440,696), dtype="float32"),
|
81 |
"next_state": datasets.Array3D((721,1440,696), dtype="float32"),
|
82 |
"timestamp": datasets.Sequence(datasets.Value("timestamp[ns]")),
|
@@ -84,20 +84,27 @@ class GFEReforecastDataset(datasets.GeneratorBasedBuilder):
|
|
84 |
"longitude": datasets.Sequence(datasets.Value("float32"))
|
85 |
# These are the features of your dataset like images, labels ...
|
86 |
}
|
87 |
-
|
88 |
-
|
89 |
-
features =
|
90 |
-
|
91 |
-
"
|
92 |
-
"timestamp": datasets.Value("timestamp[ns]"),
|
93 |
"latitude": datasets.Sequence(datasets.Value("float32")),
|
94 |
"longitude": datasets.Sequence(datasets.Value("float32"))
|
95 |
# These are the features of your dataset like images, labels ...
|
96 |
}
|
97 |
-
)
|
98 |
if "raw" in self.config.name:
|
99 |
-
# Add the raw observation features
|
100 |
-
raw_features = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
return datasets.DatasetInfo(
|
102 |
# This is the description that will appear on the datasets page.
|
103 |
description=_DESCRIPTION,
|
@@ -165,8 +172,8 @@ class GFEReforecastDataset(datasets.GeneratorBasedBuilder):
|
|
165 |
for t in range(len(dataset["time"].values)-1):
|
166 |
data_t = dataset.isel(time=t)
|
167 |
data_t1 = dataset.isel(time=(t+1))
|
168 |
-
value = {"current_state": np.
|
169 |
-
"next_state": np.
|
170 |
"timestamp": data_t["time"].values,
|
171 |
"latitude": data_t["latitude"].values,
|
172 |
"longitude": data_t["longitude"].values}
|
|
|
73 |
DEFAULT_CONFIG_NAME = "gfs_v16" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
74 |
|
75 |
def _info(self):
|
76 |
+
features = {}
|
77 |
if "v16" in self.config.name:
|
78 |
# TODO Add the variables one with all 696 variables, potentially combined by level
|
79 |
+
features = {
|
|
|
80 |
"current_state": datasets.Array3D((721,1440,696), dtype="float32"),
|
81 |
"next_state": datasets.Array3D((721,1440,696), dtype="float32"),
|
82 |
"timestamp": datasets.Sequence(datasets.Value("timestamp[ns]")),
|
|
|
84 |
"longitude": datasets.Sequence(datasets.Value("float32"))
|
85 |
# These are the features of your dataset like images, labels ...
|
86 |
}
|
87 |
+
elif "analysis" in self.config.name:
|
88 |
+
# TODO Add the variables one with all 322 variables, potentially combined by level
|
89 |
+
features = {
|
90 |
+
"current_state": datasets.Array3D((721,1440,322), dtype="float32"),
|
91 |
+
"next_state": datasets.Array3D((721,1440,322), dtype="float32"),
|
92 |
+
"timestamp": datasets.Sequence(datasets.Value("timestamp[ns]")),
|
93 |
"latitude": datasets.Sequence(datasets.Value("float32")),
|
94 |
"longitude": datasets.Sequence(datasets.Value("float32"))
|
95 |
# These are the features of your dataset like images, labels ...
|
96 |
}
|
|
|
97 |
if "raw" in self.config.name:
|
98 |
+
# Add the raw observation features, capping at 256,000 observations, padding if not enough
|
99 |
+
raw_features = {"observations": datasets.Array2D((256000,1), dtype="float32"),
|
100 |
+
"observation_type": datasets.Array2D((256000,1), dtype="string"),
|
101 |
+
"observation_lat": datasets.Array2D((256000,1), dtype="float32"),
|
102 |
+
"observation_lon": datasets.Array2D((256000,1), dtype="float32"),
|
103 |
+
}
|
104 |
+
features = features.update(raw_features)
|
105 |
+
|
106 |
+
features = datasets.Features(features)
|
107 |
+
|
108 |
return datasets.DatasetInfo(
|
109 |
# This is the description that will appear on the datasets page.
|
110 |
description=_DESCRIPTION,
|
|
|
172 |
for t in range(len(dataset["time"].values)-1):
|
173 |
data_t = dataset.isel(time=t)
|
174 |
data_t1 = dataset.isel(time=(t+1))
|
175 |
+
value = {"current_state": np.stack([data_t[v].values for v in sorted(data_t.data_vars)], axis=2),
|
176 |
+
"next_state": np.stack([data_t1[v].values for v in sorted(data_t.data_vars)], axis=2),
|
177 |
"timestamp": data_t["time"].values,
|
178 |
"latitude": data_t["latitude"].values,
|
179 |
"longitude": data_t["longitude"].values}
|