SeasonBench-EA / data_download_script /ERA5_monthly_pressure.py
SauryChen's picture
Upload 4 files
0ae0235 verified
import cdsapi
import argparse
def main(args):
client = cdsapi.Client()
variables = args.variables.split(',')
for var in variables:
request = {
"product_type": ["monthly_averaged_reanalysis"],
"variable": [var],
"pressure_level": [
"200", "500", "700",
"850", "1000"
],
"year": [
"1940", "1941", "1942",
"1943", "1944", "1945",
"1946", "1947", "1948",
"1949", "1950", "1951",
"1952", "1953", "1954",
"1955", "1956", "1957",
"1958", "1959", "1960",
"1961", "1962", "1963",
"1964", "1965", "1966",
"1967", "1968", "1969",
"1970", "1971", "1972",
"1973", "1974", "1975",
"1976", "1977", "1978",
"1979", "1980", "1981",
"1982", "1983", "1984",
"1985", "1986", "1987",
"1988", "1989", "1990",
"1991", "1992", "1993",
"1994", "1995", "1996",
"1997", "1998", "1999",
"2000", "2001", "2002",
"2003", "2004", "2005",
"2006", "2007", "2008",
"2009", "2010", "2011",
"2012", "2013", "2014",
"2015", "2016", "2017",
"2018", "2019", "2020",
"2021", "2022", "2023",
"2024", "2025"
],
"month": [
"01", "02", "03",
"04", "05", "06",
"07", "08", "09",
"10", "11", "12"
],
"time": ["00:00"],
"data_format": "netcdf",
"download_format": "unarchived"
}
filename = f"{var}.nc"
print(f"Downloading data for variable {var}...")
client.retrieve("reanalysis-era5-pressure-levels-monthly-means", request).download(filename)
print(f"Downloaded {filename} successfully.")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Download ERA5 monthly pressure data for specified variables.")
parser.add_argument("--variables", type=str, required=True, help="Comma-separated list of variables to download (e.g., geopotential,specific_humidity,temperature,u_component_of_wind,v_component_of_wind)")
args = parser.parse_args()
main(args)