X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 11 Jul 2006 01:52 PM by  anon
IDL Curve fitting
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
11 Jul 2006 01:52 PM
    Please help. Below is a script which is supposed to call some curve fitting function. However when I try to run it , it gives me the following errors: Reading file: D:\Processing\Data\avoncasi1.bin Compiled module: READ_BINARY. READ_BINARY: READU: Error encountered reading from file. Unit: 100, File: D:\Mphil2006\Processing\Data\avoncasi1.bin Error occurred at: READ_BINARY 132 D:\Processing\IDL\read_binary.pro GAUSSIAN_GAUSS_FIT 9 D:\Processing\IDL\gaussian_gauss_fit.pro $MAIN$ Execution halted at: GAUSSIAN_GAUSS_FIT 9 D:\Processing\IDL\gaussian_gauss_fit.pro _________________________________________________________________________ PRO GAUSS_gauss_FIT imageSize=[15,400,350] imagecoefSize=[6,400,350] filestr2 = '~Processing\Data\avoncasi1.bin' PRINT, 'Reading file: ' + filestr2 OPENR, 1, filestr2 image1 = READ_BINARY(filestr1, DATA_TYPE=1, DATA_DIMS=imageSize) CLOSE, 1 nx = 15 ;Size of array ny = 1 imagecoeff = FLTARR(imagecoefSize) X=[450.,490.,552.,608.,647.,670.,700.,710.,740.,750.,762.,780.,820.,865.,942.] ;P = [ 5., 10., nx/6., ny/10., nx/2., .6*ny] ;Input function parameters A = [ 5., 10., nx/6., ny/10., nx/2., .6*ny] FOR line=0, 400 DO BEGIN FOR pixel=0, 350 DO BEGIN y = REFORM(image1[*,pixel,line]) ;extract all bands for one pixel yfit = MPFITPEAK(X, Y, A, NTERMS=6) ;yfit = gaussfit(x,y,a) ;Fit the function, no rotation print, 'pixel ',string(pixel),', line', string(line) print,'channels:',string(y,format='(6f10.4)') ;Report results.. print,'coefficients: :',string(a(0:5),format='(6f10.4)') imagecoeff[*,pixel,line] = a(0:5) ENDFOR ENDFOR filestr1 = '~Processing\Data\GaussCoeffnts.bin' PRINT, 'Writing binary floating point output file: ' + filestr1 OPENW, 1, filestr2 WRITEU, 1, imagecoeff CLOSE, 1 END

    Deleted User



    New Member


    Posts:
    New Member


    --
    11 Jul 2006 01:52 PM
    READ_BINARY does not need an OPENR call; that file opening functionality is implicit in READ_BINARY. My guess is that your preceding OPENR call is locking down the data file and disabling READ_BINARY from opening it. For debugging purposes, try two things: 1) Get rid of the OPENR and CLOSE calls surrounding READ_BINARY and try again. 2) Keep the OPENR and CLOSE, and get rid of the READ_BINARY call. Replace READ_BINARY with: image1 = bytarr(imageSize) readu, 1, image1 The structure of data in your file sounds so simple that READU is as good a tool as READ_BINARY for "parsing" it. James Jones
    You are not authorized to post a reply.