Re: floating underflow errors [message #30183] |
Thu, 11 April 2002 07:19 |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Patrick McEnaney wrote:
>
> Greetings All-
>
> I've read through the fairly extensive history of posts regarding
> floating underflow arithmetic error messages on the group and wanted
> to see if anyone can suggest a fix for the problems I'm having. My
> code is a simple interpolation to create a 2d contour of oceanographic
> data values. Strangely enough I haven't always had the floating
> underflow message popping up in my code but the data can be variable
> depending on what coastal area the data is collected in. I believe the
> problem is occurring either because there are actual zeros appearing
> in the data files or as a result of the simple interpolation function
> I'm using. I would ignore the message other than the code sometimes
> crashes.
At what point does it crash? What conditions cause bogus numbers to appear? What numbers in the
input data would you consider bogus?
A small test data file that contains bogus data (you have one, right?) should reveal that.
> Below is an example of the routine I'm running on a number of
> fields and adjusting the scale appropriately. My question is can I
> work around the problem by using a combination of 1) notification
> about a floating underflow occurrence by using the !EXCEPT system
> variable,
For testing, sure. Dunno about "production" runs though.
> and 2) applying the WHERE function to replace occurrences of
> 0 with a NaN or some other null value that won't otherwise affect the
> outcome of my contour plot?
Why not just eliminate the crappy data before the interpolation is done? e.g.
crap = some_value_that_will_not_screw_up_interpolation
valid_index = WHERE( ( x1 NE crap )AND $
( y1 NE crap ) AND $
( x2 NE crap ) AND $
( y2 NE crap ), valid_count )
IF ( valid_count GT 0 ) THEN BEGIN
x1 = x1[ valid_index ]
y1 = y1[ valid_index ]
x2 = x2[ valid_index ]
y2 = y2[ valid_index ]
ENDIF ELSE $
MESSAGE, 'All the data was crappy'
Dunno if the syntax above will work, but you get the idea
(Of course you'll probably need different "crap" values for the different arrays and use a
tolerance test rather than a "NE")
paulv
>
> The data are organized as ascii arrays that interpolate between two
> locations at the same depth for various fields.
>
> Any suggestions are greatly appreciated,
>
> Regards,
>
> Patrick
>
> code:
>
> if (event.index eq 1) then begin
>
> x1 = reform((*pstate).profiledata(4,*,0)) ; depth at 1
> y1 = reform((*pstate).profiledata(4,*,1)) ; depth at 2
>
> x2 = reform((*pstate).profiledata(6,*,0)) ; density at 1 f(x1)
> y2 = reform((*pstate).profiledata(6,*,1)) ; density at 2 f(y1)
>
>
> x2=x2[sort(x1)]
> y2=y2[sort(y1)]
> x1=x1[sort(x1)]
> y1=y1[sort(y1)]
>
> ;print,(size(x1))[1],(size(y1))[1]
> ;print, x1, y1
>
> x1=x1[0:(size(x1))[1]-1]
> y1=y1[0:5684]
> x2=x2[0:(size(x2))[1]-1]
> y2=y2[0:5684]
>
> ; interpolate 1st data onto 2nd data alt grid
> x2i = interpol(x2, x1, y1) ; density at 1 f(y1)
> ;x2i(0) = ABS(x2i(0))
> badnum=fltarr(1)
> badnum = FINITE(x2i, /INFINITY)
> ndepth=(size(x2i))[1]
> nsep=100
>
> print,max(x2i),min(x2i),max(y2),min(y2)
>
> dens=DBLARR(ndepth,nsep)
> for d=0,ndepth-1 do begin
> for s=0,nsep-1 do begin
> dens[d,s]=x2i[d]+(y2[d]-x2i[d])*s/(nsep-1)
> endfor
> endfor
>
> print,min(dens),max(dens)
>
> sep=DINDGEN(nsep)/(nsep-1)
> dep=DINDGEN(ndepth)/(ndepth-1)*(MAX(y1)-MIN(y1))+MIN(y1)
>
> nlevels=10
> levels=DINDGEN(nlevels)/(nlevels-1)*(max(dens)-min(dens))+mi n(dens)
> labels=INTARR(nlevels)+1
>
> contour,transpose(dens),sep,dep ,YRANGE=[max(y1),min(y1)], $
> levels = [20.5,21.5,21.6, 21.7, $
> 21.8,21.9,22.0, 22.1] ,c_labels=labels, $
> c_annotation = ['3.0','3.5','3.6', '3.7', $
> '4.0','4.1','4.3', '4.6'],XTITLE = 'Space', YTITLE = 'Depth (m)', $
> c_colors=[60,120,250], TITLE = 'Density (sigma-t)'
>
> endif
--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
|
|
|