Unidata TDS Workshop Python Overview 22 24 October
Unidata TDS Workshop Python Overview 22 -24 October 2012
What is Python • An interpreted, dynamic, multi-purpose highlevel programming language. • Can be used. . . – as a replacement for proprietary (and $$$) analysis tools. – to build GUI and web apps. – as a higher-level “glue” language to build interfaces to Fortran/C code. Modified from a slide created by Jeff Whitaker, NOAA Earth System Research Lab, <jeffrey. s. whitaker@noaa. gov>
Python • Open source libs • Basic plotting: matplolib (gallery) • Maps: basemap (gallery) • Numerics: Num. Py • Advanced/Domain Specific Numerics: Scipy • I/O: netcdf 4 -python, pupynere, pygrib, pydap • Other goodies! • You know all that C and FORTRAN you have… • Python can leverage it! f 2 py, ctypes • Must be able to compile the code…I’m looking at you, crufty FORTRAN 77
So…python… It slices, it dices, it makes julienne fries!
Python • Simple syntax • hello_world. py print(“hello, world!”) • Num. Py x = np. arange(10) y = x ** 2 • Basic plotting: matplolib import matplotlib. pyplot as plt. plot(x, y)
Python • Interaction with TDS • Use pydap to access OPe. NDAP • urllib 2 and net. CDF Subset Service (NCSS) • Global Ensemble Forecasting System (GEFS) temperature forecast using python and NCSS • • • Ask user for zipcode Read CSV ‘database’ of zip, lat, lon, city, and state info Construct NCSS request URL Save response to disk Load CSV returned by NCSS Plot!
- Slides: 6