the solution of equation with IDL

270 Views Asked by At

how do i get the solution of equation with newton method in IDL,my procedure will provide the various( tile in here),but the newton method id IDL just recive the initially solution of equation. please help me for my thesis for remote sensing image processing.

My IDL procedure is:

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
1

There are 1 best solutions below

1
On

I don't fully understand your code, but perhaps you just need to use the GetData method on ENVIRaster? For example:

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

Then you could pass your data into the Newton function. The complete docs are here: https://www.harrisgeospatial.com/docs/enviraster__getdata.html

By the way, on a related note, if you ever need to pass additional parameters into the Newton function, one trick is to use a common block, where you set up the common block in your calling routine, and then access the variables within your "newtfunc". Something like:

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

Hope some of this helps! If not, you might contact Tech Support.