Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to return dict iso information #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions hapi/hapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def open_(*args,**argv):
'FIXED ABSOLUTE PATH BUG IN TABLE NAMES (ver. 1.1.0.9.4)',
'CORRECTED ABUNDANCE OF THE HD ISOTOPOLOGUE (ver. 1.1.0.9.5)',
'ADDED UNIFIED INTERFACES FOR ABSCOEF AND XSC CALCULATIONS (ver. 1.1.0.9.6)',
]
]

# version header
print('HAPI version: %s' % HAPI_VERSION)
Expand Down Expand Up @@ -3434,26 +3434,46 @@ def filter(TableName,Conditions):

}

def print_iso():
print('The dictionary \"ISO\" contains information on isotopologues in HITRAN\n')
print(' M I id iso_name abundance mass mol_name')
def print_iso(printout=True):
if printout:print('The dictionary \"ISO\" contains information on isotopologues in HITRAN\n')
if printout:print(' M I id iso_name abundance mass mol_name')
else: df = {'M':[], 'I':[], 'id':[],'iso_name':[], 'abundance':[], 'mass':[],'mol_name':[]}
for i in ISO:
ab = ISO[i][ISO_INDEX['abundance']]
ma = ISO[i][ISO_INDEX['mass']]
ab = ab if ab else -1
ma = ma if ma else -1
print('%4i %4i : %5i %25s %10f %10f %15s' % (i[0],i[1],ISO[i][ISO_INDEX['id']],ISO[i][ISO_INDEX['iso_name']],ab,ma,ISO[i][ISO_INDEX['mol_name']]))

def print_iso_id():
print('The dictionary \"ISO_ID\" contains information on \"global\" IDs of isotopologues in HITRAN\n')
print(' id M I iso_name abundance mass mol_name')
if printout: print('%4i %4i : %5i %25s %10f %10f %15s' % (i[0],i[1],ISO[i][ISO_INDEX['id']],ISO[i][ISO_INDEX['iso_name']],ab,ma,ISO[i][ISO_INDEX['mol_name']]))
else:
df['M'] += [i[0]]
df['I']+=[i[1]]
df['id']+=[ISO[i][ISO_INDEX['id']]]
df['iso_name']+=[ISO[i][ISO_INDEX['iso_name']]]
df['abundance']+=[ab]
df['mass']+=[ma]
df['mol_name'] +=[ISO[i][ISO_INDEX['mol_name']]]
if not printout: return df

def print_iso_id(printout=True):
if printout: print('The dictionary \"ISO_ID\" contains information on \"global\" IDs of isotopologues in HITRAN\n')
if printout: print(' id M I iso_name abundance mass mol_name')
else: df = {'id':[],'M':[], 'I':[], 'iso_name':[], 'abundance':[], 'mass':[],'mol_name':[]}
for i in ISO_ID:
ab = ISO_ID[i][ISO_ID_INDEX['abundance']]
ma = ISO_ID[i][ISO_ID_INDEX['mass']]
ab = ab if ab else -1
ma = ma if ma else -1
print('%5i : %4i %4i %25s %15.10f %10f %15s' % (i,ISO_ID[i][ISO_ID_INDEX['M']],ISO_ID[i][ISO_ID_INDEX['I']],ISO_ID[i][ISO_ID_INDEX['iso_name']],ab,ma,ISO_ID[i][ISO_ID_INDEX['mol_name']]))

if printout:print('%5i : %4i %4i %25s %15.10f %10f %15s' % (i,ISO_ID[i][ISO_ID_INDEX['M']],ISO_ID[i][ISO_ID_INDEX['I']],ISO_ID[i][ISO_ID_INDEX['iso_name']],ab,ma,ISO_ID[i][ISO_ID_INDEX['mol_name']]))
else:
df['id']+=[i]
df['M']+=[ISO_ID[i][ISO_ID_INDEX['M']]]
df['I']+=[ISO_ID[i][ISO_ID_INDEX['I']]]
df['iso_name']+=[ISO_ID[i][ISO_ID_INDEX['iso_name']]]
df['abundance']+=[ab]
df['mass']+=[ma]
df['mol_name'] += [ISO_ID[i][ISO_ID_INDEX['mol_name']]]
if not printout: return df

profiles = 'profiles'
def print_profiles():
print('Profiles available:')
Expand Down