Example #1
0
def compute5(request):
    print request.POST['stype']
    size_val = 1.0 if request.POST['stype']== 'P' else request.POST['size']
    mag_val = float(request.POST['contmagval']) if request.POST['contmagflux'] == 'M' else 20.0
    fc_val = 1e-16 if request.POST['contmagflux'] == 'M' else float(request.POST['contfluxval'])


    fluxt_val = request.POST['iflux']
    if fluxt_val == "C":
        resolvedline_val = "N"
        fline_val = 1e-13
        wline_val = 6562.8
        fwhmline_val = 6
        nfwhmline_val = 1.0
        cnfwhmline_val = 1.0

    else:
        fline_val = float(request.POST['lineflux'])
        wline_val = float(request.POST['linewave'])
        nfwhmline_val = float(request.POST['lineap'])
        cnfwhmline_val = float(request.POST['contap'])
        if fluxt_val == "L" and request.POST['rline'] == "N":
            resolvedline_val = "N"
            fwhmline_val = 6

        elif fluxt_val == "L" and request.POST['rline'] == "Y":
            resolvedline_val = "Y"
            fwhmline_val = float(request.POST['linefwhm'])


    querybandc = PhotometricFilter.objects.filter(pk=request.POST['pfilter']).values()  # get row with the values at primary key
    bandc_val = querybandc[0]['name']
    # entry_filter_cwl = querybandc[0]['cwl']
    # entry_filter_width = querybandc[0]['path']

    queryvph = VPHSetup.objects.filter(pk=request.POST['vph']).values()
    vph_val = queryvph[0]['name']

    if vph_val == '-empty-':        # Deals with -empty- VPH Setup
        # vph_val = 'MR-UB'
        outtext="WARNING: VPH Setup is -empty-! Choose a VPH."
        texti=" "
        textoc=" "
        textol=" "
        outputfilename="etc/static/etc/outputcalc.txt"
        with open(outputfilename, 'w') as f:
            print >> f, outtext
            print >> f, texti
            print >> f, textoc
            print >> f, textol
        outputofcalc = ({'outtext':outtext, 'texti':texti, 'textoc':textoc, 'textol':textol})
        # return outputofcalc
    else:
        entry_vph_fwhm = queryvph[0]['fwhm']
        entry_vph_disp = queryvph[0]['dispersion']
        entry_vph_deltab = queryvph[0]['deltab']
        entry_vph_lambdac = queryvph[0]['lambdac']
        entry_vph_relatedband = queryvph[0]['relatedband']
        entry_vph_lambdab = queryvph[0]['lambda_b']
        entry_vph_lambdae = queryvph[0]['lambda_e']
        entry_vph_specconf = queryvph[0]['specconf']

        # vphfeatures = [entry_vph_fwhm,entry_vph_disp,entry_vph_deltab,entry_vph_lambdac,\
        #                entry_vph_relatedband,entry_vph_lambdab,entry_vph_lambdae,entry_vph_specconf]
        # filtercar2 = ["0","0",entry_vph_lambdab,entry_vph_lambdae]

        spec = request.POST['spectype']
        queryspec = SpectralTemplate.objects.filter(pk=spec).values()
        entry_spec_name = queryspec[0]['name']
        # entry_spec_path = queryspec[0]['path']
        # spectdat = [entry_spec_name,entry_spec_path]
        spect_val = entry_spec_name

        skycond_val = request.POST['skycond']
        moon_val = request.POST['moonph']
        airmass_val = float(request.POST['airmass'])
        seeing_val = float(request.POST['seeing'])
        numframes_val = float(request.POST['numframes'])
        exptimepframe_val = float(request.POST['exptimepframe'])
        nsbundles_val = int(request.POST['nfibers'])

        outputofcalc = calc(request.POST['stype'],request.POST['contmagflux'],\
                            mag_val,fc_val,size_val,fluxt_val,\
                            fline_val,wline_val,nfwhmline_val,cnfwhmline_val,
                            fwhmline_val,resolvedline_val,spect_val,bandc_val,\
                            request.POST['om_val'],vph_val,\
                            skycond_val,moon_val,airmass_val,seeing_val,\
                            numframes_val,exptimepframe_val,nsbundles_val)


    # cleanstring = string1.replace("\'", '\n')
    # cleanstring = cleanstring.replace(",", ' ')
    # cleanstring = cleanstring.replace("u\n", '\n')
    # cleanstring = cleanstring[1:].replace("(", '\n')
    # cleanstring = cleanstring[:-1].replace("(", '\n')

    # cleanstring = [outtextstring,inputstring,coutputstring,loutputstring]

    return outputofcalc
