예제 #1
0
def galex_image(req, calid=None, size='full'):
    from astrometry.util import util as anutil
    from astrometry.blind import plotstuff as ps
    from astrometry.net.galex_jpegs import plot_into_wcs
    cal = get_object_or_404(Calibration, pk=calid)
    key = 'galex_size%s_cal%i' % (size, cal.id)
    df = CachedFile.get(key)

    if df is None:
        wcsfn = cal.get_wcs_file()
        plotfn = get_temp_file()
        if size == 'display':
            image = cal.job.user_image
            scale = float(image.image.get_display_image().width)/image.image.width
        else:
            scale = 1.0

        # logmsg('WCS filename:', wcsfn)
        # logmsg('Plot filename:', plotfn)
        # logmsg('Basedir:', settings.GALEX_JPEG_DIR)
        # logmsg('Scale:', scale)

        plot_into_wcs(wcsfn, plotfn, basedir=settings.GALEX_JPEG_DIR, scale=scale)
        # cache
        logmsg('Caching key "%s"' % key)
        df = CachedFile.add(key, plotfn)
    else:
        logmsg('Cache hit for key "%s"' % key)
    f = open(df.get_path())
    res = HttpResponse(f)
    res['Content-Type'] = 'image/png'
    return res
예제 #2
0
def galex_image(req, calid=None, size='full'):
    from astrometry.util import util as anutil
    from astrometry.blind import plotstuff as ps
    from astrometry.net.galex_jpegs import plot_into_wcs
    cal = get_object_or_404(Calibration, pk=calid)
    key = 'galex_size%s_cal%i' % (size, cal.id)
    df = CachedFile.get(key)

    if df is None:
        wcsfn = cal.get_wcs_file()
        plotfn = get_temp_file()
        if size == 'display':
            image = cal.job.user_image
            scale = float(image.image.get_display_image().width)/image.image.width
        else:
            scale = 1.0

        # logmsg('WCS filename:', wcsfn)
        # logmsg('Plot filename:', plotfn)
        # logmsg('Basedir:', settings.GALEX_JPEG_DIR)
        # logmsg('Scale:', scale)

        plot_into_wcs(wcsfn, plotfn, basedir=settings.GALEX_JPEG_DIR, scale=scale)
        # cache
        logmsg('Caching key "%s"' % key)
        df = CachedFile.add(key, plotfn)
    else:
        logmsg('Cache hit for key "%s"' % key)
    f = open(df.get_path())
    res = HttpResponse(f)
    res['Content-Type'] = 'image/png'
    return res