Use Case: A simple task done simply with Python and H5py *
-
Upload
naida-rhodes -
Category
Documents
-
view
26 -
download
1
description
Transcript of Use Case: A simple task done simply with Python and H5py *
![Page 1: Use Case: A simple task done simply with Python and H5py *](https://reader035.fdocuments.in/reader035/viewer/2022080902/5681322e550346895d98943a/html5/thumbnails/1.jpg)
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 *](https://reader035.fdocuments.in/reader035/viewer/2022080902/5681322e550346895d98943a/html5/thumbnails/2.jpg)
#! /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 *](https://reader035.fdocuments.in/reader035/viewer/2022080902/5681322e550346895d98943a/html5/thumbnails/3.jpg)
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.