Re: time

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 31 2013 - 11:47:16 MDT

The issue is with the type of "year" and *not* with the third argument to yyyymm_time. Here's what your error message says:

> argument type mismatch on argument (0) of yyyymm_time

"argument (0)" refers to the first (leftmost) argument that you are passing to yyyymm_time, which is "firstyr".

My guess is that "year" is a float or a double, and hence "firstyr" is a float or double.

What type is "year" and "yyyymm"?

printVarSummary(year)
printVarSummary(yyyymm)

You need to convert "year" to an integer before you pass it to yyyymm_time.

Please try the code *exactly* as I have it here. If you continue to get error messages, include the exact error message and email ncl-talk, not me directly.

year = yyyymm/100
firstyr = toint(year(0))
lastyr = toint(year(ntim-1))
nyear = lastyr-firstyr+1
yyyymm = yyyymm_time(firstyr,lastyr , "string")

--Mary

On Jul 31, 2013, at 11:35 AM, Setareh Rahimi wrote:

> Dear Mary,
>
> I wrote the exact error in blue in previous email. Each time that I replaced the type of time, I used the same function as shown by the first email. The time in my data set is exactly like "1891-1-1", as you can see time is between ". Do you think " makes difference for the type of time?
>
> Thank you,
>
>
> On Wed, Jul 31, 2013 at 6:29 PM, Mary Haley <haley@ucar.edu> wrote:
>
> Please include the *exact* error message and the code that you used, when you tried to use integer values. You said you got the same error message, but are you sure it was for the same function?
>
> Please also try this short 3-line test program to verify that yyyymm_time is working for you:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> s = yyyymm_time(1850, 2001, "string")
> print(s)
>
>
> Variable: s
> Type: string
> Total Size: 14592 bytes
> 1824 values
> Number of Dimensions: 1
> Dimensions and sizes: [time | 1824]
> Coordinates:
> time: [185001..200112]
> Number Of Attributes: 2
> long_name : time
> units : YYYYMM
> (0) 185001
> (1) 185002
> (2) 185003
> (3) 185004
> (4) 185005
> (5) 185006
> (6) 185007
> (7) 185008
> (8) 185009
> (9) 185010
> (10) 185011
> (11) 185012
> (12) 185101
> (13) 185102
> (14) 185103
> (15) 185104
>
>
> On Jul 31, 2013, at 11:15 AM, Setareh Rahimi wrote:
>
> > Dear Mary,
> >
> > I did search!!! but, as I mentioned before I have tried ineger, but it is wrong. That is why I ask you!!!
> >
> > Thank you
> >
> >
> > On Wed, Jul 31, 2013 at 6:04 PM, Mary Haley <haley@ucar.edu> wrote:
> > Setareh,
> >
> > You need to read the documentation on a function before you post your questions to ncl-talk. Many questions you've had could be answered by doing some research:
> >
> > http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymm_time.shtml
> >
> > The argument is telling you that the first argument's type is wrong. If you read the documentation, you will see that the first argument is supposed to be an integer.
> >
> > My guess is that "year" is a float or a double. It needs to be an integer:
> >
> > firstyr = toint(year(0))
> > lastyr = toint(year(ntim-1))
> >
> > --Mary
> >
> >
> > On Jul 31, 2013, at 10:30 AM, Setareh Rahimi wrote:
> >
> > > Dear all,
> > >
> > > I use a data set in which time is base on udunits which is units of time from a basedate. For example, days since 1800-01-01. In data file, time is defined as string.when I run codes below I get an error saying : argument type mismatch on argument (0) of yyyymm_time. I also tried integer, float and double, but still got the same error. Please adice me how fix this issue.
> > >
> > > year = yyyymm/100
> > > firstyr = year(0)
> > > lastyr = year(ntim-1)
> > > nyear = lastyr-firstyr+1
> > > yyyymm = yyyymm_time(firstyr,lastyr , "string")
> > >
> > >
> > >
> > > Thank you in advance.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > S.Rahimi
> > >
> > > _______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
> >
> > --
> > S.Rahimi
> >
>
>
>
>
> --
> S.Rahimi
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 31 11:47:30 2013

This archive was generated by hypermail 2.1.8 : Thu Aug 01 2013 - 15:55:03 MDT