# read in SAD information
    sad_file = open('../data/' + shrt_name + '_sad.csv', 'r')
    sadreader = csv.reader(sad_file)
    sad = []
    for row in sadreader:
        sad.append(row)
        
    # get parameters needed for computing the mete sar
    Amin = min(site_data[ : , 0])
    Amax = max(site_data[ : , 0])    
    n0vals = [int(n0) for n0 in sad[0]]
    
    sar_down_iterative = mete.downscale_sar_fixed_abu(Amax, n0vals, Amin)
    Avals = sar_down_iterative[0][ : ]
    
    sar_down_noniterative = mete.sar_noniterative_fixed_abu(Avals, Amax, n0vals)

    # Make an array so that the data is easier to output
    out = np.empty((len(sar_down_iterative[0]), 3)) 
    for i in range(0, 2):
        out[ : , i] = sar_down_iterative[i] 
    
    out[ : , 2] = sar_down_noniterative[1]
    
    filename = '../sar/' + shrt_name + '_empirSAD_mete_sar.txt'
    writer = open(filename, 'wb') 
    datawriter = csv.writer(writer)
    datawriter.writerow(['area', 'sr_iter', 'sr_noniter'])
    for i in range(0, np.shape(out)[0]):
        datawriter.writerow(out[i, ])
    
Ejemplo n.º 2
0
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, ])

writer.close()