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

Home » Public Forums » archive » problem with output on PS device / TVREAD
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
problem with output on PS device / TVREAD [message #70255] Thu, 25 March 2010 07:57
clément mayet is currently offline  clément mayet
Messages: 8
Registered: March 2010
Junior Member
Hi all,

I want to do something quite simple, but i'm on it since three
days...need help !

I have a structure like this : geo={lon:FLTARR(Nlon),
lat:FLTARR(Nlat) , amp:FLTARR(Nlon,Nlat), pha:FLTARR(Nlon,Nlat)}

Where "amp" and "pha" are tidal wave amplitude and phase.

I would like to plot these data on a geographical map and display the
output in my X window for a preview, and save this image as a PS (or
PNG).

FIRST PROBLEM :
The display in the X window finally works, not so bad, but things get
worse with the postscript....
It's not a problem with COLORS, neither POSITION, but my RESOLUTION is
crude in the Postscript, whereas the image is quite good quality on
the display window.

SECOND PROBLEM :
PS doesn't works ? Ok i'm gonna save it as a PNG, using TVREAD.
And .... my PNG only contains the map grid, titles, etc... but no
image. Worse, the titles, axes, etc. are in purple (the first color of
my color table).

If it can help, my display is 16bits.

Any (good) idea ?
Thanks a lot !



HERE IS MY CODE :

PRO test_map_geomat, ps=ps, png=png

DEVICE, decomposed=0 ;(this is actually in
my startup file)
file=!model_path+'mertz/K1.nc' ; define the
file_path

;load the file and put the data in a structure :
GEO.amp(fltarr(lon,lat), GEO.pha(fltarr(lon,lat), GEO.LON, GEO.LAT
geo=tugo2geomat_cl(file,/TIDE)

; get geographical limits
minlon=MIN(geo.lon, /NAN, MAX=maxlon)
minlat=MIN(geo.lat, /NAN, MAX=maxlat)
limit=[minlat,minlon,maxlat,maxlon]

; Define colors
ncolors=50
pal_num=25

white = GetColor('white', ncolors)
black = GetColor('black', ncolors+2)

missing=white

; Load colors for display.
!P.Background = white
!P.Color = black
erase

; Load Color table
loadct,pal_num, NCOLORS=ncolors


; For PS output Only
IF KEYWORD_SET(ps) THEN BEGIN
rightsize = PSWINDOW(/CM)
this_device = !D.name
SET_PLOT,
'PS'
device, color=1, bits_per_pixel=8 , _EXTRA=rightsize
device, filename=!idl_output+'toto.ps'
ENDIF


; FIRST PLOT : tide PHASE
; SET the plot position
pos=[0.1,0.2,0.45,0.8]

; Set the MAP
MAP_SET,/NOERASE, /MERCATOR, /ISOTROPIC, /NOBORDER, XMARGIN=[3,3],
YMARGIN=[3,3], LIMIT=limit, TITLE='Phase (deg) !C', POSITION=pos,
color=black

; compute min and max for appropriate scaling
minpha=MIN(geo.pha, /NAN, max=maxpha)
; Scaling (scale all the values between MIN and MAX from 0 to TOP,
Nan are set to 'missing')
pha_scaled = arrscl(geo.pha, min_value=minpha, max_value=maxpha,
top=(ncolors-1), missing=missing)
; wrap image to the map, returns positions and sizes
pha_img = MAP_IMAGE(pha_scaled,x_offet, y_offset,xsize,ysize, /
BILINEAR, COMPRESS=1, LONMIN=limit[1], LONMAX=limit[3],
LATMIN=limit[0], LATMAX=limit[2])
;DISPLAY on TV
tv,pha_img, x_offet, y_offset, XSIZE=xsize,YSIZE=ysize
; display the geographical grid
MAP_GRID,/BOX_AXES, _EXTRA=_EXTRA, COLOR=black

pos=[0.1,0.05,0.45,0.08]
COLORBAR, ncolors=ncolors, range=[minpha, maxpha], POSITION=pos

; SECOND PLOT : tide amplitude

pos=[0.55,0.2,0.9,0.8]
MAP_SET, /NOERASE, /MERCATOR, /ISOTROPIC, /NOBORDER, /GRID,
E_GRID={BOX_AXES:1}, XMARGIN=[3,3], YMARGIN=[3,3], LIMIT=limit,
TITLE='Amplitude (cm) !C', POSITION=pos, color=black
minamp=MIN(geo.amp, /NAN, max=maxamp)
amp_scaled = arrscl(geo.amp, min_value=minamp, max_value=maxamp,
top=(ncolors-1), missing=missing)
amp_img = MAP_IMAGE(amp_scaled,x_offet, y_offset,xsize,ysize, /
BILINEAR, COMPRESS=1, LONMIN=limit[1], LONMAX=limit[3],
LATMIN=limit[0], LATMAX=limit[2])
tv,amp_img, x_offet, y_offset, XSIZE=xsize,YSIZE=ysize
MAP_GRID,/BOX_AXES, _EXTRA=_EXTRA, color=black

pos=[0.55,0.05,0.9,0.08]
COLORBAR, ncolors=ncolors, range=[minamp*100, maxamp*100],
POSITION=pos


; CLOSE THE PS file and Display with GV
IF KEYWORD_SET(ps) THEN BEGIN
device, /close_file
set_plot, this_device
spawn, 'gv '+!idl_output+'toto.ps'
ENDIF



IF KEYWORD_SET(png) THEN BEGIN

toto=TVREAD()
erase
TVIMAGE, TOTO

;spawn, 'display '+!idl_output+'toto'
ENDIF


END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Distance between two sets of datapoints
Next Topic: PCA in IDL

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

Current Time: Wed Oct 08 15:57:20 PDT 2025

Total time taken to generate the page: 0.00520 seconds