[ncl-talk] How to convert to 360 days to 365 days calendar

Dennis Shea shea at ucar.edu
Thu Jul 11 21:35:29 MDT 2019


The issue is that the *calendar_convert_360_to_365_date *function is
expecting the input time coordinate variable to be type "double".

The precipitation precipitation_baseline.nc  has the time coordinate  [ "t"
] of type float

*float *t(t) ;
t:standard_name = "time" ;
t:units = "days since 1971-1-1 00:00:00" ;
t:calendar = "360_day" ;
t:axis = "T" ;

==
A temporary fix is to change the source coordinate  [ "t" ] to type
'double'
Specifically:

  z360 = fi->precip          ; [t | 10800] x [lat | 25] x [lon | 20]
  t360 = z360&t
  if (typeof(z360&t).ne."double") then
      t360 := *todouble*(t360)             ; convert float to double;
overwrite [ := ]
      *copy_VarMeta*(z360&t,t360)    ; copy meta data
      *delete*(z360&t)                         ; delete source values
      z360!0 = "t"                              ; reassign
      z360&t = t360
  end if

On Thu, Jul 11, 2019 at 6:10 AM Geetha R <rgeetha.cc at gmail.com> wrote:

> Dear Dennis,
> Thanks a lot for the clear explanation. I have downloaded the sample file
> " zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231_360day.nc" , executed
> the code GeethaR.360_to_365.ncl and got the output
> "zg700_day_HadGEM2-ES_rcp85_r1i1p1_19810101-20141231_365day.nc" which is
> the exact output i was looking for. Thats great Dennis.
>
> I am working on 3-dimensional data which I have enclosed for
> your reference. I have used the code for 3d from "tst.360_365.ncl" to
> convert 360 to 365 days. But I am getting the error *"fatal:["Execute.c":7925]:
> Number of subscripts on right-hand-side do not match number of dimensions
> of variable: (4), Subscripts used: (3)"*. Kindly help me on this regard.
>
>
>
>
> On Thu, Jul 11, 2019 at 4:09 PM Geetha R <rgeetha.cc at gmail.com> wrote:
>
>> Dear Dennis,
>> Thanks a lot for the clear explanation. I have downloaded the sample
>> file  " zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231_365day.nc" ,
>> executed the code GeethaR.360_to_365.ncl and got the output
>> "zg700_day_HadGEM2-ES_rcp85_r1i1p1_19810101-20141231_360day.nc" which is
>> the exact output i was looking for. Thats great Dennis.
>>
>> I am working on 3-dimensional data which I have enclosed for
>> your reference. I have used the code for 3d from "tst.360_365.ncl" to
>> convert 360 to 365 days. But I am getting the error *"fatal:["Execute.c":7925]:
>> Number of subscripts on right-hand-side do not match number of dimensions
>> of variable: (4), Subscripts used: (3)"*. Kindly help me on this regard.
>>
>>
>>
>> On Mon, Jul 8, 2019 at 7:01 AM Dennis Shea <shea at ucar.edu> wrote:
>>
>>> Sorry for the very tardy reply on *360_day conversion to 365_day
>>> calendars*.
>>>
>>> ---
>>> Another post on this same issue was sent to ncl-talk in *Feb 2019.*
>>> My recollection is that ncl-talk has previously had calendar 360-day to
>>> 365_day conversion questions. Also, the GrADS , NCO and CDO mail lists have
>>> had  similar requests.
>>>
>>> ---
>>> The attached function [ "*calendar_convert_360_to_365_date*"  ] works
>>> on *daily data.* It has *not* been extensively tested. There is no
>>> online NCL documentation with examples. Please read the documentation
>>> within the function. Note that *'linmsg_n*' is used rather that
>>> *'linint1_n*'
>>>
>>> *%>* ncl GeethaR.360_to_365.ncl
>>>
>>> I have placed a *source* 360-day file and the *derived* 365_day file at:
>>>
>>> ftp ftp.cgd.ucar.edu
>>> anonymous
>>> your_email
>>> cd pub/shea
>>> mget *nc
>>> quit
>>> ---
>>>
>>> The files are ~ 37.5 MB
>>>
>>>  37629272  zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231_365day.nc
>>>  37314184  zg700_day_HadGEM2-ES_rcp85_r1i1p1_19810101-20141231_360day.nc
>>>
>>> ---
>>> I have also attached a test code to make sure it work s for 4D/3D/2D/1D
>>> variables.
>>>
>>> *%>* ncl tst.360_to_365.ncl
>>>
>>> I think it works!  :-)
>>>
>>> On Thu, Jun 20, 2019 at 5:25 AM Geetha R via ncl-talk <ncl-talk at ucar.edu>
>>> wrote:
>>>
>>>> Dear NCLers,
>>>>  I am working on converting 360 days calendar to 365 days calendar. I
>>>> have seen a discussion on the same topic with the title "*converting
>>>> 360 day calendar to 365 day (standard) calendar*". The script shared
>>>> in the topic is :
>>>>
>>>> f = addfile("zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231.nc","r")
>>>>   var          = f->zg
>>>>   time_360     = var&time
>>>>   lat          = f->lat
>>>>   lon          = f->lon
>>>>   plev       = f->plev
>>>>   printVarSummary(var)
>>>>
>>>>   time_steps               =  34*365 ;1980 to 2013
>>>>   time_365                 =  fspan(1,time_steps,time_steps)
>>>>   time_365!0               = "time"
>>>>   time_365&time            =  time_365
>>>>   time_365 at standard_name <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>   = "time"
>>>>   time_365 at units <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>           = "days since 1980-01-01 12:00:00"
>>>>   time_365 at calendar <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>        = "365_day"
>>>>   time_365 at long_name <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>       = "time"
>>>>   time_365 at axis <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>            = "T"
>>>>   zg_new =linint1_n( time_360,rm_single_dims(var), False, time_365, 0,0)
>>>>   zg_new!0             = "time"
>>>>   zg_new&time          =  time_365
>>>>   zg_new!1             = "lat"
>>>>   zg_new&lat          =  lat
>>>>   zg_new!2             = "lon"
>>>>   zg_new&lon          =  lon
>>>>   zg_new at _FillValue <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>    =  1.0e+20
>>>>   zg_new at missing_value <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> =  1.0e+20
>>>>   zg_new at standard_name <http://mailman.ucar.edu/mailman/listinfo/ncl-talk> = "geopotential_height"
>>>>   zg_new at long_name <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>     = "Geopotential Height"
>>>>   zg_new at units <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>         = "m"
>>>>   zg_new at coordinates <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>   = "lon lat plev"
>>>>   zg_new at cell_methods <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>  = "time: mean"
>>>>   printVarSummary(zg_new)
>>>>   outf = addfile("zg700_day_HadGEM2-ES_rcp85_r1i1p1_19800101-20131231_cal.nc","c")
>>>>   outf->lat          =  lat
>>>>   outf->lon          =  lon
>>>>   outf->plev       =  plev
>>>>   outf->zg       =  zg_new
>>>>
>>>> In this code, the interpolation is done from the first day of the data
>>>> that the netcdf with 365 days differs much when compared with the 360 days
>>>> data. So, I thought that 5 days can be included at the end of each year.
>>>> So, the interpolation can be started at 360th day and end at 361th day. I
>>>> am new to ncl and may I know how to do this in ncl.
>>>>
>>>> --
>>>> With Regards,
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>
>>
>> --
>> With Regards,
>>
>>
>>
>
> --
> With Regards,
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190711/ddfe1973/attachment.html>


More information about the ncl-talk mailing list