use case: a simple task done simply with python and h5py *

3
Use Case: A simple task done simply with Python and H5py * Daniel Kahn NPP Ozone PEATE Science Systems and Applications, Inc. 31 March 2009 Goal: Retrieve HDF5 file from Configuration Management (CM) and insert CM metadata into HDF5 file. * H5py was designed and written by Andrew C

Upload: naida-rhodes

Post on 01-Jan-2016

26 views

Category:

Documents


1 download

DESCRIPTION

Use Case: A simple task done simply with Python and H5py *. Daniel Kahn NPP Ozone PEATE Science Systems and Applications, Inc. 31 March 2009. Goal: Retrieve HDF5 file from Configuration Management (CM) and insert CM metadata into HDF5 file. * H5py was designed and written by Andrew Collette. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Use Case: A simple task done simply with Python and H5py *

Use Case:A simple task done simply with Python and H5py*

Daniel KahnNPP Ozone PEATE

Science Systems and Applications, Inc.31 March 2009

Goal: Retrieve HDF5 file from Configuration Management (CM) and insert CM metadata into HDF5 file.

*H5py was designed and written by Andrew Collette

Page 2: Use Case: A simple task done simply with Python and H5py *

#! /usr/bin/env python

import sysimport osimport h5py

Rev = sys.argv[1] # Specifiy CM path on command lineSVNFilepath = sys.argv[2] # Specify revision number on #comand line.

command = 'svn export -r ' + Rev + ' ' + SVNFilepath #Subversion # CommandInStream = os.popen(command,'r')ExportString = InStream.read()ExportReturnCode = InStream.close()Elements = SVNFilepath.split('/')

# HDF5 code

fid = h5py.File(Elements[-1]) # Elements[-1] is file name

fid.attrs['SVN Path and Revision'] = SVNFilepath + '@' + Rev

fid.close()

Python script to retrieve file from CM and store Rev number as attribute.

H5py code in red. Note the minimal effort coding HDF5 calls.

Page 3: Use Case: A simple task done simply with Python and H5py *

Conclusion:

Python and the H5py module provide a means of manipulating HDF5 files with minimal development effort.

Python, H5py and the numerical package Numpy provide means of doing time efficient numerical manipulations in an array based environment.

Python's design as a modern programming language makes it appropriate for complex tasks for which a more simplistic, e.g. shell scripting, approach wouldbe cumbersome.

Python a efficient environment in which to develop develop software where the problem to be solved is not completely understood.

Other comments:

Python and related modules are open source which is useful when administering a license is inconvenient or prohibitive.