Skip to content

Commit

Permalink
Ensure that noise is added in training even if real obs are used.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpf committed Oct 13, 2023
1 parent 8d558db commit c8d6373
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions gprof_nn/bin/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def add_parser(subparsers):
)
)
parser.add_argument(
"--delta_tbs",
"--nedts",
type=float,
nargs="*",
default=None,
Expand Down Expand Up @@ -360,7 +360,7 @@ def run(args):
return 1
if args.simulated_tbs:
sensor.use_simulated_tbs = True
sensor.delta_tbs = args.delta_tbs
sensor.nedts = args.nedts

variant = args.variant
if variant.upper() not in ["1D", "3D", "SIM", "HR"]:
Expand Down Expand Up @@ -466,7 +466,7 @@ def run_training_1d(
lr = lr * len(n_epochs)

if args.normalizer is None:
nedts = args.delta_tbs
nedts = args.nedts
normalizer = get_normalizer(sensor, nedts=nedts)
else:
normalizer = Normalizer.load(args.normalizer)
Expand Down
6 changes: 3 additions & 3 deletions gprof_nn/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def __init__(self, kind, name, channels, angles, platform, viewing_geometry):
self.missing_channels = None
self.l1c_version = ""
self.use_simulated_tbs = False
self.delta_tbs = None
self.nedts = None

# Bin file types
self._bin_file_header = types.get_bin_file_header(n_chans, n_angles, kind)
Expand Down Expand Up @@ -637,8 +637,8 @@ def _load_scene_1d(self, scene, targets, augment, rng):
valid = sp >= 0

tbs = self.load_brightness_temperatures(scene, mask=valid)
if self.use_simulated_tbs and self.delta_tbs is not None:
noise = np.array(self.delta_tbs) * rng.normal(size=tbs.shape)
if self.nedts is not None:
noise = np.array(self.nedts) * rng.normal(size=tbs.shape)
tbs += noise

if augment:
Expand Down

0 comments on commit c8d6373

Please sign in to comment.