Changeset 15

Show
Ignore:
Timestamp:
12/13/11 17:56:51
Author:
cbc
Message:

Refined current statistics check.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • virtexp/trunk/virtexp/tests/currents/currents.py

    r14 r15  
    55import re 
    66 
    7 log_pattern = "/var/opt/gmc/gliders/ramses/logs/ramses_network_20111213*.log" 
     7log_patterns = ["/var/opt/gmc/gliders/ramses/logs/ramses_network_20111213*.log", 
     8                "/var/opt/gmc/gliders/ramses/logs/ramses_network_20111212*.log", 
     9                "/var/opt/gmc/gliders/ramses/logs/ramses_network_20111211*.log", 
     10               ] 
    811stamp_pattern = re.compile("ramses_network_(\w+)") 
    9 vx_pattern = re.compile("m_water_vx\(m/s\)=(\S+)") 
    10 vy_pattern = re.compile("m_water_vy\(m/s\)=(\S+)") 
     12vx_pattern = re.compile("m_water_vx\(m/s\)=(\S+)\s+(\S+) secs ago") 
     13vy_pattern = re.compile("m_water_vy\(m/s\)=(\S+)\s+(\S+) secs ago") 
     14invalid_lapse = "1e+308" 
    1115 
    1216isNorth = lambda phi: (phi >= (3*cmath.pi/8))  and (phi <= (5*cmath.pi/8)) 
     
    2125                      ((phi <= 0) and (phi <=  (-7*cmath.pi/8))) 
    2226 
    23  
    24 logs = glob(log_pattern) 
     27logs = [] 
     28for log_pattern in log_patterns: 
     29    logs.extend(glob(log_pattern)) 
    2530logs.sort() 
    2631logs.reverse() 
     
    3742        match = vx_pattern.search(line0) 
    3843        if match: 
    39             vx = match.groups()[0] 
     44            vx,lapse = match.groups() 
     45            if lapse == invalid_lapse: 
     46                continue 
    4047            match = vy_pattern.search(line1) 
    4148            if match: 
    42                 vy = match.groups()[0] 
     49                vy,lapse = match.groups() 
     50                if lapse == invalid_lapse: 
     51                    continue 
    4352                currents.append((stamp,complex(float(vx),float(vy)))) 
    4453                break 
     
    5766NW = [stamp for stamp,current in currents if isNWest(current[1])] 
    5867 
    59 print "Number of surfacings:",len(currents) 
     68print "Number of surfacings with valid vx,vy:",len(currents) 
    6069print "Current distribution:" 
    61 print "North:     %s%%" % (float(len(N))/len(currents)) 
    62 print "Northeast: %s%%" % (float(len(NE))/len(currents)) 
    63 print "East:      %s%%" % (float(len(E))/len(currents)) 
    64 print "Southeast: %s%%" % (float(len(SE))/len(currents)) 
    65 print "South:     %s%%" % (float(len(S))/len(currents)) 
    66 print "Southwest: %s%%" % (float(len(SW))/len(currents)) 
    67 print "West:      %s%%" % (float(len(W))/len(currents)) 
    68 print "Northwest: %s%%" % (float(len(NW))/len(currents)) 
     70print "North:     %.2f%%" % (float(len(N))/len(currents)) 
     71print "Northeast: %.2f%%" % (float(len(NE))/len(currents)) 
     72print "East:      %.2f%%" % (float(len(E))/len(currents)) 
     73print "Southeast: %.2f%%" % (float(len(SE))/len(currents)) 
     74print "South:     %.2f%%" % (float(len(S))/len(currents)) 
     75print "Southwest: %.2f%%" % (float(len(SW))/len(currents)) 
     76print "West:      %.2f%%" % (float(len(W))/len(currents)) 
     77print "Northwest: %.2f%%" % (float(len(NW))/len(currents)) 
    6978print 
    7079print "Cartesian currents:"