if tms_id is None:
                tms_id = TS.generate_timeseries_id(meta_data=meta_data)
                meta_data['id'] = tms_id
                TS.insert_run(meta_data=meta_data)

            # obs_end = TS.get_obs_end(id_=tms_id)

            processed_discharge_ts = []

            if station_name in (
                    'ambatale'):  # process fcst ts from model outputs
                processed_discharge_ts = process_fcst_ts_from_flo2d_outputs(
                    curw_fcst_pool=curw_fcst_pool, fcst_start=None)

            else:
                continue  ## skip the current station and move to next iteration

            if processed_discharge_ts is not None and len(
                    processed_discharge_ts) > 0:
                TS.insert_data(timeseries=processed_discharge_ts,
                               tms_id=tms_id,
                               upsert=True)
                TS.update_latest_obs(id_=tms_id, obs_end=latest_fgt)

    except Exception as e:
        traceback.print_exc()
        logger.error("Exception occurred")
    finally:
        destroy_Pool(pool=curw_sim_pool)
        destroy_Pool(pool=curw_fcst_pool)
Ejemplo n.º 2
0
                    start = (
                        obs_end -
                        timedelta(days=1)).strftime(COMMON_DATE_TIME_FORMAT)

            wl_timeseries = waterlevel_TS.get_timeseries(id_=wl_tms_id,
                                                         start_date=start,
                                                         end_date=end_time)

            estimated_discharge_ts = []

            if station_name == 'hanwella':
                estimated_discharge_ts = calculate_hanwella_discharge(
                    wl_timeseries)
            elif station_name == 'glencourse':
                estimated_discharge_ts = calculate_glencourse_discharge(
                    wl_timeseries)

            if estimated_discharge_ts is not None and len(
                    estimated_discharge_ts) > 0:
                discharge_TS.insert_data(timeseries=estimated_discharge_ts,
                                         tms_id=tms_id,
                                         upsert=True)
                discharge_TS.update_latest_obs(
                    id_=tms_id, obs_end=estimated_discharge_ts[-1][1])

    except Exception as e:
        traceback.print_exc()
        logger.error("Exception occurred")
    finally:
        destroy_Pool(pool=curw_sim_pool)