log scale colorbar in IDL 8.0 [message #76113] |
Tue, 17 May 2011 13:25  |
Kim
Messages: 19 Registered: January 2009
|
Junior Member |
|
|
Hello,
I have just started using the new graphics routines in IDL 8.0/8.1 and
am trying to incorporate them into an extensive set of customized
plotting and image type routines. I am able to use the IMAGE function
to display some log-normally distributed data, however I am unable to
create a colorbar that reflects the log-transformed data.
Here is a simplified example:
; Read the data array
; Convert the scaled float array (using ALOG10) to a byte array
im = IMAGE(bytedata)
cb =
COLORBAR(target=im,tickvalues=[0.01,0.03,0.1,0.3,1.0,3.0,10. 0,30.0],tickname=['.
01','.03','.1','.3','1','3','10','30'], title='Log Data')
Some specific questions:
1) How do you scale the color bar so that it reflects the scaled data?
2) If tickvalues are supplied, can you also input ticknames? In the
above example, the supplied ticknames are not used and instead the
ticknames are derived from the tickvalues. The only way I have been
able to use the ticknames is to remove the tickvalues keyword.
3) Is it possible to set minimum and maximum color or value ranges?
For example, in one of my commonly used rgb_tables, the 0 value is
black and above 250 are various shades of gray. How do I set it so
that mincolor=1 and maxcolor=250?
4) Is it possible to create a colorbar that is independent of some
specified data? It would be very useful to be able to create a
colorbar just using a user supplied data range instead of being
directly linked to a specfic data field. There are times when I need
to create stand alone colorbars and I can't figure out how to do this
with the COLORBAR function.
Thank you for your assistance,
Kim
|
|
|
|
Re: log scale colorbar in IDL 8.0 [message #76198 is a reply to message #76113] |
Thu, 19 May 2011 12:36   |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
On May 19, 12:53 pm, David Fanning <n...@idlcoyote.com> wrote:
> David Fanning writes:
>
>> Paolo writes:
>
>>> By the way, the cg version doesn't seem to be properly
>>> honoring the axis ranges. For instance, a y range of
>>> [-100,100] should show an image only in the upper half
>>> of the axis, as the image y-range is only [0,127]...
>
>>> (well one could wonder why would you plot that way...
>>> but the idea behind pg_plotimage was to plot an image the
>>> same way you would use "plot"...)
>
>> Hi Paolo,
>
>> I have no trouble fixing this for the display, but
>> I can't make it write a proper PostScript file. I've
>> gone back to the original code, and I can't make that
>> program write a proper PostScript file with this command
>> either! Have you ever tried to write a PostScript file
>> with the commands above in your original program? :-)
>
> Here is the code I am using with your original program.
>
> loadct,5
> im=dist(128,128)
> x=findgen(128)
> y=findgen(128)
> ps_start, filename='test_1.ps'
> pg_plotimage,im,x,y,xrange=[5,100],$
> yrange=[5,100],/xstyle,/ystyle,/xlog
> ps_end
> ps_start, filename='test_2.ps'
> pg_plotimage,im,x,y,xrange=[5,100],$
> yrange=[-100,100],/xstyle,/ystyle,/xlog
> ps_end
> END
>
> test_1.ps seems to be fine. But test_2.ps is
> buggered. :-)
It turns out it was a simple (i.e. stupid) bug
with two indices that were 0 and should have
been 1.
Since it turns out I let my password expire I can't
update the version on the CfA webpage right now,
but you can find the fixed version on:
http://www.grigis.ch/pg_plotimage.pro
Or manually fix the indices from 0 to 1 at the end of lines
249 and 252.
Ciao,
Paolo
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
Re: log scale colorbar in IDL 8.0 [message #76201 is a reply to message #76113] |
Thu, 19 May 2011 10:52   |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
On May 19, 12:53 pm, David Fanning <n...@idlcoyote.com> wrote:
> David Fanning writes:
>
>> Paolo writes:
>
>>> By the way, the cg version doesn't seem to be properly
>>> honoring the axis ranges. For instance, a y range of
>>> [-100,100] should show an image only in the upper half
>>> of the axis, as the image y-range is only [0,127]...
>
>>> (well one could wonder why would you plot that way...
>>> but the idea behind pg_plotimage was to plot an image the
>>> same way you would use "plot"...)
>
>> Hi Paolo,
>
>> I have no trouble fixing this for the display, but
>> I can't make it write a proper PostScript file. I've
>> gone back to the original code, and I can't make that
>> program write a proper PostScript file with this command
>> either! Have you ever tried to write a PostScript file
>> with the commands above in your original program? :-)
>
> Here is the code I am using with your original program.
>
> loadct,5
> im=dist(128,128)
> x=findgen(128)
> y=findgen(128)
> ps_start, filename='test_1.ps'
> pg_plotimage,im,x,y,xrange=[5,100],$
> yrange=[5,100],/xstyle,/ystyle,/xlog
> ps_end
> ps_start, filename='test_2.ps'
> pg_plotimage,im,x,y,xrange=[5,100],$
> yrange=[-100,100],/xstyle,/ystyle,/xlog
> ps_end
> END
>
> test_1.ps seems to be fine. But test_2.ps is
> buggered. :-)
Yes that's a bug for sure.
Considering the program was written with the idea to
figure out the luminosity of each pixel on the screen
by interpolating the values of the images to a pixel
grid, I guess it's not entirely surprising that it
doesn't work very well with the PS device, which in
fact does not even have the concept of a pixel...
Let me think if I can figure out a solution.
Ciao,
Paolo
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: log scale colorbar in IDL 8.0 [message #76202 is a reply to message #76113] |
Thu, 19 May 2011 09:53   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
>
> Paolo writes:
>
>> By the way, the cg version doesn't seem to be properly
>> honoring the axis ranges. For instance, a y range of
>> [-100,100] should show an image only in the upper half
>> of the axis, as the image y-range is only [0,127]...
>>
>> (well one could wonder why would you plot that way...
>> but the idea behind pg_plotimage was to plot an image the
>> same way you would use "plot"...)
>
> Hi Paolo,
>
> I have no trouble fixing this for the display, but
> I can't make it write a proper PostScript file. I've
> gone back to the original code, and I can't make that
> program write a proper PostScript file with this command
> either! Have you ever tried to write a PostScript file
> with the commands above in your original program? :-)
Here is the code I am using with your original program.
loadct,5
im=dist(128,128)
x=findgen(128)
y=findgen(128)
ps_start, filename='test_1.ps'
pg_plotimage,im,x,y,xrange=[5,100],$
yrange=[5,100],/xstyle,/ystyle,/xlog
ps_end
ps_start, filename='test_2.ps'
pg_plotimage,im,x,y,xrange=[5,100],$
yrange=[-100,100],/xstyle,/ystyle,/xlog
ps_end
END
test_1.ps seems to be fine. But test_2.ps is
buggered. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: log scale colorbar in IDL 8.0 [message #76203 is a reply to message #76113] |
Thu, 19 May 2011 09:42   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Paolo writes:
> By the way, the cg version doesn't seem to be properly
> honoring the axis ranges. For instance, a y range of
> [-100,100] should show an image only in the upper half
> of the axis, as the image y-range is only [0,127]...
>
> (well one could wonder why would you plot that way...
> but the idea behind pg_plotimage was to plot an image the
> same way you would use "plot"...)
Hi Paolo,
I have no trouble fixing this for the display, but
I can't make it write a proper PostScript file. I've
gone back to the original code, and I can't make that
program write a proper PostScript file with this command
either! Have you ever tried to write a PostScript file
with the commands above in your original program? :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: log scale colorbar in IDL 8.0 [message #76205 is a reply to message #76113] |
Thu, 19 May 2011 09:02   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Paolo writes:
> By the way, the cg version doesn't seem to be properly
> honoring the axis ranges. For instance, a y range of
> [-100,100] should show an image only in the upper half
> of the axis, as the image y-range is only [0,127]...
>
> (well one could wonder why would you plot that way...
> but the idea behind pg_plotimage was to plot an image the
> same way you would use "plot"...)
Ah, OK, I misunderstood the notion of "position".
I'll see if I can fix this.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: log scale colorbar in IDL 8.0 [message #76207 is a reply to message #76113] |
Thu, 19 May 2011 08:53   |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
On May 19, 11:42 am, David Fanning <n...@idlcoyote.com> wrote:
> Paolo writes:
>> Ah, very cool! The power of the coyote graphics is strong with you! :)
>> By the way do feel free to use my code for any purpose whatsoever -
>> it's
>> in the public domain.
>
> I have thought about creating a "public" Coyote Graphics
> space, where people can submit programs that make use of
> the CGS system. I don't personally want to maintain these
> programs (I have my hands full most days maintaining my own!),
> but I would like to make them available to the CGS community.
>
> Perhaps I could put this one in there as the inaugural
> contribution. :-)
>
>
>
>> The problem I personally have with cg (and this is entirely the fault
>> of the way IDL manages namespace) is that it can't be run within
>> solarsoft,
>> since solarsoft did seem fit to steal some coyote routines (without
>> renaming
>> them) so now I have several mutually incompatible version of some
>> coyote
>> routines...
>
> Well, I have tried very hard to fix this problem, even
> talking to some of the Solar Soft people several weeks
> ago. I thought I had made all the Coyote Library routines
> compatible with the Solar Soft routines. (Have you downloaded
> a recent Coyote Library?)
Well by putting the coyote library at the beginning
of my path I can run the cg software :) It's just
that I am not sure whether that will or will not
cause some solarsoft routines to crash... but let
me try to run a few weeks with that setup and see
how it works out.
Ciao,
Paolo
>
> If you are having problems with a specific routine,
> I'd be happy to try to fix it. Part of the name change
> business (FSC_Plot -> cgPlot) was to fix this very
> problem!
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: log scale colorbar in IDL 8.0 [message #90584 is a reply to message #76113] |
Thu, 12 March 2015 06:36  |
davide.fedele
Messages: 1 Registered: March 2015
|
Junior Member |
|
|
Hi,
did anyone found a solution to the original question?
Thanks,
Davide
On Tuesday, May 17, 2011 at 10:25:09 PM UTC+2, KH wrote:
> Hello,
>
> I have just started using the new graphics routines in IDL 8.0/8.1 and
> am trying to incorporate them into an extensive set of customized
> plotting and image type routines. I am able to use the IMAGE function
> to display some log-normally distributed data, however I am unable to
> create a colorbar that reflects the log-transformed data.
>
> Here is a simplified example:
> ; Read the data array
> ; Convert the scaled float array (using ALOG10) to a byte array
> im = IMAGE(bytedata)
> cb =
> COLORBAR(target=im,tickvalues=[0.01,0.03,0.1,0.3,1.0,3.0,10. 0,30.0],tickname=['.
> 01','.03','.1','.3','1','3','10','30'], title='Log Data')
>
> Some specific questions:
> 1) How do you scale the color bar so that it reflects the scaled data?
> 2) If tickvalues are supplied, can you also input ticknames? In the
> above example, the supplied ticknames are not used and instead the
> ticknames are derived from the tickvalues. The only way I have been
> able to use the ticknames is to remove the tickvalues keyword.
> 3) Is it possible to set minimum and maximum color or value ranges?
> For example, in one of my commonly used rgb_tables, the 0 value is
> black and above 250 are various shades of gray. How do I set it so
> that mincolor=1 and maxcolor=250?
> 4) Is it possible to create a colorbar that is independent of some
> specified data? It would be very useful to be able to create a
> colorbar just using a user supplied data range instead of being
> directly linked to a specfic data field. There are times when I need
> to create stand alone colorbars and I can't figure out how to do this
> with the COLORBAR function.
>
> Thank you for your assistance,
> Kim
|
|
|