Example #2
0
def compute5(request):
    print request.POST['stype']
    size_val = 1.0 if request.POST['stype'] == 'P' else request.POST['size']
    mag_val = float(request.POST['contmagval']
                    ) if request.POST['contmagflux'] == 'M' else 20.0
    fc_val = 1e-16 if request.POST['contmagflux'] == 'M' else float(
        request.POST['contfluxval'])

    fluxt_val = request.POST['iflux']
    if fluxt_val == "C":
        resolvedline_val = "N"
        fline_val = 1e-13
        wline_val = 6562.8
        fwhmline_val = 6
        nfwhmline_val = 1.0
        cnfwhmline_val = 1.0

    else:
        fline_val = float(request.POST['lineflux'])
        wline_val = float(request.POST['linewave'])
        nfwhmline_val = float(request.POST['lineap'])
        cnfwhmline_val = float(request.POST['contap'])
        if fluxt_val == "L" and request.POST['rline'] == "N":
            resolvedline_val = "N"
            fwhmline_val = 6

        elif fluxt_val == "L" and request.POST['rline'] == "Y":
            resolvedline_val = "Y"
            fwhmline_val = float(request.POST['linefwhm'])

    querybandc = PhotometricFilter.objects.filter(
        pk=request.POST['pfilter']).values(
        )  # get row with the values at primary key
    bandc_val = querybandc[0]['name']
    # entry_filter_cwl = querybandc[0]['cwl']
    # entry_filter_width = querybandc[0]['path']

    queryvph = VPHSetup.objects.filter(pk=request.POST['vph']).values()
    vph_val = queryvph[0]['name']

    if vph_val == '-empty-':  # Deals with -empty- VPH Setup
        # vph_val = 'MR-UB'
        outtext = "WARNING: VPH Setup is -empty-! Choose a VPH."
        texti = " "
        textoc = " "
        textol = " "
        outputfilename = "etc/static/etc/outputcalc.txt"
        with open(outputfilename, 'w') as f:
            print >> f, outtext
            print >> f, texti
            print >> f, textoc
            print >> f, textol
        outputofcalc = ({
            'outtext': outtext,
            'texti': texti,
            'textoc': textoc,
            'textol': textol
        })
        # return outputofcalc
    else:
        entry_vph_fwhm = queryvph[0]['fwhm']
        entry_vph_disp = queryvph[0]['dispersion']
        entry_vph_deltab = queryvph[0]['deltab']
        entry_vph_lambdac = queryvph[0]['lambdac']
        entry_vph_relatedband = queryvph[0]['relatedband']
        entry_vph_lambdab = queryvph[0]['lambda_b']
        entry_vph_lambdae = queryvph[0]['lambda_e']
        entry_vph_specconf = queryvph[0]['specconf']

        # vphfeatures = [entry_vph_fwhm,entry_vph_disp,entry_vph_deltab,entry_vph_lambdac,\
        #                entry_vph_relatedband,entry_vph_lambdab,entry_vph_lambdae,entry_vph_specconf]
        # filtercar2 = ["0","0",entry_vph_lambdab,entry_vph_lambdae]

        spec = request.POST['spectype']
        queryspec = SpectralTemplate.objects.filter(pk=spec).values()
        entry_spec_name = queryspec[0]['name']
        # entry_spec_path = queryspec[0]['path']
        # spectdat = [entry_spec_name,entry_spec_path]
        spect_val = entry_spec_name

        moon_val = request.POST['moonph']
        airmass_val = float(request.POST['airmass'])
        seeing_val = float(request.POST['seeing'])
        numframes_val = float(request.POST['numframes'])
        exptimepframe_val = float(request.POST['exptimepframe'])
        nsbundles_val = int(request.POST['nfibers'])

        outputofcalc = calc(request.POST['stype'],request.POST['contmagflux'],mag_val,fc_val,size_val,fluxt_val,\
                            fline_val,wline_val,nfwhmline_val,cnfwhmline_val,
                            fwhmline_val,resolvedline_val,spect_val,bandc_val,\
                            request.POST['om_val'],vph_val,moon_val,airmass_val,seeing_val,\
                            numframes_val,exptimepframe_val,nsbundles_val)

    # cleanstring = string1.replace("\'", '\n')
    # cleanstring = cleanstring.replace(",", ' ')
    # cleanstring = cleanstring.replace("u\n", '\n')
    # cleanstring = cleanstring[1:].replace("(", '\n')
    # cleanstring = cleanstring[:-1].replace("(", '\n')

    # cleanstring = [outtextstring,inputstring,coutputstring,loutputstring]

    return outputofcalc
