Skip to content

MinIO

该模块用于获取minio服务器中的数据列表,包括:

  • Era5_land
  • GPM_IMERG_Early
  • GFS_atmos

ERA5LCatalog

用于获取era5-land的数据源信息,并搜索minio服务器中的数据范围

Attributes:

Name Type Description
collection_id str

数据集名称

data_sources str

数据源

description str

数据源链接

spatial_resolution str

空间分辨率

temporal_resolution str

时间分辨率

datasets dict

minio服务器中的已有数据集

Method

search(aoi, start_time, end_time): 搜索minio服务器中的数据范围

Source code in hydro_opendata/catalog/minio.py
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class ERA5LCatalog:
    """
    用于获取era5-land的数据源信息,并搜索minio服务器中的数据范围

    Attributes:
        collection_id (str): 数据集名称
        data_sources (str): 数据源
        description (str): 数据源链接
        spatial_resolution (str): 空间分辨率
        temporal_resolution (str): 时间分辨率
        datasets (dict): minio服务器中的已有数据集

    Method:
        search(aoi, start_time, end_time): 搜索minio服务器中的数据范围
    """

    def __init__(self):
        self._collection_id = "era5-land"
        self._datasources = "ECMWF"
        self._description = "https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-land?tab=overview"
        self._spatialresolution = "0.1 x 0.1; Native resolution is 9 km."
        self._temporalresolution = "hourly"

        self._datasets = self._get_datasets()

    def _get_datasets(self):
        dss = {}

        ds = {}
        with fs.open(os.path.join(bucket_name, "geodata/era5_land/era5l.json")) as f:
            era5 = json.load(f)
            ds["start_time"] = np.datetime64(era5["start"])
            ds["end_time"] = np.datetime64(era5["end"])
            ds["bbox"] = era5["bbox"]
        dss["wis"] = ds

        return dss

    @property
    def collection_id(self):
        return self._collection_id

    @property
    def data_sources(self):
        return self._datasources

    @property
    def description(self):
        return self._description

    @property
    def spatial_resolution(self):
        return self._spatialresolution

    @property
    def temporal_resolution(self):
        return self._temporalresolution

    @property
    def datasets(self):
        return self._datasets

    def search(self, aoi, start_time=None, end_time=None):
        """
        查询并获取数据清单

        Args:
            aoi (GeoDataFrame): 矢量数据范围
            strt_time (datatime64): 查询的起始时间
            end_time (datatime64): 查询的终止时间

        Returns:
            datalist (GeoDataFrame): 符合条件的数据清单
        """

        clips = []

        for key, value in self._datasets.items():
            start = start_time
            end = end_time
            if start_time is None:
                start = value["start_time"]
            if end_time is None:
                end = value["end_time"]

            if start < value["start_time"]:
                start = value["start_time"]
            if end > value["end_time"]:
                end = value["end_time"]

            if start <= end:
                df = pd.DataFrame(
                    {
                        "id": [self._collection_id],
                        "dataset": [key],
                        "start_time": [str(start)],
                        "end_time": [str(end)],
                        "geometry": [
                            f"POLYGON(({value['bbox'][0]} {value['bbox'][3]},{value['bbox'][0]} {value['bbox'][1]},\
                                     {value['bbox'][2]} {value['bbox'][1]},{value['bbox'][2]} {value['bbox'][3]},{value['bbox'][0]} {value['bbox'][3]}))"
                        ],
                    }
                )
                df["geometry"] = gpd.GeoSeries.from_wkt(df["geometry"])
                gdf = gpd.GeoDataFrame(df, geometry="geometry", crs="EPSG:4326")

                clips.append(gdf.clip(aoi))

        return pd.concat(clips)

search(aoi, start_time=None, end_time=None)

查询并获取数据清单

Parameters:

Name Type Description Default
aoi GeoDataFrame

矢量数据范围

required
strt_time datatime64

查询的起始时间

required
end_time datatime64

查询的终止时间

None

Returns:

Name Type Description
datalist GeoDataFrame

符合条件的数据清单

