Skip to content

Commit

Permalink
Merge pull request #1244 from zxdawn/fy4a
Browse files Browse the repository at this point in the history
Bugfix (FY4A AGRI): Correct the type of orbital_parameters to float
  • Loading branch information
pnuu committed Jun 30, 2020
2 parents 9261a1c + 2f130f2 commit b909413
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions satpy/readers/agri_l1.py
Expand Up @@ -105,9 +105,9 @@ def get_dataset(self, dataset_id, ds_info):
data.attrs.update({'platform_name': satname,
'sensor': self['/attr/Sensor Identification Code'].lower(),
'orbital_parameters': {
'satellite_nominal_latitude': self['/attr/NOMCenterLat'],
'satellite_nominal_longitude': self['/attr/NOMCenterLon'],
'satellite_nominal_altitude': self['/attr/NOMSatHeight']}})
'satellite_nominal_latitude': self['/attr/NOMCenterLat'].item(),
'satellite_nominal_longitude': self['/attr/NOMCenterLon'].item(),
'satellite_nominal_altitude': self['/attr/NOMSatHeight'].item()}})
data.attrs.update(ds_info)

# remove attributes that could be confusing later
Expand Down
22 changes: 18 additions & 4 deletions satpy/tests/reader_tests/test_agri_l1.py
Expand Up @@ -184,10 +184,16 @@ def _get_4km_data(self, file_type):
def get_test_content(self, filename, filename_info, filetype_info):
"""Mimic reader input file content."""
global_attrs = {
'/attr/NOMCenterLat': 0.0, '/attr/NOMCenterLon': 104.7, '/attr/NOMSatHeight': 3.5786E7,
'/attr/dEA': 6378.14, '/attr/dObRecFlat': 298.257223563,
'/attr/OBIType': 'REGC', '/attr/RegLength': 2.0, '/attr/RegWidth': 5.0,
'/attr/Begin Line Number': 0, '/attr/End Line Number': 1,
'/attr/NOMCenterLat': np.array(0.0),
'/attr/NOMCenterLon': np.array(104.7),
'/attr/NOMSatHeight': np.array(3.5786E7),
'/attr/dEA': np.array(6378.14),
'/attr/dObRecFlat': np.array(298.257223563),
'/attr/OBIType': 'REGC',
'/attr/RegLength': np.array(2.0),
'/attr/RegWidth': np.array(5.0),
'/attr/Begin Line Number': np.array(0),
'/attr/End Line Number': np.array(1),
'/attr/Observing Beginning Date': '2019-06-03', '/attr/Observing Beginning Time': '00:30:01.807',
'/attr/Observing Ending Date': '2019-06-03', '/attr/Observing Ending Time': '00:34:07.572',
'/attr/Satellite Name': 'FY4A', '/attr/Sensor Identification Code': 'AGRI', '/attr/Sensor Name': 'AGRI',
Expand Down Expand Up @@ -286,6 +292,14 @@ def test_fy4a_all_resolutions(self):
else:
self.assertEqual('K', res[band_name].attrs['units'])

# check whether the data type of orbital_parameters is float
orbital_parameters = res[band_names[0]].attrs['orbital_parameters']
for attr in orbital_parameters:
self.assertEqual(type(orbital_parameters[attr]), float)
self.assertEqual(orbital_parameters['satellite_nominal_latitude'], 0.)
self.assertEqual(orbital_parameters['satellite_nominal_longitude'], 104.7)
self.assertEqual(orbital_parameters['satellite_nominal_altitude'], 3.5786E7)

def test_fy4a_counts_calib(self):
"""Test loading data at counts calibration."""
from satpy import DatasetID
Expand Down

0 comments on commit b909413

Please sign in to comment.