Re: uv2dvF and uv2vrF NaN values

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 21 2014 - 14:17:48 MST

Jon,

It would be an issue if you are passing in "Inf" or "NaN" values to *any* function in NCL, except for two special functions we have for checking this kind of thing.

You can use the "isieee_nan" and "replace_ieeenan" functions to "fix" any data that has bad values in it.

See the FAQ:

http://www.ncl.ucar.edu/FAQ/#data_hand_004

I'm assuming that "Inf" values will be seen as "NaN" values by these functions. Let me know if you try this and it doesn't work.

--Mary

On Feb 21, 2014, at 12:28 PM, jonathan meyer <tallj03@hotmail.com> wrote:

> Hi Mary,
>
> I've been digging into this and believe I have found the issue with returns of NaNs.
>
> It seems that the input arrays that were being fed to these functions have some 'inf and -inf' values in a few grid cells.
>
> I re-created the input files so no 'inf' values were included and the functions seem to be working normally (although plotting even a single panel is painstakingly long which I'm guessing is a product of the very small values of vorticity and divergence and the precision of the contour levels needed????).
>
> It seems the functions saw some of these 'inf' values and choked?
>
> I can send along both versions of the input files and my working .ncl code if you feel it is necessary to look into the issue further.
>
>
> Thanks,
> Jon
>
>
>
> > Subject: Re: uv2dvF and uv2vrF NaN values
> > From: haley@ucar.edu
> > Date: Thu, 20 Feb 2014 08:53:37 -0700
> > CC: ncl-talk@ucar.edu
> > To: tallj03@hotmail.com
> >
> > Hi Jon,
> >
> > If *any* NCL function is returning NaN, this is a problem. They should be returning missing values or else issuing some kind of error.
> >
> > Can you provide the two NetCDF files online? You can use our ftp:
> >
> > http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP
> >
> > --Mary
> >
> >
> > On Feb 19, 2014, at 3:50 PM, jonathan meyer <tallj03@hotmail.com> wrote:
> >
> > > Good afternoon NCL-ers,
> > >
> > > I am computing ageostrophic winds using actual winds and geostrophic winds. In order to convince myself the ageostrophic wind fields satisfy the mathematics of the atmosphere I am computing the divergence and vorticity of the ageostrophic winds which should equal zero everywhere.
> > >
> > > Using the uv2dvF and uv2vrF functions to compute these two fields returns NaN values for the entire array. I've confirmed there are no missing data, and the dataset is on a global fixed grid with the latitude monotonically increasing (-90 to 90).
> > >
> > >
> > >
> > > My question:
> > >
> > > Is the return of NaN an artifact of the functions where divergence/vorticity is actually zero?
> > >
> > > I've tested these functions using actual U and V winds and they return appropriate ranges of values, so something is unique to the ageostrophic winds.
> > >
> > > Thanks in advance,
> > > Jon
> > >
> > >
> > > My Code Snippet
> > >
> > > begin
> > > ;==================================================================
> > > print("ESTABLISH CCSM FILES AND RETRIEVE DIMENSION INFO")
> > > ; =================================================================
> > >
> > > f1_in = addfile(dir1 + "CCSM_REG_U_test1979.nc", "r")
> > > f2_in = addfile(dir2 + "CCSM_REG_V_test1979.nc", "r")
> > >
> > > lev = f1_in->lev
> > > lat = f1_in->lat2(::-1)
> > > lon = f1_in->lon2
> > >
> > > n_lev = dimsizes(lev)
> > >
> > > ; =================================================================
> > > print("READ IN CCSM DATA")
> > > ; =================================================================
> > >
> > > Ug = f1_in->Ug(:,:,::-1,:)
> > > U = f1_in->U( :,:,::-1,:)
> > >
> > > Vg = f2_in->Vg(:,:,::-1,:)
> > > V = f2_in->V( :,:,::-1,:)
> > >
> > > ; =================================================================
> > > print("COMPUTE AGEOSTROPHIC WINDS")
> > > ; =================================================================
> > >
> > > Ua = U-Ug
> > > Va = V-Vg
> > >
> > > ; =================================================================
> > > print("COMPUTE DIVERGENCE AND VORTICITY OF AGEOSTROPHIC WINDS")
> > > ; =================================================================
> > >
> > > print(num(ismissing(Ua)))
> > > print(num(ismissing(Va)))
> > >
> > > div = uv2dvF(Ua,Va)
> > > vor = uv2vrF(Ua,Va)
> > >
> > > ****RESOURCE SETTING BLAH BLAH*******
> > >
> > > do z = 0, n_lev-1
> > > print("Plotting level " + lev(z))
> > >
> > > resdiv@gsnCenterString = "Divergence"
> > > plot(0) = gsn_csm_contour_map_ce(wks, div(0,z,:,:), resdiv)
> > >
> > > resvor@gsnCenterString = "Vorticity"
> > > plot(1) = gsn_csm_contour_map_ce(wks, vor(0,z,:,:), resvor)
> > >
> > > resP@txString = "00Z 1 July 1979 "+ lev(z) + "-mb"
> > > gsn_panel(wks,plot, (/2,1/), resP)
> > >
> > > end do
> > >
> > >
> > > end
> > >
> > >
> > >
> > > When Running the code:
> > >
> > > See http://www.ncl.ucar.edu/ for more details.
> > > (0) ESTABLISH CCSM FILES AND RETRIEVE DIMENSION INFO
> > > (0) READ IN CCSM DATA
> > > (0) COMPUTE AGEOSTROPHIC WINDS
> > > (0) COMPUTE DIVERGENCE AND VORTICITY OF AGEOSTROPHIC WINDS
> > > (0) 0
> > > (0) 0
> > > (0) Plotting level 30
> > > warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]
> > > warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]
> > > (0) Plotting level 50
> > > warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]
> > > warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]
> > >
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Feb 21 14:17:59 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 03 2014 - 14:26:18 MST