Source code in hydro_opendata/catalog/minio.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def search(self, aoi, start_time=None, end_time=None):
    """
    查询并获取数据清单

    Args:
        aoi (GeoDataFrame): 矢量数据范围
        strt_time (datatime64): 查询的起始时间
        end_time (datatime64): 查询的终止时间

    Returns:
        datalist (GeoDataFrame): 符合条件的数据清单
    """

    clips = []

    for key, value in self._datasets.items():
        start = start_time
        end = end_time
        if start_time is None:
            start = value["start_time"]
        if end_time is None:
            end = value["end_time"]

        if start < value["start_time"]:
            start = value["start_time"]
        if end > value["end_time"]:
            end = value["end_time"]

        if start <= end:
            df = pd.DataFrame(
                {
                    "id": [self._collection_id],
                    "dataset": [key],
                    "start_time": [str(start)],
                    "end_time": [str(end)],
                    "geometry": [
                        f"POLYGON(({value['bbox'][0]} {value['bbox'][3]},{value['bbox'][0]} {value['bbox'][1]},\
                                 {value['bbox'][2]} {value['bbox'][1]},{value['bbox'][2]} {value['bbox'][3]},{value['bbox'][0]} {value['bbox'][3]}))"
                    ],
                }
            )
            df["geometry"] = gpd.GeoSeries.from_wkt(df["geometry"])
            gdf = gpd.GeoDataFrame(df, geometry="geometry", crs="EPSG:4326")

            clips.append(gdf.clip(aoi))

    return pd.concat(clips)

GFSCatalog

用于获取gfs的数据源信息,并搜索minio服务器中的数据范围

Attributes:

Name Type Description
collection_id str

数据集名称

data_sources str

数据源

description str

数据源链接

spatial_resolution str

空间分辨率

temporal_resolution str

时间分辨率

datasets dict

minio服务器中的已有数据集

Method

search(aoi, start_time, end_time): 搜索minio服务器中的数据范围

Source code in hydro_opendata/catalog/minio.py
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
class GFSCatalog:
    """
    用于获取gfs的数据源信息,并搜索minio服务器中的数据范围

    Attributes:
        collection_id (str): 数据集名称
        data_sources (str): 数据源
        description (str): 数据源链接
        spatial_resolution (str): 空间分辨率
        temporal_resolution (str): 时间分辨率
        datasets (dict): minio服务器中的已有数据集

    Method:
        search(aoi, start_time, end_time): 搜索minio服务器中的数据范围
    """

    def __init__(self, variable="tp"):
        self._variable = variable
        self._collection_id = f"gfs_atmos.{variable}"
        self._datasources = "NOAA"
        self._description = (
            "https://www.emc.ncep.noaa.gov/emc/pages/numerical_forecast_systems/gfs.php"
        )
        self._spatialresolution = "0.25 x 0.25"
        self._temporalresolution = "hourly; 1-120h"

        self._datasets = self._get_datasets()

    def _get_datasets(self):
        dss = {}

        ds = {}
        with fs.open(os.path.join(bucket_name, "geodata/gfs/gfs.json")) as f:
            gfs = json.load(f)
        dss["wis"] = gfs[self._variable]

        return dss

    @property
    def variable(self):
        return self._variable

    @property
    def collection_id(self):
        return self._collection_id

    @property
    def data_sources(self):
        return self._datasources

    @property
    def description(self):
        return self._description

    @property
    def spatial_resolution(self):
        return self._spatialresolution

    @property
    def temporal_resolution(self):
        return self._temporalresolution

    @property
    def datasets(self):
        return self._datasets

    def search(self, aoi, start_time=None, end_time=None):
        """
        查询并获取数据清单

        Args:
            aoi (GeoDataFrame): 矢量数据范围
            start_time (datatime64): 查询的起始时间
            end_time (datatime64): 查询的终止时间

        Returns:
            datalist (GeoDataFrame): 符合条件的数据清单
        """

        clips = []

        for key, value in self._datasets.items():
            for v in value:
                start = start_time
                end = end_time
                if start_time is None:
                    start = np.datetime64(v["start"])
                if end_time is None:
                    end = np.datetime64(v["end"])

                if start < np.datetime64(v["start"]):
                    start = np.datetime64(v["start"])

                if end > np.datetime64(v["end"]):
                    end = np.datetime64(v["end"])

                if start <= end:
                    df = pd.DataFrame(
                        {
                            "id": [self._collection_id],
                            "dataset": [key],
                            "start_time": [str(start)],
                            "end_time": [str(end)],
                            "geometry": [
                                f"POLYGON(({v['bbox'][0]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][1]},{v['bbox'][2]} {v['bbox'][1]},{v['bbox'][2]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][3]}))"
                            ],
                        }
                    )
                    df["geometry"] = gpd.GeoSeries.from_wkt(df["geometry"])
                    gdf = gpd.GeoDataFrame(df, geometry="geometry", crs="EPSG:4326")

                    clips.append(gdf.clip(aoi))

        return pd.concat(clips)

