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

fixed debug option not including certain variables

parent 71587a3c
No related branches found
No related tags found
No related merge requests found
Pipeline #47481 failed
......@@ -82,6 +82,7 @@ def mvcm():
default=1,
help="print verbose information. Argument can be used multiple times.",
)
parser.add_argument("-d", "--debug", action="store_true", help="activate debug mode")
args = parser.parse_args()
......@@ -103,6 +104,7 @@ def mvcm():
eco_file = args.eco or _eco_file
out_file = args.out or "test_out.nc"
verbose = args.verbose
debug = args.debug
main(
satellite=satellite,
......@@ -123,4 +125,5 @@ def mvcm():
eco_file=eco_file,
out_file=out_file,
verbose=verbose,
debug=debug,
)
......@@ -214,6 +214,8 @@ def main(
# logging.info(f"Band {b} not found in file. No output will be written.")
# return
logging.info(f"Reading VNP02: {file_names['MOD02']}")
viirs_data = rd.get_data(satellite, sensor, file_names, hires=use_hires)
sunglint_angle = thresholds["Sun_Glint"]["bounds"][3]
......@@ -553,9 +555,11 @@ def main(
}
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
else:
out_dict = d
sf = {k: {"dims": ("x", "y"), "data": scene_flags[k]} for k in scene_flags}
out_dict = d | sf
ds_out = xr.Dataset.from_dict(out_dict)
comp = dict(zlib=True, complevel=5)
......
......@@ -237,9 +237,15 @@ class ReadData(CollectInputs):
logger.debug(f"Reading {self.file_name_geo}")
geo_data = xr.open_dataset(self.file_name_geo, group="geolocation_data")
relazi = self.relative_azimuth_angle(geo_data.sensor_azimuth.values, geo_data.solar_azimuth.values)
sunglint = self.sun_glint_angle(geo_data.sensor_zenith.values, geo_data.solar_zenith.values, relazi)
scatt_angle = self.scattering_angle(geo_data.solar_zenith.values, geo_data.sensor_zenith.values, relazi)
relazi = self.relative_azimuth_angle(
geo_data.sensor_azimuth.values, geo_data.solar_azimuth.values
)
sunglint = self.sun_glint_angle(
geo_data.sensor_zenith.values, geo_data.solar_zenith.values, relazi
)
scatt_angle = self.scattering_angle(
geo_data.solar_zenith.values, geo_data.sensor_zenith.values, relazi
)
geo_data["relative_azimuth"] = (self.dims, relazi)
geo_data["sunglint_angle"] = (self.dims, sunglint)
......@@ -287,7 +293,9 @@ class ReadData(CollectInputs):
return rad_data
def preprocess_viirs(self, geo_data: xr.Dataset, viirs: xr.Dataset, hires_data: xr.Dataset = None) -> xr.Dataset:
def preprocess_viirs(
self, geo_data: xr.Dataset, viirs: xr.Dataset, hires_data: xr.Dataset = None
) -> xr.Dataset:
"""Create band combinations that are used by some spectral tests.
Parameters
......@@ -428,7 +436,9 @@ class ReadData(CollectInputs):
logger.debug("Viirs preprocessing completed successfully.")
return viirs_out
def relative_azimuth_angle(self, sensor_azimuth: npt.NDArray, solar_azimuth: npt.NDArray) -> npt.NDArray:
def relative_azimuth_angle(
self, sensor_azimuth: npt.NDArray, solar_azimuth: npt.NDArray
) -> npt.NDArray:
"""Compute relative azimuth angle.
Parameters
......@@ -469,9 +479,9 @@ class ReadData(CollectInputs):
-------
sunglint_angle: np.ndarray
"""
cossna = np.sin(sensor_zenith * _DTR) * np.sin(solar_zenith * _DTR) * np.cos(rel_azimuth * _DTR) + np.cos(
sensor_zenith * _DTR
) * np.cos(solar_zenith * _DTR)
cossna = np.sin(sensor_zenith * _DTR) * np.sin(solar_zenith * _DTR) * np.cos(
rel_azimuth * _DTR
) + np.cos(sensor_zenith * _DTR) * np.cos(solar_zenith * _DTR)
cossna[cossna > 1] = 1
sunglint_angle = np.arccos(cossna) * _RTD
......@@ -502,7 +512,9 @@ class ReadData(CollectInputs):
"""
cos_scatt_angle = -1.0 * (
np.cos(solar_zenith * _DTR) * np.cos(sensor_zenith * _DTR)
- np.sin(solar_zenith * _DTR) * np.sin(sensor_zenith * _DTR) * np.cos(relative_azimuth * _DTR)
- np.sin(solar_zenith * _DTR)
* np.sin(sensor_zenith * _DTR)
* np.cos(relative_azimuth * _DTR)
)
scatt_angle = np.arccos(cos_scatt_angle) * _RTD
......@@ -543,7 +555,9 @@ class ReadAncillary(CollectInputs):
]
)
out_shape: tuple = field(init=False, default=Factory(lambda self: self.latitude.shape, takes_self=True))
out_shape: tuple = field(
init=False, default=Factory(lambda self: self.latitude.shape, takes_self=True)
)
def get_granule_time(self):
"""Get granule timestamp and format it for MVCM."""
......@@ -657,7 +671,9 @@ class ReadAncillary(CollectInputs):
"land_ice_fraction",
"surface_temperature",
]
geos_data = {var: np.empty(self.out_shape, dtype=np.float32).ravel() for var in geos_variables}
geos_data = {
var: np.empty(self.out_shape, dtype=np.float32).ravel() for var in geos_variables
}
geos_data = anc.py_get_GEOS(
self.latitude.ravel(),
......@@ -750,6 +766,7 @@ def get_data(satellite: str, sensor: str, file_names: Dict, hires: bool = False)
res = 1
Ancillary = ReadAncillary(
file_name_l1b=file_names["MOD02"],
latitude=geo_data.latitude.values,
longitude=geo_data.longitude.values,
resolution=res,
......
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