Changeset 39103 for trunk/ippToPsps/jython/fits.py
- Timestamp:
- Nov 11, 2015, 11:08:06 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/fits.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/fits.py
r39085 r39103 6 6 import hashlib 7 7 from subprocess import call, PIPE, Popen 8 9 import tempfile 8 10 9 11 ''' … … 121 123 122 124 ''' 125 Find and read a header extension. 126 ''' 127 def findAndReadHeader(self, name, VERBOSE): 128 129 if False: 130 status = self.findAndReadHeaderRaw(name, VERBOSE) 131 return status 132 133 status = self.findAndReadHeaderOhana(name, VERBOSE) 134 return status 135 136 ''' 123 137 Finds and reads a header extension. 124 138 … … 132 146 through STILTS 133 147 ''' 134 def findAndReadHeader (self, name, VERBOSE):148 def findAndReadHeaderRaw(self, name, VERBOSE): 135 149 136 150 found = False … … 167 181 168 182 ''' 183 Find and read a header extension. 184 ''' 185 def findAndReadHeaderOhana(self, name, VERBOSE): 186 187 cmd = "fhead -n %s %s" % (name, self.originalPath) 188 p = Popen(cmd, shell=True, stdout=PIPE) 189 output = p.communicate()[0] 190 191 header = {} 192 193 # split the output header bytes into key/value pairs for each 80-byte line 194 for i in range(0, len(output), 80): 195 # print "line %d : %s" % (i, output[i:i+80]) 196 record = output[i:i+80] 197 198 match = re.match('^(HIERARCH )*([a-zA-Z0-9-_\.]+)\s*=\s+\'*([a-zA-Z0-9-+_\.:\s@#\(\)\,]+)\'*\\/*', record) 199 200 if match: 201 param = match.group(2) 202 value = match.group(3).strip() 203 if value == "NaN": value = "NULL" 204 header[param] = value 205 206 return header 207 208 ''' 169 209 Reads FITS header and stores all fields in a dictionary object 170 210 '''
Note:
See TracChangeset
for help on using the changeset viewer.
