Skip to content

Commit

Permalink
Add VIIRS EDR proxy python module and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Aug 8, 2023
1 parent 75922ee commit f6b5b4c
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/source/readers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using the ``--list-products`` option.
:polar2grid:acspo
:polar2grid:clavrx
:polar2grid:viirs_edr_active_fires
:polar2grid:viirs_edr
:polar2grid:mersi2_l1b
:geo2grid:abi_l1b
:geo2grid:abi_l2_nc
Expand Down
32 changes: 32 additions & 0 deletions doc/source/readers/viirs_edr.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
VIIRS EDR Reader
================

.. automodule:: polar2grid.readers.viirs_edr
:noindex:

Command Line Arguments
----------------------

.. argparse::
:module: polar2grid.readers.viirs_edr
:func: add_reader_argument_groups
:prog: polar2grid.sh -r viirs_edr -w <writer>
:passparser:

Examples:

.. code-block:: bash
polar2grid.sh -r viirs_edr -w geotiff -f <path to files>/<list of files>
polar2grid.sh -r viirs_edr -w geotiff -h
polar2grid.sh -r viirs_edr -w geotiff --list-products -f ../edr/*.h5
polar2grid.sh -r viirs_edr -w geotiff -p true_color_surf false_color_surf --num-workers 8 --no-tiled -f ../edr/*.h5
Product Explanation
-------------------

TODO
2 changes: 1 addition & 1 deletion doc/source/readers/viirs_sdr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Examples:
polar2grid.sh -r viirs_sdr -w geotiff --fill-value 0 -f ../sdr/*.h5
polar2grid.sh -r viirs_sdr -w geotiff -p true_color false_color --num-workers 8 --tiled -f ../sdr/*.h5
polar2grid.sh -r viirs_sdr -w geotiff -p true_color false_color --num-workers 8 --no-tiled -f ../sdr/*.h5
polar2grid.sh -r viirs_sdr -w awips_tiled -p i04 adaptive_dnb dynamic_dnb --awips-true-color --awips-false-color --sza-threshold=90.0 --letters --compress --sector-id Polar -g polar_alaska_1km --dnb-saturation-correction -f <path to files>
Expand Down
158 changes: 158 additions & 0 deletions polar2grid/readers/viirs_edr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Copyright (C) 2023 Space Science and Engineering Center (SSEC),
# University of Wisconsin-Madison.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is part of the polar2grid software package. Polar2grid takes
# satellite observation data, remaps it, and writes it to a file format for
# input into another program.
# Documentation: http://www.ssec.wisc.edu/software/polar2grid/
"""The VIIRS EDR Reader operates on Environmental Data Record (SDR) HDF5 files
from the Suomi National Polar-orbiting Partnership's (NPP), the NOAA20, or the
NOAA-21 Visible/Infrared Imager Radiometer Suite (VIIRS) instrument. The VIIRS
EDR reader requires filenames to match one of a couple different standard
filename schemes used for official products. EDR files are typically named
as below::
JRR-AOD_v3r2_npp_s202307230941369_e202307230943011_c202307231038217.nc
The VIIRS EDR reader supports most JPSS Risk Reduction (JRR) enterprise algorithm
output. The VIIRS EDR reader can be specified to the ``polar2grid.sh`` script
with the reader name ``viirs_edr``.
This reader's default remapping algorithm is ``ewa`` for Elliptical Weighted
Averaging resampling. The ``--weight-delta-max`` parameter set to 40 and the
``--weight-distance-max`` parameter set to 2.
+---------------------------+-----------------------------------------------------+
| Product Name | Description |
+===========================+=====================================================+
| surf_refl_i01 | I01 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_i02 | I02 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_i03 | I03 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m01 | M01 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m02 | M02 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m03 | M03 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m04 | M04 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m05 | M05 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m06 | M06 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m07 | M07 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m08 | M08 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m09 | M09 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m10 | M10 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| surf_refl_m11 | M11 Surface Reflectance Band |
+---------------------------+-----------------------------------------------------+
| true_color_surf | Ratio sharpened surface true color |
+---------------------------+-----------------------------------------------------+
| false_color_surf | Ratio sharpened surface false color |
+---------------------------+-----------------------------------------------------+
| NDVI | Normalized Difference Vegetation Index |
+---------------------------+-----------------------------------------------------+
| EVI | Enhanced Vegetation Index |
+---------------------------+-----------------------------------------------------+
| CldTopTemp | Cloud Top Temperature |
+---------------------------+-----------------------------------------------------+
| CldTopHght | Cloud Top Height |
+---------------------------+-----------------------------------------------------+
| CldTopPres | Cloud Top Pressure |
+---------------------------+-----------------------------------------------------+
| AOD550 | Aerosol Optical Depth |
+---------------------------+-----------------------------------------------------+
| VLST | Land Surface Temperature |
+---------------------------+-----------------------------------------------------+
"""
from __future__ import annotations

from argparse import ArgumentParser, _ArgumentGroup
from typing import Optional

from satpy import DataQuery

from ._base import ReaderProxyBase

PREFERRED_CHUNK_SIZE: int = 6400

I_PRODUCTS = ["surf_refl_I{:02d}".format(chan_num) for chan_num in range(1, 4)]
M_PRODUCTS = ["surf_refl_M{:02d}".format(chan_num) for chan_num in range(1, 12)]
SURF_COMPS = ["true_color_surf", "false_color_ref"]
OTHER_PRODS = ["NDVI", "EVI", "CldTopTemp", "CldTopHght", "CldTopPres", "AOD550", "VLST"]

PRODUCT_ALIASES = {}
SURF_ALIASES = []

for surf_band in I_PRODUCTS + M_PRODUCTS:
PRODUCT_ALIASES[surf_band.lower()] = surf_band
SURF_ALIASES.append(surf_band.lower())

DEFAULT_PRODUCTS = SURF_ALIASES + SURF_COMPS + OTHER_PRODS
P2G_PRODUCTS = SURF_ALIASES + SURF_COMPS + OTHER_PRODS

FILTERS = {
"day_only": {
"standard_name": [
"surface_bidirectional_reflectance",
"true_color",
"false_color",
"natural_color",
],
},
"night_only": {},
}


class ReaderProxy(ReaderProxyBase):
"""Provide Polar2Grid-specific information about this reader's products."""

is_polar2grid_reader = True

def get_default_products(self) -> list[str]:
"""Get products to load if users hasn't specified any others."""
return DEFAULT_PRODUCTS

def get_all_products(self):
"""Get all polar2grid products that could be loaded."""
return P2G_PRODUCTS

@property
def _aliases(self) -> dict[str, DataQuery | str]:
return PRODUCT_ALIASES


def add_reader_argument_groups(
parser: ArgumentParser, group: Optional[_ArgumentGroup] = None
) -> tuple[Optional[_ArgumentGroup], Optional[_ArgumentGroup]]:
"""Add reader-specific command line arguments to an existing argument parser.
If ``group`` is provided then arguments are added to this group. If not,
a new group is added to the parser and arguments added to this new group.
"""
if group is None:
group = parser.add_argument_group(title="VIIRS EDR Reader")

return group, None
6 changes: 3 additions & 3 deletions polar2grid/readers/viirs_sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"""The VIIRS SDR Reader operates on Sensor Data Record (SDR) HDF5 files from
the Suomi National Polar-orbiting Partnership's (NPP) and/or the NOAA20
Visible/Infrared Imager Radiometer Suite (VIIRS) instrument. The VIIRS
SDR reader ignores filenames and uses internal file content to determine
the type of file being provided, but SDR are typically named as below
and have corresponding geolocation files::
SDR reader requires filenames to match one of a couple different standard
filename schemes used for official products. SDR files are typically named
as below and have corresponding geolocation files::
SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5
Expand Down

0 comments on commit f6b5b4c

Please sign in to comment.