Re: ut_inv_calendar

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 04 Jul 2008 09:56:30 -0600

Maybe you could write you own "wrapper" that has the
same arguments ...

UNTESTED

function UT_INV_CLAENDAR(time, opt)

local OPT, DATE, iDATE, dimDATE, rank

begin

    OPT = opt

    if (opt.eq.5) then

        OPT = 0

    end if

    DATE = ut_calendar(time, OPT)

    if (opt.eq.5) then

          dimDATE = dimsizes(DATE)

          rank = dimsizes(dimDATE)

          if (rank.eq.2) then

              iDATE = new( dimsizes(DATE), "integer", "No_FillValue")

              iDATE(:,0) = floattointeger(DATE(:,0))

              iDATE(:,1) = floattointeger(DATE(:,1))

              iDATE(:,2) = floattointeger(DATE(:,2))

              iDATE(:,3) = floattointeger(DATE(:,3))

              iDATE(:,4) = floattointeger(DATE(:,4))

              iDATE(:,5) = floattointeger(DATE(:,5))

         else

              iDATE = new( 6, "integer", "No_FillValue")

              iDATE(0) = floattointeger(DATE(0))

              iDATE(1) = floattointeger(DATE(1))

              iDATE(2) = floattointeger(DATE(2))

              iDATE(3) = floattointeger(DATE(3))

              iDATE(4) = floattointeger(DATE(4))

              iDATE(5) = floattointeger(DATE(5))

         end if

         return(iDATE)

    else

        return(DATE)

    end if
end

Mateus Teixeira wrote:
> Thanks Dave,
>
> Maybe ut_calendar could have an option equivalent to 0 that returns
> integers.
>
> Regards,
>
>
> 2008/7/3 Dave Allured <dave.allured_at_noaa.gov
> <mailto:dave.allured_at_noaa.gov>>:
>
> Mateus,
>
> I think it is usually better to keep unencoded date information as
> integers rather than floats. You can do this in one line when
> calling ut_calendar:
>
> ymd_hms = floattoint (ut_calendar (time, 0))
>
> Then you do not have to do the multiple reverse conversions for
> ut_inv_calendar. HTH.
>
> Dave Allured
> CU/CIRES Climate Diagnostics Center (CDC)
> http://cires.colorado.edu/science/centers/cdc/
> NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
> http://www.cdc.noaa.gov/
>
> Mateus Teixeira wrote:
>
> Dear NCL developers,
>
> Is it possible modify ut_inv_calendar arguments to numerical type?
>
> Sometimes is necessary to convert a set of dates from one time
> unit to another time unit.
> Since ut_calendar with 0 option returns float, it would avoid
> the float to integer conversion to put their information into
> ut_inv_calendar.
>
> Regards,
>
> --
> Mateus da Silva Teixeira
> Meteorologista
> Instituto de Pesquisas Meteorológicas - IPMET
> (www.ipmet.unesp.br <http://www.ipmet.unesp.br>
> <http://www.ipmet.unesp.br>)
> Universidade Estadual Paulista - UNESP (www.unesp.br
> <http://www.unesp.br> <http://www.unesp.br>)
> Bauru, SP
>
> Registered Linux User #466740
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu <mailto:ncl-talk_at_ucar.edu>
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu <mailto:ncl-talk_at_ucar.edu>
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Mateus da Silva Teixeira
> Meteorologista
> Instituto de Pesquisas Meteorológicas - IPMET (www.ipmet.unesp.br
> <http://www.ipmet.unesp.br>)
> Universidade Estadual Paulista - UNESP (www.unesp.br
> <http://www.unesp.br>)
> Bauru, SP
>
> Registered Linux User #466740
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 04 2008 - 09:56:30 MDT

This archive was generated by hypermail 2.2.0 : Sun Jul 06 2008 - 17:04:16 MDT