Пример #1
0
def valarray(stream,min_val=-32,increment=0.5,product=94): #Values array for NEXRAD Level 3
    '''Array of reflectivity values (data stream, minimum dBz value, dBZ increment, amount of radials)'''
    dataarray=[]
    radials_count=int(halfw(stream[0:2])) #Get amount of radials
    p=2 #pointer
    for i in xrange(radials_count):
        amt=int(halfw(stream[p:p+2]))
        az=int(halfw(stream[p+2:p+4]))/10.0
        d_az=int(halfw(stream[p+4:p+6]))/10.0
        mindistance=0
        datarow=[]
        p+=6
        if product == 159 or product == 161 or product == 163:
            #If Dual pol products with scale and offset
            #scale=increment
            #offset=min_val
            for j in xrange(p,p+amt):
                val=getbyte(stream[j])
                if val > 1:
                    datarow.append((val-min_val)/increment)
                else:
                    datarow.append(None)
        elif product == 165: #If HCA
            #Override usual decoding system and plot them as numbers
            for j in xrange(p,p+amt):
                val=getbyte(stream[j])
                if val == 0: datarow.append(None)
                elif val > 0 and val < 140: datarow.append(val/10-1)
                elif val >= 140: datarow.append(val/10-4)
        else:
            for j in xrange(p,p+amt):
                val=getbyte(stream[j])
                if val > 1:
                    datarow.append(min_val+increment*(val-2.0))
                else:
                    datarow.append(None)
        dataarray.append([d2r(az),d2r(d_az),datarow,mindistance])
        p+=amt
    return dataarray
Пример #2
0
def headers(data): #LEVEL 3 Headers
    headerinfo=[]
    call=-1
    if data.find('SDUS') <> -1: #Kui failis sisalduvad WMO päised (SDUS*4 TUNNUS(nt. KBMX) DDHHMM(UTC))
        call=data[7:11]
        data=data.replace(data[0:30],"") #Kõrvalda need enne dekodeerimise alustamist
    product=halfw(data[0:2],False)
    headerinfo.append(product) #Product code [0]
    headerinfo.append((halfw(data[2:4],False)*86400-86400)+word(data[4:8],False)) #Timestamp of message [1]
    headerinfo.append(word(data[8:12],False)) #Length of message [2]
    headerinfo.append(halfw(data[12:14],False)) #Source ID [3]
    headerinfo.append(halfw(data[14:16],False)) #Destination ID [4]
    headerinfo.append(halfw(data[16:18],False)) #Number of blocks [5]
    headerinfo.append("%.3f" % float((word(data[20:24]))/1000.0)) #Latitude of radar [6]
    headerinfo.append("%.3f" % float((word(data[24:28]))/1000.0)) #Longitude of radar [7]
    headerinfo.append("%.2f" % float(halfw(data[28:30])*0.3048)) #Radar height [8]
    headerinfo.append(halfw(data[32:34])) #Operational mode [9]
    headerinfo.append(halfw(data[34:36])) #Volume Coverage Pattern [10]
    headerinfo.append(halfw(data[36:38])) #Sequence number [11]
    headerinfo.append(halfw(data[38:40])) #Volume Scan Number [12]
    headerinfo.append(halfw(data[40:42])) #Volume Scan date [13]
    headerinfo.append(word(data[42:46])) #Volume Scan Time [14]
    headerinfo.append(halfw(data[46:48])) #Generation date of product [15]
    headerinfo.append(word(data[48:52])) #Generation time of product [16]
    headerinfo.append("%.1f" % (halfw(data[58:60])/10.0)) #Antenna elevation [17]
    headerinfo.append(float(halfw(data[60:62]))/10) #Minimum data in dbz [18]
    headerinfo.append(float(halfw(data[62:64]))/10) #dbz increment [19]
    headerinfo.append(halfw(data[64:66])) # Amount of levels [20]
    headerinfo.append((headerinfo[15]*86400-86400)+headerinfo[16]) #Produkti loomise aeg [21]
    headerinfo.append((headerinfo[13]*86400-86400)+headerinfo[14]) #Volume Scan time [22]
    headerinfo.append(halfw(data[92:94])) #halfw 47 - min dual pol value [23]
    headerinfo.append(halfw(data[94:96])) #halfw 48 - max dual pol value [24]
    headerinfo.append(1 if product == 94 else 0.25) #Tühi Level 3 andmete korral [25]
    headerinfo.append(halfw(data[70:72])) #halfw 36 [26]
    headerinfo.append(floating(data[60:64])) #halfw 32,34 [27] (dual pol)
    headerinfo.append(floating(data[64:68])) #halfw 34,36 [28] (dual pol)

    print headerinfo
    return headerinfo