Re: To correctly define date variable

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue May 15 2012 - 19:21:21 MDT

On May 15, 2012, at 10:13 AM, Noel Aloysius wrote:

> Thanks Mary. The script you sent computes the daily time series. I
> want ntim = 1200 for a monthly series. Could you show me how I can
> modify the code please?

I'm not sure what you want. The code you originally sent me had a
calculation for the number of days in every month, and then you were
looping across each of these days to create values like 19010101,
19010102, etc.

That's what the code below is supposed to give you. If you set ntim =
1200, and you have 100 years, then this implies nmos =12, and hence
you can only have one day value per month. '

What exactly do you want date and time to look like?

--Mary

>
> Thanks,
> Noel
>
>
> On Tue, May 15, 2012 at 10:11 AM, Mary Haley <haley@ucar.edu> wrote:
> Noel,
>
> In your code, you are not incrementing the year array. You start at
> 1901 but you never increment this.
>
> You need to add a loop across 1901 to 2000. You can also remove that
> inner loop:
>
> begin
> start_year = 1901
> end_year = 2000
> nmos = 12
> nyears = (end_year-start_year)+1
>
> ;---Count the number of leap years
> nleap = num(isleapyear(ispan(start_year,end_year,1)))
>
> ;---Calculate exact size of date/time arrays
> ntim = (nleap*366) +(nyears-nleap)*365
> time = new (ntim, float, "No_FillValue")
> date = new (ntim, integer, "No_FillValue")
>
> n = 0
> do ny=start_year,end_year
> do nmo=1,nmos
> YRM = ny*10000 + nmo*100
> ndm = days_in_month(ny,nmo)
> time(n:n+ndm-1) = ispan(n,n+ndm-1,1)
> date(n:n+ndm-1) = YRM + ispan(1,ndm,1)
> n = n + ndm
> end do
> end do
> print(date)
> end
>
>
>
> On May 14, 2012, at 4:55 PM, Noel Aloysius wrote:
>
> > Hello NCL-talk,
> >
> > Attached ncl script reads a binary file and writes a netCDF
> binary. The file it correctly written except the date variable. The
> date should start at 190101 and finish at 200012.
> >
> > Lines 26-48 in the script refer to the relevant section.
> >
> > Thanks in advance,
> >
> > Noel
> >
> >
> <
> read_binary_write_netCDF
> .ncl>_______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue May 15 19:21:30 2012

This archive was generated by hypermail 2.1.8 : Thu May 17 2012 - 13:42:02 MDT