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

Home » Public Forums » archive » cgimage not generating output with cgps_open and cgps_close (fine in X window) .
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
cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89471] Mon, 20 October 2014 09:50 Go to next message
JTMHD is currently offline  JTMHD
Messages: 9
Registered: October 2014
Junior Member
Hi All,

I'm not getting what I expect to get when I try to make postscript or PNG output by nestinng a cgimage command in cgps_open and cgps_close so was wondering if anyone could point me in the right direction.


Now, if I say run

testarray=dist(256)

title='E$\subx$'
xtitle = 'x [c$\omega$$\subpe$$\up-1$]'
ytitle = 't [$\omega$$\subpe$$\up-1$]'

ct=5
cgLOADCT, ct, NCOLORS=256

cgimage,testarray,/axes,$
xs=1,ys=1,xtitle=xtitle,ytitle=ytitle,title=title, $
POSITION=[0.15, 0.3, 0.95, 0.9]
cgCOLORBAR, NCOLORS=256, POSITION=[0.15, 0.13, 0.95, 0.18], $
RANGE=[min(testarray),max(testarray)],FORMAT='(e11.1)'

I see in the x-windows display exactly what I'd expect, the image itself surrounded by axes and the greek characters and super/subscripts work properly.

Now, when attempting to do the same nested in cgps_open / cgps_close, i.e.,

testarray=dist(256)

title='E$\subx$'
xtitle = 'x [c$\omega$$\subpe$$\up-1$]'
ytitle = 't [$\omega$$\subpe$$\up-1$]'

ct=5
cgLOADCT, ct, NCOLORS=256


cgPS_OPEN,'testout.ps'
cgimage,testarray,/axes,$
xs=1,ys=1,xtitle=xtitle,ytitle=ytitle,title=title, $
POSITION=[0.15, 0.3, 0.95, 0.9]
cgCOLORBAR, NCOLORS=256, POSITION=[0.15, 0.13, 0.95, 0.18], $
RANGE=[min(testarray),max(testarray)],FORMAT='(e11.1)'
cgPS_CLOSE


This does not generate an image, in that the axes and color bar draw correctly, but there is no image drawn within those axes.

If instead of an image I go for a contour plot, as such:


testarray=dist(256)

title='E$\subx$'
xtitle = 'x [c$\omega$$\subpe$$\up-1$]'
ytitle = 't [$\omega$$\subpe$$\up-1$]'

ct=5
cgLOADCT, ct, NCOLORS=256


cgPS_OPEN,'testout.ps'
cgcontour,testarray,/axes,$
xs=1,ys=1,xtitle=xtitle,ytitle=ytitle,title=title, $
POSITION=[0.15, 0.3, 0.95, 0.9],/FILL,NLEVELS=256
cgCOLORBAR, NCOLORS=256, POSITION=[0.15, 0.13, 0.95, 0.18], $
RANGE=[min(testarray),max(testarray)],FORMAT='(e11.1)'
cgPS_CLOSE


output is expected.


What is peculiar to cgimage and its operation with postscript output that I've missed? Furthermore, I am certain I've actually managed this before (but I'm on a new machine so perhaps some subtlety with setup I've missed) without issue.

Cheers,

Jonathan
Re: cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89473 is a reply to message #89471] Mon, 20 October 2014 10:37 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JTMHD writes:

> I'm not getting what I expect to get when I try to make postscript or PNG output by nestinng a cgimage command in cgps_open and cgps_close so was wondering if anyone could point me in the right direction.

