Re: log10

From: Ben Foster (foster AT XXXXXX)
Date: Mon Feb 02 2004 - 09:20:16 MST

  • Next message: Maurice McHugh: "2 NCL Qs"

    Dennis:

    Yes, thanks, approach 1 works fine. After looking through the
    ncl docs and Sylvia's examples, I also found that the following
    works:

        var1 = mask(var,(var.gt.0.),True)
        var = log10(var1)
        
    It doesnt seem necessary to set the fill value. The plots
    look identical using both methods.

    Thanks to all who responded to my question..

    --Ben

    >
    >Ben,
    >
    >An f90 type where is on NCL's list-of-things-to-do but for now:
    >
    > var = a->$vars(n)$(time2plot,:,:,lons2plot(i))
    >
    >Approach 1: This is very fast
    >
    > var = var > 0.0 ; make all values lt 0.0 = 0.0
    > ; like f90: where(var.lt.0.0) var = 0.0
    > var@_FillValue = 0.0 ; set zero as _Fillvalue [will be ignored in log10]
    > var = log10(var)
    > ... ; There is a bug when trying to plot
    > ; contours with a _FillValue = 0.0, so change
    > var@_FillValue = 1.e20 ; all 0.0 changed to 1.e20
    > plot var
    >
    >Approach 2:
    >
    > var_1d = ndtooned(var) ; make 1d
    > indx = ind(var_1d.le.0.0)
    > var_1d(indx) = 1.e20
    > var = onedtond(var_1d, dimsizes(var))
    > var@_FillValue = 1.e20
    > var = log10(var)
    >
    >Note if this is done often u could build a function to do this.
    >
    >Regards
    >Dennis
    >>Hi ncl-talk:
    >>
    >>Here's a simple question. I want to plot log10 of my field, e.g.:
    >>
    >> var = a->$vars(n)$(time2plot,:,:,lons2plot(i))
    >> var = log10(var)
    >> ...
    >> plot var
    >>
    >>If there are values of var <= 0., I get -INF in those areas of the
    >>array after the log10 (no error or warning messages). It then hangs
    >>in the plot call.
    >>
    >>I don't think ncl has a "where" function, and I don't want to loop
    >>w/ conditionals, so what is the best way to take log10 of the field
    >>and substitute a fill_value where the array is <= 0.? Thanks,
    >>
    >>--Ben
    >>
    >>
    >>-----------------------------------------------------------------------
    >>Ben Foster High Altitude Observatory (HAO)
    >>foster@ucar.edu phone: 303-497-1595 fax: 303-497-1589
    >>Nat. Center for Atmos. Res. P.O. Box 3000 Boulder CO 80307 USA
    >>-----------------------------------------------------------------------
    >>
    >>_______________________________________________
    >>ncl-talk mailing list
    >>ncl-talk@ucar.edu
    >>http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    >
    >_______________________________________________
    >ncl-talk mailing list
    >ncl-talk@ucar.edu
    >http://mailman.ucar.edu/mailman/listinfo/ncl-talk

    -----------------------------------------------------------------------
    Ben Foster High Altitude Observatory (HAO)
    foster@ucar.edu phone: 303-497-1595 fax: 303-497-1589
    Nat. Center for Atmos. Res. P.O. Box 3000 Boulder CO 80307 USA
    -----------------------------------------------------------------------

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Mon Feb 02 2004 - 09:40:56 MST