Ejemplo n.º 1
0
Archivo: views.py Proyecto: openxxs/gps
def tableStatisticDetail(request, filename):
    result = ""
    if filename == "bulk":
        os.popen("cd %s" % GAMITTABLE)
        [os.popen("mv %s %s.bak;wget -o %s.log ftp://garner.ucsd.edu//archive/garner/gamit/tables/%s" % (
        files, files, files, files)) for files in fileList]
        os.chdir(SOFTWAREPATH + username + "/tables/")
        [os.popen("mv %s %s.bak;wget -o %s.log ftp://garner.ucsd.edu//archive/garner/gamit/tables/%s" % (
        files, files, files, files)) for files in fileList]
        for filen in fileList:
            result += readFile(GAMITTABLE + filen + ".log")
    elif filename in fileList:
        os.popen("cd %s ;mv %s %s.bak;wget -o %s.log ftp://garner.ucsd.edu//archive/garner/gamit/tables/%s" % (
        GAMITTABLE, filename, filename, filename, filename))
        os.chdir(SOFTWAREPATH + username + "/tables/")
        os.popen("mv %s %s.bak;wget -o %s.log ftp://garner.ucsd.edu//archive/garner/gamit/tables/%s" % (
        filename, filename, filename, filename))
        result += readFile(GAMITTABLE + filename + ".log")
    else:
        result = "error"
    return HttpResponse(result)
Ejemplo n.º 2
0
Archivo: views.py Proyecto: openxxs/gps
def expandrateAnalyse(request):
    
    site1 = request.POST.get("site1")
    site2 = request.POST.get("site2")
    site3 = request.POST.get("site3")
   
    #生成两两组合格式的站点组合并存入circle列表中
    circle= [doubleSite(site1, site2), doubleSite(site1, site3), doubleSite(site2, site3)]


    #获取baseline.dat中的数据
    user = request.user.username
    baselinefile = os.path.join(CONFIG.SOFTWAREPATH+user,'exp2nd/baseline_batch/baseline.dat')

    from gps.utils import readFile
    lines = readFile(baselinefile)
    #从得到的列表中获取所需要的数据
    ls = [l.split() for l in lines]
    distance = [[l[1][:8],l[15],l[0]] for l in ls if l[0] in circle]  #l[15]为L的值
    length=len(distance)
    #正常情况值应为3
    
    
    a = [eval(distance[i][0]) for i in range(length) if i%3 == 0]
    b = [eval(distance[i][0]) for i in range(length) if i%3 == 1]
    c = [eval(distance[i][0]) for i in range(length) if i%3 == 2]
    p = [(a[i]+b[i]+c[i])/2 for i in range(length/3)]
    s = [[distance[3*i][0],sqrt(p[i]*(p[i]-a[i])*(p[i]-b[i])*(p[i]-c[i]))] for i in range(length/3)]

    #!!!!!!!!!!!!!!!!!!!!!未判断文件夹是否存在,因此该文件夹应提前准备好
    #将数据写入文件
    expandratefile = os.path.join(CONFIG.SOFTWAREPATH+user,'exp2nd/expandrate_result/expandrate.dat')
    ff = open(expandratefile,"w")
    #baseX = s[0][0]
    baseY = s[0][1]
    for ss in s:
        #ss[0] = ss[0]-baseX
        ss[1] = ss[1]-baseY
        format ="%0.4f" % ss[1]
        line = str(ss[0])+" "+format+" "+"0"+'\n'
        ff.writelines(line)
    ff.close()
    
    scope = getMax_Min.getMax_MinFromFile(expandratefile,[1,2])
    x_scope = scope[0].split()
    y_scope = scope[1].split()
    
    maxX = "%d" % (float(x_scope[0]) + 1)  
    minX = "%d" % (float(x_scope[1]))
    maxY = "%d" % (abs(float(y_scope[0])))
    maxY = "%d" % (float(y_scope[0]) + 10**(len(maxY)-1))
    minY = "%d" % (abs(float(y_scope[1])))
    minY = "%d" % (float(y_scope[1]) - 10**(len(minY)-1))
    
    disY = float(maxY)/5.0
    
    #画出图像 纵坐标有问题???????????????????????????????????????
    imagename = os.path.join(CONFIG.SOFTWAREPATH+user,'exp2nd/expandrate_result/expandrate.pdf')
    
    cmd = 'psxy %s -JX6.5/2.0 -R%s/%s/%s/%s -Ba0.5f0.1:"":/a%0.2ff5:"":WSen:."": -Ey0.02/2/255/0/0 -Sc0.03 -G255/0/0 -K -P -Y7i > %s' % (expandratefile,minX,maxX,minY,maxY,disY,imagename)
    
    commands.getstatusoutput(cmd)
    now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
    png = 'exp2nd/expandrate_result/%sexpandrate%s.png' %(user,now)
    subprocess.call('cp %s %s'%(CONFIG.SOFTWAREPATH+user+'/'+png,CONFIG.SOFTWAREPATH+'static/img/%sexpandrate%s.png'%(user,now)),shell=True)
    os.popen('convert -trim %s %s ; rm %s' % (imagename,os.path.join(CONFIG.SOFTWAREPATH+user,png),imagename)) 
    return render_to_response('/DataProc/png_expandRate.html',{'file':CONFIG.SOFTWAREPATH+user+'/exp2nd/expandrate_result/expandrate.dat','png':CONFIG.SOFTWAREPATH+'static/img/%sexpandrate%s.png'%(user,now)},context_instance=RequestContext(request))
Ejemplo n.º 3
0
Archivo: views.py Proyecto: openxxs/gps
def configEditDetail(request, filename):
    username = request.user.username
    os.chdir(SOFTWAREPATH + username + "/experiment/tables/")
    print readFile(filename),filename,os.getcwd()
    return HttpResponse(readFile(filename))