equinor / sunbeam

GNU General Public License v3.0
7 stars 14 forks source link

Possibility to remove dates from TimeVector #77

Closed berland closed 6 years ago

berland commented 6 years ago

There is a need for an API call to remove date (or list of dates) from a TimeVector

joakim-hove commented 6 years ago

OK - that should be possible; assuming the deck looks like this:

DATES 
    1. JAN 2000 /

KW1
KW2
KW3

DATES
   1. FEB 2000 /

KW4
KW5
KW6

If removing the 1. FEB 2000 DATES keyword; should then also KW1, KW2 and KW3 be removed?

berland commented 6 years ago

No, KW1, 2 and 3 should be kept. 4 5 and 6 should be deleted.

joakim-hove commented 6 years ago

Ok

joakim-hove commented 6 years ago

Fixed here: https://github.com/Statoil/sunbeam/pull/83

berland commented 6 years ago

Bug in #83 found it seems:

from sunbeam.tools import TimeVector
import datetime
foo = TimeVector(datetime.datetime(2017,1,1))
foo.add_keywords(datetime.datetime(2018,1,1), ['FOO18'])
foo.add_keywords(datetime.datetime(2019,1,1), ['FOO19'])
foo.add_keywords(datetime.datetime(2020,1,1), ['FOO20'])
foo.delete(datetime.datetime(2019,1,1))
foo.delete(datetime.datetime(2020,1,1))

IndexError: list assignment index out of range

The first delete() statement works fine, but the second one fails. I suspect book-keeping-bug.

(in a "real" world case I got removal of other tsteps than the ones I asked for, I speculate that is the same bug as this one)

joakim-hove commented 6 years ago

Bug in #83 found it seems:

Fix here: https://github.com/Statoil/sunbeam/pull/84

berland commented 6 years ago

Looks good. Closing.