Skip to content

Commit

Permalink
io: Add compression to series attributes in netcdf exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
coroa committed Dec 18, 2017
1 parent a54b58c commit 352598b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pypsa/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ def get_series(self, list_name):
yield attr[len(t):], df

class ExporterNetCDF(Exporter):
def __init__(self, path):
def __init__(self, path, least_significant_digit=3):
self.path = path
self.least_significant_digit = least_significant_digit
self.ds = xr.Dataset()

def save_attributes(self, attrs):
Expand All @@ -242,6 +243,11 @@ def save_series(self, list_name, attr, df):
df.index.name = 'snapshots'
df.columns.name = list_name + '_t_' + attr + '_i'
self.ds[list_name + '_t_' + attr] = df
if self.least_significant_digit is not None:
self.ds.encoding.upate({
'zlib': True,
'least_significant_digit': self.least_significant_digit
})

def finish(self):
if self.path is not None:
Expand Down

0 comments on commit 352598b

Please sign in to comment.