Python 3

Commandes de base

- en interactif :

python

>>>

>>> exit()

- dans un script :

#!/usr/bin/env python

YEAR=1979

print (YEAR)

YEARCAR=str(YEAR)

YEARI=int(YEARCAR)

Exemple : telechargement v_3D ERAI journalier

#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
import sys
server = ECMWFDataServer()
YEAR=sys.argv[1]
server.retrieve({
    "class": "ei",
    "dataset": "interim",
    "date": str(YEAR)+"-01-01/to/"+str(YEAR)+"-12-31",
    "expver": "1",
    "grid": "1.5/1.5",
    "levelist": "1/2/3/5/7/10/",
    "levtype": "pl",
    "param": "132.128",
    "step": "0",
    "stream": "oper",
    "time": "06:00:00",
    "type": "an",
    "format" : "netcdf",
    "target": "output.nc",
})

- Notes Formation Python debutant IFORM 09/2019

Published on  September 12th, 2019