Skip to content

Commit

Permalink
Add option to interpolate missing_values on plot (close brazil-data-c…
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelrpl committed May 27, 2021
1 parent 642bf02 commit c49846a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion wtss/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ def values(self, attr_name):
return getattr(self, attr_name)


def plot(self, **options):
def plot(self, discard_nodata=False, **options):
"""Plot the time series on a chart.
Keyword Args:
discard_nodata (bool): Discard the missing values in time series. Default is False.
attributes (sequence): A sequence like ('red', 'nir') or ['red', 'nir'] .
line_styles (sequence): Not implemented yet.
markers (sequence): Not implemented yet.
Expand Down Expand Up @@ -118,8 +119,27 @@ def plot(self, **options):
attrs = options['attributes'] if 'attributes' in options else self.attributes

for attr in attrs:
missing_value = None
for coverage_attribute in self._coverage.attributes:
print(coverage_attribute)
if coverage_attribute['name'] == attr:
missing_value = coverage_attribute['missing_value']
break

y = self.values(attr)

if discard_nodata:
_y = []
_x = []

for i, value in enumerate(y):
if value != missing_value:
_y.append(value)
_x.append(x[i])

y = _y
x = _x

ax.plot(x, y,
ls='-',
marker='o',
Expand Down

0 comments on commit c49846a

Please sign in to comment.