Uploaded image for project: 'Software Support'
  1. Software Support
  2. SUP-488

The ecmwf web api python client is not working on windows

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • WEBAPI
    • OS WINDOWS 7

      Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32

      ecmwf-api-client-python

    • Member State Other

      The python clietn is not working on Windows because the HOME environment variable is not defined

      C:\Users\antonio>python
      Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> from ecmwfapi import ECMWFDataServer
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "D:\Users\Meteo\ECMWF\api-client\ecmwf-api-client-python\ecmwfapi_init_.py", line 12, in <module>
      from ecmwfapi import api
      File "D:\Users\Meteo\ECMWF\api-client\ecmwf-api-client-python\ecmwfapi\api.py", line 39, in <module>
      rc = os.path.normpath(os.path.join(os.environ["HOME"],".ecmwfapirc"))
      File "C:\Python27\lib\os.py", line 423, in _getitem_
      return self.data[key.upper()]
      KeyError: 'HOME'

      Modifying this line in the api.py:
      rc = os.path.normpath(os.path.join(os.environ["HOME"],".ecmwfapirc"))

      in this way:
      rc = os.path.normpath(os.path.join(os.path.expanduser("~"),".ecmwfapirc"))

      solves the issue and it makes the python api more OS friendly.

      After this change the python client web api is working
      {{
      C:\Users\antonio>python
      Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> from ecmwfapi import ECMWFDataServer
      >>>
      ... server = ECMWFDataServer()
      >>>
      >>> server.retrieve(

      { ... "dataset" : "interim", ... "date" : "2013-01-31", ... "levelist" : "500", ... "stream" : "oper", ... "levtype" : "pl", ... "param" : "129.128", ... "step" : "0", ... "time" : "00", ... "type" : "an", ... "area" : "90/-45/0/45", ... "grid" : "0.75/0.75", ... "target" : "output.grib", ... }

      )
      2013-04-26 19:33:14 ECMWF API python library 1.2
      2013-04-26 19:33:14 ECMWF API at https://api.ecmwf.int/v1
      2013-04-26 19:33:15 Welcome Antonio Cofino
      2013-04-26 19:33:16 In case of problems, please check https://software.ecmwf.int/wiki/display/WEBAPI/Troubleshooting or contact mars@ecmwf.int
      2013-04-26 19:33:17 Request is active
      DEBUG:jobtools:Request object: [

      {'stream': ['oper'], 'levelist': ['500'], 'area': ['90', '-45', '0', '45'], 'levtype': ['pl'], 'expver': ['0001'], 'step': ['0'] , 'grid': ['0.75/0.75'], 'param': ['129.128'], 'time': ['00'], 'date': [Interval('2013-01-31:2013-01-31')], 'type': ['an'], 'class': ['ei']}

      ]
      Running the following MARS request:
      mars retrieve,stream=oper,levelist=500,area=90/-45/0/45,levtype=pl,expver=0001,step=0,grid=0.75/0.75,param=129.128,time=00,date=2013-01-31,type=an,class=ei,expe
      ct=any

      MARS - INFO - **
      MARS - INFO - **

      PPDIR is /data/soa/scratch/ppdir
      mars - INFO - 20130426.173317 - Welcome to MARS with grib_api and ODB
      mars - INFO - 20130426.173317 - EMOSLIB version: 392
      mars - INFO - 20130426.173317 - Using grib_api version 1.10.0
      mars - INFO - 20130426.173317 - grib_api created on 20130213
      mars - INFO - 20130426.173317 - Using odb_api version: 0.9.24 (file format version: 0.5)
      mars - INFO - 20130426.173317 - odb_api created on 20121109
      retrieve,stream=oper,levelist=500,area=90/-45/0/45,levtype=pl,expver=0001,step=0,grid=0.75/0.75,param=129.128,time=00,date=2013-01-31,type=an,class=ei,expect=an
      y

      mars - INFO - 20130426.173317 - Processing request 1

      RETRIEVE,
      CLASS = EI,
      TYPE = AN,
      STREAM = OPER,
      EXPVER = 0001,
      REPRES = SH,
      LEVTYPE = PL,
      LEVELIST = 500,
      PARAM = 129.128,
      DATE = 20130131,
      TIME = 0000,
      STEP = 0,
      DOMAIN = G,
      RESOL = AUTO,
      AREA = 90/-45/0/45,
      GRID = 0.75/0.75,
      EXPECT = ANY

      mars - INFO - 20130426.173317 - Requesting any number of fields (request describes 1)
      517 FDB; INFO; DB$_ Fields DataBase 4.3
      mars - INFO - 20130426.173317 - Calling mars on 'marser', callback on 49130
      mars - INFO - 20130426.173317 - Server task is 848 [marser]
      mars - INFO - 20130426.173317 - Request cost: 1 field, 129.514 Kbytes online, nodes: mvr01 [marser]
      mars - INFO - 20130426.173317 - Transfering 132622 bytes
      mars - WARN - 20130426.173317 - INTFB: Resolution automatically set to 213
      mars - INFO - 20130426.173317 - 1 field retrieved from 'marser'
      mars - INFO - 20130426.173317 - 1 field has been interpolated on 'web239'
      mars - INFO - 20130426.173317 - No errors reported
      2013-04-26 19:33:23 Request is complete
      2013-04-26 19:33:23 Transfering 28.7109 Kbytes into output.grib
      2013-04-26 19:33:23 From http://download.ecmwf.int/data/239/batch-idle-web239-20130426173316-l56Hx7.grib
      2013-04-26 19:33:24 Transfer rate 58.5937 Kbytes/s
      }}

            usv Daniel Varela Santoalla
            sp4 Antonio S. Cofino Gonzalez
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: