Commit 2bf59f01 authored by felix kleinert's avatar felix kleinert

update inverse_transform: X and y are also updated. update __repr__ and related methods

parent c0fee4fe
Pipeline #41400 failed with stages
in 6 minutes and 11 seconds
......@@ -103,14 +103,17 @@ class StationPrep(AbstractStationPrep):
@property
def _print_transformation_as_string(self):
str_name = ''
for k, v in self.transformation.items():
if v is not None:
try:
v_pr = f"xr.DataArray.from_dict({v.to_dict()})"
except AttributeError:
v_pr = f"'{v}'"
str_name += f"'{k}':{v_pr}, "
str_name = f"{{{str_name}}}"
if self.transformation is None:
str_name = f'{None}'
else:
for k, v in self.transformation.items():
if v is not None:
try:
v_pr = f"xr.DataArray.from_dict({v.to_dict()})"
except AttributeError:
v_pr = f"'{v}'"
str_name += f"'{k}':{v_pr}, "
str_name = f"{{{str_name}}}"
return str_name
def get_transposed_history(self) -> xr.DataArray:
......@@ -615,6 +618,8 @@ class StationPrep(AbstractStationPrep):
self.check_inverse_transform_params(self.mean, self.std, self._transform_method)
self.data, self.mean, self.std = f_inverse(self.data, self.mean, self.std, self._transform_method)
self._transform_method = None
# update X and Y
self.make_samples()
class AbstractDataPrep(object):
......@@ -1153,8 +1158,14 @@ if __name__ == "__main__":
statistics_per_var=statistics_per_var, station_type='background',
network='UBA', sampling='daily', target_dim='variables', target_var='o3',
interpolate_dim='datetime', window_history_size=7, window_lead_time=3,
transformation={'method': 'standardise'})
sp.set_transformation({'method': 'standardise', 'mean': sp.mean+2, 'std': sp.std+1})
) # transformation={'method': 'standardise'})
# sp.set_transformation({'method': 'standardise', 'mean': sp.mean+2, 'std': sp.std+1})
sp2 = StationPrep(data_path='/home/felix/PycharmProjects/mlt_new/data/', station='DEBY122',
statistics_per_var=statistics_per_var, station_type='background',
network='UBA', sampling='daily', target_dim='variables', target_var='o3',
interpolate_dim='datetime', window_history_size=7, window_lead_time=3,
transformation={'method': 'standardise'})
sp2.transform(inverse=True)
sp.get_X()
sp.get_Y()
print(len(sp))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment