def from_analytic_to_visual(analytic_filename, download_dir='/tmp'):
    GDAL_TRANSLATE = 'gdal_translate -b 3 -b 2 -b 1 -b 6 -co ALPHA=YES -co PHOTOMETRIC=RGB %s %s'
    # % (input, output)

    # Unfortunately gdalwarp looks like it has a bug passing the alpha channel through when a
    # projection happens, so commented out for now. Not applying the projection doesn't seem
    # to hurt anything.
    #GDAL_WARP = 'gdalwarp -co photometric=RGB -co tfw=yes -t_srs EPSG:3857 %s %s'
    # % (input, output)

    CONVERT = 'convert -sigmoidal-contrast 20x5%% -depth 8 -alpha on %s %s'
    # % (input, output)

    base = os.path.basename(os.path.splitext(analytic_filename)[0])

    print "Extracting RGB bands..."
    translate_filename = os.path.join(
        download_dir, '%s-rgb.tif' % (base)
    )
    os.system(GDAL_TRANSLATE % (
        analytic_filename, translate_filename
    ))

    # print "Projecting image..."
    # proj_filename = os.path.join(
    #     download_dir, '%s-proj.tif' % (base)
    # )
    # os.system(GDAL_WARP % (
    #     translate_filename, proj_filename
    # ))

    print "Converting to visual color scheme..."
    bright_filename = os.path.join(
        download_dir, '%s-bright.tif' % base
    )
    os.system(CONVERT % (
        translate_filename, bright_filename
    ))

    print "Fixing alpha channel..."
    fix_alpha_channel(bright_filename)

    # Cleanup
    print "Cleaning up..."
    shutil.move(bright_filename, analytic_filename)
    os.remove(translate_filename)
    os.remove(os.path.join(download_dir, '%s-rgb.tif.aux.xml' % (base)))
    # No output from gdal_warp for now.
    #os.remove(proj_filename)
    #os.remove(os.path.join(download_dir, '%s-proj.tfw' % (base)))
RapidEye images are 16-bit non-color corrected images. We need to extract the RGB bands and
dataset/ETHPy150Open BradNeuberg/cloudless/src/annotate/train/scripts/download_planetlabs.py/from_analytic_to_visual