Skip to content

Commit

Permalink
change y scale range (0, 1) to (-1, 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
patel-zeel authored and tom-andersson committed Sep 6, 2023
1 parent b072d1d commit 5b6ea67
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions deepsensor/data/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,25 +323,31 @@ def map_array(
params = self.get_norm_params(var_ID, data, method)

if method == "mean_std":
std = params["std"]
mean = params["mean"]
if unnorm:
data = data * params["std"]
if add_offset:
data = data + params["mean"]
scale = std
offset = mean
else:
if add_offset:
data = data - params["mean"]
data = data / params["std"]
scale = 1 / std
offset = -mean / std
data = data * scale
if add_offset:
data = data + offset
return data

elif method == "min_max":
minimum = params["min"]
maximum = params["max"]
if unnorm:
data = data * (params["max"] - params["min"])
if add_offset:
data = data + params["min"]
scale = (maximum - minimum) / 2
offset = (maximum + minimum) / 2
else:
if add_offset:
data = data - params["min"]
data = data / (params["max"] - params["min"])
scale = 2 / (maximum - minimum)
offset = -(maximum + minimum) / (maximum - minimum)
data = data * scale
if add_offset:
data = data + offset
return data

def map(
Expand Down

0 comments on commit 5b6ea67

Please sign in to comment.