Skip to content

Commit

Permalink
sync scripts with these pulled to satpy
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdawn committed Jun 27, 2019
1 parent 1e6003a commit 56b8527
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 18 deletions.
18 changes: 11 additions & 7 deletions satpy/agri_l1.py
Expand Up @@ -60,7 +60,8 @@ def get_dataset(self, dataset_id, ds_info):
# convert bytes to string
data.attrs['long_name'] = data.attrs['long_name'].decode('gbk')
data.attrs['band_names'] = data.attrs['band_names'].decode('gbk')
data.attrs['center_wavelength'] = data.attrs['center_wavelength'].decode('gbk')
if ds_info['file_type'] != 'agri_l1_4000m_geo':
data.attrs['center_wavelength'] = data.attrs['center_wavelength'].decode('gbk')

# calibration
calibration = ds_info['calibration']
Expand Down Expand Up @@ -92,7 +93,10 @@ def get_dataset(self, dataset_id, ds_info):
ds_info['valid_range'] = lut.attrs['valid_range']

data.attrs.update({'platform_name': self['/attr/Satellite Name'],
'sensor': self['/attr/Sensor Identification Code']})
'sensor': self['/attr/Sensor Identification Code'],
'satellite_nominal_latitude': self['/attr/NOMCenterLat'],
'satellite_nominal_longitude': self['/attr/NOMCenterLon'],
'satellite_nominal_altitude': self['/attr/NOMSatHeight']})
data.attrs.update(ds_info)

# remove attributes that could be confusing later
Expand All @@ -113,10 +117,9 @@ def get_area_def(self, key):
loff = _LOFF_list[_resolution_list.index(res)]
cfac = _CFAC_list[_resolution_list.index(res)]
lfac = _LFAC_list[_resolution_list.index(res)]
a = 6378137.0 # equator radius (m)
b = 6356752.3 # polar radius(m)
H = 42164000.0 # the distance between spacecraft and centre of earth (m)
h = H - a # the altitude of satellite
a = self.file_content['/attr/dEA'] * 1E3 # equator radius (m)
b = a * (1 - 1 / self.file_content['/attr/dObRecFlat']) # polar radius (m)
h = self.file_content['/attr/NOMSatHeight'] # the altitude of satellite (m)

lon_0 = self.file_content['/attr/NOMCenterLon']
nlines = self.file_content['/attr/RegLength']
Expand All @@ -139,7 +142,8 @@ def get_area_def(self, key):
'lon_0': float(lon_0),
'h': float(h),
'proj': 'geos',
'units': 'm'}
'units': 'm',
'sweep': 'y'}

area = geometry.AreaDefinition(
self.filename_info['observation_type'],
Expand Down
53 changes: 48 additions & 5 deletions satpy/agri_l1.yaml
Expand Up @@ -12,16 +12,19 @@ reader:
file_types:
agri_l1_0500m:
file_reader: !!python/name:satpy.readers.agri_l1.HDF_AGRI_L1
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_{code:s}-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_0500M_{version:s}.HDF']
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_FDI-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_0500M_{version:s}.HDF']
agri_l1_1000m:
file_reader: !!python/name:satpy.readers.agri_l1.HDF_AGRI_L1
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_{code:s}-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_1000M_{version:s}.HDF']
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_FDI-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_1000M_{version:s}.HDF']
agri_l1_2000m:
file_reader: !!python/name:satpy.readers.agri_l1.HDF_AGRI_L1
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_{code:s}-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_2000M_{version:s}.HDF']
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_FDI-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_2000M_{version:s}.HDF']
agri_l1_4000m:
file_reader: !!python/name:satpy.readers.agri_l1.HDF_AGRI_L1
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_{code:s}-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_4000M_{version:s}.HDF']
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_FDI-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_4000M_{version:s}.HDF']
agri_l1_4000m_geo:
file_reader: !!python/name:satpy.readers.agri_l1.HDF_AGRI_L1
file_patterns: ['{platform_id:4s}-_{instrument:4s}--_N_{observation_type:s}_{longitude:5s}_L1-_GEO-_MULT_{projection:s}_{start_time:%Y%m%d%H%M%S}_{end_time:%Y%m%d%H%M%S}_4000M_{version:s}.HDF']

datasets:
C01:
Expand Down Expand Up @@ -281,4 +284,44 @@ datasets:
file_key: NOMChannel14
lut_key: CALChannel14
file_type: agri_l1_4000m
fill_value: 65535
fill_value: 65535

solar_zenith_angle:
name: solar_zenith_angle
units: degree
standard_name: solar_zenith_angle
resolution: 4000
file_type: agri_l1_4000m_geo
file_key: NOMSunZenith

solar_azimuth_angle:
name: solar_azimuth_angle
units: degree
standard_name: solar_azimuth_angle
resolution: 4000
file_type: agri_l1_4000m_geo
file_key: NOMSunAzimuth

solar_glint_angle:
name: solar_glint_angle
units: degree
standard_name: solar_glint_angle
resolution: 4000
file_type: agri_l1_4000m_geo
file_key: NOMSunGlintAngle

satellite_zenith_angle:
name: satellite_zenith_angle
units: degree
standard_name: satellite_zenith_angle
resolution: 4000
file_type: agri_l1_4000m_geo
file_key: NOMSatelliteZenith

satellite_azimuth_angle:
name: satellite_azimuth_angle
units: degree
standard_name: satellite_azimuth_angle
resolution: 4000
file_type: agri_l1_4000m_geo
file_key: NOMSatelliteAzimuth
8 changes: 2 additions & 6 deletions satpy/test_agri_l1.py
Expand Up @@ -21,16 +21,11 @@
"""Test for readers/agri_l1.py.
"""
from satpy.tests.reader_tests.test_hdf5_utils import FakeHDF5FileHandler
import sys
import numpy as np
import dask.array as da
import xarray as xr
import os

if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest
import unittest

try:
from unittest import mock
Expand Down Expand Up @@ -197,6 +192,7 @@ 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/Observing Beginning Date': '2019-06-03', '/attr/Observing Beginning Time': '00:30:01.807',
Expand Down

0 comments on commit 56b8527

Please sign in to comment.