rigoudyg / climaf

CliMAF - a Climate Model Analysis Framework - doc at : http://climaf.readthedocs.org/
Other
18 stars 7 forks source link

bug in module period.py #123

Closed stchepounoff closed 5 years ago

stchepounoff commented 5 years ago

trying to declare a climaf dataset with period 1996010100-1999123123 => File "/cnrm/est/COMMON/climaf/current/climaf/period.py", line 242, in init_period raise Climaf_Period_Error("period end string %s is not a date"%end) climaf.period.Climaf_Period_Error: 'period end string 1999123123 is not a date'

The problem is the treatment beginning on line 231 of module period.py.

Solution may be :+1:

if (ehour > 23) : ehour=0 months_days = [31,28,31,30,31,30,31,31,30,31,30,31]

            if emonth==2 :
                if eday > 28 :
                    if eyear%4==0 and eyear%100!=0 :
                        eday=eday+1
                    else :
                        emonth=emonth+1
                        eday=1
            else :  
                if eday < months_days[emonth-1] :
                    eday=eday+1
                else :
                    emonth=emonth+1
                    if emonth > 12 :
                        eyear=eyear+1
                        emonth=1
                        eday=1
senesis commented 5 years ago

Yes, the code is quite dirty, and wrong, around that place. It will be cleaned for next version

Before it is released, you can circumvent the problem by simplifying your period from '1996010100-1999123123' to '1996-1999', which represents exactly the same thing for CliMAF (see the two last examples in init_period doc)

senesis commented 5 years ago

Fixed with commit 0bb5a6e