download_u10v10.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. # This script downloads the zonal and meridional 10m height wind components
  4. # from the ERA-interim reanalysis on the original reduced gaussian grid which
  5. # was used to perform ERA-interim.
  6. #
  7. # If you use this script for the first time, you need to install you API key
  8. # as described here : https://software.ecmwf.int/wiki/display/WEBAPI/Accessing+ECMWF+data+servers+in+batch
  9. #
  10. # History : Virginie Guemas - Initial version - May 2014
  11. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. # Arguments
  13. #
  14. # date1 - YYYYMMDD : First date to be downloaded
  15. # date2 - YYYYMMDD : Last date to downloaded
  16. #
  17. # Example : ./download_u10v10.py 20140101 20140228
  18. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. import sys
  20. date1=sys.argv[1]
  21. date2=sys.argv[2]
  22. from ecmwfapi import ECMWFDataServer
  23. server = ECMWFDataServer()
  24. server.retrieve({
  25. 'dataset' : "interim",
  26. 'stream' : "oper",
  27. 'step' : "0",
  28. 'levtype' : "sfc",
  29. 'class' : "ei",
  30. 'date' : date1+"/to/"+date2,
  31. 'time' : "00:00:00/06:00:00/12:00:00/18:00:00",
  32. 'type' : "an",
  33. 'param' : "165.128/166.128",
  34. 'gaussian': "reduced",
  35. 'grid' : "128",
  36. 'target' : "output.grib"
  37. })