예제 #1
0
 def execute_item(self, item):
     source_ts = Timeseries()
     with open(item['source_file']) as f:
         source_ts.read_file(f)
     self.target_step.interval_type = item['interval_type']
     target_ts, missing = source_ts.aggregate(
         self.target_step,
         missing_allowed=self.missing_allowed,
         missing_flag=self.missing_flag)
     with open(item['target_file'], 'w') as f:
         target_ts.write_file(f, version=3)
예제 #2
0
파일: tsprocess.py 프로젝트: aptiko/pthelma
def AggregateDbTimeseries(source_id, dest_id, db, read_tstep_func, transaction=None,
                          commit=True, missing_allowed=0.0,
                          missing_flag='MISSING', append_only=False,
                          last_incomplete=False, all_incomplete=False):
    source = Timeseries(id=source_id, time_step=read_tstep_func(source_id))
    dest_step = read_tstep_func(dest_id)
    if append_only:
        bounds = timeseries_bounding_dates_from_db(db = db, id = dest_id)
        end_date = bounds[1] if bounds else None
    source.read_from_db(db)
    dest = source.aggregate(target_step=dest_step,
                            missing_allowed=missing_allowed, 
                            missing_flag=missing_flag,
                            last_incomplete=last_incomplete,
                            all_incomplete=all_incomplete)[0]
    dest.id = dest_id
    if append_only:
        d=dest.bounding_dates()
        while (d is not None) and (end_date is not None) and d[0]<=end_date:
            del dest[d[0]]
            d=dest.bounding_dates()
        dest.append_to_db(db=db, transaction=transaction, commit=commit)
    else:
        dest.write_to_db(db=db, transaction=transaction, commit=commit)