comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Having trouble with code for data to image.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Having trouble with code for data to image. [message #64104 is a reply to message #63985] Wed, 26 November 2008 12:40 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
mbwel...@gmail.com wrote:
> On Nov 26, 5:09�am, Jeremy Bailin <astroco...@gmail.com> wrote:
>> On Nov 26, 7:37�am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
>> wrote:
>>
>>
>>
>>> mbwel...@gmail.com wrote:
>>>> Hello,
>>
>>>> I am running the code:
>>
>>>> image = fltarr(nx,ny)
>>>> deltax = (xrange[1]-xrange[0])/float(nx)
>>>> deltay = (yrange[1]-yrange[0])/float(ny)
>>>> for i=0l,ndata-1 do $
>>>> � image[(left[i]-xrange[0])/deltax:(right[i]-xrange[0])/deltax , $
>>>> � � (bottom[i]-yrange[0])/deltay:(top[i]-yrange[0])/deltay] =
>>>> magnitude
>>>> [i]
>>
>>>> where: �nx=ny=180
>>>> xrange= [-180,0]
>>>> yrange = [-90,90]
>>>> ndata = 32400 � ( or180^2 or nx*ny)
>>>> eg left -180
>>>> � � right -179
>>>> � � top 90
>>>> � � bottom 89
>>>> � � magnitude 0.1648
>>
>>>> and i get the error when I run the code:
>>
>>>> % Subscript range values of the form low:high must be >= 0, < size,
>>>> with low <= high: IMAGE
>>
>>>> I assume the problem is in the way that my data is ordered, and I have
>>>> tried switching lows and highs around, but to no avail. I would
>>>> imagine this is pretty simple to solve, but it is not clear to me
>>>> right now.
>>
>>>> Any insight?
>>
>>>> Thanks,
>>
>>>> ~Matt
>>
>>> Hi,
>>> with the data you provide, you are out of bounds...
>>> (bottom[i]-yrange[0])/deltay:(top[i]-yrange[0])/deltay] ==> 179:180
>>> ... 180 is out of bound. Remember that indexing is from 0 to n-1. You
>>> might want to throw a -1 in your indexes...
>>> As Chris has suggested it, print your indexes and be sure they are correct!
>>
>>> Jean
>>
>> That looks distinctly like code I suggested. ;-)
>>
>> Yes, Jean is exactly right - there should be -1 in both the "top" and
>> "right" part of the indexing, i.e. replace the current line with:
>>
>> � �image[(left[i]-xrange[0])/deltax:(right[i]-xrange[0])/del tax-1, $
>> � � �(bottom[i]-yrange[0])/deltay:(top[i]-yrange[0])/deltay-1] =
>> magnitude[i]
>>
>> Sorry about that!
>>
>> -Jeremy.
>
>
> That fixed the problem! Thank you all for your help; However, as these
> things often go, I have a new problem.
>
> In trying to run:
>
> erase
> loadct, 10 ; or whatever you want - the Brewer tables would probably
> be useful
> location = [0.1,0.1,0.9,0.9]
> tvimage, bytscl(image,top=250)+4, position=location
> plot, /noerase, /nodata, [0],[0], position=location, xrange=xrange,
> yrange=yrange
>
> I get an error that I don't quite understand (probably my relative
> inexperience) with:
>
> tvimage, bytscl(image,top=250)+4, position=location
>
> Erase, Color=FSC_Color(background, BREWER=brewer)
> ^
> % Syntax error.
> At: G:\Mars_tectonics\IDL_programs\tvimage.pro, Line 662
>
> IF Size(acolor, /TNAME) EQ 'STRING' THEN acolor = FSC_COLOR
> (acolor, BREWER=brewer)

Is that in one or two lines in your file? If on two, remove
the line break.

Paolo

>
> ^
> % Syntax error.
> At: G:\Mars_tectonics\IDL_programs\tvimage.pro, Line 995
> % Compiled module: TVIMAGE.
> % Attempt to call undefined procedure/function: 'TVIMAGE'.
> % Execution halted at: $MAIN$
>
>
>
> Is this a problem within TVImage, or something I failed to do
> correctly?
>
> And Jeremy the code should look familiar ;)
> Thanks again for you help
>
> ~Matt
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Memory allocation problem
Next Topic: Re: inverse gradient

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 00:58:21 PDT 2025

Total time taken to generate the page: 0.39359 seconds