Re: time conversion

Can you use the udunits package to do the conversion for you?

http://my.unidata.ucar.edu/content/software/udunits/index.html

On Thu, 24 Feb 2005 12:17:02 -0800
araligin@xxxxxxxxxxxxx wrote:

Hi,

 I have my time variable reading below for the netcdf file
   double time(time) ;
               time:units = "hours since 1-1-1 00:00:0.0" ;
               time:long_name = "Time" ;
               time:actual_range = 17461560., 17549208. ;
               time:delta_t = "0000-00-01 00:00:00" ;


   my first data is from 01 Jan 1993. I read the time as double
   precision and
convert it to integer and give input to the subroutine which converts
into UTC. But I get the first date as 27 Nov 1993.  following is the
subroutine.

subroutine  ymd(jn)
   integer W,X,A,B,C,D,E,F
   integer mnt,yr,day
     integer  jn,Z
      write(*,*) jn
     jn=int(jn/24.0)
     z=jn
       w=int((z - 1867216.25)/36524.25)
c       w=z/36524.25
c       w=z
C       x=int(w/4)
       a=z+1+w-int(0.250*w)
       write(*,*) w,x,a
       b=a+1524
       c=int( 6680.0+((b-2439870)-122.1)/365.25)
       d = 365*c+int(0.25*c)
       e= int((b-d)/30.6001)
       f= int(30.6001*e)
       write(*,*) b,c,d,e,f
       day= b - d - f
       if(e.lt.13.5) then
              mnth=e-1
        else
              mnth=e-13
       endif
       if(mnth.le.2) yr = c -1
       if(mnth.gt.2) yr = c-2
       write(12,*) yr,mnth,day
       return
       END


Thanking you,
Nilesh



From owner-netcdfgroup@xxxxxxxxxxxxxxxx 3 2005 Mar -0000 09:07:50
Message-ID: <20050303090750.18857.qmail@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: 3 Mar 2005 09:07:50 -0000
From: "lvgbuoy nio" <lvgbuoy@xxxxxxxxxxxxxx>
To: netcdfgroup@xxxxxxxxxxxxxxxx
Subject: cdf file
Received: (from majordo@localhost)
        by unidata.ucar.edu (UCAR/Unidata) id j2396R3f012665
        for netcdfgroup-out; Thu, 3 Mar 2005 02:06:27 -0700 (MST)
Organization: UCAR/Unidata
Keywords: 200503030906.j2396Mv2012658
MIME-Version: 1.0
Content-type: multipart/alternative;
        boundary="Next_1109840870---0-203.199.83.35-18832"
Sender: owner-netcdfgroup@xxxxxxxxxxxxxxxx
Precedence: bulk
Reply-To: "lvgbuoy nio" <lvgbuoy@xxxxxxxxxxxxxx>

This is a multipart mime message


--Next_1109840870---0-203.199.83.35-18832
Content-type: text/plain;
        charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

=A0=0AHi,=0ACan anyone send a sample cdf file.We r using LAS.so we r just
trying to add new datasets.=0A=0AThanx
--Next_1109840870---0-203.199.83.35-18832


  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: