#!/usr/bin/python2 fileName = 'pds.img' # <<- put your file's name here dirName = 'c:\\pds-files' # & the directory where it is located print '\nSimple Bippy PDS module test...' import os, sys thisDir = os.path.split(sys.argv[0])[0] if not thisDir in sys.path: sys.path.append(thisDir) import common, pds pname = common.fixPath(dirName,fileName) if os.path.exists(pname): headObj,msg = pds.parsePDS(pn=pname,vals=['TARGET_NAME'],headonly=1) if msg: print ' headObj msg:',msg if headObj: print ' file',pname,'target name =',headObj.values['TARGET_NAME'] rasObj,msg = pds.parsePDS(pn=pname) if msg: print ' rasObj msg:',msg if rasObj: pn = pname[:-3]+'raw' f = open(pn,'wb') #write binary! rasObj.array().tofile(f) #write data to headerless RAW file in same dir f.flush() f.close() print ' saved',pn else: print ' ',pname,'not found' print ' Done'