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

Adapt viirs2pps also to viirs_compact #85

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion bin/viirs2pps.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
help="Output directory where to store the level1c file")
parser.add_argument('--iband', action='store_true',
help="Iband resolution include I01-I03, M15-M16 and optional M09, M14")
parser.add_argument('--reader', type=str, nargs='?',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really handle nargs (multiple readers) and if, how does it work? Try the first one first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nargs ='?' means that the argument can be present or not https://docs.python.org/3/library/argparse.html.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. I have misundertsood it.

required=False, default="viirs_sdr",
help="VIIRS reader default: viirs_sdr")
parser.add_argument('-ne', '--nc_engine', type=str, nargs='?',
required=False, default='h5netcdf',
help="Engine for saving netcdf files netcdf4 or h5netcdf (default).")
Expand All @@ -53,6 +56,7 @@
help="Orbit number (default is 00000).")

options = parser.parse_args()
process_one_scene(options.files, options.out_dir, options.iband, engine=options.nc_engine,
process_one_scene(options.files, options.out_dir, options.iband, reader=options.reader,
engine=options.nc_engine,
all_channels=options.all_channels, pps_channels=options.pps_channels,
orbit_n=options.orbit_number)
4 changes: 2 additions & 2 deletions level1c4pps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ def rename_latitude_longitude(scene):
"""Rename latitude longitude to lat lon."""
lat_name_satpy = 'latitude'
lon_name_satpy = 'longitude'
for alt_latname in ['lat_pixels', 'm_latitude', 'i_latitude']:
for alt_latname in ['lat_pixels', 'm_latitude', 'latitude_m', 'i_latitude']:
if alt_latname in scene and 'latitude' not in scene:
lat_name_satpy = alt_latname
for alt_lonname in ['lon_pixels', 'm_longitude', 'i_longitude']:
for alt_lonname in ['lon_pixels', 'm_longitude','longitude_m', 'i_longitude']:
if alt_lonname in scene and 'longitude' not in scene:
lon_name_satpy = alt_lonname
scene[lat_name_satpy].attrs['name'] = 'lat'
Expand Down
8 changes: 5 additions & 3 deletions level1c4pps/viirs2pps_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Nina Hakansson <nina.hakansson@smhi.se>
# Adam.Dybbroe <adam.dybbroe@smhi.se>

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

import os
import time
Expand Down Expand Up @@ -124,12 +124,12 @@
return nimg


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

MY_MBAND = MBAND_DEFAULT
Expand All @@ -149,6 +149,8 @@
scn_.load(MY_IBAND_I + ANGLE_NAMES + ['i_latitude', 'i_longitude'], resolution=371)
scn_.load(MY_IBAND_M, resolution=742)
scn_ = scn_.resample(resampler='native')
elif reader == "viirs_compact":
scn_.load(MY_MBAND + ANGLE_NAMES + ['latitude_m', 'longitude_m'], resolution=742)

Check warning on line 153 in level1c4pps/viirs2pps_lib.py

View check run for this annotation

Codecov / codecov/patch

level1c4pps/viirs2pps_lib.py#L153

Added line #L153 was not covered by tests
else:
scn_.load(MY_MBAND + ANGLE_NAMES + ['m_latitude', 'm_longitude'], resolution=742)

Expand Down
Loading