search(aoi, start_time=None, end_time=None)

查询并获取数据清单

Parameters:

Name Type Description Default
aoi GeoDataFrame

矢量数据范围

required
start_time datatime64

查询的起始时间

None
end_time datatime64

查询的终止时间

None

Returns:

Name Type Description
datalist GeoDataFrame

符合条件的数据清单

Source code in hydro_opendata/catalog/minio.py
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
def search(self, aoi, start_time=None, end_time=None):
    """
    查询并获取数据清单

    Args:
        aoi (GeoDataFrame): 矢量数据范围
        start_time (datatime64): 查询的起始时间
        end_time (datatime64): 查询的终止时间

    Returns:
        datalist (GeoDataFrame): 符合条件的数据清单
    """

    clips = []

    for key, value in self._datasets.items():
        for v in value:
            start = start_time
            end = end_time
            if start_time is None:
                start = np.datetime64(v["start"])
            if end_time is None:
                end = np.datetime64(v["end"])

            if start < np.datetime64(v["start"]):
                start = np.datetime64(v["start"])

            if end > np.datetime64(v["end"]):
                end = np.datetime64(v["end"])

            if start <= end:
                df = pd.DataFrame(
                    {
                        "id": [self._collection_id],
                        "dataset": [key],
                        "start_time": [str(start)],
                        "end_time": [str(end)],
                        "geometry": [
                            f"POLYGON(({v['bbox'][0]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][1]},{v['bbox'][2]} {v['bbox'][1]},{v['bbox'][2]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][3]}))"
                        ],
                    }
                )
                df["geometry"] = gpd.GeoSeries.from_wkt(df["geometry"])
                gdf = gpd.GeoDataFrame(df, geometry="geometry", crs="EPSG:4326")

                clips.append(gdf.clip(aoi))

    return pd.concat(clips)

GPMCatalog

用于获取gpm的数据源信息,并搜索minio服务器中的数据范围

Attributes:

Name Type Description
collection_id str

数据集名称

data_sources str

数据源

description str

数据源链接

spatial_resolution str

空间分辨率

temporal_resolution str

时间分辨率

datasets dict

minio服务器中的已有数据集

Method

search(aoi, start_time, end_time): 搜索minio服务器中的数据范围

