示例#1
0
        if sadType == 'meteSAD':
            S0 = int(max(site_data[ : , 1]))
            N0 = int(max(site_data[ : , 2]))
        else:
            n0vals = [int(n0) for n0 in sad[0]]

        if sadType == 'meteSAD':
            sar_down_iterative = mete.downscale_sar(Amax, S0, N0, Amin)
        else:
            sar_down_iterative = mete.downscale_sar_fixed_abu(Amax, n0vals, Amin)
            
        Avals = sar_down_iterative[0][ : ]
        
        try:
            if sadType == 'meteSAD':
                sar_down_noniterative = mete.sar_noniterative(Avals, Amax, S0, N0, 'precise')
            else:
                sar_down_noniterative = mete.sar_noniterative_fixed_abu(Avals, Amax, n0vals)
            sar_noniterative_worked = True
        except ValueError:
            print "Downscaling non-iterative SAR failed"
            sar_noniterative_worked = False
    
        if sadType == 'meteSAD':
            # add values at Amax
            sar_down_iterative[0].append(Amax)
            sar_down_iterative[1].append(S0)

        # Make an array so that the data is easier to output
        if sar_noniterative_worked:    
            out = np.empty((len(sar_down_iterative[0]), 3)) 
示例#2
0
n0 = mete.trunc_logser_rvs(exp(-beta), N0, S0)
n0 = list(n0)
n0 = [int(x) for x in n0]
n0.sort(reverse=True)

rad = mete.get_mete_rad(S0, N0)[0]

Amax = 4
Amin = 1

recur = mete.downscale_sar(Amax, S0, N0, Amin)
recur_obsSAD = mete.downscale_sar_fixed_abu(Amax, n0, Amin)

Avals = recur_obsSAD[0][ : ]

nonrecur = mete.sar_noniterative(Avals, Amax, S0, N0, 'precise')
nonrecur_obsSAD = mete.sar_noniterative_fixed_abu(Avals, Amax, n0)

sad_out = np.empty((S0, 2)) 

sad_out[ : , 0] = n0
sad_out[ : , 1] = rad

filename = '../demo/' + 'abu_sar_demo.txt'

writer = open(filename, 'wb') 
datawriter = csv.writer(writer)
datawriter.writerow(['n0', 'sad'])
for i in range(0, np.shape(sad_out)[0]):
    datawriter.writerow(sad_out[i, ])