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

Home » Public Forums » archive » cgPlotS problem with NaN values in data
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
cgPlotS problem with NaN values in data [message #88960] Tue, 08 July 2014 12:05 Go to next message
morganlsilverman is currently offline  morganlsilverman
Messages: 46
Registered: February 2013
Member
Hello,

I'm plotting latitude/longitude data on a map background using cgPlotS and keep getting the error message: % Program caused arithmetic error: Floating illegal operand when it gets to a NaN value in the data. Because I'm plotting this in a resizable graphics window it also brings up the keep command or delete command box each time, eventually crashing my session. Is there a way to get around this without removing the NaN values from my data? I haven't converted the coordinates to metered space because when I did it plotted the lat/lon values in the wrong locations. I think because the data is taken from a model that was run on a map coordinate system maybe. Thanks.

-Morgan

Pro MOZAICPanel3

lonmin = -125
lonmax = -65
latmin = 25
latmax = 60
centerlon = (lonmax-lonmin)/2.0 + lonmin
centerlat = (latmax-latmin)/2.0 + latmin
limit = [latmin, lonmin, latmax, lonmax]
xrange = [lonmin, lonmax]
yrange = [latmin, latmax]
mapCoord = Obj_New('cgmap', 'Stereographic', Ellipsoid='WGS 84', Limit=limit, $
center_lat=centarlat, center_lon=centerlon)

; Set up 2-col by 3-row grid
p = cgLayout([2,3], Aspect=0.65, YGap=3.5, XGap=4, OXMargin=[3,3], OYMargin=[2.5,2.5])

; Draw plots
pos = p(*,5)
restore, './MOZAIC/Trajectories/MOZAIC_Washington_BackTrajectory.sav'
mapCoord->SetProperty, Position=pos, /Draw
cgMap_Grid, map=mapCoord, /box
cgMap_Continents, map=mapCoord, /continents, /countries, /usa
cgplots, lon2500(3,*), lat2500(3,*), map=mapCoord, color='green', thick=4
cgplots, lon3000(3,*), lat3000(3,*), map=mapCoord, color='cyan', thick=4
cgplots, lon3500(3,*), lat3500(3,*), map=mapCoord, color='magenta', thick=4

end
Re: cgPlotS problem with NaN values in data [message #88962 is a reply to message #88960] Tue, 08 July 2014 13:18 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Try plotting only the points that have non-NaN values.


iGood = where(finite(lon2500[3,*]) and finite(lat2500[3,*]), nGood)
if nGood gt 0 then cgplots, lon2500[3,iGood], lat2500[3,iGood], map=mapCoord, color='green', thick=4

etc.
Re: cgPlotS problem with NaN values in data [message #88963 is a reply to message #88960] Tue, 08 July 2014 13:39 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Morgan Silverman writes:

> I'm plotting latitude/longitude data on a map background using cgPlotS and keep getting the error message: % Program caused arithmetic error: Floating illegal operand when it gets to a NaN value in the data. Because I'm plotting this in a resizable graphics window it also brings up the keep command or delete command box each time, eventually crashing my session. Is there a way to get around this without removing the NaN values from my data? I haven't converted the
coordinates to metered space because when I did it plotted the lat/lon values in the wrong locations. I think because the data is taken from a model that was run on a map coordinate system maybe.

As you point out (somewhat ungraciously by blaming cgPlotS, I might
add), there is a problem when you try to do numbery things with things
that aren't, well, numbers. It's like adding (4 + "atrocious"). What in
the world do you end up with?

But, your problem is not that you can't plot the numbers. To plot the
numbers, you have to first convert them to projected meter space (the
purpose of the map coordinate object you are passing to cgPlotS). This
is the thing that is failing you, I believe.

I don't think you have any choice but to remove the incalculable points.
Where would you locate the darn things on the map otherwise?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: cgPlotS problem with NaN values in data [message #88964 is a reply to message #88963] Tue, 08 July 2014 14:00 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 07/08/14 16:39, David Fanning wrote:
> there is a problem when you try to do numbery things with things
> that aren't, well, numbers. It's like adding (4 + "atrocious"). What in
> the world do you end up with?

Ha! I was going to go with the boring old:

Man: "Doctor, it hurts when I do this."
Doctor: "Well, don't do that!"

but your wordz is bettah.

I'm going to cogitate on how to use the phrases 'numbery things' and '(4
+ "atrocious")' in my near-future interactions with colleagues....

cheers,

paulv
Re: cgPlotS problem with NaN values in data [message #88965 is a reply to message #88964] Tue, 08 July 2014 15:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul van Delst writes:

>
> On 07/08/14 16:39, David Fanning wrote:
>> there is a problem when you try to do numbery things with things
>> that aren't, well, numbers. It's like adding (4 + "atrocious"). What in
>> the world do you end up with?
>
> Ha! I was going to go with the boring old:
>
> Man: "Doctor, it hurts when I do this."
> Doctor: "Well, don't do that!"
>
> but your wordz is bettah.
>
> I'm going to cogitate on how to use the phrases 'numbery things' and '(4
> + "atrocious")' in my near-future interactions with colleagues....

I was worried you were going to say my example was too much like
operator overloading. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL in IPython notebooks
Next Topic: Projected Meter Space and mapCoord

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

Current Time: Wed Oct 08 11:34:48 PDT 2025

Total time taken to generate the page: 0.00502 seconds