Source code in hydro_opendata/catalog/minio.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
class GPMCatalog:
    """
    用于获取gpm的数据源信息,并搜索minio服务器中的数据范围

    Attributes:
        collection_id (str): 数据集名称
        data_sources (str): 数据源
        description (str): 数据源链接
        spatial_resolution (str): 空间分辨率
        temporal_resolution (str): 时间分辨率
        datasets (dict): minio服务器中的已有数据集

    Method:
        search(aoi, start_time, end_time): 搜索minio服务器中的数据范围
    """

    def __init__(self):
        self._collection_id = "gpm-imerg-early"
        self._datasources = "NASA & JAXA"
        self._description = (
            "https://disc.gsfc.nasa.gov/datasets/GPM_3IMERGHHE_06/summary"
        )
        self._spatialresolution = "0.1 x 0.1; Native resolution is 9 km. (60°S-60°N)"
        self._temporalresolution = "half-hourly; 1 day"

        self._datasets = self._get_datasets()

    def _get_datasets(self):
        dss = {}
        lds = []
        ds = {}
        with fs.open(os.path.join(bucket_name, "geodata/gpm/gpm.json")) as f:
            gpm = json.load(f)
            ds["time_resolution"] = "30 minutes"
            ds["start_time"] = np.datetime64(gpm["start"])
            ds["end_time"] = np.datetime64(gpm["end"])
            ds["bbox"] = gpm["bbox"]
        lds.append(ds)

        ds = {}
        with fs.open(os.path.join(bucket_name, "geodata/gpm1d/gpm1d.json")) as f:
            gpm = json.load(f)
            ds["time_resolution"] = "1 day"
            ds["start_time"] = np.datetime64(gpm["start"])
            ds["end_time"] = np.datetime64(gpm["end"])
            ds["bbox"] = gpm["bbox"]
        lds.append(ds)
        dss["wis"] = lds

        lds = []
        ds = {}
        with fs.open(os.path.join(bucket_name, "camdata/gpm/gpm.json")) as f:
            gpm = json.load(f)
            ds["time_resolution"] = "30 minutes"
            ds["start_time"] = np.datetime64(gpm["start"])
            ds["end_time"] = np.datetime64(gpm["end"])
            ds["bbox"] = gpm["bbox"]
        lds.append(ds)

        ds = {}
        with fs.open(os.path.join(bucket_name, "camdata/gpm1d/gpm1d.json")) as f:
            gpm = json.load(f)
            ds["time_resolution"] = "1 day"
            ds["start_time"] = np.datetime64(gpm["start"])
            ds["end_time"] = np.datetime64(gpm["end"])
            ds["bbox"] = gpm["bbox"]
        lds.append(ds)
        dss["camels"] = lds

        return dss

    @property
    def collection_id(self):
        return self._collection_id

    @property
    def data_sources(self):
        return self._datasources

    @property
    def description(self):
        return self._description

    @property
    def spatial_resolution(self):
        return self._spatialresolution

    @property
    def temporal_resolution(self):
        return self._temporalresolution

    @property
    def datasets(self):
        return self._datasets

    def search(self, aoi, start_time=None, end_time=None):
        """
        查询并获取数据清单

        Args:
            aoi (GeoDataFrame): 矢量数据范围
            strt_time (datatime64): 查询的起始时间
            end_time (datatime64): 查询的终止时间

        Returns:
            datalist (GeoDataFrame): 符合条件的数据清单
        """

        clips = []

        for key, value in self._datasets.items():
            for v in value:
                start = start_time
                end = end_time
                if start_time is None:
                    start = v["start_time"]
                if end_time is None:
                    end = v["end_time"]

                if start < v["start_time"]:
                    start = v["start_time"]
                if end > v["end_time"]:
                    end = v["end_time"]

                if start <= end:
                    df = pd.DataFrame(
                        {
                            "id": [self._collection_id],
                            "dataset": [key],
                            "time_resolution": v["time_resolution"],
                            "start_time": [str(start)],
                            "end_time": [str(end)],
                            "geometry": [
                                f"POLYGON(({v['bbox'][0]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][1]},\
                                         {v['bbox'][2]} {v['bbox'][1]},{v['bbox'][2]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][3]}))"
                            ],
                        }
                    )
                    df["geometry"] = gpd.GeoSeries.from_wkt(df["geometry"])
                    gdf = gpd.GeoDataFrame(df, geometry="geometry", crs="EPSG:4326")

                    clips.append(gdf.clip(aoi))

        return pd.concat(clips)

search(aoi, start_time=None, end_time=None)

查询并获取数据清单

Parameters:

Name Type Description Default
aoi GeoDataFrame

矢量数据范围

required
strt_time datatime64

查询的起始时间

required
end_time datatime64

查询的终止时间

None

Returns:

Name Type Description
datalist GeoDataFrame

符合条件的数据清单

Source code in hydro_opendata/catalog/minio.py
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
def search(self, aoi, start_time=None, end_time=None):
    """
    查询并获取数据清单

    Args:
        aoi (GeoDataFrame): 矢量数据范围
        strt_time (datatime64): 查询的起始时间
        end_time (datatime64): 查询的终止时间

    Returns:
        datalist (GeoDataFrame): 符合条件的数据清单
    """

    clips = []

    for key, value in self._datasets.items():
        for v in value:
            start = start_time
            end = end_time
            if start_time is None:
                start = v["start_time"]
            if end_time is None:
                end = v["end_time"]

            if start < v["start_time"]:
                start = v["start_time"]
            if end > v["end_time"]:
                end = v["end_time"]

            if start <= end:
                df = pd.DataFrame(
                    {
                        "id": [self._collection_id],
                        "dataset": [key],
                        "time_resolution": v["time_resolution"],
                        "start_time": [str(start)],
                        "end_time": [str(end)],
                        "geometry": [
                            f"POLYGON(({v['bbox'][0]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][1]},\
                                     {v['bbox'][2]} {v['bbox'][1]},{v['bbox'][2]} {v['bbox'][3]},{v['bbox'][0]} {v['bbox'][3]}))"
                        ],
                    }
                )
                df["geometry"] = gpd.GeoSeries.from_wkt(df["geometry"])
                gdf = gpd.GeoDataFrame(df, geometry="geometry", crs="EPSG:4326")

                clips.append(gdf.clip(aoi))

    return pd.concat(clips)

Last update: 2023-11-02