Skip to content

Commit 46a1988

Browse files
Merge pull request #85 from ninahakansson/viirs_compact
Adapt viirs2pps also to viirs_compact
2 parents e7e5465 + 644ba6c commit 46a1988

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

bin/viirs2pps.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
help="Output directory where to store the level1c file")
4242
parser.add_argument('--iband', action='store_true',
4343
help="Iband resolution include I01-I03, M15-M16 and optional M09, M14")
44+
parser.add_argument('--reader', type=str, nargs='?',
45+
required=False, default="viirs_sdr",
46+
help="VIIRS reader default: viirs_sdr")
4447
parser.add_argument('-ne', '--nc_engine', type=str, nargs='?',
4548
required=False, default='h5netcdf',
4649
help="Engine for saving netcdf files netcdf4 or h5netcdf (default).")
@@ -53,6 +56,7 @@
5356
help="Orbit number (default is 00000).")
5457

5558
options = parser.parse_args()
56-
process_one_scene(options.files, options.out_dir, options.iband, engine=options.nc_engine,
59+
process_one_scene(options.files, options.out_dir, options.iband, reader=options.reader,
60+
engine=options.nc_engine,
5761
all_channels=options.all_channels, pps_channels=options.pps_channels,
5862
orbit_n=options.orbit_number)

level1c4pps/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,10 @@ def rename_latitude_longitude(scene):
334334
"""Rename latitude longitude to lat lon."""
335335
lat_name_satpy = 'latitude'
336336
lon_name_satpy = 'longitude'
337-
for alt_latname in ['lat_pixels', 'm_latitude', 'i_latitude']:
337+
for alt_latname in ['lat_pixels', 'm_latitude', 'latitude_m', 'i_latitude']:
338338
if alt_latname in scene and 'latitude' not in scene:
339339
lat_name_satpy = alt_latname
340-
for alt_lonname in ['lon_pixels', 'm_longitude', 'i_longitude']:
340+
for alt_lonname in ['lon_pixels', 'm_longitude','longitude_m', 'i_longitude']:
341341
if alt_lonname in scene and 'longitude' not in scene:
342342
lon_name_satpy = alt_lonname
343343
scene[lat_name_satpy].attrs['name'] = 'lat'

level1c4pps/viirs2pps_lib.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Nina Hakansson <nina.hakansson@smhi.se>
2323
# Adam.Dybbroe <adam.dybbroe@smhi.se>
2424

25-
"""Functions to convert MERSI-2 level-1 data to a NWCSAF/PPS level-1c formatet netCDF/CF file."""
25+
"""Functions to convert VIIRS level-1 data to a NWCSAF/PPS level-1c formatet netCDF/CF file."""
2626

2727
import os
2828
import time
@@ -124,12 +124,12 @@ def set_header_and_band_attrs(scene, orbit_n=0):
124124
return nimg
125125

126126

127-
def process_one_scene(scene_files, out_path, use_iband_res=False, engine='h5netcdf',
127+
def process_one_scene(scene_files, out_path, use_iband_res=False, reader='viirs_sdr', engine='h5netcdf',
128128
all_channels=False, pps_channels=False, orbit_n=0):
129129
"""Make level 1c files in PPS-format."""
130130
tic = time.time()
131131
scn_ = Scene(
132-
reader='viirs_sdr',
132+
reader=reader,
133133
filenames=scene_files)
134134

135135
MY_MBAND = MBAND_DEFAULT
@@ -149,6 +149,8 @@ def process_one_scene(scene_files, out_path, use_iband_res=False, engine='h5netc
149149
scn_.load(MY_IBAND_I + ANGLE_NAMES + ['i_latitude', 'i_longitude'], resolution=371)
150150
scn_.load(MY_IBAND_M, resolution=742)
151151
scn_ = scn_.resample(resampler='native')
152+
elif reader == "viirs_compact":
153+
scn_.load(MY_MBAND + ANGLE_NAMES + ['latitude_m', 'longitude_m'], resolution=742)
152154
else:
153155
scn_.load(MY_MBAND + ANGLE_NAMES + ['m_latitude', 'm_longitude'], resolution=742)
154156

0 commit comments

Comments
 (0)