Well, leave the XSCALE and YSCALE keywords off your cgImage command.
They aren't needed (cgImage does this automatically), and they are
somehow (don't understand it yet) screwing things up.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89474 is a reply to message #89473] Mon, 20 October 2014 11:06 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Well, leave the XSCALE and YSCALE keywords off your cgImage command.
> They aren't needed (cgImage does this automatically), and they are
> somehow (don't understand it yet) screwing things up.

Alright, here is what is happening. This is a combination of the usual
keyword inheritance nonsense, with a little twist from IDL letting you
abbreviate keyword names.

The proper way to set axis properties in cgImage is via the AXKeywords
keyword, which no one can figure out how to use. So I allow a *limited*
number of axis keywords to be used on the cgImage command line (e.g.,
xrange and yrange). I don't forbid you to use XSCALE and YSCALE keywords
(the ol' keyword inheritance problem), but there should be no reason to
use them, either. cgImage knows what it is doing and does axis things
correctly.

Had you actually used XSCALE and YSCALE keywords, instead of their
shorted form XS and YS, you would have received an error message, since
these keywords are passed along to the TV command. They don't mean
anything to the TV command, so the TV command complains. But, in their
shortened form, XS and YS, they are interpreted by the TV command as the
XSIZE and YSIZE keywords, and they will overwrite the XSIZE and YSIZE
values cgImage uses internally to size a PostScript image. (The XSIZE
and YSIZE keywords are only used by the TV command when in the
PostScript device.) As a result, and this is why you weren't getting an
error, your image was being sized to a one-by-one pixel, which was being
displayed correctly in your output. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89475 is a reply to message #89474] Mon, 20 October 2014 11:14 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

>
> David Fanning writes:
>
>> Well, leave the XSCALE and YSCALE keywords off your cgImage command.
>> They aren't needed (cgImage does this automatically), and they are
>> somehow (don't understand it yet) screwing things up.
>
> Alright, here is what is happening. This is a combination of the usual
> keyword inheritance nonsense, with a little twist from IDL letting you
> abbreviate keyword names.
>
> The proper way to set axis properties in cgImage is via the AXKeywords
> keyword, which no one can figure out how to use. So I allow a *limited*
> number of axis keywords to be used on the cgImage command line (e.g.,
> xrange and yrange). I don't forbid you to use XSCALE and YSCALE keywords
> (the ol' keyword inheritance problem), but there should be no reason to
> use them, either. cgImage knows what it is doing and does axis things
> correctly.
>
> Had you actually used XSCALE and YSCALE keywords, instead of their
> shorted form XS and YS, you would have received an error message, since
> these keywords are passed along to the TV command. They don't mean
> anything to the TV command, so the TV command complains. But, in their
> shortened form, XS and YS, they are interpreted by the TV command as the
> XSIZE and YSIZE keywords, and they will overwrite the XSIZE and YSIZE
> values cgImage uses internally to size a PostScript image. (The XSIZE
> and YSIZE keywords are only used by the TV command when in the
> PostScript device.) As a result, and this is why you weren't getting an
> error, your image was being sized to a one-by-one pixel, which was being
> displayed correctly in your output. :-)

By the way, when you write code like this:

cgimage, image, /xs, /ys

You are doing two things wrong in my opinion. You are abbreviating
keyword names, which makes your programs difficult to understand and
debug (see current discussion today), and you are using a keyword
shortcut that is inappropriate with non-boolean keywords that can have
values *other* than 0 or 1. It works, but it strikes me as a lousy
programming practice, since it, too, sends the wrong message to people
looking for problems in your programs.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89477 is a reply to message #89474] Mon, 20 October 2014 12:52 Go to previous messageGo to next message
JTMHD is currently offline  JTMHD
Messages: 9
Registered: October 2014
Junior Member
On Monday, 20 October 2014 19:06:14 UTC+1, David Fanning wrote:
> David Fanning writes:
>
>
>
>> Well, leave the XSCALE and YSCALE keywords off your cgImage command.
>
>> They aren't needed (cgImage does this automatically), and they are
>
>> somehow (don't understand it yet) screwing things up.
>
>
>
> Alright, here is what is happening. This is a combination of the usual
>
> keyword inheritance nonsense, with a little twist from IDL letting you
>
> abbreviate keyword names.
>
>
>
> The proper way to set axis properties in cgImage is via the AXKeywords
>
> keyword, which no one can figure out how to use. So I allow a *limited*
>
> number of axis keywords to be used on the cgImage command line (e.g.,
>
> xrange and yrange). I don't forbid you to use XSCALE and YSCALE keywords
>
> (the ol' keyword inheritance problem), but there should be no reason to
>
> use them, either. cgImage knows what it is doing and does axis things
>
> correctly.
>
>
>
> Had you actually used XSCALE and YSCALE keywords, instead of their
>
> shorted form XS and YS, you would have received an error message, since
>
> these keywords are passed along to the TV command. They don't mean
>
> anything to the TV command, so the TV command complains. But, in their
>
> shortened form, XS and YS, they are interpreted by the TV command as the
>
> XSIZE and YSIZE keywords, and they will overwrite the XSIZE and YSIZE
>
> values cgImage uses internally to size a PostScript image. (The XSIZE
>
> and YSIZE keywords are only used by the TV command when in the
>
> PostScript device.) As a result, and this is why you weren't getting an
>
> error, your image was being sized to a one-by-one pixel, which was being
>
> displayed correctly in your output. :-)
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Hi David,

Thank you for reply - I can happily confirm that this fixes the problem. I guess the reason I've not came up against this in the past is that for some reason its only today that I've absent-mindedly stuck the xs=1,ys=1 keywords in despite not needing them (perhaps a habit from other plotting!).

I would just like to stress how much time I think your answer has saved me - I was copying and pasting the code from a little text file so who knows how long it would have been before I would have typed it out again without those keywords and perhaps noticed the culprit!


Thanks,

Jonathan
Re: cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89478 is a reply to message #89475] Mon, 20 October 2014 12:54 Go to previous messageGo to next message
JTMHD is currently offline  JTMHD
Messages: 9
Registered: October 2014
Junior Member
On Monday, 20 October 2014 19:14:50 UTC+1, David Fanning wrote:
> David Fanning writes:
>
>
>
>>
>
>> David Fanning writes:
>
>>
>
>>> Well, leave the XSCALE and YSCALE keywords off your cgImage command.
>
>>> They aren't needed (cgImage does this automatically), and they are
>
>>> somehow (don't understand it yet) screwing things up.
>
>>
>
>> Alright, here is what is happening. This is a combination of the usual
>
>> keyword inheritance nonsense, with a little twist from IDL letting you
>
>> abbreviate keyword names.
>
>>
>
>> The proper way to set axis properties in cgImage is via the AXKeywords
>
>> keyword, which no one can figure out how to use. So I allow a *limited*
>
>> number of axis keywords to be used on the cgImage command line (e.g.,
>
>> xrange and yrange). I don't forbid you to use XSCALE and YSCALE keywords
>
>> (the ol' keyword inheritance problem), but there should be no reason to
>
>> use them, either. cgImage knows what it is doing and does axis things
>
>> correctly.
>
>>
>
>> Had you actually used XSCALE and YSCALE keywords, instead of their
>
>> shorted form XS and YS, you would have received an error message, since
>
>> these keywords are passed along to the TV command. They don't mean
>
>> anything to the TV command, so the TV command complains. But, in their
>
>> shortened form, XS and YS, they are interpreted by the TV command as the
>
>> XSIZE and YSIZE keywords, and they will overwrite the XSIZE and YSIZE
>
>> values cgImage uses internally to size a PostScript image. (The XSIZE
>
>> and YSIZE keywords are only used by the TV command when in the
>
>> PostScript device.) As a result, and this is why you weren't getting an
>
>> error, your image was being sized to a one-by-one pixel, which was being
>
>> displayed correctly in your output. :-)
>
>
>
> By the way, when you write code like this:
>
>
>
> cgimage, image, /xs, /ys
>
>
>
> You are doing two things wrong in my opinion. You are abbreviating
>
> keyword names, which makes your programs difficult to understand and
>
> debug (see current discussion today), and you are using a keyword
>
> shortcut that is inappropriate with non-boolean keywords that can have
>
> values *other* than 0 or 1. It works, but it strikes me as a lousy
>
> programming practice, since it, too, sends the wrong message to people
>
> looking for problems in your programs.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

I see what you are saying and will bear it in mind. Its a hangover from using IDL interactively for a quick look at data, but I can totally see how this good practice would pay off if you where writing more sophisticated tools
Re: cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89479 is a reply to message #89475] Mon, 20 October 2014 12:56 Go to previous messageGo to next message
JTMHD is currently offline  JTMHD
Messages: 9
Registered: October 2014
Junior Member
On Monday, 20 October 2014 19:14:50 UTC+1, David Fanning wrote:
> David Fanning writes:
>
>
>
>>
>
>> David Fanning writes:
>
>>
>
>>> Well, leave the XSCALE and YSCALE keywords off your cgImage command.
>
>>> They aren't needed (cgImage does this automatically), and they are
>
>>> somehow (don't understand it yet) screwing things up.
>
>>
>
>> Alright, here is what is happening. This is a combination of the usual
>
>> keyword inheritance nonsense, with a little twist from IDL letting you
>
>> abbreviate keyword names.
>
>>
>
>> The proper way to set axis properties in cgImage is via the AXKeywords
>
>> keyword, which no one can figure out how to use. So I allow a *limited*
>
>> number of axis keywords to be used on the cgImage command line (e.g.,
>
>> xrange and yrange). I don't forbid you to use XSCALE and YSCALE keywords
>
>> (the ol' keyword inheritance problem), but there should be no reason to
>
>> use them, either. cgImage knows what it is doing and does axis things
>
>> correctly.
>
>>
>
>> Had you actually used XSCALE and YSCALE keywords, instead of their
>
>> shorted form XS and YS, you would have received an error message, since
>
>> these keywords are passed along to the TV command. They don't mean
>
>> anything to the TV command, so the TV command complains. But, in their
>
>> shortened form, XS and YS, they are interpreted by the TV command as the
>
>> XSIZE and YSIZE keywords, and they will overwrite the XSIZE and YSIZE
>
>> values cgImage uses internally to size a PostScript image. (The XSIZE
>
>> and YSIZE keywords are only used by the TV command when in the
>
>> PostScript device.) As a result, and this is why you weren't getting an
>
>> error, your image was being sized to a one-by-one pixel, which was being
>
>> displayed correctly in your output. :-)
>
>
>
> By the way, when you write code like this:
>
>
>
> cgimage, image, /xs, /ys
>
>
>
> You are doing two things wrong in my opinion. You are abbreviating
>
> keyword names, which makes your programs difficult to understand and
>
> debug (see current discussion today), and you are using a keyword
>
> shortcut that is inappropriate with non-boolean keywords that can have
>
> values *other* than 0 or 1. It works, but it strikes me as a lousy
>
> programming practice, since it, too, sends the wrong message to people
>
> looking for problems in your programs.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

I see what you are saying and will bear it in mind. Its a hangover from using IDL interactively for a quick look at data, but I can totally see how this good practice would pay off if you where writing more sophisticated tools
Re: cgimage not generating output with cgps_open and cgps_close (fine in X window) . [message #89480 is a reply to message #89475] Mon, 20 October 2014 12:56 Go to previous message
JTMHD is currently offline  JTMHD
Messages: 9
Registered: October 2014
Junior Member
On Monday, 20 October 2014 19:14:50 UTC+1, David Fanning wrote:
> David Fanning writes:
>
>
>
>>
>
>> David Fanning writes:
>
>>
>
>>> Well, leave the XSCALE and YSCALE keywords off your cgImage command.
>
>>> They aren't needed (cgImage does this automatically), and they are
>
>>> somehow (don't understand it yet) screwing things up.
>
>>
>
>> Alright, here is what is happening. This is a combination of the usual
>
>> keyword inheritance nonsense, with a little twist from IDL letting you
>
>> abbreviate keyword names.
>
>>
>
>> The proper way to set axis properties in cgImage is via the AXKeywords
>
>> keyword, which no one can figure out how to use. So I allow a *limited*
>
>> number of axis keywords to be used on the cgImage command line (e.g.,
>
>> xrange and yrange). I don't forbid you to use XSCALE and YSCALE keywords
>
>> (the ol' keyword inheritance problem), but there should be no reason to
>
>> use them, either. cgImage knows what it is doing and does axis things
>
>> correctly.
>
>>
>
>> Had you actually used XSCALE and YSCALE keywords, instead of their
>
>> shorted form XS and YS, you would have received an error message, since
>
>> these keywords are passed along to the TV command. They don't mean
>
>> anything to the TV command, so the TV command complains. But, in their
>
>> shortened form, XS and YS, they are interpreted by the TV command as the
>
>> XSIZE and YSIZE keywords, and they will overwrite the XSIZE and YSIZE
>
>> values cgImage uses internally to size a PostScript image. (The XSIZE
>
>> and YSIZE keywords are only used by the TV command when in the
>
>> PostScript device.) As a result, and this is why you weren't getting an
>
>> error, your image was being sized to a one-by-one pixel, which was being
>
>> displayed correctly in your output. :-)
>
>
>
> By the way, when you write code like this:
>
>
>
> cgimage, image, /xs, /ys
>
>
>
> You are doing two things wrong in my opinion. You are abbreviating
>
> keyword names, which makes your programs difficult to understand and
>
> debug (see current discussion today), and you are using a keyword
>
> shortcut that is inappropriate with non-boolean keywords that can have
>
> values *other* than 0 or 1. It works, but it strikes me as a lousy
>
> programming practice, since it, too, sends the wrong message to people
>
> looking for problems in your programs.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

I see what you are saying and will bear it in mind. Its a hangover from using IDL interactively for a quick look at data, but I can totally see how this good practice would pay off if you where writing more sophisticated tools
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: File time issue
Next Topic: cgWindRose has error producing legend?

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

Current Time: Wed Oct 08 11:53:17 PDT 2025

Total time taken to generate the page: 0.00850 seconds