2017-03-01 59 views
0

如何在IDL中用newton方法得到方程的解,我的程序將提供各種(在這裏的方塊),但牛頓方法ID IDL只是收回方程的初始解。請幫助我的論文進行遙感圖像處理。IDL方程的解決方案

我的IDL程序是:

Pro TSM_lixiaModel 
!Except=0 
Compile_opt idl2 
dir='I:\lwkDATA\waterRegion\MODIS\' 
files=file_search(dir,'*RC.tif',count=num) 
for i=0,num-1 do begin 
file=files[i] 
    raster=e.Openraster(file,external_type='ADS40') 
    outFile=file_dirname(file)+'\'+file_basename(file,'.tif')$ 
    +'_TSM_lixiaModel.tif' 


TSMraster=enviraster(uri=outfile,$ 
     nrows=raster.nrows,$ 
     ncolumns=raster.ncolumns,$ 
     nbands=1,$ 
     data_type=raster.data_type,$ 
     SPATIALREF=raster.SPATIALREF) 
tileIterator=raster.createtileiterator(bands=2,tile_size=[100,100]) 
count=0 
foreach tile,tileiterator do begin 
    count++ 

    ***;Tile is variable, but not the needed Solution of the equation 
    ;S is needed Solution of the equation 
    ;????? is the initially solution of the ‘newtfunc’,how do i give the  various(Tile) to newtfunc*** 

    processedTile=newton(??????,'newtfunc'); 

    currentSubRect=tileIterator.Current_subrect 
    TSMraster.setdata,processedTile,sub_rect=currentsubrect 
    print,'1' 
endforeach 
TSMraster.save 
endfor 
End 

function newtfunc,S 
    compile_opt idl2 
    return,(r-93.0943)*S+49.2464*S*exp(-0.0001*S)-344.016+45*r 
end 

回答

0

我不完全理解你的代碼,但也許你只需要使用上ENVIRaster GetData方法? 例如:

data = raster.GetData(BANDS=[0], SUB_RECT=[100,449,550,899]) 

然後,您可以將您的數據傳遞到牛頓函數。 完整的文檔是在這裏: https://www.harrisgeospatial.com/docs/enviraster__getdata.html

順便說一句,在一個相關的說明,如果你需要將其他參數傳遞到牛頓的功能,一招是使用公共塊,在這裏建立了共同的在你的調用例程中阻塞,然後訪問你的「newtfunc」中的變量。例如:

pro mymain 
    common foo, x, y, z 
    x=1 & y=1 & z=1 
    result = newton(...,'newtfunc') 
end 

function newtfunc,S 
    common foo 
    <use x,y,z here> 
    return,... 
end 

希望這可以幫助一些!如果不是,您可以聯繫技術支持。

+0

謝謝。函數包括R和S,牛頓方法剛開始需要S,那麼牛頓方法就會計算出真實的S.但是在這裏,我需要先給出S和各種R,R需要用牛頓法來計算。那我的麻煩 –