예제 #1
0
def climatologyRegions(request):
    try:
        data = [1,2,3,4,5]
        variableList = ["", "mdn","pon","spi", "spei","pdsi","pzi", "scpdsi"]

        region = request.GET['region']


      
        variable = int(request.GET['variable'])
        variable = variableList[variable]

        monthSpan = int(request.GET['span'])

        year = int(request.GET['year'])
        month = int(request.GET['month'])
   
        # Print PNG to page
        try:
            newPlot = regionClimatology(region=region, variable=variable, monthSpan=monthSpan, month=month, year=year)
            fig = newPlot.getData()            

            canvas=FigureCanvas(fig)
            response=django.http.HttpResponse(content_type='image/png')
            canvas.print_png(response)

            return response
        except:
            return HttpResponse("Plot feature under development for this location.")
    except:
        return HttpResponse("No data.")
예제 #2
0
def climatologyRegions_text(request):
    variableList = ["", "mdn","pon","spi","spei","pdsi","pzi", "scpdsi"]

    region = request.GET['region']
      
    variable = int(request.GET['variable'])
    variable = variableList[variable]
    #print 'variable:', variable
    monthSpan = int(request.GET['span'])
    year = int(request.GET['year'])
    month = int(request.GET['month'])
   
    text = regionClimatology(region=region, variable=variable, monthSpan=monthSpan, month=month, year=year).getText()
    #print 'text:', text[:]
    data = []
    for value in text:
        data.append(value)
    return render_to_response('print.html', {'data': data})#, {'year': data}, {'mean': data})
예제 #3
0
def climatologyRegions_text(request):
    variableList = ["", "mdn", "pon", "spi", "spei", "pdsi", "pzi", "scpdsi"]

    region = request.GET['region']

    variable = int(request.GET['variable'])
    variable = variableList[variable]
    #print 'variable:', variable
    monthSpan = int(request.GET['span'])
    year = int(request.GET['year'])
    month = int(request.GET['month'])

    text = regionClimatology(region=region,
                             variable=variable,
                             monthSpan=monthSpan,
                             month=month,
                             year=year).getText()
    #print 'text:', text[:]
    data = []
    for value in text:
        data.append(value)
    return render_to_response(
        'print.html', {'data': data})  #, {'year': data}, {'mean': data})
예제 #4
0
def climatologyRegions(request):
    try:
        data = [1, 2, 3, 4, 5]
        variableList = [
            "", "mdn", "pon", "spi", "spei", "pdsi", "pzi", "scpdsi"
        ]

        region = request.GET['region']

        variable = int(request.GET['variable'])
        variable = variableList[variable]

        monthSpan = int(request.GET['span'])

        year = int(request.GET['year'])
        month = int(request.GET['month'])

        # Print PNG to page
        try:
            newPlot = regionClimatology(region=region,
                                        variable=variable,
                                        monthSpan=monthSpan,
                                        month=month,
                                        year=year)
            fig = newPlot.getData()

            canvas = FigureCanvas(fig)
            response = django.http.HttpResponse(content_type='image/png')
            canvas.print_png(response)

            return response
        except:
            return HttpResponse(
                "Plot feature under development for this location.")
    except:
        return HttpResponse("No data.")