def makeflat(lista):
    # print "LOGX:: Entering `makeflat` method/function in %(__file__)s" %
    # globals()
    flat = ''
    import datetime
    import glob
    import os
    import ntt
    from ntt.util import readhdr, readkey3, delete, name_duplicate, updateheader, correctcard
    from pyraf import iraf
    iraf.images(_doprint=0, Stdout=0)
    iraf.imutil(_doprint=0, Stdout=0)
    iraf.imgeom(_doprint=0, Stdout=0)
    # iraf.blkavg(_doprint=0, Stdout=0)
    iraf.noao(_doprint=0, Stdout=0)
    iraf.imred(_doprint=0, Stdout=0)
    iraf.generic(_doprint=0, Stdout=0)
    toforget = ['imgeom.blkavg', 'imutil.imarith',
                'immatch.imcombine', 'noao.imred']
    for t in toforget:
        iraf.unlearn(t)
    import datetime
    MJDtoday = 55927 + (datetime.date.today() - datetime.date(2012, 01, 01)).days
    _date = readkey3(readhdr(lista[0]), 'date-night')
    _filter = readkey3(readhdr(lista[0]), 'filter')
    output = name_duplicate(
        lista[3], 'flat_' + str(_date) + '_' + str(_filter) + '_' + str(MJDtoday), '')
    if os.path.isfile(output):
        answ = raw_input('file already prooduced, do again [y/[n]] ? ')
        if not answ:
            answ = 'n'
    else:
        answ = 'y'
    if answ in ['yes', 'y', 'YES', 'Y', 'Yes']:
        delete("temp_off.fits,temp_off_mask.fits,temp_on_mask.fits,temp_on.fits")
        iraf.image.immatch.imcombine(
            lista[0] + ',' + lista[7], output="temp_off.fits")
        iraf.image.immatch.imcombine(
            lista[1] + ',' + lista[6], output="temp_off_mask.fits")
        iraf.image.immatch.imcombine(
            lista[2] + ',' + lista[5], output="temp_on_mask.fits")
        iraf.image.immatch.imcombine(
            lista[3] + ',' + lista[4], output="temp_on.fits")
        #   create the bias correction for the flat-on according to the
        #   Lidman technique0
        delete("temp_onA.fits,temp_onC.fits,temp_onB.fits,temp_onAC.fits,temp_onACB.fits,temp_onACB_2D.fits")
        delete("temp_on_bias.fits")
        iraf.imgeom.blkavg(
            input="temp_on.fits[500:600,*]", output="temp_onA.fits", option="average", b1=101, b2=1)
        iraf.imgeom.blkavg(
            input="temp_on_mask.fits[500:600,*]", output="temp_onC.fits", option="average", b1=101, b2=1)
        iraf.imgeom.blkavg(
            input="temp_on_mask.fits[50:150,*]", output="temp_onB.fits", option="average", b1=101, b2=1)
        iraf.imutil.imarith("temp_onA.fits", "-",
                            "temp_onC.fits", "temp_onAC.fits")
        iraf.imutil.imarith("temp_onAC.fits", "+",
                            "temp_onB.fits", "temp_onACB.fits")