Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle some broken time information in VGAC files #88

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions level1c4pps/vgac2pps_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

"""Functions to convert VGAC level-1c data to a NWCSAF/PPS level-1c formatet netCDF/CF file."""

import numpy as np
import os
import time
from satpy.scene import Scene
Expand Down Expand Up @@ -187,9 +188,14 @@
start_date = scene["M05"].attrs["start_time"].strftime("%Y-%m-%d")
end_date = scene["M05"].attrs["end_time"].strftime("%Y-%m-%d")
start_fine_search = len(scene['scanline_timestamps']) - 1 # As default start the fine search from end of time array
file_contain_bad_time_info = False
for ind in range(0, len(scene['scanline_timestamps']), 100):
# Search from the beginning in large chunks (100) and break when we
# pass midnight.
if np.isnan(scene['scanline_timestamps'].values[:][ind]):
# Sometimes time info is wrong 10^36 hours since ...
file_contain_bad_time_info = True
continue

Check warning on line 198 in level1c4pps/vgac2pps_lib.py

View check run for this annotation

Codecov / codecov/patch

level1c4pps/vgac2pps_lib.py#L197-L198

Added lines #L197 - L198 were not covered by tests
dt_obj = dt64_to_datetime(scene['scanline_timestamps'].values[:][ind])
date_linei = dt_obj.strftime("%Y-%m-%d")
if date_linei == end_date:
Expand All @@ -198,12 +204,16 @@
break
for indj in range(start_fine_search, start_fine_search - 100, -1):
# Midnight is in one of the previous 100 lines.
if np.isnan(scene['scanline_timestamps'].values[:][indj]):
raise ValueError("Error in time information in VGAC file.")

Check warning on line 208 in level1c4pps/vgac2pps_lib.py

View check run for this annotation

Codecov / codecov/patch

level1c4pps/vgac2pps_lib.py#L208

Added line #L208 was not covered by tests
dt_obj = dt64_to_datetime(scene['scanline_timestamps'].values[:][indj])
date_linei = dt_obj.strftime("%Y-%m-%d")
if date_linei == start_date:
# We just passed midnight this is the last line for previous day.
midnight_linenr = indj
break
if file_contain_bad_time_info and indj == start_fine_search - 99:
raise ValueError("Error in time information in VGAC file.")

Check warning on line 216 in level1c4pps/vgac2pps_lib.py

View check run for this annotation

Codecov / codecov/patch

level1c4pps/vgac2pps_lib.py#L216

Added line #L216 was not covered by tests
return midnight_linenr


Expand Down
Loading