I tried to use python script to retrieve ERA5 model level data, but i can only get one data at a time, since it seem there is the restriction on the amount of data per time.

The picture below is the screenshot of the fail reason on "Your Request" Page.

its OK when I want to retrieve the data like Geopotential and Logarithm(‘leveltype’:'ml') of surface pressure,  beacuse the 'levelist' is only '1', While data like Specific Humidity and Temperature, the levelist is 1/to/137/by/1, which measn I have to  submit retrieve requests 137 times to get t/q data at one 'time', and oneday has 24 'time'. This is so disturbing.

I want to know  is there some particular restrictions on  ERA5 model level data and how can i break through these blocks.

How can I download multi-levelist or multi-time data in a request but not one request one 'time' and one 'param' data. This is so time-consuming for a researcher.


Thank you for looking through my problem. 

5 Comments

  1. hi, Can  you share the script you are running, please?

    Kevin

    1. This is the script I use to retrieve ERA5 model level data, param:152(Logarithm of surface pressure).
      I'm also restricted to get only one time data per request.

      # 2022.4.3
      # xdw
      # Autodownload To retrieve ERA5 data on MARS tape via CDS API
      # file naming: folder'201807'\\dataname"'era5_' + + d + h + '_rain_water_sfc.grib"

      import calendar
      import datetime
      import os
      import cdsapi
      import time
      from multiprocessing import process
      from subprocess import call

      if __name__ == '__main__':
      c = cdsapi.Client()
      for y in range(2019, 2021):
      # time list
      print(y)
      time_list = ['00:00:00', '01:00:00', '02:00:00', '03:00:00', '04:00:00',
      '05:00:00', '06:00:00', '07:00:00', '08:00:00', '09:00:00',
      '10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00',
      '15:00:00', '16:00:00', '17:00:00', '18:00:00', '19:00:00',
      '20:00:00', '21:00:00', '22:00:00', '23:00:00']
      keyword_dic={
      'class': 'ea',
      'date': '20190101',
      'time': '00:00:00',
      'exper': '1',
      'levelist': '1',
      'levtype': 'ml',
      'param': '152',
      'stream': 'oper',
      'type': 'an',
      'area': '90/-180/-90/180',
      'format': 'netcdf',
      'grid': '0.25/0.25'
      }
      for m in range(1, 13):
      # print(m)
      daycount_thismonth = calendar.monthrange(y, m)[1]
      for d in range(1, daycount_thismonth+1):
      # print(d)
      # Specify particular date
      date_ = datetime.date(y, m, d)
      # give a time format Y meas 2019y means 19
      date = date_.strftime("%Y%m%d")
      for Time_clock in time_list:
      # Storage File Prefix
      folder_prefix = "D:\\01 AOD\\01 ERA5数据\\"
      yearmonth = str(y) + str(m).zfill(2)
      # name the folder as year-month
      folder_name = folder_prefix + yearmonth
      # create the folder if not exist
      print(folder_name)
      if not os.path.exists(folder_name):
      os.makedirs(folder_name)
      # name the data as below, param corresponds to specific para
      file_name = 'ERA5_' + 'lnsp' + '_' \
      + date + Time_clock[0:2] + '.nc'
      path_name = folder_name + '\\' + file_name
      print(path_name)
      with open(path_name, "wb") as op:
      # Execute the task
      # Update the dic
      keyword_dic['date'] = date
      keyword_dic['time'] = Time_clock
      RequestStart_time = time.perf_counter()
      c.retrieve('reanalysis-era5-complete', keyword_dic, path_name)
      RequestEnd_time = time.perf_counter()
      print(RequestEnd_time - RequestStart_time)
      op.close()



      This is the script I use to retrieve ERA5 model level data, param:133(Temperature).
      With 137 model levellist, it'll be time-consuming if i retrieve data one data(which means one 'levelist' and one 'time').
      But in some examples listed on other pages, I've seen examples like

      ('time':'00:00:00/to/23:00:00/by/1')and 
      ('levelist':'1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/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/128/129/130/131/132/133/134/135/136/137')

      Is that implies multi-time and multi-levelist is allowed and can function well actually.

      However, things became different when i code like the examples, The error message tell  "Exception: the request you have submitted is not valid. Expected 1, got 137.; Request failed; Some errors reported (last error -1)."

      Can you help me point any wrong with my request script? 

      With my regards and deepest gratitude.

      # 2022.4.3
      # xdw
      # Autodownload To retrieve ERA5 data on MARS tape via CDS API
      # file naming: folder'201807'\\dataname"'era5_' + + d + h + '_rain_water_sfc.grib"
      # param:130 Temperature

      import calendar
      import datetime
      import os
      import cdsapi
      import time
      from multiprocessing import process
      from subprocess import call

      if __name__ == '__main__':
      c = cdsapi.Client()
      for y in range(2019, 2021):
      # time list
      print(y)
      time_list = ['00:00:00', '01:00:00', '02:00:00', '03:00:00', '04:00:00',
      '05:00:00', '06:00:00', '07:00:00', '08:00:00', '09:00:00',
      '10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00',
      '15:00:00', '16:00:00', '17:00:00', '18:00:00', '19:00:00',
      '20:00:00', '21:00:00', '22:00:00', '23:00:00']
      keyword_dic={
      'class': 'ea',
      'date': '20190101',
      'time': '00:00:00',
      'exper': '1',
      'levelist': '1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/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/128/129/130/131/132/133/134/135/136/137',
      'levtype': 'ml',
      'param': '130',
      'stream': 'oper',
      'type': 'an',
      'area': '90/-180/-90/180',
      'format': 'netcdf',
      'grid': '0.25/0.25'
      }
      for m in range(1, 13):
      # print(m)
      daycount_thismonth = calendar.monthrange(y, m)[1]
      for d in range(1, daycount_thismonth+1):
      # print(d)
      # Specify particular date
      date_ = datetime.date(y, m, d)
      # give a time format Y meas 2019y means 19
      date = date_.strftime("%Y%m%d")
      for Time_clock in time_list:
      # Storage File Prefix
      folder_prefix = "D:\\01 AOD\\01 ERA5数据\\"
      yearmonth = str(y) + str(m).zfill(2)
      # name the folder as year-month
      folder_name = folder_prefix + yearmonth
      # create the folder if not exist
      print(folder_name)
      if not os.path.exists(folder_name):
      os.makedirs(folder_name)
      # name the data as below, param corresponds to specific para
      file_name = 'ERA5_' + 't' + '_' \
      + date + Time_clock[0:2] + '.nc'
      path_name = folder_name + '\\' + file_name
      print(path_name)
      with open(path_name, "wb") as op:
      # Execute the task
      # Update the dic
      keyword_dic['date'] = date
      keyword_dic['time'] = Time_clock
      RequestStart_time = time.perf_counter()
      c.retrieve('reanalysis-era5-complete', keyword_dic, path_name)
      RequestEnd_time = time.perf_counter()
      print(RequestEnd_time - RequestStart_time)
      op.close()



  2. Hi.

    If you are requesting parameter 152 (logarithm of surface pressure, https://apps.ecmwf.int/codes/grib/param-db/?id=152), this is only defined on 1 level, as it is the pressure at the earths surface. If you ask for it on 137 levels you get an error message because your script was expecting it to be on 137 levels, but it actually only exists on 1. The other parameters you specified (e.g Temperature) are defined on all 137 levels.

    In terms of efficiency, it's best to request all the data you need for a given month in 1 request if possible; see

    How to download ERA5

    Hope that helps,

    Kevin


    1. Hi,

      Thanks for your guide, I realized that i used to work on a wrong sequence.

      I've submitted My Request afresh.

      Thanks Kevin.

      Davy.