X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 07 Feb 2010 09:41 AM by  anon
Converting intger to float for spectral data
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
07 Feb 2010 09:41 AM
    Hi.  I am having trouble with what seems like a very simple problem. I am attempting to write a short program in IDL to process a hyperspectral image (each pixel has 99 bands). I am trying to perform a calculation on my data and I need to get it into a float data type. Once I have isolated the spectra in each pixel using an IF loop, I have tried nspectrum = float(spectrum)*0.001 and nspectrum =float(spectrum)/100000 each time I still get an integer result and just can't seem to figure this out. I would appreciate any help. Thank you. Victoria

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Feb 2010 08:24 AM
    You are doing this correctly. The FLOAT() function does indeed convert the data type to float. I think that perhaps if this is in an IF statement, as you mention, it may not be executing if the criterion in the IF statement is not met. To test the FLOAT() function try something like that below. As you can see, the data type before and after the FLOAT() function is used has changed: IDL> x = indgen(3,3) IDL> help, x X INT = Array[3, 3] IDL> print, x 0 1 2 3 4 5 6 7 8 IDL> newx = float(x) IDL> help, newx NEWX FLOAT = Array[3, 3] IDL> print, newx 0.000000 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 What I think might be going on, again, is that the criterion in the IF statement is not being met. For example, something like this would not convert to float: IDL> x = indgen(3,3) IDL> help, x X INT = Array[3, 3] IDL> criterion = 0 IDL> if criterion eq 1 then newx = float(x) IDL> help, newx NEWX UNDEFINED = Use the HELP statement in your code to debug the issue, to determine what the data type has become, or if it has changed. You may need to place a HELP statement in several places in your code to determine what might be happening. -JE ITT VIS Tech Support : support@ittvis.com
    You are not authorized to post a reply.