jacobbieker commited on
Commit
c729c76
1 Parent(s): 43bc6cb

Update loader a bit

Browse files
Files changed (1) hide show
  1. gfs-reforecast.py +14 -16
gfs-reforecast.py CHANGED
@@ -23,8 +23,7 @@ import datasets
23
  _CITATION = """\
24
  @InProceedings{ocf:gfs,
25
  title = {GFS Forecast Dataset},
26
- author={Jacob Bieker
27
- },
28
  year={2022}
29
  }
30
  """
@@ -42,18 +41,12 @@ _LICENSE = "US Government data, Open license, no restrictions"
42
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
43
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
44
  _URLS = {
45
- "2021": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/2021/2021.zarr.zip",
46
- "2017": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/2017/2017.zarr.zip",
47
- "2016": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/2016/2016.zarr.zip",
48
- "2018": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/2018/2018.zarr.zip",
49
- "2019": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/2019/2019.zarr.zip",
50
- "2022": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/2022/2022.zarr.zip",
51
  }
52
- # Add default training one, train on all before 2020, validate on 2021, test on 2022
53
- _URLS["default"] = {"train": [_URLS["2016"], _URLS["2017"], _URLS["2018"], _URLS["2019"]], "valid": [_URLS["2021"]], "test": [_URLS["2022"]]}
54
- _URLS["default_sequence"] = _URLS["default"]
55
 
56
- class MRMS(datasets.GeneratorBasedBuilder):
57
  """Archival MRMS Precipitation Rate Radar data for the continental US, covering most of 2016-2022."""
58
 
59
  VERSION = datasets.Version("1.0.0")
@@ -71,16 +64,21 @@ class MRMS(datasets.GeneratorBasedBuilder):
71
  # data = datasets.load_dataset('my_dataset', 'second_domain')
72
  BUILDER_CONFIGS = [
73
  datasets.BuilderConfig(name="analysis", version=VERSION, description="FNL 0.25 degree Analysis files"),
74
- datasets.BuilderConfig(name="default_sequence", version=VERSION, description="Train on 2016-2020, validate on 2021, test on 2022, with 24 timesteps per example"),
 
 
 
75
  ]
76
 
77
  DEFAULT_CONFIG_NAME = "analysis" # It's not mandatory to have a default configuration. Just use one if it make sense.
78
 
79
  def _info(self):
80
- if "sequence" in self.config.name:
 
81
  features = datasets.Features(
82
  {
83
- "precipitation_rate": datasets.Array4D((3500,7000,2), dtype="float16"),
 
84
  "timestamp": datasets.Sequence(datasets.Value("timestamp[ns]")),
85
  "latitude": datasets.Sequence(datasets.Value("float32")),
86
  "longitude": datasets.Sequence(datasets.Value("float32"))
@@ -90,7 +88,7 @@ class MRMS(datasets.GeneratorBasedBuilder):
90
  else:
91
  features = datasets.Features(
92
  {
93
- "precipitation_rate": datasets.Array3D((3500,7000,1), dtype="float16"),
94
  "timestamp": datasets.Value("timestamp[ns]"),
95
  "latitude": datasets.Sequence(datasets.Value("float32")),
96
  "longitude": datasets.Sequence(datasets.Value("float32"))
 
23
  _CITATION = """\
24
  @InProceedings{ocf:gfs,
25
  title = {GFS Forecast Dataset},
26
+ author={Jacob Bieker},
 
27
  year={2022}
28
  }
29
  """
 
41
  # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
42
  # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
43
  _URLS = {
44
+ "GFSv16": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/forecasts/GFSv16/*.zarr.zip",
45
+ "raw": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/raw/*.zarr.zip",
46
+ "analysis": "https://huggingface.co/datasets/openclimatefix/mrms/resolve/main/data/analysis/*.zarr.zip",
 
 
 
47
  }
 
 
 
48
 
49
+ class GFEReforecastDataset(datasets.GeneratorBasedBuilder):
50
  """Archival MRMS Precipitation Rate Radar data for the continental US, covering most of 2016-2022."""
51
 
52
  VERSION = datasets.Version("1.0.0")
 
64
  # data = datasets.load_dataset('my_dataset', 'second_domain')
65
  BUILDER_CONFIGS = [
66
  datasets.BuilderConfig(name="analysis", version=VERSION, description="FNL 0.25 degree Analysis files"),
67
+ datasets.BuilderConfig(name="raw_analysis", version=VERSION, description="FNL 0.25 degree Analysis files coupled with raw observations"),
68
+ datasets.BuilderConfig(name="gfs_v16", version=VERSION, description="GFS v16 Forecasts from April 2021 through 2022, returned as a 696 channel image"),
69
+ datasets.BuilderConfig(name="raw_gfs_v16", version=VERSION, description="GFS v16 Forecasts from April 2021 through 2022, returned as a 696 channel image, coupled with raw observations"),
70
+ datasets.BuilderConfig(name="gfs_v16_variables", version=VERSION, description="GFS v16 Forecasts from April 2021 through 2022 with one returned array per variable"),
71
  ]
72
 
73
  DEFAULT_CONFIG_NAME = "analysis" # 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 = datasets.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]")),
83
  "latitude": datasets.Sequence(datasets.Value("float32")),
84
  "longitude": datasets.Sequence(datasets.Value("float32"))
 
88
  else:
89
  features = datasets.Features(
90
  {
91
+ "precipitation_rate": datasets.Array3D((721,1440,696), dtype="float32"),
92
  "timestamp": datasets.Value("timestamp[ns]"),
93
  "latitude": datasets.Sequence(datasets.Value("float32")),
94
  "longitude": datasets.Sequence(datasets.Value("float32"))