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

Home » Public Forums » archive » Please, please, please can we have a missing data color for image()
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Please, please, please can we have a missing data color for image() [message #88755 is a reply to message #88745] Fri, 13 June 2014 14:48 Go to previous messageGo to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Thursday, June 12, 2014 2:38:39 AM UTC-6, Fabien wrote:
> Thanks Gordon! I completely agree

Okay, here's some code to try. I didn't add the MISSING_VALUE/COLOR keywords yet. Instead, I'm just keying off of NaN values.

Open up lib/components/idlitvisimage__define.pro, and navigate to around line 1965. Modify the following block of code (I've included bits of code before & after for reference).

pImageData = self->ByteScaleData(pImgData, data, nPlanes)
; Single-channel images must have a palette.
; This will also retrieve the red, green, blue values.
if (nPlanes eq 1) then $
self->EnsurePalette, red, green, blue

**** NEW CODE
; Handle float images with missing data.
if (~self._isByteData && nPlanes eq 1) then begin
good = FINITE(*pImgData)
if (~ARRAY_EQUAL(good, 1b)) then begin
nPlanes = 2
d = TEMPORARY(data)
data = BYTARR(imgDims[0], imgDims[1], 2)
data[0,0,0] = TEMPORARY(d)
data[0,0,1] = 255b*good
endif
endif
**** END NEW CODE

; Map projections. This may modify both the data and nPlanes.
self->_UpdateMapProjection, data, nPlanes, red, green, blue
imgDims = (SIZE(data, /DIMENSIONS))[0:1]

Then, try your test case, but be sure to use /BITMAP when writing to the PDF file (to avoid alpha channel issues):

data = findgen(100, 100) - 5000.
data[30:60,30:60] = !values.f_nan
im1 = image(data, RGB_TABLE=70, POSITION=[0.1, 0.1, 0.9, 0.9])
cb1 = colorbar(TARGET=im1)
im1.save,'test.pdf',/bitmap

Let me know if this works. If it does, I'll think about adding the MISSING_* keywords.

Cheers,
Chris
ExelisVIS
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fitting with three parameters ???
Next Topic: Error while creating video in IDL

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

Current Time: Wed Oct 08 16:13:47 PDT 2025

Total time taken to generate the page: 0.00433 seconds