> Hi all,
>
> I have a variable with the time axis as a STRING, say
> (0)     1980_02_26_01_0
> (1)     1980_04_21_01_0
> (2)     1980_05_28_01_0
> .......................................
> .......................................
>
> Is is possible to write this variable into a netcdf file? I have tried the 
> method 1 (http://www.ncl.ucar.edu/Applications/method_1.shtml) but gives the 
> following error.
>
> fatal:Attempting to write variable (time) of type (string) which is not 
> representable in the format of file (./CNRM_05_TO/PATT_IND0.nc)
> fatal:Trying using a type conversion function
> warning:FileWriteVarVar: Could not write coordinate variable (time) to file 
> (PATT_IND0), continuing anyway
>
> I even tried to convert the string to integer, but the result is
> (0)     1980
> (1)     1980
> (2)     1980
>
> Any tips on how to handle this time axis? Thanks in advance
> Prince
> _______________________________________________
It is not NCL that is the problem.
netCDF currently does not allow string variables.
The next release of netCDF will allow string variables.
http://www.unidata.ucar.edu/software/netcdf/netcdf-4/
  _______________________________________________
begin
      stime = (/"1980_02_26_01_0","1980_04_21_01_0","1980_05_28_01_0"/)
      ctime = stringtochar( stime )
      print(ctime)                     ; note: it is 2D
      ntim  = dimsizes( stime )
      year  = stringtoint( chartostring(ctime(:,0:3)) )
      mon   = stringtoint( chartostring(ctime(:,5:6)) )
      day   = stringtoint( chartostring(ctime(:,8:9)) )
      print( year+"  "+mon+"  "+day )
      time  = year*10000 + mon*100 + day
      time!0         = "time"
      time_at_long_name = "time"
      time_at_units     = "yyyymmdd"
      print( time )
end
-------------------------------------------------
You could also use ut_calendar
http://www.ncl.ucar.edu/Document/Functions/Built-in/ut_calendar.shtml
if you want units like "days/hours since ..."
If you do this I would recommend that you
also create and "auxilary time variable" , say "date" or "yyyymmdd"
      date  = year*10000 + mon*100 + day
      date!0         = "time"
      date_at_long_name = "date"
      date_at_units     = "yyyymmdd"
-------------------
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Aug 09 2006 - 09:44:15 MDT
This archive was generated by hypermail 2.2.0 : Thu Aug 10 2006 - 15:20:04 MDT