[ncl-talk] delete 31 march for leap year

Dennis Shea shea at ucar.edu
Fri Apr 17 08:05:29 MDT 2015


ikeep = ind(.not.(isleapyear(TIME(:,0)) .and. TIME(:,1).eq.3 .and.
TIME(:,2).eq.31) )

===
re: "..Yes because i just need to analyze JFM (90 days) for 40 years."

I would suggest another approach:

ii   = ind(TIME(:,1).eq.1 .and. TIME(:,2).eq.1)    ; Jan 1 each year

nii = dimsizes(ii)

do n=0,n_istart-1
     x = f->X(ii(n):ii(n)+89, :,:)


end do

On Fri, Apr 17, 2015 at 6:58 AM, Alan Brammer <abrammer at albany.edu> wrote:

> Depending on how long your dataset is, this may be more reliable than mod
> 4.
> https://www.ncl.ucar.edu/Document/Functions/Built-in/isleapyear.shtml
> e.g. 1900 was not a leap year.
>
> On 17 April 2015 at 08:30, Marcus Morgan <mmorgan2009 at my.fit.edu> wrote:
>
>> Here you would use the modulus function.  Every four years a leap year
>> occurs, so:
>>
>>
>> leap=ind(mod(Time(:,0), 4) .eq. 0 .and. TIME(:,1).eq.3 .and.
>> TIME(:,2).eq.31)        ; Chooses March 31st From those Leap Years
>>
>> keep=ind(.not.Time(leap,0))
>> FOO = foo(keep,:,:)
>> delete(foo)
>>
>> Haven't tested it, but it should work.
>> Good Luck
>>
>>
>> *Marcus N. Morgan*Graduate of Meteorology
>>
>> *Department of Marine and Environmental Systems*   Florida Institute of
>> Technology
>>    150 W. University Blvd.
>>    Melbourne, FL 32901
>>
>> On Fri, Apr 17, 2015 at 1:52 AM, Xi Chang <xi.chang01 at gmail.com> wrote:
>>
>>> Thanks Dennis,
>>>
>>> Yes because i just need to analyze JFM (90 days) for 40 years. I know
>>> the above trick but i just want delete 31 march only for LEAP YEAR not for
>>> whole years. Do you know how to do that?
>>>
>>> thanks
>>>
>>>
>>> On Friday, April 17, 2015, Dennis Shea <shea at ucar.edu> wrote:
>>>
>>>> [1] Yes ... there is a way
>>>> [2] But ... why would ypu want to do that? It introduces a 'spectral
>>>> gap' in the time series.
>>>>
>>>> ===
>>>>   foo(time,lat,lon)
>>>>
>>>>   time has units understood by cd_calendar
>>>>
>>>> https://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml
>>>>
>>>>   TIME = cd_calendar(time, 0)
>>>>
>>>>   ikeep = ind(.not.(TIME(:,1).eq.3 .and. TIME(:,2).eq.31) )
>>>>   FOO = foo(ikeep,:,:)
>>>>   delete(foo)
>>>>
>>>>
>>>>
>>>> On Thu, Apr 16, 2015 at 4:16 PM, Xi Chang <xi.chang01 at gmail.com> wrote:
>>>>
>>>>> Hi NCL,
>>>>> I have 40 years daily data, i need to delete 31 march only for the
>>>>> leap year, is there any quick way to do that?
>>>>>
>>>>> Regards
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150417/5e9b2eb0/attachment.html 


More information about the ncl-talk mailing list