Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
On Tuesday, April 2, 2013 10:04:49 AM UTC-7, gpet...@ucsc.edu wrote: > Can you use the cursor command on a 2d contour map? Could anyone explain how this procedure works.I am not really finding anything on the internet.
On Tuesday, April 2, 2013 1:57:36 PM UTC-4, gpet...@ucsc.edu wrote: > On Tuesday, April 2, 2013 10:04:49 AM UTC-7, gpet...@ucsc.edu wrote: > >> Can you use the cursor command on a 2d contour map? > > > > Could anyone explain how this procedure works.I am not really finding anything on the internet. Cursor is a way of grabbing an (x,y) coordinate pair from the mouse action. You have options on when (x,y) is returned, for example is it returned when you press the mouse button, when you release the button, or move the mouse, etc. (as set by the wait variable). The (x,y) pair will be returned in whatever units you like (whether normal, device, or data), which is useful depending on your purpose. http://www.exelisvis.com/docs/CURSOR_Procedure.html As for your question about contour. I assume you're using the contour procedure (as opposed to the contour function). In which case, what you do next depends on what you want from the (x,y) pair --- and I can't answer that for you. Do you want the value of the contour plot? or do you want the position of the plot (in the window)? The answer to these questions (and other related ones), will dictate how you set the wait variable and the units you use (though you can change the units using convert_coords afterward, should you need all the units for some reason). Good luck, Russell
On Tuesday, April 2, 2013 11:04:48 AM UTC-7, rr...@stsci.edu wrote: > On Tuesday, April 2, 2013 1:57:36 PM UTC-4, gpet...@ucsc.edu wrote: > >> On Tuesday, April 2, 2013 10:04:49 AM UTC-7, gpet...@ucsc.edu wrote: > >> > >>> Can you use the cursor command on a 2d contour map? > >> > >> > >> > >> Could anyone explain how this procedure works.I am not really finding anything on the internet. > > > > Cursor is a way of grabbing an (x,y) coordinate pair from the mouse action. You have options on when (x,y) is returned, for example is it returned when you press the mouse button, when you release the button, or move the mouse, etc. (as set by the wait variable). The (x,y) pair will be returned in whatever units you like (whether normal, device, or data), which is useful depending on your purpose. > > > > http://www.exelisvis.com/docs/CURSOR_Procedure.html > > > > As for your question about contour. I assume you're using the contour procedure (as opposed to the contour function). In which case, what you do next depends on what you want from the (x,y) pair --- and I can't answer that for you. Do you want the value of the contour plot? or do you want the position of the plot (in the window)? The answer to these questions (and other related ones), will dictate how you set the wait variable and the units you use (though you can change the units using convert_coords afterward, should you need all the units for some reason). > > > > Good luck, > > Russell openr, lun, 'arial.txt',/get_lun data=dindgen(824,914) readf, lun, data close,lun rotatedata=ROTATE(data,2) window, 1, retain=2 While (!mouse.button Ne 4) DO BEGIN cursor, data, /device contour, rotatedata ENDWHILE end The error I receive is: CURSOR: Incorrect number of arguments. I am not sure what to do with this.
Den tisdagen den 2:e april 2013 kl. 19:42:51 UTC+1 skrev gpet...@ucsc.edu: > > cursor, data, /device > [...] > The error I receive is: CURSOR: Incorrect number of arguments. > > I am not sure what to do with this. Maybe add the missing argument? From the web page linked to above: CURSOR, X, Y, /DEVICE
Two things. (1) Of course you get an error. Did you read the webpage I sent you? It says that cursor has two *MANDATORY* outputs, and you only gave it one. So, of course it's going to throw an error. (2) Again, you didn't really answer the question. What are you trying to do? Because your code seems to say you want to contour the image *INSIDE* the while loop? That doesn't make any sense to me. It seems you probably want to contour the image *OUTSIDE* the while loop, then move the cursor around inside the plot window? If so, then you still need to ask yourself what you want those (x,y) pairs *FOR*? Do you want the return the value of the contour, that seems logical? If so, then you need to first plot the contour. Then start the while loop. You've got the logic correct there. Look at the webpage I sent you, you need to give cursor a variable for the x and y separately, then a variable specifying *WHEN* to return (ie. does cursor return when you press a mouse button? does it return constantly? does it return when you release the mouse button?) Then set the units. You've set device, which I doubt is what you want (but might be). The device coordinates tell you the position *IN PIXELS* in the device, but the plot need not be anywhere in the device (in fact you can set that in contour). I'm guessing you probably want /data, but that's just a hunch. Either way, this call to cursor (once you get it right), goes inside the while loop (presumably). Then I suppose you want to do something with those x y variables? If so, then that goes there. Good Luck, Russell On Tuesday, April 2, 2013 2:42:51 PM UTC-4, gpet...@ucsc.edu wrote: > On Tuesday, April 2, 2013 11:04:48 AM UTC-7, rr...@stsci.edu wrote: > >> On Tuesday, April 2, 2013 1:57:36 PM UTC-4, gpet...@ucsc.edu wrote: > >> > >>> On Tuesday, April 2, 2013 10:04:49 AM UTC-7, gpet...@ucsc.edu wrote: > >> > >>> > >> > >>>> Can you use the cursor command on a 2d contour map? > >> > >>> > >> > >>> > >> > >>> > >> > >>> Could anyone explain how this procedure works.I am not really finding anything on the internet. > >> > >> > >> > >> Cursor is a way of grabbing an (x,y) coordinate pair from the mouse action. You have options on when (x,y) is returned, for example is it returned when you press the mouse button, when you release the button, or move the mouse, etc. (as set by the wait variable). The (x,y) pair will be returned in whatever units you like (whether normal, device, or data), which is useful depending on your purpose. > >> > >> > >> > >> http://www.exelisvis.com/docs/CURSOR_Procedure.html > >> > >> > >> > >> As for your question about contour. I assume you're using the contour procedure (as opposed to the contour function). In which case, what you do next depends on what you want from the (x,y) pair --- and I can't answer that for you. Do you want the value of the contour plot? or do you want the position of the plot (in the window)? The answer to these questions (and other related ones), will dictate how you set the wait variable and the units you use (though you can change the units using convert_coords afterward, should you need all the units for some reason). > >> > >> > >> > >> Good luck, > >> > >> Russell > > > > openr, lun, 'arial.txt',/get_lun > > > > data=dindgen(824,914) > > readf, lun, data > > close,lun > > > > > > rotatedata=ROTATE(data,2) > > > > window, 1, retain=2 > > > > While (!mouse.button Ne 4) DO BEGIN > > cursor, data, /device > > > > contour, rotatedata > > ENDWHILE > > > > end > > > > > > The error I receive is: CURSOR: Incorrect number of arguments. > > > > I am not sure what to do with this.
On Tuesday, April 2, 2013 12:04:50 PM UTC-7, rr...@stsci.edu wrote: > Two things. > > > > (1) Of course you get an error. Did you read the webpage I sent you? It says that cursor has two *MANDATORY* outputs, and you only gave it one. So, of course it's going to throw an error. > > > > (2) Again, you didn't really answer the question. What are you trying to do? Because your code seems to say you want to contour the image *INSIDE* the while loop? That doesn't make any sense to me. It seems you probably want to contour the image *OUTSIDE* the while loop, then move the cursor around inside the plot window? If so, then you still need to ask yourself what you want those (x,y) pairs *FOR*? Do you want the return the value of the contour, that seems logical? If so, then you need to first plot the contour. Then start the while loop. You've got the logic correct there. Look at the webpage I sent you, you need to give cursor a variable for the x and y separately, then a variable specifying *WHEN* to return (ie. does cursor return when you press a mouse button? does it return constantly? does it return when you release the mouse button?) Then set the units. You've set device, which I doubt is what you want (but might be). The device coordinates tell you the position *IN PIXELS* in the device, but the plot need not be anywhere in the device (in fact you can set that in contour). I'm guessing you probably want /data, but that's just a hunch. Either way, this call to cursor (once you get it right), goes inside the while loop (presumably). Then I suppose you want to do something with those x y variables? If so, then that goes there. > > > > Good Luck, > > Russell > > > > On Tuesday, April 2, 2013 2:42:51 PM UTC-4, gpet...@ucsc.edu wrote: > >> On Tuesday, April 2, 2013 11:04:48 AM UTC-7, rr...@stsci.edu wrote: > >> > >>> On Tuesday, April 2, 2013 1:57:36 PM UTC-4, gpet...@ucsc.edu wrote: > >> > >>> > >> > >>>> On Tuesday, April 2, 2013 10:04:49 AM UTC-7, gpet...@ucsc.edu wrote: > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > Can you use the cursor command on a 2d contour map? > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> Could anyone explain how this procedure works.I am not really finding anything on the internet. > >> > >>> > >> > >>> > >> > >>> > >> > >>> Cursor is a way of grabbing an (x,y) coordinate pair from the mouse action. You have options on when (x,y) is returned, for example is it returned when you press the mouse button, when you release the button, or move the mouse, etc. (as set by the wait variable). The (x,y) pair will be returned in whatever units you like (whether normal, device, or data), which is useful depending on your purpose. > >> > >>> > >> > >>> > >> > >>> > >> > >>> http://www.exelisvis.com/docs/CURSOR_Procedure.html > >> > >>> > >> > >>> > >> > >>> > >> > >>> As for your question about contour. I assume you're using the contour procedure (as opposed to the contour function). In which case, what you do next depends on what you want from the (x,y) pair --- and I can't answer that for you. Do you want the value of the contour plot? or do you want the position of the plot (in the window)? The answer to these questions (and other related ones), will dictate how you set the wait variable and the units you use (though you can change the units using convert_coords afterward, should you need all the units for some reason). > >> > >>> > >> > >>> > >> > >>> > >> > >>> Good luck, > >> > >>> > >> > >>> Russell > >> > >> > >> > >> openr, lun, 'arial.txt',/get_lun > >> > >> > >> > >> data=dindgen(824,914) > >> > >> readf, lun, data > >> > >> close,lun > >> > >> > >> > >> > >> > >> rotatedata=ROTATE(data,2) > >> > >> > >> > >> window, 1, retain=2 > >> > >> > >> > >> While (!mouse.button Ne 4) DO BEGIN > >> > >> cursor, data, /device > >> > >> > >> > >> contour, rotatedata > >> > >> ENDWHILE > >> > >> > >> > >> end > >> > >> > >> > >> > >> > >> The error I receive is: CURSOR: Incorrect number of arguments. > >> > >> > >> > >> I am not sure what to do with this. Okay, let me give you a summary of what I am trying to accomplish. I have created a contour plot from a 2 dimensional data set. Now I am trying to take image profiles of this data. So far the only way for me to get a profile is by just looking at my graph and estimating where the starting x and y locations and the ending x and y locations, thus I am trying to be more accurate using cursor. I think my question lies on how to properly separate the x and the y values from the 2d data array. I have done this openr, lun, 'arial.txt',/get_lun data=dindgen(824,914) readf, lun, data close,lun For i=0, 823 Do Begin FOR j=0, 913 Do Begin x=data(i,*) y=data(*,j) endfor endfor window, 1, retain=2 contour, rotatedata While (!mouse.button Ne 4) DO BEGIN cursor, x, y, /data ENDWHILE However, when I try this nothing happens. On the website you gave my I am not sure what this does in the example code they provide? could this be one section I am doing wrong? PLOTS,[X,X1], [Y,Y1], /NORMAL X = X1 & Y = Y1 Thanks, Georgia
Den onsdagen den 3:e april 2013 kl. 00:41:48 UTC+1 skrev gpet...@ucsc.edu: > > Okay, let me give you a summary of what I am trying to accomplish. I have created a contour plot from a 2 dimensional data set. Now I am trying to take image profiles of this data. So far the only way for me to get a profile is by just looking at my graph and estimating where the starting x and y locations and the ending x and y locations, thus I am trying to be more accurate using cursor. I don't know what you mean by "image profile", but let's go through the program you've written: > I think my question lies on how to properly separate the x and the y values from the 2d data array. I have done this > > openr, lun, 'arial.txt',/get_lun > data=dindgen(824,914) > readf, lun, data > close,lun OK, so you read a 2D array into "data". > For i=0, 823 Do Begin > FOR j=0, 913 Do Begin > x=data(i,*) > y=data(*,j) > endfor > endfor Then you have a double for loop where you set x and y to the different rows and columns of data. But you never use those x and y for anything. > window, 1, retain=2 > contour, rotatedata Then you open a window and make a contour plot of some other variable, rotatedata, which we don't know where you get or what it looks like. > While (!mouse.button Ne 4) DO BEGIN > cursor, x, y, /data > ENDWHILE Then you enter a while loop, with a cursor command. The first time you click the mouse, the last row and column that you had in x and y will be replaced with the data coordinates at the location where the mouse pointer was positioned when you clicked. (Assuming cursor does work with contour, this will be x and y coordinates in the plot.) But as far as I understand you can keep clicking away with the other two mouse buttons with no apparent effect, as this loop will not terminate until you click the rightmost mouse button, at which point the last position coordinates will be available in the x and y variables. > However, when I try this nothing happens. What mouse buttons did you click, if any? > On the website you gave my I am not sure what this does in the example code they provide? could this be one section I am doing wrong? > > PLOTS,[X,X1], [Y,Y1], /NORMAL > X = X1 & Y = Y1 In the example, before the while loop, the coordinates of a starting point (the first point where you click) is read with cursor. Then the while loop lets you keep clicking and it will draw lines from one point to the next for as long as you wish. When you want to stop drawing lines, you click the rightmost button and the loop will terminate after drawing the final line segment. Why don't you run it?
Ok that helps trying to zero in on the problem. But there's still some confusing things. What do you mean by "image profile"? What do you mean by "starting x/y and ending x/y positions"? Starting/ending of what? How do you expect or want the cursor procedure to help with these things? To me, it sounds like you might want to plot a contour plot. Then use the cursor to trace out the contour lines and save those x,y values for later use. If so, then I think you're wasting your time with cursor (though this can be done). Let me know, I have a feeling we're close to answering your problem. Russell On Tuesday, April 2, 2013 7:41:48 PM UTC-4, gpet...@ucsc.edu wrote: > On Tuesday, April 2, 2013 12:04:50 PM UTC-7, rr...@stsci.edu wrote: > >> Two things. > >> > >> > >> > >> (1) Of course you get an error. Did you read the webpage I sent you? It says that cursor has two *MANDATORY* outputs, and you only gave it one. So, of course it's going to throw an error. > >> > >> > >> > >> (2) Again, you didn't really answer the question. What are you trying to do? Because your code seems to say you want to contour the image *INSIDE* the while loop? That doesn't make any sense to me. It seems you probably want to contour the image *OUTSIDE* the while loop, then move the cursor around inside the plot window? If so, then you still need to ask yourself what you want those (x,y) pairs *FOR*? Do you want the return the value of the contour, that seems logical? If so, then you need to first plot the contour. Then start the while loop. You've got the logic correct there. Look at the webpage I sent you, you need to give cursor a variable for the x and y separately, then a variable specifying *WHEN* to return (ie. does cursor return when you press a mouse button? does it return constantly? does it return when you release the mouse button?) Then set the units. You've set device, which I doubt is what you want (but might be). The device coordinates tell you the position *IN PIXELS* in the device, but the plot need not be anywhere in the device (in fact you can set that in contour). I'm guessing you probably want /data, but that's just a hunch. Either way, this call to cursor (once you get it right), goes inside the while loop (presumably). Then I suppose you want to do something with those x y variables? If so, then that goes there. > >> > >> > >> > >> Good Luck, > >> > >> Russell > >> > >> > >> > >> On Tuesday, April 2, 2013 2:42:51 PM UTC-4, gpet...@ucsc.edu wrote: > >> > >>> On Tuesday, April 2, 2013 11:04:48 AM UTC-7, rr...@stsci.edu wrote: > >> > >>> > >> > >>>> On Tuesday, April 2, 2013 1:57:36 PM UTC-4, gpet...@ucsc.edu wrote: > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > On Tuesday, April 2, 2013 10:04:49 AM UTC-7, gpet...@ucsc.edu wrote: > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > > Can you use the cursor command on a 2d contour map? > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > Could anyone explain how this procedure works.I am not really finding anything on the internet. > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> Cursor is a way of grabbing an (x,y) coordinate pair from the mouse action. You have options on when (x,y) is returned, for example is it returned when you press the mouse button, when you release the button, or move the mouse, etc. (as set by the wait variable). The (x,y) pair will be returned in whatever units you like (whether normal, device, or data), which is useful depending on your purpose. > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> http://www.exelisvis.com/docs/CURSOR_Procedure.html > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> As for your question about contour. I assume you're using the contour procedure (as opposed to the contour function). In which case, what you do next depends on what you want from the (x,y) pair --- and I can't answer that for you. Do you want the value of the contour plot? or do you want the position of the plot (in the window)? The answer to these questions (and other related ones), will dictate how you set the wait variable and the units you use (though you can change the units using convert_coords afterward, should you need all the units for some reason). > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> Good luck, > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> Russell > >> > >>> > >> > >>> > >> > >>> > >> > >>> openr, lun, 'arial.txt',/get_lun > >> > >>> > >> > >>> > >> > >>> > >> > >>> data=dindgen(824,914) > >> > >>> > >> > >>> readf, lun, data > >> > >>> > >> > >>> close,lun > >> > >>> > >> > >>> > >> > >>> > >> > >>> > >> > >>> > >> > >>> rotatedata=ROTATE(data,2) > >> > >>> > >> > >>> > >> > >>> > >> > >>> window, 1, retain=2 > >> > >>> > >> > >>> > >> > >>> > >> > >>> While (!mouse.button Ne 4) DO BEGIN > >> > >>> > >> > >>> cursor, data, /device > >> > >>> > >> > >>> > >> > >>> > >> > >>> contour, rotatedata > >> > >>> > >> > >>> ENDWHILE > >> > >>> > >> > >>> > >> > >>> > >> > >>> end > >> > >>> > >> > >>> > >> > >>> > >> > >>> > >> > >>> > >> > >>> The error I receive is: CURSOR: Incorrect number of arguments. > >> > >>> > >> > >>> > >> > >>> > >> > >>> I am not sure what to do with this. > > > > Okay, let me give you a summary of what I am trying to accomplish. I have created a contour plot from a 2 dimensional data set. Now I am trying to take image profiles of this data. So far the only way for me to get a profile is by just looking at my graph and estimating where the starting x and y locations and the ending x and y locations, thus I am trying to be more accurate using cursor. > > > > > > I think my question lies on how to properly separate the x and the y values from the 2d data array. I have done this > > > > openr, lun, 'arial.txt',/get_lun > > > > data=dindgen(824,914) > > readf, lun, data > > close,lun > > > > > > > > For i=0, 823 Do Begin > > FOR j=0, 913 Do Begin > > x=data(i,*) > > y=data(*,j) > > endfor > > endfor > > > > > > > > window, 1, retain=2 > > > > contour, rotatedata > > > > > > While (!mouse.button Ne 4) DO BEGIN > > cursor, x, y, /data > > > > ENDWHILE > > > > > > > > However, when I try this nothing happens. > > > > > > On the website you gave my I am not sure what this does in the example code they provide? could this be one section I am doing wrong? > > > > PLOTS,[X,X1], [Y,Y1], /NORMAL > > > > X = X1 & Y = Y1 > > > > > > Thanks, Georgia
http://www.idlcoyote.com/ip_tips/image_profile.html This link i posted describes what I was previously talking about with the image profiling. I just need to be able to accurately find the two endpoints for any line I choose on the contour map.
On Tuesday, April 2, 2013 10:11:01 PM UTC-4, gpet...@ucsc.edu wrote: > http://www.idlcoyote.com/ip_tips/image_profile.html > > > > This link i posted describes what I was previously talking about with the image profiling. I just need to be able to accurately find the two endpoints for any line I choose on the contour map. It kind of depends on what OS and what version of IDL you are using. On the Mac, CURSOR has a "cursed" history of stopping working and then being fixed, and then stopping working again. This has happened several times through the IDL 7 and IDL 8 release cycles. The symptoms are what you describe: CURSOR just pauses and doesn't do anything, doesn't respond to clicks. Also, on X11 I have to disable the "Click through to inactive windows" setting. Craig
On Tuesday, April 2, 2013 7:18:29 PM UTC-7, Craig Markwardt wrote: > On Tuesday, April 2, 2013 10:11:01 PM UTC-4, gpet...@ucsc.edu wrote: > >> http://www.idlcoyote.com/ip_tips/image_profile.html > >> > >> > >> > >> This link i posted describes what I was previously talking about with the image profiling. I just need to be able to accurately find the two endpoints for any line I choose on the contour map. > > > > It kind of depends on what OS and what version of IDL you are using. On the Mac, CURSOR has a "cursed" history of stopping working and then being fixed, and then stopping working again. This has happened several times through the IDL 7 and IDL 8 release cycles. The symptoms are what you describe: CURSOR just pauses and doesn't do anything, doesn't respond to clicks. Also, on X11 I have to disable the "Click through to inactive windows" setting. > > > > Craig Has there been problems with linux machines?
On Tuesday, April 2, 2013 10:11:01 PM UTC-4, gpet...@ucsc.edu wrote: > http://www.idlcoyote.com/ip_tips/image_profile.html > > > > This link i posted describes what I was previously talking about with the image profiling. I just need to be able to accurately find the two endpoints for any line I choose on the contour map. Ok. So now I think I know what's wrong. You want to draw a contour plot, then select a line, then have it plot the profile along that line. Got it. Well, I suppose a line is given by either two points: (x1,y1) and (x2,y2) or by a slope-intercept pair (m,b). Of course it's easy to convert between the two, but since you'e asked about cursor, I suppose we should use the two xy pairs. Here's the pseudocode. 1. plot the contour. 2. click once to get one point. 3. click a second time to get the other point. 4. draw the profile 5. Goto 2 or quit. Here's some IDL code ;step 0 read the image img=dist(200) sz=size(img,/dim) ;the size of the image ;step 1. draw the contour window,1,retain=2,xsize=400,ysize=400 contour,img npoints=100 ;number of the line plot ;start a while loop so we can "goto" step 2 ;save the current state of the mouse button. this is generally ;a good habit anytime you modify or test the system variables mousebutton=!mouse.button & !mouse.button=0 print,'right click to quit' while !mouse.button ne 4 do begin ;double chcek that the window is set to the main one. wset,1 print,'please click on one point.' cursor,x1,y1,3,/data if x1 lt 0 || y1 lt 0 || x1 gt sz(0) || y1 gt sz(1) then begin print,'first point is off the image.' goto,skip endif print,'please click on a second point.' cursor,x2,y2,3,/data if x2 lt 0 || y2 lt 0 || x2 gt sz(0) || y2 gt sz(1) then begin print,'second point is off the image.' goto,skip endif ;okay at this point, we have the two x,y pairs ;over plot the line oplot,[x1,x2],[y1,y2],line=1 ;now extract the contour (via Fanning's webpage) xloc=x1+(x2-x1)*findgen(npoints)/(npoints-1) yloc=y1+(y2-y1)*findgen(npoints)/(npoints-1) line=interpolate(img,xloc,yloc) ;now create a second window for the plot window,3,retain=2,xsize=400,ysize=400 plot,line ;set the window back to the first (in case you want to do it again) wset,1 skip: endwhile ;if here, menas you quit. so lets uset the mousestate !mouse.button=mousebutton
On Tuesday, April 2, 2013 1:04:49 PM UTC-4, gpet...@ucsc.edu wrote: > Can you use the cursor command on a 2d contour map? Ok. So now I think I know what's wrong. You want to draw a contour plot, then select a line, then have it plot the profile along that line. Got it. Well, I suppose a line is given by either two points: (x1,y1) and (x2,y2) or by a slope-intercept pair (m,b). Of course it's easy to convert between the two, but since you'e asked about cursor, I suppose we should use the two xy pairs. Here's the pseudocode. 1. plot the contour. 2. click once to get one point. 3. click a second time to get the other point. 4. draw the profile 5. Goto 2 or quit. Here's some IDL code ;step 0 read the image img=dist(200) sz=size(img,/dim) ;the size of the image ;step 1. draw the contour window,1,retain=2,xsize=400,ysize=400 contour,img npoints=100 ;number of the line plot ;start a while loop so we can "goto" step 2 ;save the current state of the mouse button. this is generally ;a good habit anytime you modify or test the system variables mousebutton=!mouse.button & !mouse.button=0 print,'right click to quit' while !mouse.button ne 4 do begin ;double chcek that the window is set to the main one. wset,1 print,'please click on one point.' cursor,x1,y1,3,/data if x1 lt 0 || y1 lt 0 || x1 gt sz(0) || y1 gt sz(1) then begin print,'first point is off the image.' goto,skip endif print,'please click on a second point.' cursor,x2,y2,3,/data if x2 lt 0 || y2 lt 0 || x2 gt sz(0) || y2 gt sz(1) then begin print,'second point is off the image.' goto,skip endif ;okay at this point, we have the two x,y pairs ;over plot the line oplot,[x1,x2],[y1,y2],line=1 ;now extract the contour (via Fanning's webpage) xloc=x1+(x2-x1)*findgen(npoints)/(npoints-1) yloc=y1+(y2-y1)*findgen(npoints)/(npoints-1) line=interpolate(img,xloc,yloc) ;now create a second window for the plot window,3,retain=2,xsize=400,ysize=400 plot,line ;set the window back to the first (in case you want to do it again) wset,1 skip: endwhile ;if here, menas you quit. so lets uset the mousestate !mouse.button=mousebutton
On Tuesday, April 2, 2013 11:08:37 PM UTC-4, gpet...@ucsc.edu wrote: > Has there been problems with linux machines? Linux server machines displaying X windows on a Mac, then yes. I don't know about a Linux desktop, it's been a while since I've had one. Craig
On Wednesday, April 3, 2013 6:48:07 AM UTC-7, rr...@stsci.edu wrote: > On Tuesday, April 2, 2013 10:11:01 PM UTC-4, gpet...@ucsc.edu wrote: > >> http://www.idlcoyote.com/ip_tips/image_profile.html > >> > >> > >> > >> This link i posted describes what I was previously talking about with the image profiling. I just need to be able to accurately find the two endpoints for any line I choose on the contour map. > > > > Ok. So now I think I know what's wrong. You want to draw a contour plot, then select a line, then have it plot the profile along that line. Got it. Well, I suppose a line is given by either two points: (x1,y1) and (x2,y2) or by a slope-intercept pair (m,b). Of course it's easy to convert between the two, but since you'e asked about cursor, I suppose we should use the two xy pairs. > > > > Here's the pseudocode. > > 1. plot the contour. > > 2. click once to get one point. > > 3. click a second time to get the other point. > > 4. draw the profile > > 5. Goto 2 or quit. > > > > Here's some IDL code > > ;step 0 read the image > > img=dist(200) > > sz=size(img,/dim) ;the size of the image > > > > ;step 1. draw the contour > > window,1,retain=2,xsize=400,ysize=400 > > contour,img > > > > npoints=100 ;number of the line plot > > > > ;start a while loop so we can "goto" step 2 > > > > > > ;save the current state of the mouse button. this is generally > > ;a good habit anytime you modify or test the system variables > > mousebutton=!mouse.button & !mouse.button=0 > > print,'right click to quit' > > while !mouse.button ne 4 do begin > > ;double chcek that the window is set to the main one. > > wset,1 > > > > print,'please click on one point.' > > cursor,x1,y1,3,/data > > if x1 lt 0 || y1 lt 0 || x1 gt sz(0) || y1 gt sz(1) then begin > > print,'first point is off the image.' > > goto,skip > > endif > > > > print,'please click on a second point.' > > cursor,x2,y2,3,/data > > if x2 lt 0 || y2 lt 0 || x2 gt sz(0) || y2 gt sz(1) then begin > > print,'second point is off the image.' > > goto,skip > > endif > > > > > > > > ;okay at this point, we have the two x,y pairs > > ;over plot the line > > oplot,[x1,x2],[y1,y2],line=1 > > > > ;now extract the contour (via Fanning's webpage) > > xloc=x1+(x2-x1)*findgen(npoints)/(npoints-1) > > yloc=y1+(y2-y1)*findgen(npoints)/(npoints-1) > > line=interpolate(img,xloc,yloc) > > > > ;now create a second window for the plot > > window,3,retain=2,xsize=400,ysize=400 > > plot,line > > > > ;set the window back to the first (in case you want to do it again) > > wset,1 > > > > skip: > > endwhile > > > > ;if here, menas you quit. so lets uset the mousestate > > !mouse.button=mousebutton Thank you russell! works great!