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

bump version

parent 869c5e84
No related branches found
No related tags found
No related merge requests found
Pipeline #51767 failed with stages
in 7 seconds
......@@ -10,7 +10,6 @@ ci:
services:
- docker:19.03.1-dind
script:
- docker --version
- docker login --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD $CI_REGISTRY
- cd ci
- docker build --tag $CI_REGISTRY_IMAGE .
......
"""Set up version."""
__version__ = "0.2.3"
__version__ = "0.2.4"
......@@ -12,6 +12,7 @@ import time
import numpy as np
import xarray as xr
from netCDF4 import Dataset
from pkg_resources import get_distribution # type: ignore
from rich.logging import RichHandler
......@@ -217,7 +218,11 @@ def main(
return
logger.info(f"All bands found in file {file_names['IMG02']}. The code will run.")
# logger.info(f"Reading VNP02: {file_names['MOD02']}")
with Dataset(file_names["MOD03"]) as f:
# time_coverage_start = f.getncattr("time_coverage_start")
# time_coverage_end = f.getncattr("time_coverage_end")
# orbit_number = f.getncattr("OrbitNumber")
attrs = {attr: f.getncattr(attr) for attr in f.ncattrs()}
viirs_data = rd.get_data(satellite, sensor, file_names, hires=use_hires)
......@@ -483,33 +488,8 @@ def main(
# cmin,
# bits['r06'])[idx]
# cmin_3d[i, :, :] = cmin
# i += 1
# cmin_final = np.min(cmin_3d, axis=0)
# bit['15'] = np.max(temp_bit, axis=0)
cmin_final = cmin
"""
idx = np.nonzero((scene_flags['day'] == 1) & (scene_flags['water'] == 1) &
(scene_flags['ice'] == 0))
cmin[idx] = restore.shallow_water(sh_water_bits, cmin)[idx]
idx = np.nonzero((scene_flags['day'] == 1) & (scene_flags['land'] == 1) &
(scene_flags['snow'] == 0) & (scene_flags['ice'] == 0) &
(cmin <= 0.95))
cmin[idx] = restore.land(land_bits, cmin)[idx]
idx = np.nonzero((scene_flags['day'] == 1) & (scene_flags['land'] == 1) &
(scene_flags['snow'] == 0) & (scene_flags['ice'] == 0) &
(scene_flags['coast'] == 1))
cmin[idx] = restore.coast(coast_bits, cmin)[idx]
idx = np.nonzero((scene_flags['night'] == 1) & (scene_flags['land'] == 1) &
(scene_flags['snow'] == 0) & (scene_flags['ice'] == 0) &
(cmin <= 0.95))
cmin[idx] = restore.land_night(land_night_bits, cmin)[idx]
"""
# bits translation MVCM-python -> MVCM-C
# 01 13 test_11um
# 02 27 surface_temperature_test
......@@ -523,29 +503,6 @@ def main(
# 15 16 test_1_38um_high_clouds
# 16 17 thin_cirrus_4_12um_BTD_test
# if scene_name in ['Ocean_Day']:
# # total_bit = np.full(viirs_data.M01.shape, 4)
# total_bit = bit1 + bit2 + bit4 + bit11
# sunglint_angle = thresholds['Sun_Glint']['bounds'][3]
# scene_flags = scn.find_scene(viirs_data, sunglint_angle)
#
# # idx = np.nonzero((scene_flags['water'] == 1) &
# (scene_flags['ice'] == 0) &
# # (scene_flags['uniform'] == 1) &
# (cmin <= 0.99) & (cmin >= 0.05))
# # cmin[idx] = restoral.spatial(viirs_data, thresholds['Sun_Glint'],
# scene_flags, cmin)[idx]
#
# idx = np.nonzero((scene_flags['water'] == 1) &
# (scene_flags['sunglint'] == 1) &
# (scene_flags['uniform'] == 1) & (cmin <= 0.95))
# cmin[idx] = restoral.sunglint(viirs_data, thresholds['Sun_Glint'],
# total_bit, cmin)[idx]
#
# # MVCM = tst.ComputeTests(viirs_data, scene_name, thresholds)
# # cmin = MVCM.clear_sky_restoral(cmin)
#
# # return cmin
csc = cmin_final
cloud_mask = np.zeros(csc.shape)
cloud_mask[csc > 0.99] = 3
......@@ -560,6 +517,7 @@ def main(
"longitude": {"dims": ("x", "y"), "data": viirs_data.longitude.values},
"confidence": {"dims": ("x", "y"), "data": cmin_final},
"cloud_mask": {"dims": ("x", "y"), "data": cloud_mask},
"sensor_zenith": {"dims": ("x", "y"), "data": viirs_data.sensor_zenith.values},
}
d_debug = {
"ndvi": {"dims": ("x", "y"), "data": viirs_data.ndvi.values},
......@@ -632,54 +590,17 @@ def main(
ds_out = xr.Dataset.from_dict(out_dict)
comp = dict(zlib=True, complevel=5)
comp = {"zlib": True, "complevel": 5}
if type(ds_out) is xr.Dataset:
for var in ds_out:
ds_out[var].encoding.update(comp)
if type(ds_out) is xr.DataArray:
ds_out.encoding.update(comp)
# if use_hires is False:
# ds_out.to_netcdf('test_w_restorals.nc')
# else:
# ds_out.to_netcdf('test_hires.nc')
ds_out.to_netcdf(out_file)
"""
def test_main():
rad1 = [
[255, 260, 265, 248, 223],
[278, 285, 270, 268, 256],
[275, 273, 266, 254, 259],
]
rad2 = [
[270, 273, 271, 268, 265],
[277, 286, 275, 277, 269],
[280, 281, 272, 270, 267],
]
thresh_file = (
"/home/pveglio/mvcm_leo/thresholds/new_thresholds.mvcm.snpp.v1.0.0.yaml"
)
with open(thresh_file) as f:
text = f.read()
rad1 = np.array(rad1)
rad2 = np.array(rad2)
for attr in attrs:
ds_out.attrs[attr] = attrs[attr]
confidence = np.zeros((2, rad1.shape[0], rad1.shape[1]))
thresholds = yml.safe_load(text)
confidence[0, :, :] = tests.test_11um(rad1, thresholds["Daytime_Ocean"])
confidence[1, :, :] = tests.test_11_4diff(rad1, rad2, thresholds["Daytime_Ocean"])
print(f"Confidence[0,:,:]: \n {confidence[0, :, :]}")
print(f"Confidence[1,:,:]: \n {confidence[1, :, :]}")
return confidence
"""
ds_out.to_netcdf(out_file)
if __name__ == "__main__":
......
......@@ -16,7 +16,7 @@ _DTR = np.pi / 180
logger = logging.getLogger(__name__)
def prepare_11_12um_thresholds(thresholds: Dict, dim1: int) -> Dict:
def prepare_11_12um_thresholds(thresholds: dict, dim1: int) -> dict:
"""Prepare 11-12um test thresholds."""
coeff_values = np.empty((dim1, 2))
coeff_values[:, 0] = np.full(dim1, thresholds["coeffs"][0])
......@@ -108,9 +108,11 @@ def thresholds_11_12um(
elif scene in ["Day_Snow"]:
hicut = locut - (thr_dict["cmult"] * locut)
else:
raise ValueError("Scene name not valid")
err_msg = "Scene name not valid"
raise ValueError(err_msg)
else:
raise ValueError("Scene name not valid")
err_msg = "Scene name not valid"
raise ValueError(err_msg)
thr_out = np.dstack((locut, midpt, hicut, np.ones(locut.shape), np.ones(locut.shape)))
return np.squeeze(thr_out.T)
......
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