Exemplo n.º 1
0
Arquivo: views.py Projeto: openxxs/gps
def dataStatisticDetail(request):
    usern = username.username
    os.chdir(SOFTWAREPATH + usern + "/experiment/")
    os.path.exists("rinex") and True or os.mkdir("rinex")
    os.popen("ln -s %s/????/* rinex;" % RINEXPATH)
    form = BulkProcessForm()
    if request.method == 'POST':
        form = BulkProcessForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            year_1, day_1, year_2, day_2,IGS = int(data['StartYear']), int(data['StartDay']), int(data['EndYear']), int(data['EndDay']),data['IGS']
        else:
            fileStatus = tableStatistic(user)
            return render_to_response('DataProcDataProc.html',{'form':form,'fileStatus':fileStatus,'fileList':fileList})
    siteList = config.get("path", "checklist").split('%%')
    years = [str(year)[:2] for year in xrange(year_1, year_2 + 1)]
    if len(years) == 1:
        days = [('%03d' % day, years[0]) for day in xrange(day_1, day_2 + 1)]
    if len(years) > 1:
        common_years = [years[i] for i in xrange(1, len(years) - 1)]
        days = [('%03d' % day, years[0]) for day in xrange(day_1, isLeap(int(years[0]) + 2000) + 1)]
        days += [('%03d' % day, year) for year in common_years for day in xrange(1, isLeap(int(year) + 2000) + 1)]
        days += [('%03d' % day, years[len(years) - 1]) for day in xrange(1, day_2 + 1)]
    for site in siteList:
        os.chdir(SOFTWAREPATH + userm + "/experiment/rinex/")
        l = commands.getoutput("ls *.*o | grep %s" % site)
        l = [(a[4:7], a[9:11]) for a in l]
        infos = list(set(copy.deepcopy(days)) - set(dates[1]))
        inforarray.append({'site': site, 'info': infos})
    inforarray = []
    return render_to_response("dataStatisticResult.html",
            {'sitelist': siteList, 'infoList': inforarray, 'year_1': year_1,
             'year_2': year_2, 'day_1': day_1, 'day_2': day_2, 'IGS': IGS, 'years': xrange(year_1, year_2 + 1)},context_instance=RequestContext(request))
Exemplo n.º 2
0
def getData(typename,user):                             #extract data into file
    
    atmosphere_path=''
    if typename == 'atmosphere':
        atmosphere_path=os.path.join(cwd,user,'exp2nd/atmosphere')
        filepath = os.path.join(atmosphere_path,'atmosphere.dat')
        if os.path.isfile(filepath) == True:
            os.remove(filepath)
    elif typename == 'batch':
        atmosphere_path=os.path.join(cwd,user,'exp2nd/atmosphere_batch')
    
    
    oscala_path=os.path.join(cwd,user,'exp2nd/oscala_%s/oscala.*' % typename)
    

    list_files = os.popen("dir %s" % oscala_path).read().split() #按生成创建时间排列文件
    list_files.sort()

    for l in list_files:
        (oscala_path,filename)=os.path.split(l)
        year_day=filename.split('.')
        year=year_day[1]
        day=year_day[2]
        

        d = dToMd(year,day)
        format='"%.6f ",'
        sum_day=isLeap(int(year))
        hour_base = sum_day*24
        
        cmd=" awk '/^ATM/ && $2~/X/ && /[0-9]$/ {if($7==%d) {printf(%s$5+%f/%d+$8/%d);print $3,$12,$13}}' %s >> %s/atmosphere.dat " % (d,format,float(day),sum_day,float(hour_base),l,atmosphere_path)
            
        print cmd
     
        os.popen(cmd)    
Exemplo n.º 3
0
def extractTempFile(start_year,start_day,end_year,end_day,typename,user): 
        
    filedir1=os.path.join(cwd+user,'exp2nd')
    filedir2=os.path.join(cwd+user,'exp2nd/oscala_%s' % typename)  #new file
    if os.path.isdir(filedir2) == True:
        shutil.rmtree(filedir2)
    os.mkdir(filedir2) 
    
    
    start=start_day
    end=end_day
        
    if start_year == end_year:
        file_dir=os.path.join(cwd+user,'experiment/%s' % str(start_year))+'/'  #old file
        print file_dir
            
        for d in range(start,end+1):
            d_str = numberToDay(d)
            goal_dir=file_dir + d_str+'/'
            goal_name = goal_dir+'oscala.'+d_str
            print 'goal_name',goal_name
            if os.path.isfile(goal_name) == True: 
                cp_cmd = "cp %soscala.%s %s/oscala.%s.%s" % (goal_dir,d_str,filedir2,str(start_year),d_str)
                print cp_cmd
                os.popen(cp_cmd)

        
    if  start_year <  end_year:
        for y in range(start_year,end_year+1):
            if(y==start_year):
                end = isLeap(y)
            elif(y==end_year):  
                start=1
            else:
                start=1
                end = isLeap(y)
            file_dir=os.path.join(cwd+user,'experiment/%s' % str(y))+'/'  #old file
            for d in range(start,end+1):
                d_str = numberToDay(d)
                goal_dir=file_dir + d_str+'/'
                goal_name = goal_dir+'oscala.'+d_str
                if os.path.isfile(goal_name) == True: 
                    print "goal_name 2"
                    os.popen("cp %s/oscala.%s %s/oscala.%s.%s" % (goal_dir,d_str,filedir2,str(y),d_str))
Exemplo n.º 4
0
Arquivo: views.py Projeto: openxxs/gps
def Gamitdata_analysing(prj, year_1, day_1, year_2, day_2, IGS):
    error = ''
    log.info('analysing')
    os.chdir(SOFTWAREPATH + prj)
    for t in xrange(year_1, year_2 + 1):
        outfiles0 = commands.getstatusoutput('cd experiment/%s ; sh_setup -yr %d' % (str(t), t))
        log.info(outfiles0)
        try:
            if  year_2 - year_1 == 0:
                cmd_gamit = 'cd experiment/%s ; sh_gamit -expt scal -s %d %d %d -orbit %s -copt x k p -dopts c ao > sh_gamit.log' % (
                str(t), t, day_1, day_2, IGS)
                cmd_glred = 'cd experiment/%s ; sh_glred -s %d %d %d %d -expt scal -opt H G E > sh_glred.log' % (
                str(t), t, day_1, t, day_2)  #----------------bxy 2012-1-5)
                os.popen(cmd_gamit)
                os.popen(cmd_glred)
                os.popen(
                    'cp ' + os.path.join(SOFTWAREPATH + prj, 'experiment/%s/glbf/h*glx ' % str(year_1)) + os.path.join(
                        cwd, 'exp2nd/h_results'))
            if  year_2 - year_1 == 1:
                if  t == year_1:
                    sumday = isLeap(year_1)
                    log.info(
                        'cd experiment/%s ; sh_gamit -expt scal -s %d %d %d -orbit %s -copt x k p -dopts c ao > sh_gamit.log' % (
                        str(t), t, day_1, sumday, IGS))

                    outfiles5 = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_gamit -expt scal -s %d %d %d -orbit %s -copt x k p -dopts c ao > sh_gamit.log' % (
                    str(t), t, day_1, sumday, IGS))
                    outfiles12 = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_glred -s %d %d %d %d -expt scal -opt H G E >&! sh_glred.log' % (
                    str(t), t, day_1, t, sumday))
                    outfiles13 = commands.getstatusoutput(
                        'cd experiment/%s ; sh_cleanup -s %d %d %d %d -dopts p x k' % (str(t), t, day_1, t, sumday))
                    os.popen('cp ' + os.path.join(cwd, 'experiment/%s/glbf/h*glx ' % str(year_1)) + os.path.join(cwd,
                                                                                                                 'exp2nd/h_results'))
                else:
                    log.info(
                        'cd experiment/%s ; sh_gamit -expt scal -s %d 1 %d  -orbit %s -copt x k p -dopts c ao> sh_gamit.log' % (
                        str(t), t, day_2, IGS))
                    outfiles6 = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_gamit -expt scal -s %d 1 %d  -orbit %s -copt x k p -dopts c ao> sh_gamit.log' % (
                    str(t), t, day_2, IGS))
                    outfiles = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_glred -s %d 1 %d %d -expt scal -opt H G E >&! sh_glred.log' % (
                    str(t), t, t, day_2))
                    outfiles = commands.getstatusoutput(
                        'cd experiment/%s ; sh_cleanup -s %d 1 %d %d-dopts p x k' % (str(t), t, t, day_2))
                    os.popen('cp ' + os.path.join(cwd, 'experiment/%s/glbf/h*glx ' % str(year_2)) + os.path.join(cwd,
                                                                                                                 'exp2nd/h_results'))

            if  year_2 - year_1 > 1:
                if  t == year_1:
                    sumday = isLeap(t)
                    outfiles7 = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_gamit -expt scal -s %d %d %d  -orbit %s -copt x k p -dopts c ao> sh_gamit.log' % (
                    str(t), t, day_1, sumday, IGS))
                    outfiles = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_glred -s %d %d %d %d -expt scal -opt H G E >&! sh_glred.log' % (
                    str(t), t, day_1, t, sumday))
                    outfiles = commands.getstatusoutput(
                        'cd experiment/%s ; sh_cleanup -s %d %d %d %d -dopts p x k' % (str(t), t, day_1, t, sumday))
                    os.popen('cp ' + os.path.join(cwd, 'experiment/%s/glbf/h*glx ' % str(year_1)) + os.path.join(cwd,
                                                                                                                 'exp2nd/h_results'))
                if  t == year_2:
                    outfiles8 = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_gamit -expt scal -s %d 1 %d  -orbit %s -copt x k p -dopts c ao> sh_gamit.log' % (
                    str(t), t, day_2, IGS))
                    outfiles = commands.getstatusoutput('cd experiment/%s ; \
                                                sh_glred -s %d 1 %d %d -expt scal -opt H G E >&! sh_glred.log' % (
                    str(t), t, t, day_2))
                    outfiles = commands.getstatusoutput(
                        'cd experiment/%s ; sh_cleanup -s %d 1 %d %d-dopts p x k' % (str(t), t, t, day_2))
                    os.popen('cp ' + os.path.join(cwd, 'experiment/%s/glbf/h*glx ' % str(year_2)) + os.path.join(cwd,
                                                                                                                 'exp2nd/h_results'))
                if  t != year_1 and t != year_2:
                    sumday = isLeap(year_2 - 1)

                    log.info(
                        'cd experiment/%s ; sh_gamit -expt scal -s %d 1 %d %d  -orbit %s -copt x k p -dopts c ao> sh_gamit.log' % (
                        str(t), t, t, sumday, IGS))
                    outfiles9 = commands.getstatusoutput('cd experiment/%s ; \
                                                    sh_gamit -expt scal -s %d 1 %d %d  -orbit %s -copt x k p -dopts c ao> sh_gamit.log' % (
                    str(t), t, t, sumday, IGS))
                    outfiles = commands.getstatusoutput('cd experiment/%s ; \
                                                    sh_glred -s %d 1 %d %d -expt scal -opt H G E >&! sh_glred.log' % (
                    str(t), t, t, sumday))
                    outfiles = commands.getstatusoutput(
                        'cd experiment/%s ; sh_cleanup -s %d 1 %d %d -dopts p x k' % (str(t), t, t, sumday))
                    os.popen('cp ' + os.path.join(cwd, 'experiment/%s/glbf/h*glx ' % str(t)) + os.path.join(cwd,
                                                                                                            'exp2nd/h_results'))
        except Exception:
            error += "%s: Error occured when processing by command sh_gamit , sh_glred or sh_cleanup.\n" % datetime.datetime.now()
            log.info(
                "%s: Error occured when processing by command sh_gamit , sh_glred or sh_cleanup.\n" % datetime.datetime.now())
    return error
Exemplo n.º 5
0
def extractFile(start_y,start_d,end_y,end_d):  

    
    filepath = os.path.join(cwd+user,'exp2nd/time_record')+'/timeRecord.txt'
    print filepath
    
    ff = open(filepath,'r')
    lastTime = ff.read()
    ff.close()
    print lastTime,
    
    strStart_d=str(start_d)
    if(len(strStart_d)==1):
        strStart_d='00'+strStart_d
    if(len(strStart_d)==2):
        strStart_d='0'+strStart_d
        
    strEnd_d=str(end_d)
    if(len(strEnd_d)==1):
        strEnd_d='00'+strEnd_d
    if(len(strEnd_d)==2):
        strEnd_d='0'+strEnd_d
        
    startTime = str(start_y)+"."+strStart_d
    print startTime
    endTime = str(end_y)+"."+strEnd_d
    print endTime
    
    if endTime > lastTime:
        if startTime > lastTime: 
           
            start_year = start_y   
            start=start_d
        else:
            tmpStartTime = lastTime.split(".")
            start_year = int(tmpStartTime[0])
            start = int(tmpStartTime[1])+1
            print tmpStartTime
        
        
        end_year = end_y
        end = end_d
        
        
        filedir1=os.path.join(cwd+user,'exp2nd')
        filedir2=os.path.join(cwd+user,'exp2nd/oscala_batch')  #new file
        print 'oscala dir', filedir2
        
        if os.path.isdir(filedir2) == False: 
            os.mkdir(filedir2)
        

        if start_year == end_year:
            file_dir=os.path.join(cwd+user,'experiment/%s' % str(start_year))+'/'  #old file
            print file_dir
            
            for d in range(start,end+1):
                d_str = numberToDay(d)
                goal_dir=file_dir + d_str+'/'
                goal_name = goal_dir+'oscala.'+d_str
                print 'goal_name',goal_name
                if os.path.isfile(goal_name) == True: 
                    cp_cmd = "cp %soscala.%s %s/oscala.%s.%s" % (goal_dir,d_str,filedir2,str(start_year),d_str)
                    print cp_cmd
                    os.popen(cp_cmd)

        
        if  start_year <  end_year:
            for y in range(start_year,end_year+1):
                if(y==start_year):
                    end = isLeap(y)
                elif(y==end_year):  
                    start=1
                else:
                    start=1
                    end = isLeap(y)
                file_dir=os.path.join(cwd+user,'experiment/%s' % str(y))+'/'  #old file
                for d in range(start,end+1):
                    d_str = numberToDay(d)
                    goal_dir=file_dir + d_str+'/'
                    goal_name = goal_dir+'oscala.'+d_str
                    if os.path.isfile(goal_name) == True: 
                        print "goal_name 2"
                        os.popen("cp %s/oscala.%s %s/oscala.%s.%s" % (goal_dir,d_str,filedir2,str(y),d_str))
                    #goal_dir=file_dir+'/'+ d_str+'/'
                    #os.popen("cp %s/oscala.* %s/oscala.%s.%s" % (goal_dir,filedir2,str(y),d_str))
        # 记录最后更新时间,这个不太准确因为万一中间断掉了,因此需要用try、expect写。交给邓家源处理!!!
        
        f = open(filepath,'w')       
        f.write(str(end_y)+"."+strEnd_d)
        f.close()
    else:
        print 'Done!'
Exemplo n.º 6
0
def changeToFraction(y,d):
    sum_day = isLeap(y)
    sum_time = y+float(d)/sum_day
    s_time = '%.5f' % sum_time
    #print s_time
    return s_time