Post-processing with Python

The pyHDF library (distributed with the Enthought Python Distribution) has a simple, clean interface to read the LFM model output.

LFM HDF4 output

from pyhdf.SD import SD, SDC

def getData(filename):
    hdfFile = SD(filename, SDC.READ)
    datasets = ['X_grid','Y_grid','Z_grid',
                'vx_','vy_','vz_',
                'bi_','bj_','bk_',
                'bx_','by_','bz_',
                'ei_','ej_','ek_',
                'rho_', 'c_']

    dataDict = {}
    for variable in datasets:
        dataDict[variable] = { 'data': hdfFile.select(variable).get() }

    return dataDict

if __name__ == '__main__':
    dataDict = getData('LTR_mhd_1995-03-21T10-00-00Z.dmp')
    # You can now access data in the dictionary via:
    x = dataDict['X_grid']['data']
    y = dataDict['Y_grid']['data']
    z = dataDict['Z_grid']['data']

MIX HDF4 Output

from pyhdf.SD import SD, SDC

def getData(filename):
    hdfFile = SD(filename, SDC.READ)
    datasets = ['Grid X', 'Grid Y',
                'Potential North [V]','Potential South [V]',
                'FAC North [A/m^2]', 'FAC South [A/m^2]',
                'Pedersen conductance North [S]', 'Pedersen conductance South [S]',
                'Hall conductance North [S]', 'Hall conductance South [S]',
                'Average energy North [keV]', 'Average energy South [keV]',
                'Number flux North [1/cm^2 s]', 'Number flux South [1/cm^2 s]']

    dataDict = {}
    for variable in datasets:
        dataDict[variable] = { 'data': hdfFile.select(variable).get() }

    return dataDict

if __name__ == '__main__':
    dataDict = getData('LTR_mix_1995-03-21T10-00-00Z.hdf')
    # You can now access data in the dictionary via:
    x = dataDict['Grid X']['data']
    y = dataDict['Grid Y']['data']
    phiNorth = dataDict['Potential North [V]']['data']
  • No labels