Source code for diva.data.data_downloader_local.retrieve_data

# Copyright 2024 Mews
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#     http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.

from diva.data.data_downloader_local.data_retriever import ServiceDataRetriever


[docs] class GetData: def __init__(self, params): """ Initializes the retrieve_data class. Parameters: params (tuple): A tuple containing the parameters required for data retrieval, including: - OUTPUT_PATH (str): The path where the downloaded data will be saved. - LIST_DATA (list): A list of data variables to be retrieved. - LIST_YEARS (list): A list of years for which the data will be retrieved. - DATASET (str): The name of the dataset from which data will be retrieved. - BOX_LAT_LON (dict): A dictionary specifying the latitude and longitude bounds. """ self.__params = params
[docs] def download_data(self): """ Downloads the data using the specified parameters. This method initializes the data_retriever with the provided parameters and calls its get_data() method to perform the data retrieval. """ dr = ServiceDataRetriever(self.__params) dr.get_data()
if __name__ == "__main__": list_years_all = [1970, 1980, 1990, 2000, 2010, 2020, 2025] # 1950, for idx in range(len(list_years_all) - 1): print(list_years_all[idx], list_years_all[idx + 1]) # ----- retrieve data ----- OUTPUT_PATH = "data/data/input/" LIST_DATA = [ "sea_surface_temperature" ] # '2m_temperature', '10m_wind_gust_since_previous_post_processing', 'total_precipitation', 'surface_pressure' LIST_YEARS = [ year for year in range(list_years_all[idx], list_years_all[idx + 1]) ] DATASET = "reanalysis-era5-single-levels" BOX_LAT_LON = { "lat_min": 35.0, "lat_max": 66.70, "lon_min": -14.0, "lon_max": 45.7, } params = (OUTPUT_PATH, LIST_DATA, LIST_YEARS, DATASET, BOX_LAT_LON) dr = GetData(params) dr.download_data() # ----- combine data -----