00001
00002 """
00003 Created on Tue Nov 1 18:57:30 2011
00004
00005 @author: Sat Kumar Tomer
00006 @website: www.ambhas.com
00007 @email: satkumartomer@gmail.com
00008
00009 http://nowlin.css.msu.edu/software/triangle_form.html
00010 http://ag.arizona.edu/research/rosetta/rosetta.html#download
00011
00012 """
00013 import matplotlib.nxutils as nx
00014 import numpy as np
00015
00016
00017 class soil_texture:
00018 """
00019 Input:
00020 sand
00021 clay
00022 output:
00023
00024 """
00025 def __init__(self, sand, clay):
00026 self.sand = sand
00027 self.clay = clay
00028
00029
00030 soil_names = ['silty_loam', 'sand', 'silty_clay_loam', 'loam', 'clay_loam',
00031 'sandy_loam', 'silty_clay', 'sandy_clay_loam', 'loamy_sand ',
00032 'clay', 'silt', 'sandy_clay']
00033
00034
00035 t0 = np.array([ [0,12], [0,27], [23,27], [50,0], [20,0], [8,12]], float)
00036 t1 = np.array([ [85,0], [90,10], [100,0]], float)
00037 t2 = np.array([ [0,27], [0,40], [20,40], [20,27]], float)
00038 t3 = np.array([ [43,7], [23,27], [45,27], [52,20], [52,7]], float)
00039 t4 = np.array([ [20,27], [20,40], [45,40], [45,27]], float)
00040 t5 = np.array([ [50,0], [43,7], [52,7], [52,20], [80,20], [85,15], [70,0]], float)
00041 t6 = np.array([ [0,40], [0,60], [20,40]], float)
00042 t7 = np.array([ [52,20], [45,27], [45,35], [65,35], [80,20]], float)
00043 t8 = np.array([ [70,0], [85,15], [90,10], [85,0]], float)
00044 t9 = np.array([ [20,40], [0,60], [0,100], [45,55], [45,40]], float)
00045 t10 = np.array([ [0,0], [0,12], [8,12], [20,0]], float)
00046 t11 = np.array([ [45,35], [45,55], [65,35]], float)
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 shp = [[330, 0.065, 0.073, 0.439, 0.093, -2.296, 0.57, 0.221, 0.14, 1.261, 0.74, 0.243, 0.26, 0.365, 1.42],
00059 [308, 0.053, 0.029, 0.375, 0.055, -1.453, 0.25, 0.502, 0.18, 2.808, 0.59, 1.389, 0.24, -0.930, 0.49],
00060 [172, 0.090, 0.082, 0.482, 0.086, -2.076, 0.59, 0.182, 0.13, 1.046, 0.76, 0.349, 0.26, -0.156, 1.23],
00061 [242, 0.061, 0.073, 0.399, 0.098, -1.954, 0.73, 0.168, 0.13, 1.081, 0.92, 0.568, 0.21, -0.371, 0.84],
00062 [140, 0.079, 0.076, 0.442, 0.079, -1.801, 0.69, 0.151, 0.12, 0.913, 1.09, 0.699, 0.23, -0.763, 0.90],
00063 [476, 0.039, 0.054, 0.387, 0.085, -1.574, 0.56, 0.161, 0.11, 1.583, 0.66, 1.190, 0.21, -0.861, 0.73],
00064 [28, 0.111, 0.119, 0.481, 0.080, -1.790, 0.64, 0.121, 0.10, 0.983, 0.57, 0.501, 0.27, -1.287, 1.23],
00065 [87, 0.063, 0.078, 0.384, 0.061, -1.676, 0.71, 0.124, 0.12, 1.120, 0.85, 0.841, 0.24, -1.280, 0.99],
00066 [201, 0.049, 0.042, 0.390, 0.070, -1.459, 0.47, 0.242, 0.16, 2.022, 0.64, 1.386, 0.24, -0.874, 0.59],
00067 [84, 0.098, 0.107, 0.459, 0.079, -1.825, 0.68, 0.098, 0.07, 1.169, 0.92, 0.472, 0.26, 1.561, 1.39],
00068 [6, 0.050, 0.041, 0.489, 0.078, -2.182, 0.30, 0.225, 0.13, 1.641, 0.27, 0.524, 0.32, 0.624, 1.57],
00069 [11, 0.117, 0.114, 0.385, 0.046, -1.476, 0.57, 0.082, 0.06, 1.055, 0.89, 0.637, 0.34, -3.665, 1.80]]
00070
00071 for i in range(12):
00072 exec("if nx.pnpoly(sand, clay, t0):tt=i").replace('0',str(i))
00073
00074 if sand+clay<100:
00075 self.soil_type = soil_names[tt]
00076 self.theta_r = shp[tt][1]
00077 self.theta_s = shp[tt][3]
00078 self.alpha = 10**shp[tt][5]*100
00079 self.n = 10**shp[tt][7]
00080 self.ks= np.exp(shp[tt][9])/100/86400
00081 self.l= shp[tt][13]
00082 else:
00083 print("sand+clay is more than 100 percent")
00084 self.soil_type = np.nan
00085 self.theta_r = np.nan
00086 self.theta_s = np.nan
00087 self.alpha = np.nan
00088 self.n = np.nan
00089 self.ks= np.nan
00090 self.l= np.nan