Re: correct way to use INTERPOLATE function [message #55972 is a reply to message #55968] |
Fri, 21 September 2007 14:35   |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
R.G. Stockwell wrote:
> "Ryan." <rchughes@gmail.com> wrote in message
> news:1190408773.723336.302670@o80g2000hse.googlegroups.com.. .
>>> Is that waht you are trying to do?
>>
>> Thanks Paolo and David. That's not what I wanted to do but it did
>> help me out to produce the plot I want. I want to create a smallarray
>> vs. largearray plot but If I just tried to plot it, IDL will do what
>> it does best and plot only the first N_ELEMENTS(smallarray) points.
>> The code that I did come up with is as follows (It is very close to
>> what Paolo had):
>>
>> l = FINDGEN(100)*0.5
>> s = [10.3, 9.6, 9.2, 8.5, 7.7, 6.9, 5.8, 5.4, 4.7, 4.1]
>> ns = N_ELEMENTS(s)
>> nl = N_ELEMENTS(l)
>>
>> x = FINDGEN(ns)/(ns-1)
>> x2 = FINDGEN(nl)/nl
>>
>> z = INTERPOL(s, x, x2)
>>
>> PLOT, z, l, PSYM=-6
>
>
> Hi Ryan,
>
> I took a quick glance, and for the life of me i can't figure out
> what it is that you really want to do. You are plotting the
> "l" array here as a function of your "z" (which is
> based on your original "s"). I don't think that means
> anything.
Maybe I know what's happening here...
Let's assume you have a low-resolution circle
given by x1 and y1 coordinates:
n=10
t1=findgen(n)/(n-1)*!Pi*2
x1=sin(t1)
y1=cos(t1)
and a high resolution circle given by x2 and y2
n=64
t2=findgen(n)/(n-1)*!Pi*2
x2=sin(t2)
y2=cos(t2)
Then, assume that for some reason you have
access to x1 and to y2 and not to x2, and you
want to try to plot the best possible approximation
of the high-res circle. Then one may need to
do something like:
xx2=interpol(x1,t1,t2)
and plotting (xx2,y2) is an approximation
to the circle (of course, in such a case,
use of the /spline keyword to interpol may
make the plot nicer).
So, this may be something along the line
of what the OP is doing...
Ciao,
Paolo
>
> I assume you have a watered down example of your
> original problem, but it just seems like
> 1) you have it backwards (i.e. you want to plot
>> plot l,z
>
> and 2)
> you probably shouldn't be doing that in the first place.
>
> My point would be that the elements of "s" should have some
> ordinate related to them. Select the proper ordinate to pair with
> the "s"es and just plot that.
>
> Or if you need to interpolate, then interpolate both in the exact
> same way.
>
> Cheers,
> bob
|
|
|