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

cleaned up code from debugging missing group and fixed Cloud_Mask_SPI dimensions

parent 72b29f85
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,6 @@ import logging ...@@ -5,7 +5,6 @@ import logging
import os import os
from datetime import datetime as dt from datetime import datetime as dt
import netCDF4 as nc
import numpy as np import numpy as np
import psutil import psutil
import xarray as xr import xarray as xr
...@@ -137,10 +136,6 @@ def main( ...@@ -137,10 +136,6 @@ def main(
text = f.read() text = f.read()
thresholds = YAML(typ="safe").load(text) thresholds = YAML(typ="safe").load(text)
f = nc.Dataset(out_file)
logger.info(f"#1 list of groups: {list(f.groups)}")
f.close()
viirs_m_bands = SensorConstants.VIIRS_VIS_BANDS + SensorConstants.VIIRS_IR_BANDS viirs_m_bands = SensorConstants.VIIRS_VIS_BANDS + SensorConstants.VIIRS_IR_BANDS
with Dataset(file_names["MOD03"]) as f: with Dataset(file_names["MOD03"]) as f:
...@@ -194,9 +189,6 @@ def main( ...@@ -194,9 +189,6 @@ def main(
logger.info(f"Memory usage #4: {proc.memory_info().rss / 1e6} MB") logger.info(f"Memory usage #4: {proc.memory_info().rss / 1e6} MB")
f = nc.Dataset(out_file)
logger.info(f"#2 list of groups: {list(f.groups)}")
f.close()
### ###
......
...@@ -4,7 +4,6 @@ import argparse ...@@ -4,7 +4,6 @@ import argparse
import logging import logging
import os import os
import netCDF4 as nc
import numpy as np import numpy as np
import psutil import psutil
import xarray as xr import xarray as xr
...@@ -100,10 +99,6 @@ def main( ...@@ -100,10 +99,6 @@ def main(
text = f.read() text = f.read()
thresholds = YAML(typ="safe").load(text) thresholds = YAML(typ="safe").load(text)
f = nc.Dataset(out_file)
logger.info(f"#1 list of groups in output file: {list(f.groups)}")
f.close()
pixel_type = xr.open_dataset(pixel_data, chunks="auto") pixel_type = xr.open_dataset(pixel_data, chunks="auto")
viirs_data = xr.open_dataset(input_data, chunks="auto") viirs_data = xr.open_dataset(input_data, chunks="auto")
...@@ -454,7 +449,7 @@ def main( ...@@ -454,7 +449,7 @@ def main(
"cloud_mask": {"dims": ("bits", "x", "y"), "data": cloud_mask}, "cloud_mask": {"dims": ("bits", "x", "y"), "data": cloud_mask},
"quality_assurance": {"dims": ("x", "y", "qa"), "data": quality_assurance}, "quality_assurance": {"dims": ("x", "y", "qa"), "data": quality_assurance},
"integer_cloud_mask": {"dims": ("x", "y"), "data": integer_cloud_mask}, "integer_cloud_mask": {"dims": ("x", "y"), "data": integer_cloud_mask},
"spi": {"dims": ("spi_dim", "x1", "y1"), "data": spi.values}, "spi": {"dims": ("x1", "y1", "spi_dim"), "data": spi.values},
} }
old_debug_data = { old_debug_data = {
...@@ -566,10 +561,6 @@ def main( ...@@ -566,10 +561,6 @@ def main(
if debug: if debug:
output_dict.update(debug_data) output_dict.update(debug_data)
f = nc.Dataset(out_file)
logger.info(f"#2 list of groups in output file: {list(f.groups)}")
f.close()
output_data = xr.Dataset.from_dict(output_dict) output_data = xr.Dataset.from_dict(output_dict)
attrs = {"version": _VERSION, "satellite": "VIIRS", "sensor": "VIIRS"} attrs = {"version": _VERSION, "satellite": "VIIRS", "sensor": "VIIRS"}
save_output(output_data, attrs, out_file, compression=5, debug=debug) save_output(output_data, attrs, out_file, compression=5, debug=debug)
......
...@@ -362,8 +362,8 @@ def create_empty_dataset(lat_shape: tuple) -> xr.Dataset: ...@@ -362,8 +362,8 @@ def create_empty_dataset(lat_shape: tuple) -> xr.Dataset:
}, },
"integer_cloud_mask": {"dims": ("x", "y"), "data": np.full(lat_shape, -9999)}, "integer_cloud_mask": {"dims": ("x", "y"), "data": np.full(lat_shape, -9999)},
"spi": { "spi": {
"dims": ("spi_dim", "x1", "y1"), "dims": ("x1", "y1", "spi_dim"),
"data": np.full((2, int(lat_shape[0] / 2), int(lat_shape[1] / 2)), -999.9), "data": np.full((int(lat_shape[0] / 2), int(lat_shape[1] / 2), 2), -999.9),
}, },
} }
......
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