def etc_do(request): if request.method == 'GET': # import matplotlib.pyplot as plt # import mpld3 # from mpld3 import plugins, utils # # plt.plot([3,1,4,1,5], 'ks-', mec='w', mew=5, ms=20) # mpld3.save_html() return HttpResponse("<html><body>It works!</body></html>") elif request.method == 'POST': outputofcalc = compute5(request) tocheck = str(outputofcalc['outtext']) if not tocheck: outtextstring = "" #No warning. else: outtextstring = tocheck # GET relevant data vph = request.POST['vph'] queryvph = VPHSetup.objects.filter(pk=vph).values() vph_val = queryvph[0]['name'] spec = request.POST['spectype'] queryspec = SpectralTemplate.objects.filter(pk=spec).values() entry_spec_name = queryspec[0]['name'] if not tocheck: x = outputofcalc['lamb'] y = outputofcalc['fc'] label1 = entry_spec_name label2 = outputofcalc['mag_val'] label3 = outputofcalc['bandc_val'] x2 = x y2 = outputofcalc['pframesn_psp_asp'] x2b = x2 y2b = outputofcalc['allframesn_psp_asp'] x2c = x2 y2c = outputofcalc['pframesn_psp_asp_all'] x2d = x2 y2d = outputofcalc['allframesn_psp_asp_all'] label2a = entry_spec_name label2b = vph_val label2c = outputofcalc['bandc_val'] else: x = numpy.arange(1, 100, 1) y = numpy.arange(1, 100, 1) x2 = numpy.arange(1, 100, 1) y2 = numpy.arange(1, 100, 1) x2b = numpy.arange(1, 100, 1) y2b = numpy.arange(1, 100, 1) x2c = numpy.arange(1, 100, 1) y2c = numpy.arange(1, 100, 1) x2d = numpy.arange(1, 100, 1) y2d = numpy.arange(1, 100, 1) label1 = "none" label2 = 20.0 # Float label3 = "none" label2a = "none" label2b = "none" label2c = "none" # # CREATE TEMPORARY FILE # temp = tempfile.NamedTemporaryFile(suffix=".png", prefix="temp", dir="etc/static/etc/tmp/", delete=False) # # graphic = plot_and_save(temp.name, x, y, label1, label2, label3) # temp2 = tempfile.NamedTemporaryFile(suffix=".png", prefix="temp", dir="etc/static/etc/tmp/", delete=False) # graphic2 = plot_and_save2(temp2.name, x2, y2, x2b, y2b, x2c, y2c, x2d, y2d, label2a, label2b, label2c) # # # RENAME FILE PATH # dirname, basename = os.path.split(graphic) # newpath = '/static/etc/tmp/' # graphic = os.path.join(newpath, basename) # # dirname2, basename2 = os.path.split(graphic2) # newpath2 = '/static/etc/tmp/' # graphic2 = os.path.join(newpath2, basename2) inputstring = '<br /><p>' + str(outputofcalc['texti']) + '</p>' coutputstring = '<br /><p>' + str(outputofcalc['textoc']) + '</p>' loutputstring = '<br /><p>' + str(outputofcalc['textol']) + '</p>' figura = plot_and_save_new('', x, y, label1, label2, label3) html = mpld3.fig_to_html(figura) figura2 = plot_and_save2_new('', x2, y2, x2b, y2b, x2c, y2c, x2d, y2d, label2a, label2b, label2c) html += mpld3.fig_to_html(figura2) html = html.replace("None", "") # No se xq introduce string None if not tocheck: om_val_string = str(outputofcalc['om_val']) bandc_val_string = str(outputofcalc['bandc_val']) sourcet_val_string = str(outputofcalc['sourcet_val']) mag_val_string = str(outputofcalc['mag_val']) netflux_string = str(outputofcalc['netflux']) size_val_string = str(outputofcalc['size_val']) seeingx_string = str(outputofcalc['seeingx']) fluxt_val_string = str(outputofcalc['fluxt_val']) wline_val_string = str(outputofcalc['wline_val']) fline_val_string = str(outputofcalc['fline_val']) fwhmline_val_string = str(outputofcalc['fwhmline_val']) vph_val_string = str(outputofcalc['vph_val']) skycond_val_string = str(outputofcalc['skycond_val']) moon_val_string = str(outputofcalc['moon_val']) airmass_val_string = str(outputofcalc['airmass_val']) seeing_zenith_string = str(outputofcalc['seeing_zenith']) fsky_string = str(outputofcalc['fsky']) numframe_val_string = str(outputofcalc['numframe_val']) exptimepframe_val_string = str(outputofcalc['exptimepframe_val']) exptime_val_string = str(outputofcalc['exptime_val']) npdark_val_string = str(outputofcalc['npdark_val']) nsbundles_val_string = str(outputofcalc['nsbundles_val']) nfwhmline_val_string = str(outputofcalc['nfwhmline_val']) cnfwhmline_val_string = str(outputofcalc['cnfwhmline_val']) resolvedline_val_string = str(outputofcalc['resolvedline_val']) bandsky_string = str(outputofcalc['bandsky']) sourcespectrum_string = str(outputofcalc['sourcespectrum']) lamb_string = str(outputofcalc['lamb']) spect_val_string = str(outputofcalc['spect_val']) fc_string = str(outputofcalc['fc']) pframesn_psp_asp_string = str(outputofcalc['pframesn_psp_asp']) allframesn_psp_asp_string = str(outputofcalc['pframesn_psp_asp']) pframesn_psp_asp_all_string = str(outputofcalc['pframesn_psp_asp_all']) allframesn_psp_asp_all_string = str(outputofcalc['allframesn_psp_asp_all']) nfibres_string = str(outputofcalc['nfibres']) nfib_string = str(outputofcalc['nfib']) nfib1def_string = str(outputofcalc['nfib1def']) sncont_p2sp_all_string = "{0:.2f}".format(float(outputofcalc['sncont_p2sp_all'])/2) tsncont_p2sp_all_string = "{0:.2f}".format(float(outputofcalc['tsncont_p2sp_all'])/2) sncont_pspfwhm_all_string = "{0:.2f}".format(float(outputofcalc['sncont_p2sp_all'])) tsncont_pspfwhm_all_string = "{0:.2f}".format(float(outputofcalc['tsncont_p2sp_all'])) sncont_1aa_all_string = "{0:.2f}".format(float(outputofcalc['sncont_1aa_all'])) tsncont_1aa_all_string = "{0:.2f}".format(float(outputofcalc['tsncont_1aa_all'])) sncont_band_all_string = str(outputofcalc['sncont_band_all']) tsncont_band_all_string = str(outputofcalc['tsncont_band_all']) sncont_p2sp_fibre_string = "{0:.2f}".format(float(outputofcalc['sncont_p2sp_fibre'])) tsncont_p2sp_fibre_string = "{0:.2f}".format(float(outputofcalc['tsncont_p2sp_fibre'])) sncont_1aa_fibre_string = "{0:.2f}".format(float(outputofcalc['sncont_1aa_fibre'])) tsncont_1aa_fibre_string = "{0:.2f}".format(float(outputofcalc['tsncont_1aa_fibre'])) sncont_band_fibre_string = str(outputofcalc['sncont_band_fibre']) tsncont_band_fibre_string = str(outputofcalc['tsncont_band_fibre']) sncont_p2sp_seeing_string = "{0:.2f}".format(float(outputofcalc['sncont_p2sp_seeing'])) tsncont_p2sp_seeing_string = "{0:.2f}".format(float(outputofcalc['tsncont_p2sp_seeing'])) sncont_1aa_seeing_string = "{0:.2f}".format(float(outputofcalc['sncont_1aa_seeing'])) tsncont_1aa_seeing_string = "{0:.2f}".format(float(outputofcalc['tsncont_1aa_seeing'])) sncont_band_seeing_string = "{0:.2f}".format(float(outputofcalc['sncont_band_seeing'])) tsncont_band_seeing_string = "{0:.2f}".format(float(outputofcalc['tsncont_band_seeing'])) sncont_p2sp_1_string = "{0:.2f}".format(float(outputofcalc['sncont_p2sp_1'])) tsncont_p2sp_1_string = "{0:.2f}".format(float(outputofcalc['tsncont_p2sp_1'])) sncont_1aa_1_string = "{0:.2f}".format(float(outputofcalc['sncont_1aa_1'])) tsncont_1aa_1_string = "{0:.2f}".format(float(outputofcalc['tsncont_1aa_1'])) sncont_band_1_string = "{0:.2f}".format(float(outputofcalc['sncont_band_1'])) tsncont_band_1_string = "{0:.2f}".format(float(outputofcalc['tsncont_band_1'])) sncont_psp_pspp_string = "{0:.2f}".format(float(outputofcalc['sncont_psp_pspp'])) tsncont_psp_pspp_string = "{0:.2f}".format(float(outputofcalc['tsncont_psp_pspp'])) sncont_psp_pspp2_string = "{0:.2f}".format(float(outputofcalc['sncont_psp_pspp']*2)) tsncont_psp_pspp2_string = "{0:.2f}".format(float(outputofcalc['tsncont_psp_pspp']*2)) lambdaeff_string = str(outputofcalc['lambdaeff']) snline_all_string = "{0:.2f}".format(float(outputofcalc['snline_all'])) snline_fibre_string = "{0:.2f}".format(float(outputofcalc['snline_fibre'])) snline_pspp_string = "{0:.2f}".format(float(outputofcalc['snline_pspp'])) snline_1_aa_string = "{0:.2f}".format(float(outputofcalc['snline_1_aa'])) snline_seeing_string = str(outputofcalc['snline_seeing']) snline_1_string = str(outputofcalc['snline_1']) snline_spaxel_string = "{0:.2f}".format(float(outputofcalc['snline_spaxel'])) snline_fibre1aa_string = "{0:.2f}".format(float(outputofcalc['snline_fibre1aa'])) tablecoutstring = 'OUTPUT CONTINUUM SNR:'+\ '<br />(at lambda_c(VPH) = '+lambdaeff_string+' AA)'+\ '<table border=1>'+\ '<tr><th class="iconcolumn" scope="col"> </th><th scope="col" colspan="2">* SNR per fibre:</th><th scope="col"></th></tr>'+\ '<tr><th class="iconcolumn" scope="row"> </th><td class="perframecolumn">per frame</td><td class="allframecolumn">all frames</td><td></td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_pdp.jpeg" /></td><td class="perframecolumn"> '+sncont_psp_pspp_string+' </td><td> '+tsncont_psp_pspp_string+'</td><td> per detector pixel</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_pspp.jpeg" /></td><td class="perframecolumn"> '+sncont_psp_pspp2_string+' </td><td> '+tsncont_psp_pspp2_string+'</td><td> per spectral pixel</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_pspfwhm.jpeg" /></td><td class="perframecolumn"> '+sncont_p2sp_fibre_string+' </td><td> '+tsncont_p2sp_fibre_string+'</td><td> per spectral FWHM (voxel)</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_peraa.jpeg" /></td><td class="perframecolumn"> '+sncont_1aa_fibre_string+' </td><td> '+tsncont_1aa_fibre_string+'</td><td> per AA</td></tr>'+\ '<tr class="rowheight"><td> </td></tr>'+\ '<tr><td class="iconcolumn"> </td><th scope="col" colspan="2">* SNR in total source area:</th><th>(number of fibers = '+nfibres_string+')</th></tr>'+\ '<tr><td class="iconcolumn"> </td><td class="perframecolumn">per frame</td><td class="allframecolumn">all frames</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_pspp.jpeg" /></td><td> '+sncont_p2sp_all_string+' </td><td> '+tsncont_p2sp_all_string+'</td><td> per spectral pixel</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_pspfwhm.jpeg" /></td><td> '+sncont_pspfwhm_all_string+' </td><td> '+tsncont_pspfwhm_all_string+'</td><td> per spectral FWHM</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_peraa.jpeg" /></td><td> '+sncont_1aa_all_string+' </td><td> '+tsncont_1aa_all_string+'</td><td> per AA</td></tr>'+\ '</table><br />' if sourcet_val_string == 'E': tablecoutstring = tablecoutstring+\ '<table border=1>'+\ '<tr><th class="iconcolumn" scope="col"> </td><th scope="col" colspan="2">* SNR in one seeing:</th><th scope="col"></th></tr>'+\ '<tr><th class="iconcolumn" scope="row"> </th><td class="perframecolumn">per frame</td><td class="allframecolumn">all frames</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_pspfwhm.jpeg" /></td><td> '+sncont_p2sp_seeing_string+' </td><td> '+tsncont_p2sp_seeing_string+'</td><td> per spectral FWHM</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_peraa.jpeg" /></td><td> '+sncont_1aa_seeing_string+' </td><td> '+tsncont_1aa_seeing_string+'</td><td> per AA</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_collapsed.jpeg" /></td><td> '+sncont_band_seeing_string+' </td><td> '+tsncont_band_seeing_string+'</td><td> per collapsed spectrum (spaxel)</td></tr>'+\ '<tr class="rowheight"><td> </td></tr>'+\ '<tr><td class="iconcolumn"> </td><th scope="col" colspan="2">* SNR in one arcsec^2:</th><th></th></tr>'+\ '<tr><td class="iconcolumn"> </td><td class="perframecolumn">per frame</td><td class="allframecolumn">all frames</td><td></td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_pspfwhm.jpeg" /></td><td> '+sncont_p2sp_1_string+' </td><td> '+tsncont_p2sp_1_string+'</td><td> per spectral FWHM</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_peraa.jpeg" /></td><td> '+sncont_1aa_1_string+' </td><td> '+tsncont_1aa_1_string+'</td><td> per AA</td></tr>'+\ '<tr><td class="iconcolumn"><img class="iconsize" src="/static/etc/images/icon_collapsed.jpeg" /></td><td> '+sncont_band_1_string+' </td><td> '+tsncont_band_1_string+'</td><td> per collapsed spectrum (spaxel)</td></tr>'+\ '</table><br />' tableloutstring = '<table border=1>'+\ '<tr><td>OUTPUT LINE SNR:</td><td></td></tr>'+\ '<tr><td>* SNR per arcsec per AA = </td><td>'+ snline_1_aa_string +'</td></tr>'+\ '<tr><td>* SNR in 1 fibre (in aperture) = </td><td>'+ snline_fibre_string +'</td></tr>'+\ '<tr><td>* SNR in 1 fibre (in 1 AA) = </td><td>'+ snline_fibre1aa_string +'</td></tr>'+\ '<tr><td>* SNR per voxel = </td><td>'+ snline_spaxel_string +'</td></tr>'+\ '<tr><td>* SNR per detector pixel = </td><td>'+ snline_pspp_string +'</td></tr>'+\ '<tr><td>* SNR total (in aperture) = </td><td>'+ snline_all_string +'</td></tr>'+\ '</table><br />' tableinputstring = '<table border=1>'+\ '<tr><td>INPUT PARAMETERS:</td><td></td></tr>'+\ '<tr><td>Observing mode:</td><td>'+om_val_string+'</td></tr>'+\ '<tr><td>VPH:</td><td>'+vph_val_string+'</td></tr>'+\ '<tr><td>Source type:</td><td>'+sourcet_val_string+'</td></tr>'+\ '<tr><td>Continuum:</td><td>'+bandc_val_string+' = '+mag_val_string+'mag</td></tr>'+\ '<tr><td>Continuum flux:</td><td>'+netflux_string+' cgs</td></tr>'+\ '<tr><td>*Sky Condition:</td><td>'+skycond_val_string+'</td></tr>'+\ '<tr><td>Moon:</td><td>'+moon_val_string+'</td></tr>'+\ '<tr><td>Airmass: X=</td><td>'+airmass_val_string+'</td></tr>'+\ '<tr><td>Seeing(@X=1):</td><td>'+seeing_zenith_string+'</td></tr>'+\ '<tr><td>Sky-flux(R,@X):</td><td>'+fsky_string+' cgs</td></tr>'+\ '<tr><td>Seeing(@X):</td><td>'+seeingx_string+'</td></tr>'+\ '<tr><td>*Observation:</td></td><td></tr>'+\ '<tr><td>Number of frames:</td><td>'+numframe_val_string+'</td></tr>'+\ '<tr><td>Exptime per frame:</td><td>'+exptimepframe_val_string+' s</td></tr>'+\ '<tr><td>Total exptime:</td><td>'+exptime_val_string+' s</td></tr>'+\ '<tr><td>NP_Dark:</td><td>'+npdark_val_string+'</td></tr>'+\ '<tr><td>Sky-bundles:</td><td>'+nsbundles_val_string+'</td></tr>'+\ '</table><br />' else: tablecoutstring = '' tableloutstring = '' tableinputstring = '' from django.http import JsonResponse return JsonResponse({'outtext' : outtextstring, 'textinput' : inputstring, 'textcout' : coutputstring, 'textlout' : loutputstring, 'tablecout' : tablecoutstring, 'tablelout' : tableloutstring, 'tableinput' : tableinputstring, 'graphic' : html, })
def etc_do(request): if request.method == 'GET': # import matplotlib.pyplot as plt # import mpld3 # from mpld3 import plugins, utils # # plt.plot([3,1,4,1,5], 'ks-', mec='w', mew=5, ms=20) # mpld3.save_html() return HttpResponse("<html><body>It works!</body></html>") elif request.method == 'POST': outputofcalc = compute5(request) tocheck = str(outputofcalc['outtext']) if not tocheck: outtextstring = "" #No warning. else: outtextstring = tocheck # GET relevant data vph = request.POST['vph'] queryvph = VPHSetup.objects.filter(pk=vph).values() vph_val = queryvph[0]['name'] spec = request.POST['spectype'] queryspec = SpectralTemplate.objects.filter(pk=spec).values() entry_spec_name = queryspec[0]['name'] if not tocheck: x = outputofcalc['lamb'] y = outputofcalc['fc'] label1 = entry_spec_name label2 = outputofcalc['mag_val'] label3 = outputofcalc['bandc_val'] x2 = outputofcalc['lamb'] y2 = outputofcalc['pframesn_psp_asp'] x2b = x2 y2b = outputofcalc['allframesn_psp_asp'] x2c = x2 y2c = outputofcalc['pframesn_psp_asp_all'] x2d = x2 y2d = outputofcalc['allframesn_psp_asp_all'] label2a = entry_spec_name label2b = vph_val label2c = outputofcalc['bandc_val'] else: x = numpy.arange(1, 100, 1) y = numpy.arange(1, 100, 1) x2 = numpy.arange(1, 100, 1) y2 = numpy.arange(1, 100, 1) x2b = numpy.arange(1, 100, 1) y2b = numpy.arange(1, 100, 1) x2c = numpy.arange(1, 100, 1) y2c = numpy.arange(1, 100, 1) x2d = numpy.arange(1, 100, 1) y2d = numpy.arange(1, 100, 1) label1 = "none" label2 = 20.0 # Float label3 = "none" label2a = "none" label2b = "none" label2c = "none" # # CREATE TEMPORARY FILE # temp = tempfile.NamedTemporaryFile(suffix=".png", prefix="temp", dir="etc/static/etc/tmp/", delete=False) # # graphic = plot_and_save(temp.name, x, y, label1, label2, label3) # temp2 = tempfile.NamedTemporaryFile(suffix=".png", prefix="temp", dir="etc/static/etc/tmp/", delete=False) # graphic2 = plot_and_save2(temp2.name, x2, y2, x2b, y2b, x2c, y2c, x2d, y2d, label2a, label2b, label2c) # # # RENAME FILE PATH # dirname, basename = os.path.split(graphic) # newpath = '/static/etc/tmp/' # graphic = os.path.join(newpath, basename) # # dirname2, basename2 = os.path.split(graphic2) # newpath2 = '/static/etc/tmp/' # graphic2 = os.path.join(newpath2, basename2) inputstring = '<br /><p>' + str(outputofcalc['texti']) + '</p>' coutputstring = '<br /><p>' + str(outputofcalc['textoc']) + '</p>' loutputstring = '<br /><p>' + str(outputofcalc['textol']) + '</p>' figura = plot_and_save_new('', x, y, label1, label2, label3) html = mpld3.fig_to_html(figura) figura2 = plot_and_save2_new('', x2, y2, x2b, y2b, x2c, y2c, x2d, y2d, label2a, label2b, label2c) html += mpld3.fig_to_html(figura2) html = html.replace("None", "") # No se xq introduce string None from django.http import JsonResponse return JsonResponse({ 'outtext': outtextstring, 'textinput': inputstring, 'textcout': coutputstring, 'textlout': loutputstring, 'graphic': html, })
def etc_do(request): if request.method == 'GET': # import matplotlib.pyplot as plt # import mpld3 # from mpld3 import plugins, utils # # plt.plot([3,1,4,1,5], 'ks-', mec='w', mew=5, ms=20) # mpld3.save_html() return HttpResponse("<html><body>It works!</body></html>") elif request.method == 'POST': outputofcalc = compute5(request) tocheck = str(outputofcalc['outtext']) if not tocheck: outtextstring = "" #No warning. else: outtextstring = tocheck # GET relevant data vph = request.POST['vph'] queryvph = VPHSetup.objects.filter(pk=vph).values() vph_val = queryvph[0]['name'] spec = request.POST['spectype'] queryspec = SpectralTemplate.objects.filter(pk=spec).values() entry_spec_name = queryspec[0]['name'] if not tocheck: x = outputofcalc['lamb'] y = outputofcalc['fc'] label1 = entry_spec_name label2 = outputofcalc['mag_val'] label3 = outputofcalc['bandc_val'] x2 = outputofcalc['lamb'] y2 = outputofcalc['pframesn_psp_asp'] x2b = x2 y2b = outputofcalc['allframesn_psp_asp'] x2c = x2 y2c = outputofcalc['pframesn_psp_asp_all'] x2d = x2 y2d = outputofcalc['allframesn_psp_asp_all'] label2a = entry_spec_name label2b = vph_val label2c = outputofcalc['bandc_val'] else: x = numpy.arange(1, 100, 1) y = numpy.arange(1, 100, 1) x2 = numpy.arange(1, 100, 1) y2 = numpy.arange(1, 100, 1) x2b = numpy.arange(1, 100, 1) y2b = numpy.arange(1, 100, 1) x2c = numpy.arange(1, 100, 1) y2c = numpy.arange(1, 100, 1) x2d = numpy.arange(1, 100, 1) y2d = numpy.arange(1, 100, 1) label1 = "none" label2 = 20.0 # Float label3 = "none" label2a = "none" label2b = "none" label2c = "none" # # CREATE TEMPORARY FILE # temp = tempfile.NamedTemporaryFile(suffix=".png", prefix="temp", dir="etc/static/etc/tmp/", delete=False) # # graphic = plot_and_save(temp.name, x, y, label1, label2, label3) # temp2 = tempfile.NamedTemporaryFile(suffix=".png", prefix="temp", dir="etc/static/etc/tmp/", delete=False) # graphic2 = plot_and_save2(temp2.name, x2, y2, x2b, y2b, x2c, y2c, x2d, y2d, label2a, label2b, label2c) # # # RENAME FILE PATH # dirname, basename = os.path.split(graphic) # newpath = '/static/etc/tmp/' # graphic = os.path.join(newpath, basename) # # dirname2, basename2 = os.path.split(graphic2) # newpath2 = '/static/etc/tmp/' # graphic2 = os.path.join(newpath2, basename2) inputstring = '<br /><p>' + str(outputofcalc['texti']) + '</p>' coutputstring = '<br /><p>' + str(outputofcalc['textoc']) + '</p>' loutputstring = '<br /><p>' + str(outputofcalc['textol']) + '</p>' figura = plot_and_save_new('', x, y, label1, label2, label3) html = mpld3.fig_to_html(figura) figura2 = plot_and_save2_new('', x2, y2, x2b, y2b, x2c, y2c, x2d, y2d, label2a, label2b, label2c) html += mpld3.fig_to_html(figura2) html = html.replace("None", "") # No se xq introduce string None from django.http import JsonResponse return JsonResponse({'outtext' : outtextstring, 'textinput' : inputstring, 'textcout' : coutputstring, 'textlout' : loutputstring, 'graphic' : html, })