def lbldis_hs3(nfov=99999,
               file_kw='kwarg_lbldis.pk',
               file_flight='hs3_flight.pk',
               **kwargs):
    ''' run model on hs3 profiles '''
    from libtools import combination
    import pickle

    #_read lbldis run options from file
    file_kwarg = os.path.join(DIR_PROD, 'LBL-RTM', 'hs3', file_kw)
    kw = pickle.load(open(file_kwarg, 'rb'))

    #_read profiles from file
    file_flight = os.path.join(DIR_PROD, 'LBL-RTM', 'hs3', file_flight)
    flt = pickle.load(open(file_flight, 'rb'))

    #_had to do all this to get the size of the collocated/avg
    #_setup submission command
    env = ','.join(['='.join((var, os.environ[var])) \
     for var in ['PYTHONPATH', 'PRODUCTS', 'PATH', 'LOG']])
    qsub = ' '.join(('qsub -v', env, '-o', DIR_LOG, '-e', DIR_LOG,
                     '-cwd -S /opt/ShellB3/bin/python'))
    srpt = os.path.expanduser('~/lib/run_lbldis.py')

    #_loop over collocated files, run lblrtm
    runs = combination([xrange(flt.shis.size), xrange(len(kw))])
    for fov_idx, kw_idx in runs:
        #_write run options
        cmd = ' '.join((qsub, srpt, 'hs3', str(fov_idx), str(kw_idx)))
        os.system(cmd)
def lbldis_hs3_lim(kidx=[0],
                   fidx=[],
                   file_kw='kwarg_lbldis.pk',
                   file_flight='hs3_flight.nc',
                   experiment='hs3',
                   **kwargs):
    ''' run model on hs3 profiles '''
    from libtools import combination
    from hs3_utils import Flight_segment as read_flight_file

    #_had to do all this to get the size of the collocated/avg
    #_setup submission command
    env = ','.join(['='.join((var, os.environ[var])) \
     for var in ['PYTHONPATH', 'PRODUCTS', 'PATH', 'LOG']])
    qsub = ' '.join(('qsub -v', env, '-o', DIR_LOG, '-e', DIR_LOG,
                     '-cwd -S /opt/ShellB3/bin/python'))
    srpt = os.path.expanduser('~/lib/run_lbldis.py')

    #_if none passed, do them all
    if len(fidx) == 0:
        flight = read_flight_file(file_seg=file_flight)
        fidx = range(flight.size)

    runs = combination([fidx, kidx])
    print fidx, kidx
    for f, k in runs:
        #_write run options
        cmd = ' '.join(
            (qsub, srpt, experiment, str(f), str(k), file_flight, file_kw))
        os.system(cmd)
        print cmd