def extract_range (geisa, xLow, xHigh): """ Read all lines up to a upper wavenumber limit from Geisa formatted database. """ # determine position (first and last indices) of wavenmber, moleculeID, isotopeID fields = set_geisa_fields (geisa.name) iw, lw, lM = fields['iw'], fields['lw'], fields['lM'] # proceed to first requested line record = bisect_first_line (geisa, xLow, xHigh, iw, lw) # initialize list if lines lines = [] # collect lines while record: wvn = float(record[:lw]) if wvn<=xHigh: lines.append(record) else: break # read next record record = geisa.readline() if len(lines)>0: print '# last line accepted \n', lines[-1][:lM] if record: print '# first line not accepted \n', record[:lM] # empty string returned at end-of-file return lines
def extract_MolStr (geisa, xLow, xHigh, getMol, strMin): """ Read strong lines of a given molecule up to a upper wavenumber limit from Geisa formatted database. """ # determine position (first and last indices) of wavenmber, moleculeID, isotopeID fields = set_geisa_fields (geisa.name) iw, lw, iM, lM, iS, lS = fields['iw'], fields['lw'], fields['iM'], fields['lM'], fields['iS'], fields['lS'] # proceed to first requested line record = bisect_first_line (geisa, xLow, xHigh, iw, lw) # initialize list if lines lines = [] # collect lines while record: wvn = float(record[:lw]) if wvn>xHigh: break mol = int(record[iM:lM]) str = float(replace(record[iS:lS],'D','e')) if mol==getMol and str>=strMin: lines.append(record) # read next record record = geisa.readline() if len(lines)>0: print '# last line accepted \n', lines[-1][:lM] if record: print '# first line not accepted \n', record[:lM] # empty string returned at end-of-file return lines