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

seviri l1b netcdf reader needs to be updated due to EUM fixing Attribute Issue #753

Closed
ColinDuff opened this issue May 6, 2019 · 3 comments · Fixed by #791
Closed

seviri l1b netcdf reader needs to be updated due to EUM fixing Attribute Issue #753

ColinDuff opened this issue May 6, 2019 · 3 comments · Fixed by #791

Comments

@ColinDuff
Copy link
Contributor

When creating the seviri l1b netcdf reader i noticed that EUM had incorrectly set some attributes as dimensions. We created a workaround to allow us to work with the netcdf files.

EUM have now fixed this but now the reader will fail

The sevii l1b netcdf reader needs to be updated to now treat these dimension parameters as attributes.

the HRV netcdf metadata is now also correctly formatted and the reader should also be updated to allows us to read this data.

@sfinkens
Copy link
Member

sfinkens commented May 7, 2019

@ColinDuff I have been working on SEVIRI scanline timestamps (#752) . As this is for HRIT only, @mraspaud suggested to also checkout the other SEVIRI readers. I quickly tried to do the same for the nc-reader but didn't succeed because of this issue. But at least here's a sketch (not tested):

diff --git a/satpy/readers/seviri_l1b_nc.py b/satpy/readers/seviri_l1b_nc.py
index 501a7f56..b1d3e52e 100644
--- a/satpy/readers/seviri_l1b_nc.py
+++ b/satpy/readers/seviri_l1b_nc.py
@@ -24,7 +24,8 @@
 
 from satpy.readers.file_handlers import BaseFileHandler
 from satpy.readers.seviri_base import (SEVIRICalibrationHandler,
-                                       CHANNEL_NAMES, CALIB, SATNUM)
+                                       CHANNEL_NAMES, CALIB, SATNUM,
+                                       get_cds_time)
 import xarray as xr
 # Needed for xarray netcdf workaround
 from netCDF4 import Dataset as tmpDataset
@@ -42,6 +43,7 @@ class NCSEVIRIFileHandler(BaseFileHandler, SEVIRICalibrationHandler):
         self.mda = {}
         self.reference = datetime.datetime(1958, 1, 1)
         self._read_file()
+        self._acq_time_visir = self._acq_time_hrv = None
 
     @property
     def start_time(self):
@@ -122,6 +124,11 @@ class NCSEVIRIFileHandler(BaseFileHandler, SEVIRICalibrationHandler):
         elif dataset_id.calibration == 'brightness_temperature':
             dataset = self._ir_calibrate(dataset, channel, cal_type)
 
+        # Add scanline timestamps as additional y-coordinate
+        dataset['acq_time'] = ('y', self._acq_time_hrv if channel == 'HRV' else self._acq_time_visir)
+        dataset['acq_time'].attrs['long_name'] = 'Mean scanline acquisition time'
+
+        # Update attributes
         dataset.attrs.update(self.nc[dataset_info['nc_key']].attrs)
         dataset.attrs.update(dataset_info)
         dataset.attrs['platform_name'] = "Meteosat-" + SATNUM[self.platform_id]
@@ -202,6 +209,22 @@ class NCSEVIRIFileHandler(BaseFileHandler, SEVIRICalibrationHandler):
 
         return area_extent
 
+    @property
+    def acq_time_visir(self):
+        if self._acq_time_visir is None:
+            days = self.nc['channel_data_hrv_data_l10_line_mean_acquisition_time_day']
+            msecs = self.nc['channel_data_hrv_data_l10_line_mean_acquisition_msec']
+            self._acq_time_visir = get_cds_time(days=days, msecs=msecs)
+        return self._acq_time_visir
+
+    @property
+    def acq_time_hrv(self):
+        if self._acq_time_hrv is None:
+            days = self.nc['channel_data_visir_data_l10_line_mean_acquisition_time_day']
+            msecs = self.nc['channel_data_visir_data_l10_line_mean_acquisition_msec']
+            self._acq_time_hrv = get_cds_time(days=days, msecs=msecs)
+        return self._acq_time_hrv
    

@djhoese
Copy link
Member

djhoese commented May 19, 2019

What is the status of this issue? Isn't this something you worked on at the PCW @ColinDuff?

@ColinDuff
Copy link
Contributor Author

hi, the reader has been updated but i just need to add a test script for it. will work on it this week if i have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants