[ncl-talk] Changing 360 day calendar to 365 day standard calendar

Kwesi A. Quagraine starskykwesi at gmail.com
Wed Sep 25 02:22:28 MDT 2019


Thanks Dennis for pointing this out. Much grateful.

I have been able to resolve this and getting the right time variable.

What I did was to reset the time axis with cdo and then proceed to use the
‘calendar_convert_360_to_365_date’ function.

Best regards
Kwesi

On 25 September 2019 at 03:37:35, Dennis Shea (shea at ucar.edu) wrote:

The issue is *NOT* with the 'calendar_convert_360_to_365_date' function.
Rather, the source file's 'time' variable is NOT properly formed. For a
360_day
calendar all months have 30-days [ 12*30=360  :-) ]. This includes February.
The following look correct/similar:

A: Correct 360_day
zg700_day_HadGEM2-ES_rcp85_r1i1p1_19810101-20141231_360day.nc    <====
 Correct 360_day

        double time(time) ;
                [snip]
                time:units = "days since 1859-12-01" ;
                time:calendar = "360_day" ;

B: Incorrect 360_day   ... generically looks the same but the time is wrong
zg700_day_HadGEM2-ES_historical_rcp85_r1i1p1_SMHI-RCA4_19800101-20131231_norm.nc
<=== Incorrect 360_day

        double time(time) ;
                [snip]
                time:units = "days since 1949-12-1 00:00:00" ;
                time:calendar = "360_day" ;

====================


  diri = "./"
  fila = "zg700_day_HadGEM2-ES_rcp85_r1i1p1_19810101-20141231_360day.nc"
  ptha = diri+fila
  fa   = addfile(ptha,"r")

  filb =
"zg700_day_HadGEM2-ES_historical_rcp85_r1i1p1_SMHI-RCA4_19800101-20131231_norm.nc"
  pthb = diri+filb
  fb   = addfile(pthb,"r")

  time360a = fa->time
  YMDH360a = cd_calendar(time360a,-3)

  time360b = fb->time
  YMDH360b = cd_calendar(time360b,-3)
  print("A: "+time360a+"  "+YMDH360a+"  ; B: "+time360b+"  "+YMDH360b)
======================

The 'time360a' and 'time360b' are numerically different due to different
reference dates. However, successive time steps should be separated by
one-day [ 1.0 ]
for the original 'time' variable.

The "B" file is separated by 2.0 in leap years and 3.0 in non-leap years.



[SNIP]
(56)    A: 43646.5  1981022712  ; B: 10886.5  1980022712
(57)    A: 43647.5  1981022812  ; B: 10887.5  1980022812
(58)    A: 43648.5  1981022912  ; B: 10888.5  1980022912    should be
followed by

                                      1981023012
(59)    A: 43649.5  1981023012  ; B: 10890.5  1980030112    1980030112
repeated twice
(60)    A: 43650.5  1981030112  ; B: 10890.5  1980030112
(61)    A: 43651.5  1981030212  ; B: 10891.5  1980030212
(62)    A: 43652.5  1981030312  ; B: 10892.5  1980030312
[SNIP]
(413)   A: 44003.5  1982022412  ; B: 11243.5  1981022412
(414)   A: 44004.5  1982022512  ; B: 11244.5  1981022512
(415)   A: 44005.5  1982022612  ; B: 11245.5  1981022612
(416)   A: 44006.5  1982022712  ; B: 11246.5  1981022712
(417)   A: 44007.5  1982022812  ; B: 11247.5  1981022812    should be
followed
                                                            1981022912
                                                            1981023012
                                                            The following
two-day sequence
(418)   A: 44008.5  1982022912  ; B: 11250.5  1981030112    <=== twice
repeated
(419)   A: 44009.5  1982023012  ; B: 11251.5  1981030212    <===
(420)   A: 44010.5  1982030112  ; B: 11250.5  1981030112    <===
(421)   A: 44011.5  1982030212  ; B: 11251.5  1981030212    <===
[SNIP]

=====
*%> ncl* hadgem.calendar_compare.ncl

Good luck

On Mon, Sep 23, 2019 at 9:40 PM Kwesi A. Quagraine via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Dear NCLers,
>
> Apologies for revisiting this again.
>
> I am using the calendar_convert_360_to_365_date.ncl script provided
> earlier by Denis, to convert a 360 day calendar to 365 day standard
> calendar. However I get this error below;
>
> fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading it360
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 161 in
> file ./calendar_convert_360_to_365_date.ncl
>
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 27 in
> file hadgem_360_365.ncl
>
> fatal:Variable (zg365) is undefined
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 29 in
> file hadgem_360_365.ncl
>
> fatal:Variable (zg365) is undefined
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 30 in
> file hadgem_360_365.ncl
>
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 31 in
> file hadgem_360_365.ncl
>
> (0) ==================
> fatal:Variable (zg365) is undefined
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 65 in
> file hadgem_360_365.ncl
>
> I am not sure what is happening there since the loop that is being
> iterated through uses the correct loop structure in NCL;
>
> ======
> do nt=0,nitime-1
>          x365(it360(nt),:,:,:) = x360(it365(nt),:,:,:)
>       end do
>   end if
> ======
>
> I will be grateful for any help on this. I have attached my file and the
> calendar convert file I am using.
>
> Warm regards
> Kwesi
>
> (ncl_notebook) kwesi at maggie:~/terra/cordex$ ncl -V
> 6.6.2
>
> (ncl_notebook) kwesi at maggie:~/terra/cordex$ conda --version
> conda 4.3.30
>
> (ncl_notebook) kwesi at maggie:~/terra/cordex$ env | grep NCARG
> OLD_NCARG_ROOT=/share/apps/ncl-6.2.1
> NCARG_ROOT=/home/kwesi/miniconda3/envs/ncl_notebook
>
> ncdump file gives;
>
> netcdf
> zg700_day_HadGEM2-ES_historical_rcp85_r1i1p1_SMHI-RCA4_19800101-20131231_norm
> {
> dimensions:
>         lon = 91 ;
>         lat = 103 ;
>         plev = 1 ;
>         time = UNLIMITED ; // (12240 currently)
>         bnds = 2 ;
> variables:
>         double lon(lon) ;
>                 lon:standard_name = "longitude" ;
>                 lon:long_name = "longitude" ;
>                 lon:units = "degrees_east" ;
>                 lon:axis = "X" ;
>         double lat(lat) ;
>                 lat:standard_name = "latitude" ;
>                 lat:long_name = "latitude" ;
>                 lat:units = "degrees_north" ;
>                 lat:axis = "Y" ;
>         double plev(plev) ;
>                 plev:standard_name = "air_pressure" ;
>                 plev:long_name = "pressure" ;
>                 plev:units = "Pa" ;
>                 plev:positive = "down" ;
>                 plev:axis = "Z" ;
>         double time(time) ;
>                 time:standard_name = "time" ;
>                 time:long_name = "time" ;
>                 time:bounds = "time_bnds" ;
>                 time:units = "days since 1949-12-1 00:00:00
> <http://airmail.calendar/1949-12-01%2000:00:00%20GMT+2>" ;
>                 time:calendar = "360_day" ;
>                 time:axis = "T" ;
>         double time_bnds(time, bnds) ;
>         float zg(time, plev, lat, lon) ;
>                 zg:standard_name = "geopotential_height" ;
>                 zg:long_name = "Geopotential Height" ;
>                 zg:units = "m" ;
>                 zg:_FillValue = 1.e+20f ;
>                 zg:missing_value = 1.e+20f ;
>                 zg:cell_methods = "time: mean" ;
>
> -----------
> Try not to become a man of success but rather a man of value- Albert
> Einstein
>
> Kwesi A. Quagraine
> Climate System Analysis Group (CSAG)
> Environmental and Geographical ScIence (EGS)
> University of Cape Town
> Private Bag, Rondebosch, 7701
> South Africa
>
> Alt. Email: starskykwesi at gmail.com
> Web: http://www.csag.uct.ac.za
> Office: +27 21 650 3164
> Skype: quagraine_cwasi
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

------------
Try not to become a man of success but rather a man of value- Albert
Einstein

Kwesi A. Quagraine
Department of Physics
School of Physical Sciences
College of Agriculture and Natural Sciences
University of Cape Coast
Cape Coast, Ghana

Alt. Email: kwesi at csag.uct.ac.za
Web: http://www.recycleupghana.org/
Office: +27 21 650 3164
Skype: quagraine_cwasi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190925/10f1ec25/attachment.html>


More information about the ncl-talk mailing list