def check(date): if not re.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}$', date): raise Exception("Invalid product date value: {}".format(date)) start = md.to_ordinal(md.startdate(acquired)) end = md.to_ordinal(md.enddate(acquired)) val = md.to_ordinal(date) if val < start or val > end: raise Exception("Product date {} out of range{}".format( date, acquired))
def changedate(rdd): return safely(func=fp.changedate, kwargs={ 'models': result_to_models(rdd['data']), 'ord_date': dates.to_ordinal(rdd['datestr']) }, x=rdd['x'], y=rdd['y'], chip_x=rdd['chip_x'], chip_y=rdd['chip_y'], alg=algorithm('changedate', fp.version), datestr=rdd['datestr'], error=rdd['error'])
def curveqa(rdd): chip_x = rdd[0][0][0] chip_y = rdd[0][0][1] x = rdd[0][0][2] y = rdd[0][0][3] data = rdd[0][1] errs = rdd[0][2] date = rdd[1] kwargs = { 'models': result_to_models(data), 'ord_date': dates.to_ordinal(date) } return safely(func=fp.curveqa, kwargs=kwargs, x=x, y=y, chip_x=chip_x, chip_y=chip_y, alg=algorithm('curveqa', fp.version), datestr=date, errors=errs)
def test_changemag(): ord_date = d.to_ordinal("1984-04-01") assert products.changemag([{'change_probability': 1, 'break_day': ord_date}], ord_date) == 0.0
def test_qa(): assert products.curveqa([{'start_day': d.to_ordinal("1986-04-01"), 'end_day': d.to_ordinal("1988-07-01"), 'curve_qa': 999}], d.to_ordinal('1987-01-01')) == 999
def test_seglength(): assert products.seglength([{'start_day': d.to_ordinal("1986-04-01"), 'end_day': d.to_ordinal("1988-07-01")}], d.to_ordinal("1984-04-01"), bot=d.to_ordinal("1982-01-01")) == 821
def test_to_ordinal(): assert dates.to_ordinal('1999-01-01') == 729755 assert dates.to_ordinal('1999/11/01') == 730059