Skip to content
Snippets Groups Projects
Commit d957c5a1 authored by Paolo Veglio's avatar Paolo Veglio
Browse files

updated main to compute integer cloud mask. added debug mode to optionally...

updated main to compute integer cloud mask. added debug mode to optionally include bits in output file
parent 6c9504df
No related branches found
No related tags found
No related merge requests found
Pipeline #47195 failed
......@@ -128,6 +128,7 @@ def main(
eco_file: str = _eco_file,
out_file: str = "temp_out.nc",
verbose: int = 0,
debug: bool = False,
) -> None:
"""MVCM main function.
......@@ -290,8 +291,12 @@ def main(
cmin_g2, bits["04"] = MyScene.bt_diff_86_11um("M14-M15", cmin_g2, bits["04"])
cmin_g2, bits["05"] = MyScene.test_11_12um_diff("M15-M16", cmin_g2, bits["05"])
cmin_g2, bits["06"] = MyScene.variability_11um_test(m15_name, cmin_g2, bits["06"])
cmin_g2, bits["07"] = MyScene.bt_difference_11_4um_test_ocean("M15-M12", cmin_g2, bits["07"])
cmin_g2, bits["08"] = MyScene.bt_difference_11_4um_test_land("M15-M16", "M15-M12", cmin_g2, bits["08"])
cmin_g2, bits["07"] = MyScene.bt_difference_11_4um_test_ocean(
"M15-M12", cmin_g2, bits["07"]
)
cmin_g2, bits["08"] = MyScene.bt_difference_11_4um_test_land(
"M15-M16", "M15-M12", cmin_g2, bits["08"]
)
cmin_g2, bits["09"] = MyScene.oceanic_stratus_11_4um_test("M15-M12", cmin_g2, bits["09"])
# Group 3
......@@ -348,7 +353,9 @@ def main(
cmin[idx], bits["r01"]["test"][idx] = Restore.spatial_variability(cmin, idx, bits["r01"])
# Sun Glint
sunglint_bits = restoral_bits["01"] * restoral_bits["03"] * restoral_bits["05"] * restoral_bits["15"]
sunglint_bits = (
restoral_bits["01"] * restoral_bits["03"] * restoral_bits["05"] * restoral_bits["15"]
)
idx = np.nonzero(
(scene_flags["day"] == 1)
......@@ -367,8 +374,12 @@ def main(
"nir_2": restoral_bits["15"],
"sst": restoral_bits["03"],
}
idx = np.nonzero((scene_flags["day"] == 1) & (scene_flags["water"] == 1) & (scene_flags["ice"] == 0))
cmin[idx], bits["r03"]["test"][idx] = Restore.shallow_water(sh_water_bits, cmin, idx, bits["r03"])
idx = np.nonzero(
(scene_flags["day"] == 1) & (scene_flags["water"] == 1) & (scene_flags["ice"] == 0)
)
cmin[idx], bits["r03"]["test"][idx] = Restore.shallow_water(
sh_water_bits, cmin, idx, bits["r03"]
)
desert_bits = restoral_bits["15"] * restoral_bits["05"]
# make sure that the land_bits are calculated properly
......@@ -486,10 +497,20 @@ def main(
# # cmin = MVCM.clear_sky_restoral(cmin)
#
# # return cmin
csc = cmin_final
cloud_mask = np.zeros(csc.shape)
cloud_mask[csc > 0.99] = 3
cloud_mask[(csc <= 0.99) & (csc > 0.95)] = 2
cloud_mask[(csc <= 0.95) & (csc > 0.66)] = 1
cloud_mask[csc <= 0.66] = 0
d = {
"latitude": {"dims": ("x", "y"), "data": viirs_data.latitude.values},
"longitude": {"dims": ("x", "y"), "data": viirs_data.longitude.values},
"confidence": {"dims": ("x", "y"), "data": cmin_final},
"cloud_mask": {"dims": ("x", "y"), "data": cloud_mask},
}
d_debug = {
"ndvi": {"dims": ("x", "y"), "data": viirs_data.ndvi.values},
"sunglint_bits": {"dims": ("x", "y"), "data": sunglint_bits},
"eco": {"dims": ("x", "y"), "data": viirs_data.ecosystem.values},
......@@ -530,6 +551,8 @@ def main(
# 'data': viirs_data.M16.values},
"GEMI": {"dims": ("x", "y"), "data": viirs_data.GEMI.values},
}
if debug is True:
d.update(d_debug)
sf = {k: {"dims": ("x", "y"), "data": scene_flags[k]} for k in scene_flags}
out_dict = d | sf
......@@ -632,6 +655,7 @@ if __name__ == "__main__":
help="print version and exit",
)
parser.add_argument("-v", "--verbose", action="store_true", help="print verbose information")
parser.add_argument("-d", "--debug", action="store_true", help="activate debug mode")
args = parser.parse_args()
......@@ -653,6 +677,7 @@ if __name__ == "__main__":
eco_file = args.eco or _eco_file
out_file = args.out or "test_out.nc"
verbose = args.verbose or False
debug = args.debug or False
main(
satellite=satellite,
......@@ -673,4 +698,5 @@ if __name__ == "__main__":
eco_file=eco_file,
out_file=out_file,
verbose=verbose,
debug=debug,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment