In [3]:
#hideme
from IPython.core.display import Image 
Image(filename='img/UV-CDAT_logo.png')


Out[3]:

Ultra-scale Visualization Climate Data Analysis Tools (UV-CDAT)

  • Designed for climate science data, CDAT was first released in 1997
  • UV-CDAT was first released in late 2010
  • Based on the object‐oriented Python computer language
  • Added Packages that are useful to the climate community and other geophysical sciences
    • Climate Data Management System (CDMS)
    • NumPy / Masked Array / Metadata
    • Visualization (VCS, IaGraphics, Xmgrace, Matplotlib, VTK, Visus, etc.)
    • Graphical User Interface (VCDAT)
    • XML representation (CDML/NcML) for data sets
  • One environment from start to finish
  • Integrated with other packages (i.e., LAS, OPeNDAP, ESG, etc.)
  • Community Software (BSD open source license)
  • Links
      CDAT Website : http://www2-pcmdi.llnl.gov/cdat
      UV-CDAT Website : http://uvcdat.llnl.gov/
      Binary* Download : http://sourceforge.net/projects/cdat/files/Releases/UV-CDAT/
      Daily Update Source : https://github.com/UV-CDAT/uvcdat
    * Ubuntu, CentOS, RedHat & MacOS  
  • Funded by NASA & Department of Energy, U.S.
Climate Data Management System (CDMS)

import cdms2
  • Best way to ingest and write NetCDF‐CF, HDF, Grib[1 & 2], PP, DRS, Ctl, etc., data!
  • Opening a file for reading
    import cdms2
    f = cdms2.open(file_name)
    – It will open an existing file protected against writing
  • Opening a new file for writing
    f = cdms2.open(file_name, 'w')
    – It will create a new file even if it already exists
  • Opening an existing file for writing
    f = cdms2.open(file_name, 'r+') # or 'a'
    – It will open an existing file ready for writing or reading

GUI Intro / Demo

Exercise 2 : Opening a NetCDF file


In [ ]:
import cdms2
DATAPATH = './data/Obs/mo/sst/HadISST/'
# open the nc file throgh cdms2 module
f = cdms2.open(DATAPATH + 'sst_HadISST_Climatology_1961-1990.nc')
# You can query the file
print f.listvariables()

In [ ]:
# You can “access” the data through file variable
x = f['sst']
# You can get some information about the variables by
x.info()

In [ ]:
# or read all of it into memory
y = f('sst') # Causion : It will load the whole data into RAM memory 
y.info()

In [ ]:
# You can also find out what class the object x or y belong to
print x.__class__
# Close the file
f.close() # do remeber we opened the nc file throgh 'f' file object
  • All the above snippets into single script # demo_1.py

In [ ]:
%load scripts/demo_1.py
Multiple way to retrieve data : Dimension
  • All of it, omitted dimensions are retrieved entirely
    data = f('var')
  • Specifying dimension type and values
    data = f('var', time=(time1,time2))
    • Known dimension types : time, level, latitude, longitude (t,z,y,x)
  • Dimension names and values
    data = f('var', dimname1=(val1,val2))
  • Sometimes indices are more useful than actual values
    data = f('var', time=slice(index1, index2, step))
cdtime module
  • Import the cdtime module

In [ ]:
a = raw_input("emne")

In [ ]:
import cdtime
  • Relative time

In [ ]:
r = cdtime.reltime(19, "days since 2011-5-1")
r

In [ ]:
dir(r)
  • Component time

In [ ]:
c = cdtime.comptime(2011, 5, 20)
c

In [ ]:
dir(c)
  • You can interchange between component and relative time

In [ ]:
c1 = c.torel("days since 2011-1-1")
print "Comptime - ", c
print "Relative - ", c1

In [ ]:
r1 = r.tocomp()
print "Relative - ", r
print "Component - ", r1
Arrays, Masked Arrays and Masked Variables

In [4]:
#hideme
Image(filename='img/ma.png')


Out[4]:
Arrays, Masked Arrays and Masked Variables

In [5]:
#hideme
Image(filename='img/ma2.png')


Out[5]:
Summary
  • Take advantage of NumPy's array syntax to make operations with arrays both faster and more flexible (i.e., act on arrays of arbitrary rank).
  • Use any one of a number of Python packages (e.g., CDAT, PyNIO, pysclint, PyTables, ScientificPython) to handle netCDF, HDF, etc. files.

Acknowledgments

  • Dean Williams, Charles Doutriaux (PCMDI, LLNL).
  • Dr. Johnny Lin (Physics Department, North Park University, Chicago, Illinois).
  • Dr.Krishna AchtuaRao (Centre for Atmospheic Sciences, Indian Institute of Technology Delhi, India).

License

  • IPython Notebook Created by
      Arulalan.T 
      Date : 17.02.2014
      Project Associate,
      Centre for Atmospheic Sciences,
      Indian Institute of Technology Delhi, India.
      Blog : http://tuxcoder.wordpress.com 
      Repo : https://github.com/arulalant/UV-CDAT-IPython-Notebooks
      
  • This work (IPython Notebook & Html Slide) is licensed under a Creative Commons Attribution‐NonCommercial‐ShareAlike 3.0
  • Includes all python scripts
  • Freeware license (only for research purpose, not for commercial) for 'data' directory which contains '.nc' files (any one can download it from TIGGE http://tigge-portal.ecmwf.int/ website)