Example #3
0
def compute5(request):
    print request.POST['stype']
    print '### LOG: Entered compute5'

    if request.POST['stype'] == 'P':
        isize_val = 'A'
        size_val = 1.0
        radius_val = 1.0
    else:
        if request.POST['isize'] == 'A':
            isize_val = request.POST['isize']
            size_val = request.POST['size']
            radius_val = 1.0
        else:
            isize_val = request.POST['isize']
            radius_val = float(request.POST['radius'])
            size_val = numpy.pi * (radius_val**2)
    mag_val = float(request.POST['contmagval']) if request.POST[
                                                       'contmagflux'] == 'M' else 20.0
    fc_val = 1e-16 if request.POST['contmagflux'] == 'M' else float(
        request.POST['contfluxval'])

    fluxt_val = request.POST['iflux']
    if fluxt_val == "C":
        resolvedline_val = "N"
        fline_val = 1e-13
        wline_val = 6562.8
        fwhmline_val = 6
        nfwhmline_val = 1.0
        cnfwhmline_val = 1.0

    else:
        fline_val = float(request.POST['lineflux'])
        wline_val = float(request.POST['linewave'])
        nfwhmline_val = float(request.POST['lineap'])
        cnfwhmline_val = float(request.POST['contap'])
        if fluxt_val == "L" and request.POST['rline'] == "N":
            resolvedline_val = "N"
            fwhmline_val = 6

        elif fluxt_val == "L" and request.POST['rline'] == "Y":
            resolvedline_val = "Y"
            fwhmline_val = float(request.POST['linefwhm'])

    querybandc = PhotometricFilter.objects.filter(pk=request.POST[
        'pfilter']).values()  # get row with the values at primary key
    bandc_val = querybandc[0]['name']
    # entry_filter_cwl = querybandc[0]['cwl']
    # entry_filter_width = querybandc[0]['path']

    queryvph = VPHSetup.objects.filter(pk=request.POST['vph']).values()
    vph_val = queryvph[0]['name']

    if vph_val == '-empty-':  # Deals with -empty- VPH Setup
        # vph_val = 'MR-UB'
        outtext = "WARNING: VPH Setup is -empty-! Choose a VPH."
        texti = " "
        textoc = " "
        textol = " "
        outputfilename = "mect/static/etc/outputcalc.txt"
        with open(outputfilename, 'w') as f:
            print >> f, outtext
            print >> f, texti
            print >> f, textoc
            print >> f, textol
        outputofcalc = ({'outtext': outtext, 'texti': texti, 'textoc': textoc,
                         'textol': textol})
        # return outputofcalc
    else:
        entry_vph_fwhm = queryvph[0]['fwhm']
        entry_vph_disp = queryvph[0]['dispersion']
        entry_vph_deltab = queryvph[0]['deltab']
        entry_vph_lambdac = queryvph[0]['lambdac']
        entry_vph_relatedband = queryvph[0]['relatedband']
        entry_vph_lambdab = queryvph[0]['lambda_b']
        entry_vph_lambdae = queryvph[0]['lambda_e']
        entry_vph_specconf = queryvph[0]['specconf']

        # vphfeatures = [entry_vph_fwhm,entry_vph_disp,entry_vph_deltab,entry_vph_lambdac,\
        #                entry_vph_relatedband,entry_vph_lambdab,entry_vph_lambdae,entry_vph_specconf]
        # filtercar2 = ["0","0",entry_vph_lambdab,entry_vph_lambdae]

        spec = request.POST['spectype']
        if fluxt_val == "L":
            if spec == '7':  # NGC1068
                spec = '47'  # NGC1068 (smooth)
            elif spec == '20':  # Orion
                spec = '48'  # Orion (smooth)
            elif spec == '21':  # PN
                spec = '49'  # PN (smooth)
            elif spec == '6':  # Sc
                spec = '50'  # Sc (smooth)
            elif spec == '9':  # Starburst1
                spec = '51'  # Starburst1 (smooth)
            elif spec == '10':  # Starburst2
                spec = '52'  # Starburst2 (smooth)
            elif spec == '11':  # Starburst3
                spec = '53'  # Starburst3 (smooth)
            elif spec == '12':  # Starburst4
                spec = '54'  # Starburst4 (smooth)
            elif spec == '13':  # Starburst5
                spec = '55'  # Starburst5 (smooth)
            elif spec == '14':  # Starburst6
                spec = '56'  # Starburst6 (smooth)
            elif spec == '19':  # Sy2
                spec = '57'  # Sy2 (smooth)
        queryspec = SpectralTemplate.objects.filter(pk=spec).values()
        entry_spec_name = queryspec[0]['name']
        spect_val = entry_spec_name

        skycond_val = request.POST['skycond']
        moon_val = request.POST['moonph']
        airmass_val = float(request.POST['airmass'])

        queryseeing = SeeingTemplate.objects.filter(pk=request.POST['seeing']).values()
        seeing_val = queryseeing[0]['name']

        numframes_val = float(request.POST['numframes'])
        exptimepframe_val = float(request.POST['exptimepframe'])
        nsbundles_val = int(request.POST['nsbundles'])

        plotflag_val = request.POST['plotflag']

        outputofcalc = calc(request.POST['stype'],
                            request.POST['contmagflux'],
                            mag_val, fc_val,
                            isize_val,
                            size_val, radius_val,
                            fluxt_val,
                            fline_val, wline_val,
                            nfwhmline_val, cnfwhmline_val,
                            fwhmline_val, resolvedline_val,
                            spect_val, bandc_val,
                            request.POST['om_val'], vph_val,
                            skycond_val, moon_val, airmass_val, seeing_val,
                            numframes_val, exptimepframe_val, nsbundles_val,
                            plotflag_val
                            )

    # cleanstring = string1.replace("\'", '\n')
    # cleanstring = cleanstring.replace(",", ' ')
    # cleanstring = cleanstring.replace("u\n", '\n')
    # cleanstring = cleanstring[1:].replace("(", '\n')
    # cleanstring = cleanstring[:-1].replace("(", '\n')

    # cleanstring = [outtextstring,inputstring,coutputstring,loutputstring]
    print 'LOG: About to leave compute5 and return outputofcalc'
    # print outputofcalc
    return outputofcalc