コード例 #1
0
ファイル: sm_sim.py プロジェクト: sadeghst/geolearn
caseLst = [
    '080305', '090301', '090303', '090401', '090402', '100105', '100204'
]
caseLabLst = ['8.3.5', '9.3.1', '9.3.3', '9.4.1', '9.4.2', '10.1.5', '10.2.4']
saveFolder = r'C:\Users\geofk\work\paper\SMAP-regional'
matplotlib.rcParams.update({'font.size': 16})
matplotlib.rcParams.update({'lines.linewidth': 2})
matplotlib.rcParams.update({'lines.markersize': 10})

# test
tRange = [20160401, 20180401]
subsetPattern = 'ecoReg_{}_L{}_v2f1'
levLst = [3, 2, 1, 0]
rootDB = pathSMAP['DB_L3_NA']
dfC = dbCsv.DataframeCsv(rootDB=rootDB, subset='CONUSv2f1', tRange=tRange)
latC, lonC = dfC.getGeo()

errLstAll = list()
for case in caseLst:
    testName = subsetPattern.format(case, 3)
    errLst = list()
    for k in levLst:
        if k in [0, 1]:
            subset = 'ecoReg_{}_L{}_v2f1'.format(case, k)
        else:
            subset = subsetPattern.format(case, k)
        outName = subset + '_Forcing'
        out = os.path.join(pathSMAP['Out_L3_NA'], 'ecoRegionCase', outName)
        df, yp, yt = master.test(out, tRange=tRange, subset=testName)
        err = stat.statError(yp[:, :, 0], yt[:, :, 0])
コード例 #2
0
ファイル: checkEcoRegion1.py プロジェクト: sadeghst/geolearn
shape = shapeLst[ecoIdLst.index(ecoId)]
mm = Basemap(llcrnrlat=25,
             urcrnrlat=50,
             llcrnrlon=-125,
             urcrnrlon=-65,
             projection='cyl',
             resolution='c',
             ax=ax)
mm.drawcoastlines()
crd = np.array(shape.points)
par = list(shape.parts)
par.append(len(crd))
if len(par) > 1:
    for k in range(0, len(par) - 1):
        # for k in range(0, 2):
        x = crd[par[k]:par[k + 1], 0]
        y = crd[par[k]:par[k + 1], 1]
        mm.plot(x, y, color='r', linewidth=2)

subsetFile = r'D:\rnnSMAP\Database_SMAPgrid\Daily_L3_NA\Subset\ecoRegion{:02d}_v2f1.csv'.format(
    ecoId)
# read database crd
rootDB = hydroDL.pathSMAP['DB_L3_NA']
tRange = [20150401, 20160401]
df = dbCsv.DataframeCsv(rootDB=rootDB,
                        subset='ecoRegion{:02d}_v2f1'.format(ecoId),
                        tRange=tRange)
lat, lon = df.getGeo()

mm.plot(lon, lat, '*b')
fig.show()
コード例 #3
0
import time
import csv

# read shapefile
# fileEcoShp = r'C:\Users\geofk\work\map\ecoRegion\NA_CEC_Eco_Level3\NA_CEC_Eco_Level3_Project.shp'
fileEcoShp = '/mnt/sdb/Kuai/map/ecoRegion/NA_CEC_Eco_Level3/NA_CEC_Eco_Level3_Project.shp'
shapeLst = shapefile.Reader(fileEcoShp).shapes()
shapeRecLst = shapefile.Reader(fileEcoShp).records()
codeLstTemp = [x['NA_L3CODE'].split('.') for x in shapeRecLst]
codeLst = [[x[0] for x in codeLstTemp], [x[1] for x in codeLstTemp],
           [x[2] for x in codeLstTemp]]

# read database crd
rootDB = hydroDL.pathSMAP['DB_L3_NA']
tRange = [20150401, 20160401]
df = dbCsv.DataframeCsv(rootDB=rootDB, subset='CONUS', tRange=tRange)
lat, lon = df.getGeo()

# calculate inside poligon
# indLst=gis.pointInPoly(lat,lon,shapeLst)
# df.saveDataConst(indLst, 'ecoShapeInd', bWriteStat=True)
indLst = df.getDataConst('ecoShapeInd').squeeze().astype(int).tolist()
shapeCodeLst = [shapeRecLst[x]['NA_L3CODE'].split('.') for x in indLst]
for k in range(3):
    data = [int(x[k]) for x in shapeCodeLst]
    # df.saveDataConst(data, 'ecoRegionL'+str(k+1), bCalStat=False)

# subset
fieldLst = ['ecoRegionL' + str(x + 1) for x in range(3)]
codeLst = df.getDataConst(fieldLst, doNorm=False, rmNan=False)
dataGrid, uy, ux = grid.array2grid(codeLst[0], lat=lat, lon=lon)