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

Home » Public Forums » archive » Re: why do not the results agree?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: why do not the results agree? [message #43577] Thu, 21 April 2005 07:46
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
lixiaoyao wrote:
> thank you so much.this time IDL give me the correct answer. Can you
> kindly explain to me what is the the normalized coordinates.
> Thank you so much
>

Normalized coordinates go from 0 to 1 in each direction, i.e. the lower
right corner of the window has the normalized coordinates (1., 0.).

Device coordinates are pixels. In a window 256 by 256 pixels large, the
lower right corner has the device coordinates (255, 0) (count from
zero). On the postscript device, you don't want to use device
coordinates because the depend on resolution.

Data coordinates refer to a plot coordinate system. If you have a line
plot and the axis ranges are (0, 100) and (0, 50) in X and Y, the center
position of the plot frame (not the window!) has data coordinates (50,
25). The conversion to / from data coordinates of course depends on the
position of the plot frame in the window, which is stored in some system
variables (!x, !y, !z, I believe).

Many plot routines take keywords /NORM, /DEVICE or /DATA to specify
which coordinates you want to work with.

Have a look at the help entry for CONVERT_COORD and other entries under
"coordinate(s)" in the help index.

Benjamin
Re: why do not the results agree? [message #43578 is a reply to message #43577] Thu, 21 April 2005 07:43 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lixiaoyao writes:

> what is the seven programming mysteries the IDL programmer
> must discover on his own?
> I will buy a IDL book.heihei

Now, *there's* a good idea! I'd be sure to read it, too. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: why do not the results agree? [message #43579 is a reply to message #43578] Thu, 21 April 2005 07:38 Go to previous message
lixiaoyao is currently offline  lixiaoyao
Messages: 49
Registered: April 2005
Member
what is the seven programming mysteries the IDL programmer
must discover on his own?
I will buy a IDL book.heihei
Re: why do not the results agree? [message #43580 is a reply to message #43579] Thu, 21 April 2005 07:32 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lixiaoyao writes:

> thank you so much.this time IDL give me the correct answer. Can you
> kindly explain to me what is the the normalized coordinates.

No, it is one of the seven Programming Mysteries the IDL programmer
must discover on his own. :-)

Cheers,

David

P.S. Let's just say in your case there might be more than seven,
but that will get you started anyway. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: why do not the results agree? [message #43581 is a reply to message #43580] Thu, 21 April 2005 07:23 Go to previous message
lixiaoyao is currently offline  lixiaoyao
Messages: 49
Registered: April 2005
Member
thank you so much.this time IDL give me the correct answer. Can you
kindly explain to me what is the the normalized coordinates.
Thank you so much
Re: why do not the results agree? [message #43585 is a reply to message #43581] Thu, 21 April 2005 05:49 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"lixiaoyao" <lixiaoyao5880@yahoo.com> writes:
> Dear David
> You are right,when you plot it,it is the same.but the problem is when
> I output the xy data to the file.and plot it again,it give the wrong
> data just like I send to you.

Li Xi--

I believe the problem is that you are working in "normal" coordinates.
These coordinates depend on how the coordinate system of the plot is
set up. For example, the presence of axis labels (or not) will change
the normal coordinates of the same data point, since the view window
shifts to accomodate the labels.

The problem is that in your two different calls, you are using
different font and title options.

Compare:
> contour,R,x,y,levels=[0.6,0.7,0.8,0.892521,1.0,1.1,1.2],c_la bels=[1,1,1,1,1,1,1],xtitle='Dimensionless Radius',ytitle='Mach number',title='Isothermal case'

to:

> contour,R,x,y,level=[0.892521],path_xy=xy,path_info=info,clo sed=0,/path_double

Note the missing *TITLE options.

You can either be sure the second call is a duplicate of the first, or
use "data" coordinates instead of "normal" coordinates (see
PATH_DATA).

Good luck,
CM
Re: why do not the results agree? [message #43586 is a reply to message #43585] Thu, 21 April 2005 05:45 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lixiaoyao writes:

> You are right,when you plot it,it is the same.but the problem is when
> I output the xy data to the file.and plot it again,it give the wrong
> data just like I send to you.
> contour,R,x,y,level=[0.892521],path_xy=xy,$
> path_info=info,closed=0,/path_double
> for I=0,(N_ELEMENTS(info)-1) DO BEGIN
> S=[INDGEN(info(I).N),0]
> print,xy(*,INFO(I).OFFSET+S)
> the proble is in there,when I copy this to a data file,it is the
> wrong result?
>
> plots,xy(*,INFO(I).OFFSET+S),/norm, color=1, linestyle=2
> endfor
> thank you for your help

It's still raining here, so I can't get out in the garden...

It is not clear to me what you think is "wrong" about it.
A contour line is a series of XY points in space. That's
what this line is. It describes a particular contour
in your data space. It is absolutely correct.

Perhaps you want the XY points in data coordinates,
rather than the normalized coordinates that you have.
If so, just set up your data coordinate space and
convert these coordinates to it. They are in normalized
coordinates space to make the transformation to any
coordinate system you like easy for you. Use Convert_Coord
to do the transformation *after* you have established
your data coordinate system (I.e., after you have
issued the CONTOUR command).

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: why do not the results agree? [message #43593 is a reply to message #43586] Wed, 20 April 2005 20:30 Go to previous message
lixiaoyao is currently offline  lixiaoyao
Messages: 49
Registered: April 2005
Member
Dear David
You are right,when you plot it,it is the same.but the problem is when
I output the xy data to the file.and plot it again,it give the wrong
data just like I send to you.
contour,R,x,y,level=[0.892521],path_xy=xy,$
path_info=info,closed=0,/path_double
for I=0,(N_ELEMENTS(info)-1) DO BEGIN
S=[INDGEN(info(I).N),0]
print,xy(*,INFO(I).OFFSET+S)
the proble is in there,when I copy this to a data file,it is the
wrong result?

plots,xy(*,INFO(I).OFFSET+S),/norm, color=1, linestyle=2
endfor
thank you for your help
Re: why do not the results agree? [message #43594 is a reply to message #43593] Wed, 20 April 2005 20:14 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lixiaoyao writes:

> Are you aware the in the two cases,the cross(intersection point) are
> not same.in the case one,the intersection point is in (0.5,1),this is
> right.but in the second case,the intersection is in about(0.28,0.42),I
> do not think this is correct. DO I have something
> wrong there?

I don't know what you mean by the "intersection", but
are you aware that if you run the program I wrote you and
overlay the second plot on the first that the lines
overlap *exactly*. I would say that makes them the same
line.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: why do not the results agree? [message #43595 is a reply to message #43594] Wed, 20 April 2005 19:55 Go to previous message
lixiaoyao is currently offline  lixiaoyao
Messages: 49
Registered: April 2005
Member
Dear David
Are you aware the in the two cases,the cross(intersection point) are
not same.in the case one,the intersection point is in (0.5,1),this is
right.but in the second case,the intersection is in about(0.28,0.42),I
do not think this is correct. DO I have something
wrong there?
Thanks a lot
Re: why do not the results agree? [message #43598 is a reply to message #43595] Wed, 20 April 2005 19:00 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning wrote:
> I'm pretty sure it is *exactly* the same. :-)
>
> Cheers,
>
> David

So, David, what does it feel like to be retired?



--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: why do not the results agree? [message #43600 is a reply to message #43598] Wed, 20 April 2005 18:58 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lixiaoyao writes:

> are you sure the contour in two cases are the same?
> when I draw it,it just not the same.

I'm pretty sure it is *exactly* the same. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: why do not the results agree? [message #43601 is a reply to message #43600] Wed, 20 April 2005 18:54 Go to previous message
lixiaoyao is currently offline  lixiaoyao
Messages: 49
Registered: April 2005
Member
are you sure the contour in two cases are the same?
when I draw it,it just not the same.
Thanks a lot
David Fanning wrote:
> lixiaoyao writes:
>
>> Hi all
>> This time I have read all the manual for contour,I have a
question,my
>> code is
>> in the following. I will say problem following,please help me.
>> ;DEVICE,RETAIN=2
>> set_plot,'ps',/copy
>> device,filename='isothermal.ps'
>> device,/landscape
>>
>>
>> MAX=100
>> x=2*findgen(MAX)/MAX+0.1
>> y=2*findgen(MAX)/MAX+0.1
>> F=exp(y^2/2-alog(y))
>> G=(exp(2*alog(x)+1/x))
>> R=fltarr(MAX,MAX)
>> for i=0,MAX-1 do R(i,*)=F
>> for j=0,MAX-1 do R(*,j)/=G
>>
contour,R,x,y,levels=[0.6,0.7,0.8,0.892521,1.0,1.1,1.2],c_la bels=[1,1,1,1,1,1,1],xtitle='Dimensionless
>> Radius',ytitle='Mach number',title='Isothermal case'
>>
>> until now,it give the correct answer.
>>
>> MAX=100
>> x=2*findgen(MAX)/MAX+0.1
>> y=2*findgen(MAX)/MAX+0.1
>> F=exp(y^2/2-alog(y))
>> G=(exp(2*alog(x)+1/x))
>> R=fltarr(MAX,MAX)
>> for i=0,MAX-1 do R(i,*)=F
>> for j=0,MAX-1 do R(*,j)/=G
>>
contour,R,x,y,level=[0.892521],path_xy=xy,path_info=info,clo sed=0,/path_double
>> for I=0,(N_ELEMENTS(info)-1) DO BEGIN
>> S=[INDGEN(info(I).N),0]
>> print,xy(*,INFO(I).OFFSET+S)
>> ; plots,xy(*,INFO(I).OFFSET+S),/norm
>> endfor
>> this times contour results do not agree with I got from the above
code.
>> I have read all the contour help file,I just can not know to solver
>> it.IF who knows the question is,please tell me.
>
> I don't know. It works for me. You will need these two
> programs from my web page to run the code below:
>
> http://www.dfanning.com/programs/loaddata.pro
> http://www.dfanning.com/programs/scale_vector.pro
>
> Cheers,
>
> David
>
> PRO Example
>
> x = findgen(41)
> y = findgen(41)
> r = loaddata(2)
> r = scale_vector(r, 0.4, 1.4)
>
> TVLCT, 0, 255, 0, 1
> TVLCT, 255, 255, 0, 2
>
> window, 1
> device, decomposed=0
> contour,R,x,y,levels=[0.6,0.7,0.8,0.892521,1.0,1.1,1.2],$
> c_labels=[1,1,1,1,1,1,1],$
> xtitle='Dimensionless Radius',ytitle='Mach number',$
> title='Isothermal case', $
> c_colors=[255, 255, 255, 2, 255, 255, 255]
>
> contour,R,x,y,level=[0.892521],path_xy=xy,$
> path_info=info,closed=0,/path_double
>
> window, 2
> contour,R,x,y,levels=[0.6,0.7,0.8,0.892521,1.0,1.1,1.2],$
> c_labels=[1,1,1,1,1,1,1],$
> xtitle='Dimensionless Radius',ytitle='Mach number',$
> title='Isothermal case', /Nodata
>
> for I=0,(N_ELEMENTS(info)-1) DO BEGIN
> S=[INDGEN(info(I).N),0]
> print,xy(*,INFO(I).OFFSET+S)
> plots,xy(*,INFO(I).OFFSET+S),/norm, color=1, linestyle=2
> endfor
>
> END
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: why do not the results agree? [message #43602 is a reply to message #43601] Wed, 20 April 2005 18:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lixiaoyao writes:

> Hi all
> This time I have read all the manual for contour,I have a question,my
> code is
> in the following. I will say problem following,please help me.
> ;DEVICE,RETAIN=2
> set_plot,'ps',/copy
> device,filename='isothermal.ps'
> device,/landscape
>
>
> MAX=100
> x=2*findgen(MAX)/MAX+0.1
> y=2*findgen(MAX)/MAX+0.1
> F=exp(y^2/2-alog(y))
> G=(exp(2*alog(x)+1/x))
> R=fltarr(MAX,MAX)
> for i=0,MAX-1 do R(i,*)=F
> for j=0,MAX-1 do R(*,j)/=G
> contour,R,x,y,levels=[0.6,0.7,0.8,0.892521,1.0,1.1,1.2],c_la bels=[1,1,1,1,1,1,1],xtitle='Dimensionless
> Radius',ytitle='Mach number',title='Isothermal case'
>
> until now,it give the correct answer.
>
> MAX=100
> x=2*findgen(MAX)/MAX+0.1
> y=2*findgen(MAX)/MAX+0.1
> F=exp(y^2/2-alog(y))
> G=(exp(2*alog(x)+1/x))
> R=fltarr(MAX,MAX)
> for i=0,MAX-1 do R(i,*)=F
> for j=0,MAX-1 do R(*,j)/=G
> contour,R,x,y,level=[0.892521],path_xy=xy,path_info=info,clo sed=0,/path_double
> for I=0,(N_ELEMENTS(info)-1) DO BEGIN
> S=[INDGEN(info(I).N),0]
> print,xy(*,INFO(I).OFFSET+S)
> ; plots,xy(*,INFO(I).OFFSET+S),/norm
> endfor
> this times contour results do not agree with I got from the above code.
> I have read all the contour help file,I just can not know to solver
> it.IF who knows the question is,please tell me.

I don't know. It works for me. You will need these two
programs from my web page to run the code below:

http://www.dfanning.com/programs/loaddata.pro
http://www.dfanning.com/programs/scale_vector.pro

Cheers,

David

PRO Example

x = findgen(41)
y = findgen(41)
r = loaddata(2)
r = scale_vector(r, 0.4, 1.4)

TVLCT, 0, 255, 0, 1
TVLCT, 255, 255, 0, 2

window, 1
device, decomposed=0
contour,R,x,y,levels=[0.6,0.7,0.8,0.892521,1.0,1.1,1.2],$
c_labels=[1,1,1,1,1,1,1],$
xtitle='Dimensionless Radius',ytitle='Mach number',$
title='Isothermal case', $
c_colors=[255, 255, 255, 2, 255, 255, 255]

contour,R,x,y,level=[0.892521],path_xy=xy,$
path_info=info,closed=0,/path_double

window, 2
contour,R,x,y,levels=[0.6,0.7,0.8,0.892521,1.0,1.1,1.2],$
c_labels=[1,1,1,1,1,1,1],$
xtitle='Dimensionless Radius',ytitle='Mach number',$
title='Isothermal case', /Nodata

for I=0,(N_ELEMENTS(info)-1) DO BEGIN
S=[INDGEN(info(I).N),0]
print,xy(*,INFO(I).OFFSET+S)
plots,xy(*,INFO(I).OFFSET+S),/norm, color=1, linestyle=2
endfor

END

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: idlwave-launch-idlhelp doesn't help
Next Topic: IDLWAVE Questions (?)

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

Current Time: Fri Oct 10 15:43:51 PDT 2025

Total time taken to generate the page: 1.65712 seconds