Skip to content

Commit

Permalink
in FR.py parser, remove datapoints where all production values are nu…
Browse files Browse the repository at this point in the history
…ll (#1566)
  • Loading branch information
maxbellec authored and corradio committed Aug 17, 2018
1 parent 2da44ee commit 303d57d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions parsers/FR.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import json
import logging
import os
import math

import pandas as pd
import requests
import xml.etree.ElementTree as ET
Expand All @@ -27,6 +29,11 @@
'pompage'
]

def is_not_nan_and_truthy(v):
if isinstance(v, float) and math.isnan(v):
return False
return bool(v)


def fetch_production(zone_key='FR', session=None, target_datetime=None,
logger=logging.getLogger(__name__)):
Expand Down Expand Up @@ -76,6 +83,11 @@ def fetch_production(zone_key='FR', session=None, target_datetime=None,
'hydro': row[1]['pompage'] * -1 + row[1]['hydraulique_step_turbinage'] * -1
}

# if all production values are null, ignore datapoint
if not any([is_not_nan_and_truthy(v)
for k, v in production.items()]):
continue

datapoints.append({
'zoneKey': zone_key,
'datetime': arrow.get(row[1]['date_heure']).datetime,
Expand Down

0 comments on commit 303d57d

Please sign in to comment.