Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58586] |
Thu, 07 February 2008 06:58 |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Kathryn,
below is the scheme that I use. The trick is to map the z uffer plot to true
colors. Also, I make a huge plot in the z-buffer and then rebin the plot to
a smaller size so my fonts looks decent.
Good luck, haje
; create spectrogram in z buffer and take snapshot
thisdevice=!d.name
set_plot,'z'
device,set_resolution=[2400,3200],set_font='helvetica',/tt_f ont,set_character_size=[40,50]
*** plot here what needs to be plotted ***
; take snapshot of z buffer
snapshot=tvrd()
device,/close
set_plot,thisdevice
; convert snapshot from index colors to true colors
tvlct,r,g,b,/get
sz=size(snapshot,/dimensions)
snapshot3=bytarr(3,sz[0],sz[1])
snapshot3[0,*,*]=r[snapshot]
snapshot3[1,*,*]=g[snapshot]
snapshot3[2,*,*]=b[snapshot]
; shrink snapshot
xsize=600
ysize=800
snapshot3=rebin(snapshot3,3,xsize,ysize)
; write jpeg graphics file
jpg_fname=file_basename(fname,'dat')+'jpg'
write_jpeg,jpg_fname,snapshot3,/true,quality=100
<kathryn.ksm@gmail.com> wrote in message
news:72597909-3fc0-4419-be49-578f37fea7c1@s8g2000prg.googleg roups.com...
> Hi folks,
>
> This newsgroup has been a huge help to me with these sorts of problems
> in the past, and I am hoping once again to draw on your expertise.
>
> My problem is a little complicated. I have a particular plotting
> routine that uses a color scale to represent signal response over a
> grid of detectors. I use this a lot and it's really handy. It also
> took me a really long time to get it to work and to be able to
> write_png files from it without getting goofy colors. What I would
> like to do is automate this routine and run it with a cron job,
> outputting png files to include in a daily web page.
>
> I have noticed that quite a few people have tried to do similar things
> and run into problems. I have problems with all of the suggested
> solutions. Any one of them would be fine but I can't get them to
> work. So here goes:
>
> option 1) use the Z buffer: Here I think I am running into problems
> with my understanding of true-color display issues in IDL. My plot
> routine includes a line 'Device, decomposed = 0' and the Z-buffer
> doesn't work the same way as the X buffer. That's problem number
> one. Problem number two is that I can't figure out how to take the Z-
> buffer plot and make a png file out of it with correct colors.
>
> option 2) write to a ps file and convert it to png after the fact. I
> have similar problems here with my Device, decomposed = 0, and I don't
> understand how to translate my plotting routine so that it will do the
> same thing with the ps device that it does with standard X output.
>
> option 3) use the /pixmap option with an X window, and then use Xvfb
> to run a virtual X session so that I can run this from cron. I have
> Xvfb installed and with some fiddling, I can get the authentication to
> work out so that I don't get an immediate Xlib: connection to ":1.0"
> refused by server, but even then I still get WINDOW: Unable to connect
> to X Windows display: :1.0 errors, even though the DISPLAY variable
> looks to be set correctly to me. I really hoped I could get this to
> work, because doing window, 1, /pixmap, running the plotter, and then
> calling write_png, 'file.png', tvrd(/true) works wonderfully and gives
> exactly what I want... just not through cron.
>
> I think the main reason I'm having so much trouble here is I'm trying
> to get something to work with color tables and true-color display
> without really understanding them. A stripped-down version of the
> plotting routine is below. I would invoke it with something like
>> plot_test, [0,2,3],[0.2,0.7,1.0]. Before I run this, I have quite a
> few graphics setup calls in my idl_startup file. Between running it,
> I typically do
> loadct, 0
> !p.color = !black
> !p.background = !white
> to make the display look right each time.
>
> Sorry for the long-winded question. Sample plotting routine follows:
>
> pro plot_test, indices, color_scale,$
> title=title
>
> if n_elements(title) eq 0 then title=''
>
> ; example simple grid of 4 points:
> x_pos=[1., 2., 1., 2.]
> y_pos=[1.,1.,2.,2]
>
> ;plot, the center points for each detector:
> plot, x_pos, y_pos, xrange=[0,3],yrange=[0,3],/xstyle,/ystyle,/iso,$
> psym = 3, title = title
> Device, decomposed = 0
> LoadCT, 33
> ; determine the color scale to use
> color_scale=float(color_scale)
>
> color_values = ((color_scale - min(color_scale))/(max(color_scale)-
> min(color_scale)))* 255
>
> ;plot circles filled with the colors in the scale
> for i=0,n_elements(indices)-1 do begin
> polyfill, circle(x_pos[indices[i]],y_pos[indices[i]],0.25),
> color=color_values[i]
> endfor
>
> colorbar, /vertical, format='(F6.2)',$
> range=[min(color_scale),max(color_scale)]
>
> end
>
>
> - Kathryn
>
|
|
|