コード例 #1
0
            sad_file = open('./data/' + shrt_name + '_sad.csv', 'r')
            sadreader = csv.reader(sad_file)
            sad = []
            for row in sadreader:
                sad.append(row)

        Amin = min(site_data[ : , 0])
        Amax = max(site_data[ : , 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
    
コード例 #2
0
if os.path.exists('../demo') is False:
    os.mkdir('../demo')

beta = mete.get_beta(S0, N0)

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')