├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ ├── ci.yaml │ └── deploy-sdist.yaml ├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE.txt ├── Makefile ├── NEWS.rst ├── NEWS_GEO2GRID.rst ├── README.rst ├── RELEASING.md ├── awips_scmi ├── Polar │ └── PolarCommonDescription.xml ├── README.txt └── styleRules │ └── goesrCMI-ImageryStyleRules.xml ├── build_environment.yml ├── continuous_integration └── environment.yaml ├── create_conda_software_bundle.sh ├── doc ├── Makefile └── source │ ├── NEWS.rst │ ├── NEWS_GEO2GRID.rst │ ├── _static │ ├── 300px_JPSS_Blue_Logo_WEB.png │ ├── CIMSS_logo_web_multicolor_PNG_1100x800.png │ ├── CSPP_Logo.png │ ├── G2G Logo.psd │ ├── G2G_PDF_Logos.png │ ├── NOAA_logo_256px.png │ ├── P2G Logo.psd │ ├── P2G_PDF_Logos.png │ ├── SSEC_logo_small24.png │ ├── favicon.ico │ └── prettytables.css │ ├── compositors.rst │ ├── conf.py │ ├── custom_config.rst │ ├── custom_grids.rst │ ├── data_access.rst │ ├── design_overview.rst │ ├── dev_guide │ ├── adding_readers.rst │ ├── api │ │ └── .gitkeep │ ├── dev_env.rst │ ├── index.rst │ ├── json_input.rst │ └── swbundle.rst │ ├── doi_role.py │ ├── enhancements.rst │ ├── examples │ ├── abi_example.rst │ ├── abi_l2_example.rst │ ├── acspo_example.rst │ ├── ahi_example.rst │ ├── amsr2_example.rst │ ├── asci_example.rst │ ├── creating_animations_example.rst │ ├── index.rst │ ├── modis_example.rst │ └── viirs_example.rst │ ├── generate_summary_table.py │ ├── getting_started.rst │ ├── grids.rst │ ├── image_processing_techniques.rst │ ├── index.rst │ ├── installation.rst │ ├── introduction.rst │ ├── misc_recipes.rst │ ├── overview.rst │ ├── readers │ ├── abi_l1b.rst │ ├── abi_l2_nc.rst │ ├── acspo.rst │ ├── agri_fy4a_l1.rst │ ├── agri_fy4b_l1.rst │ ├── ahi_hrit.rst │ ├── ahi_hsd.rst │ ├── ami_l1b.rst │ ├── amsr2_l1b.rst │ ├── avhrr.rst │ ├── clavrx.rst │ ├── fci_l1c_nc.rst │ ├── glm_l2.rst │ ├── index.rst │ ├── mersi2_l1b.rst │ ├── mersi_ll_l1b.rst │ ├── mirs.rst │ ├── modis_l1b.rst │ ├── nucaps.rst │ ├── viirs_edr.rst │ ├── viirs_edr_active_fires.rst │ ├── viirs_edr_flood.rst │ ├── viirs_l1b.rst │ └── viirs_sdr.rst │ ├── remapping.rst │ ├── summary_table.rst │ ├── summary_table_geo2grid_readers.rst │ ├── summary_table_geo2grid_writers.rst │ ├── toctree_filter.py │ ├── utilscripts.rst │ ├── verification │ ├── abi_verification.rst │ ├── index.rst │ ├── modis_verification.rst │ └── viirs_verification.rst │ ├── version3_implementation.rst │ ├── viirs_day_night_band.rst │ └── writers │ ├── awips_tiled.rst │ ├── binary.rst │ ├── geotiff.rst │ ├── hdf5.rst │ └── index.rst ├── integration_tests ├── README.rst ├── features │ ├── environment.py │ ├── geo2grid.feature │ ├── polar2grid.feature │ ├── steps │ │ └── compare_images.py │ └── utilities.feature └── run.sh ├── jenkins_environment.yml ├── polar2grid ├── __init__.py ├── __main__.py ├── _glue_argparser.py ├── add_coastlines.py ├── add_colormap.py ├── compare.py ├── composites │ ├── __init__.py │ └── enhanced.py ├── core │ ├── __init__.py │ ├── containers.py │ ├── dtype.py │ └── script_utils.py ├── debug_data.py ├── enhancements │ ├── __init__.py │ ├── shared.py │ └── viirs.py ├── etc │ ├── colormaps │ │ ├── IFR_PROB.cmap │ │ ├── LIFR_PROB.cmap │ │ ├── MVFR_PROB.cmap │ │ ├── abi_l2_modified_cloud_top.cmap │ │ ├── amsr2_36h.cmap │ │ ├── amsr2_89h.cmap │ │ ├── gridded_data.cmap │ │ ├── hsl256_no_black.cmap │ │ ├── p2g_sst_palette.txt │ │ ├── tropix_no_white.cmap │ │ └── viirs_edr_flood_water_detection.cmap │ ├── composites │ │ ├── abi.yaml │ │ ├── ahi.yaml │ │ ├── mersi-2.yaml │ │ ├── modis.yaml │ │ └── viirs.yaml │ ├── enhancements │ │ ├── abi.yaml │ │ ├── agri.yaml │ │ ├── ahi.yaml │ │ ├── ami.yaml │ │ ├── amsr2.yaml │ │ ├── generic.yaml │ │ ├── mersi-2.yaml │ │ ├── modis.yaml │ │ └── viirs.yaml │ ├── pyspectral.yaml │ ├── readers │ │ └── mirs.yaml │ ├── resampling.yaml │ └── writers │ │ ├── awips_tiled.yaml │ │ ├── binary.yaml │ │ └── hdf5.yaml ├── filters │ ├── __init__.py │ ├── _base.py │ ├── _filter_scene.py │ ├── _utils.py │ ├── day_night.py │ └── resample_coverage.py ├── fonts │ ├── Vera.ttf │ └── __init__.py ├── glue.py ├── grids │ ├── __init__.py │ ├── config_helper.py │ ├── grids.yaml │ └── manager.py ├── readers │ ├── __init__.py │ ├── _base.py │ ├── abi_l1b.py │ ├── abi_l2_nc.py │ ├── acspo.py │ ├── agri_fy4a_l1.py │ ├── agri_fy4b_l1.py │ ├── ahi_hrit.py │ ├── ahi_hsd.py │ ├── ami_l1b.py │ ├── amsr2_l1b.py │ ├── amsr2_l2_gaasp.py │ ├── avhrr_l1b_aapp.py │ ├── clavrx.py │ ├── fci_l1c_nc.py │ ├── glm_l2.py │ ├── mersi2_l1b.py │ ├── mersi_ll_l1b.py │ ├── mirs.py │ ├── modis_l1b.py │ ├── modis_l2.py │ ├── nucaps.py │ ├── viirs_edr.py │ ├── viirs_edr_active_fires.py │ ├── viirs_edr_flood.py │ ├── viirs_l1b.py │ ├── viirs_sdr.py │ └── virr_l1b.py ├── resample │ ├── __init__.py │ ├── _resample_scene.py │ └── resample_decisions.py ├── tests │ ├── __init__.py │ ├── _abi_fixtures.py │ ├── _avhrr_fixtures.py │ ├── _fixture_utils.py │ ├── _viirs_fixtures.py │ ├── conftest.py │ ├── etc │ │ ├── colormaps │ │ │ ├── WV_Chile_Short.cmap │ │ │ ├── amsr2_36h.cmap │ │ │ └── reds.cmap │ │ ├── enhancements │ │ │ └── generic.yaml │ │ ├── grids.conf │ │ └── test_p2g_palettize3.npy │ ├── test_add_coastlines.py │ ├── test_add_colormap.py │ ├── test_compare.py │ ├── test_configs.py │ ├── test_dtype.py │ ├── test_enhancements.py │ ├── test_filters │ │ ├── __init__.py │ │ ├── test_day_night.py │ │ └── test_utils.py │ ├── test_glue.py │ ├── test_grids │ │ ├── __init__.py │ │ ├── test_config_helper.py │ │ └── test_manager.py │ ├── test_main.py │ ├── test_readers │ │ ├── __init__.py │ │ └── test_base.py │ ├── test_resample │ │ ├── __init__.py │ │ └── test_resample_scene.py │ ├── test_utils │ │ ├── __init__.py │ │ ├── test_convert_grids_conf.py │ │ └── test_legacy_compat.py │ └── test_writers │ │ ├── __init__.py │ │ ├── test_base.py │ │ ├── test_binary.py │ │ └── test_hdf5.py ├── utils │ ├── __init__.py │ ├── config.py │ ├── convert_grids_conf_to_yaml.py │ ├── create_awips_debug_tiles.py │ ├── dynamic_imports.py │ ├── legacy_compat.py │ └── warnings.py └── writers │ ├── __init__.py │ ├── awips_tiled.py │ ├── binary.py │ ├── cf.py │ ├── geotiff.py │ └── hdf5.py ├── pyproject.toml └── swbundle ├── GEO2GRID_README.txt ├── POLAR2GRID_README.txt ├── add_coastlines.sh ├── add_colormap.sh ├── convert_grids_conf_to_yaml.sh ├── download_pyspectral_data.sh ├── env.sh ├── example_enhancements └── amsr2_png │ └── enhancements │ └── generic.yaml ├── geo2grid.sh ├── geocat2scmi.py ├── grid_configs └── grid_example.yaml ├── gtiff2kmz.sh ├── gtiff2mp4.sh ├── overlay.sh ├── p2g_compare.sh ├── p2g_grid_helper.sh ├── polar2grid.sh ├── polar2grid_env.sh └── reproject_goes.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | *.png filter=lfs diff=lfs merge=lfs -text 2 | *.psd filter=lfs diff=lfs merge=lfs -text 3 | *.jpg filter=lfs diff=lfs merge=lfs -text 4 | *.tif filter=lfs diff=lfs merge=lfs -text 5 | *.mp4 filter=lfs diff=lfs merge=lfs -text 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "monthly" 12 | -------------------------------------------------------------------------------- /.github/workflows/deploy-sdist.yaml: -------------------------------------------------------------------------------- 1 | name: Deploy sdist 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | jobs: 9 | deploysdist: 10 | name: "Deploy sdist" 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout source 15 | uses: actions/checkout@v4 16 | 17 | - name: Create sdist 18 | shell: bash -l {0} 19 | run: | 20 | python -m pip install -U build pip 21 | python -m build 22 | 23 | - name: Publish package to PyPI 24 | # upload to PyPI on every release for a tag starting with 'v' 25 | if: github.event.action == 'published' && startsWith(github.event.release.tag_name, 'v') 26 | uses: pypa/gh-action-pypi-publish@v1.12.4 27 | with: 28 | user: __token__ 29 | password: ${{ secrets.pypi_password }} 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### PYTHON IGNORES ### 2 | *.py[cod] 3 | 4 | # C extensions 5 | *.so 6 | 7 | # Packages 8 | *.egg 9 | *.egg-info 10 | dist 11 | build 12 | eggs 13 | parts 14 | bin 15 | var 16 | sdist 17 | develop-eggs 18 | .installed.cfg 19 | lib 20 | lib64 21 | 22 | # Installer logs 23 | pip-log.txt 24 | 25 | # Unit test / coverage reports 26 | .coverage 27 | .tox 28 | nosetests.xml 29 | 30 | #Translations 31 | *.mo 32 | 33 | #Mr Developer 34 | .mr.developer.cfg 35 | 36 | ### C IGNORES ### 37 | # Object files 38 | *.o 39 | 40 | # Libraries 41 | *.lib 42 | *.a 43 | 44 | # Shared objects (inc. Windows DLLs) 45 | *.dll 46 | *.so 47 | *.so.* 48 | *.dylib 49 | 50 | # Executables 51 | *.exe 52 | *.out 53 | *.app 54 | 55 | # PyCharm configs 56 | .idea 57 | 58 | # Image Editing Tools 59 | *.xcf 60 | 61 | # Example images should not be added to the repository 62 | doc/source/_static/example_images 63 | doc/source/dev_guide/api/*.rst 64 | doc/source/grids_list.rst 65 | 66 | # Polar2Grid Bundles being compared against 67 | polar2grid-swbundle-* 68 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | exclude: '^$' 2 | fail_fast: false 3 | repos: 4 | - repo: https://github.com/astral-sh/ruff-pre-commit 5 | rev: 'v0.11.8' 6 | hooks: 7 | - id: ruff 8 | args: ["--fix"] 9 | - id: ruff-format 10 | - repo: https://github.com/pre-commit/pre-commit-hooks 11 | rev: v5.0.0 12 | hooks: 13 | - id: trailing-whitespace 14 | - id: end-of-file-fixer 15 | - id: check-yaml 16 | args: [--unsafe] 17 | - repo: https://github.com/scop/pre-commit-shfmt 18 | rev: v3.11.0-1 19 | hooks: 20 | - id: shfmt-src # native (requires Go to build) 21 | args: ["-i", "4"] 22 | ci: 23 | # To trigger manually, comment on a pull request with "pre-commit.ci autofix" 24 | autofix_prs: false 25 | autoupdate_schedule: "monthly" 26 | -------------------------------------------------------------------------------- /NEWS_GEO2GRID.rst: -------------------------------------------------------------------------------- 1 | Release Notes 2 | ============= 3 | 4 | Version 1.3.0 (unreleased) 5 | -------------------------- 6 | 7 | * Fix resampling coverage calculations 8 | 9 | Version 1.2.0 (2023-05-10) 10 | -------------------------- 11 | * Preliminary GOES-19 ABI reader support added 12 | * Preliminary EUMETSAT MTG FCI (fci_l1c_nc) reader support added 13 | * Additional ABI Product readers support added: 14 | 15 | * Aerosol Optical Depth (AOD) 16 | * Low Cloud and Fog (FLS) 17 | * Land Surface Temperature (LST) 18 | 19 | * New 3.9 micron band scaling 20 | * Added ABI AOD product example to documenation 21 | * Support for additional RGBs 22 | * Optimizations 23 | * Bug fixes 24 | 25 | Version 1.1.0 (2022-12-12) 26 | -------------------------- 27 | * GOES-18 ABI reader support added 28 | * ABI Level 2 (abi_l2_nc) reader added 29 | * Gridded GLM (glm_l2) reader added 30 | * GEO-KOMPSAT AMI (ami_l1b) reader added 31 | * FY-4A AGRI (agri_fy4a_l1) reader added 32 | * FY-4B AGRI (agri_fy4b_l1) reader added 33 | * Various optimizations 34 | * Support for additional RGBs 35 | * Use of yaml files for grid definitions 36 | * Various bug fixes 37 | 38 | Version 1.0.2 (2020-08-17) 39 | -------------------------- 40 | 41 | * Add workaround for threading issue in pyresample 42 | 43 | Version 1.0.1 (2020-03-18) 44 | -------------------------- 45 | 46 | * Significantly improved performance by enabling multithreaded geotiff compression 47 | * Improve day/night transition region in day/night composites 48 | * Fix resampling freezing when output grid was larger than 1024x1024 49 | * Fix crash when certain RGBs were created with '--ll-bbox' 50 | * Add missing '--radius-of-influence' flag for nearest neighbor resampling 51 | * Add ability to native resample to lower resolution grids 52 | * Add 'goes_east_Xkm' and 'goes_west_Xkm' grids for easier lower resolution resampling 53 | * Add AHI airmass, ash, dust, fog, and night_microphysics RGBs 54 | * Accept PNG or GeoTIFFs with gtiff2mp4.sh video generation 55 | 56 | Version 1.0.0 (2019-03-01) 57 | -------------------------- 58 | 59 | * New Geo2Grid Package! 60 | * ABI L1B (abi_l1b) reader added 61 | * AHI HSD (ahi_hsd) reader added 62 | * AHI HRIT/HimawariCast (ahi_hrit) reader added 63 | * Geotiff (geotiff) writer added 64 | * Multi-threaded (multiple worker) processing 65 | * Sharpened rayleigh-corrected full-resolution true and natural color RGBs 66 | * Command line Lat/Lon defined subsets 67 | * User defined grid capability 68 | * MIN/MAX native resampling possible 69 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | # Releasing the Polar2Grid Python Package 2 | 3 | 1. Update pyproject.toml with the new version. 4 | 2. Create a git tag for the new version: 5 | 6 | ```bash 7 | git tag -a vX.Y.Z -m "Version X.Y.Z" 8 | ``` 9 | 10 | 3. Push the tag to github: 11 | 12 | ```bash 13 | git push --follow-tags 14 | ``` 15 | 16 | 4. Create a GitHub release for this tag with name "Version X.Y.Z" and add 17 | release notes to the description. 18 | 5. The GitHub release will trigger various GitHub jobs to run. Make sure they succeed. 19 | -------------------------------------------------------------------------------- /awips_scmi/Polar/PolarCommonDescription.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /awips_scmi/README.txt: -------------------------------------------------------------------------------- 1 | This directory and it's subdirectories contain configuration files for the 2 | GOES-R netcdf imagery decoder. Each configuration is an xml file that contains 3 | one or more description elements that can be applied to a product. A 4 | description consists of three parts, the match elements, the data elements, 5 | and the descriptive elements. 6 | 7 | The match elements of a description are used to determine if the description 8 | applies to a particular product. It consists of an attribute_name that matches 9 | a global attribute on the netcdf file and a pattern that is a regular 10 | expression matched to the value of that attribute. If all match elements on a 11 | description match attributes in a file then that description will be used to 12 | describe the satellite data in the file. 13 | 14 | A data element is optional in a description, if present there can be only one. 15 | If a data element is specified then it should contain the name of the variable 16 | containing the numeric, gridded data for the satellite image. An 17 | alternative to specifying a variable name within the data element is to specify 18 | a bitset containing multiple variables that will be joined together, one bit per 19 | product. Products containing data in more than 2 directions can include a 20 | verticalDimension attribute which should be the name of the variable describing 21 | the 3rd dimension. 22 | 23 | The descriptive elements are used to specify the physicalElement, 24 | creatingEntity, source, sectorID, satHeight, units, and dataTime of a 25 | SatelliteRecord. Each description can include a constant value, an attribute 26 | name whose value will be stored in the correct attribute, or a format and a 27 | list of attributes whose values will be used within the format. The dataTime 28 | description also requires a date format that will be used to parse a date 29 | from an the specified attribute. 30 | 31 | For netcdf files that contain multiple products a description contaiing a data 32 | element should be created for each product. The descriptive for a description 33 | with a data element will only be applied to products created with the data. Any 34 | description without a data element will be applied to all the satellite records 35 | that are generated from the file. 36 | 37 | The directory structure of this directory is purely for organization, the 38 | decoder does not do anything special with specific files/subdirectories. A 39 | single product can match descriptions in multiple files as easily as multiple 40 | descriptions in a single file. 41 | -------------------------------------------------------------------------------- /awips_scmi/styleRules/goesrCMI-ImageryStyleRules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | i04 9 | i05 10 | m12 11 | m13 12 | m14 13 | m15 14 | m16 15 | 16 | 17 | C 18 | 19 | 55 20 | -110 21 | 22 | Sat/IR/CIRA (IR Default) 23 | 24 | 55 10 -20 -50 -80 25 | 26 | 27 | 28 | 29 | 30 | 31 | dynamic_dnb 32 | adaptive_dnb 33 | histogram_dnb 34 | 35 | 36 | 37 | 0 38 | 1 39 | 40 | Sat/VIS/Linear 41 | 42 | 43 | 44 | 45 | 46 | i01 47 | i02 48 | i03 49 | m01 50 | m02 51 | m03 52 | m04 53 | m05 54 | m06 55 | m07 56 | m08 57 | m09 58 | m10 59 | m11 60 | viirs_crefl01 61 | viirs_crefl03 62 | viirs_crefl04 63 | viirs_crefl08 64 | 65 | 66 | % 67 | 68 | 0 69 | 100 70 | 71 | GOES-R/VIS/VIS_gray_sq-root-12 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /build_environment.yml: -------------------------------------------------------------------------------- 1 | name: jenkins_p2g_swbundle 2 | channels: 3 | - conda-forge 4 | dependencies: 5 | - aggdraw 6 | - appdirs 7 | - cftime 8 | - conda-pack 9 | - configobj 10 | - curl 11 | - dask>=2024.2.1 12 | - distributed>=2022.2.1 13 | - donfig>=0.8.1 14 | - ffmpeg 15 | - fontconfig 16 | - freetype 17 | - gdal 18 | - hdf5plugin 19 | - h5py 20 | - netcdf4 21 | - pillow 22 | - pip 23 | - pooch 24 | - pycoast>=1.7.0 25 | - pydecorate>=0.4.0 26 | - pyhdf 27 | - pykdtree>=1.3.11 28 | - pyorbital>=1.8.2 29 | - pyproj>=3.6.1 30 | - pyresample>=1.28.2 31 | - pyshp>=2.3.1 32 | - pyspectral>=0.13.0 33 | - python=3.11 34 | - python-geotiepoints>=1.7.2 35 | - pyyaml>=6.0.1 36 | - rasterio>=1.3.9 37 | - requests 38 | - setuptools 39 | - trollimage>=1.23.1 40 | - trollsift>=0.5.1 41 | - scipy 42 | - zarr 43 | - xarray>=2024.2.0 44 | - fsspec 45 | - s3fs 46 | - pip: 47 | - git+https://github.com/pytroll/satpy.git 48 | -------------------------------------------------------------------------------- /continuous_integration/environment.yaml: -------------------------------------------------------------------------------- 1 | name: test 2 | channels: 3 | - conda-forge 4 | dependencies: 5 | - aggdraw 6 | - appdirs 7 | - cftime 8 | - configobj 9 | - curl 10 | - dask 11 | - distributed 12 | - ffmpeg 13 | - fontconfig 14 | - freetype 15 | - gdal 16 | - h5py 17 | - matplotlib 18 | - netcdf4 19 | - pillow 20 | - pycoast 21 | - pydecorate 22 | - pyhdf 23 | - pykdtree 24 | - pyorbital 25 | - pyproj 26 | - pyshp 27 | - pyspectral 28 | - python=3.11 29 | - python-geotiepoints 30 | - pyyaml 31 | - rasterio 32 | - requests 33 | - setuptools 34 | - six 35 | - trollimage 36 | - trollsift 37 | - scipy 38 | - zarr 39 | - xarray 40 | - pytest 41 | - pytest-cov 42 | - sphinx 43 | - pip 44 | - python-graphviz 45 | # - sphinx-argparse 46 | - fsspec 47 | - s3fs 48 | - sphinxcontrib-apidoc 49 | - pip: 50 | - pytest-lazy-fixtures 51 | - git+https://github.com/pytroll/satpy.git 52 | - git+https://github.com/pytroll/pyresample.git 53 | - git+https://github.com/djhoese/sphinx-argparse.git@bugfix-section-nums 54 | -------------------------------------------------------------------------------- /doc/source/NEWS.rst: -------------------------------------------------------------------------------- 1 | ../../NEWS.rst -------------------------------------------------------------------------------- /doc/source/NEWS_GEO2GRID.rst: -------------------------------------------------------------------------------- 1 | ../../NEWS_GEO2GRID.rst -------------------------------------------------------------------------------- /doc/source/_static/300px_JPSS_Blue_Logo_WEB.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d0a5b4d06e426284d87ae664745b77f9d0e5725edc0d93ea6c073e3cd1142632 3 | size 134842 4 | -------------------------------------------------------------------------------- /doc/source/_static/CIMSS_logo_web_multicolor_PNG_1100x800.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fa7d9ff780fdb83be58e684e9afc664d0aad00a046ec21395a4656e14827edf8 3 | size 64079 4 | -------------------------------------------------------------------------------- /doc/source/_static/CSPP_Logo.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:69b128d64b866ab1f123c3165f11c594bb9877313f794ccb376ccea48f663013 3 | size 142577 4 | -------------------------------------------------------------------------------- /doc/source/_static/G2G Logo.psd: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c5070e01e344291a4884d2d87754c4b0892a0fadccb54d614234cd7c5fe370a7 3 | size 936667 4 | -------------------------------------------------------------------------------- /doc/source/_static/G2G_PDF_Logos.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:658c4317da264aacb11ad7978d6aeb35150653188d909dca4c8441c00b93357a 3 | size 172110 4 | -------------------------------------------------------------------------------- /doc/source/_static/NOAA_logo_256px.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:deadd21089aafb75baf3144f0920ed013b2f8e237621f5618c0f7a28000fcd8d 3 | size 29857 4 | -------------------------------------------------------------------------------- /doc/source/_static/P2G Logo.psd: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:fe45542d9fab8435e6763546be9e31ae6b7bb9941e2f76dd13bb4126fab06073 3 | size 773172 4 | -------------------------------------------------------------------------------- /doc/source/_static/P2G_PDF_Logos.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f8002f327a2a323e11855313a7180bb10750723d817a8d98dc13555c7554f70f 3 | size 227279 4 | -------------------------------------------------------------------------------- /doc/source/_static/SSEC_logo_small24.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:06a6993581e8858eec85b2b9c28976608207edb302717cbab950b7be3fdac30e 3 | size 20094 4 | -------------------------------------------------------------------------------- /doc/source/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssec/polar2grid/0280a81b1998fd226667619a62097d7dd9678a45/doc/source/_static/favicon.ico -------------------------------------------------------------------------------- /doc/source/_static/prettytables.css: -------------------------------------------------------------------------------- 1 | /* Customization so that all tables have a set width 2 | * 3 | * The default uses colgroup tags with percentages, but it doesn't set a 4 | * definite size for the table so the table's size is an undefined behavior 5 | */ 6 | 7 | table.docutils { 8 | border: 0; 9 | border-collapse: collapse; 10 | width: 85%; 11 | } 12 | 13 | /* above is the default, this is the override to go back to normal width */ 14 | table.full-width-table { 15 | border: 0; 16 | border-collapse: collapse; 17 | width: inherit; 18 | } 19 | -------------------------------------------------------------------------------- /doc/source/data_access.rst: -------------------------------------------------------------------------------- 1 | Data Access 2 | =========== 3 | 4 | Geo2Grid software is designed with the direct broadcast community 5 | in mind as the target end user. However, the software can be used 6 | by anyone to create images from standard mission compliant input 7 | files. NOAA GOES ABI data is now freely available from Cloud 8 | Service Providers (CSPs) including Amazon Web Services (AWS), 9 | Google and Microsoft Azure. More information about accessing 10 | data that is part of NOAA's Open Data Dissemination Program 11 | can be found at this website: 12 | 13 | https://www.noaa.gov/nodd/datasets 14 | 15 | And a very nice interface that allows direct downloads from 16 | the AWS can be found here: 17 | 18 | http://home.chpc.utah.edu/~u0553130/Brian_Blaylock/cgi-bin/goes16_download.cgi 19 | -------------------------------------------------------------------------------- /doc/source/dev_guide/api/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssec/polar2grid/0280a81b1998fd226667619a62097d7dd9678a45/doc/source/dev_guide/api/.gitkeep -------------------------------------------------------------------------------- /doc/source/dev_guide/dev_env.rst: -------------------------------------------------------------------------------- 1 | Development Environment 2 | ======================= 3 | 4 | Before adding components to polar2grid you will need to set up a polar2grid 5 | development environment. This will make it easier to get the newest updates 6 | from other developers and vice versa. Creating a development environment does 7 | not provide the bash wrapper scripts since they depend on a software bundle. 8 | It is recommended that you contact the Polar2Grid team before adding/developing 9 | any new features to coordinate efforts. 10 | 11 | The main code repository for polar2grid can be found on github at 12 | https://github.com/ssec/polar2grid. 13 | Changes to this repository are done through a 14 | `pull request `_ 15 | which will require creating a 16 | `fork `_ of the repository. 17 | 18 | The following instructions will assist in getting an environment up and running 19 | that will allow for easy development of polar2grid. The instructions will use an 20 | existing conda-based Python environment. This isn't strictly required, but is the 21 | easiest way to get going. To avoid possible Terms of Service issues with 22 | Anaconda.org, we recommend using ``miniforge`` or ``mambaforge`` to install 23 | conda on your system. See https://github.com/conda-forge/miniforge#miniforge 24 | for more information. 25 | 26 | 1. Get a copy of the code repository: 27 | 28 | .. code-block:: bash 29 | 30 | mkdir ~/polar2grid 31 | cd ~/polar2grid 32 | git clone https://github.com/ssec/polar2grid.git 33 | cd polar2grid 34 | 35 | 36 | 2. Create a conda environment specifically for Polar2Grid/Geo2Grid work: 37 | 38 | .. code-block:: bash 39 | 40 | conda env create -n p2g_dev --file build_environment.yml 41 | 42 | This script will walk you through a few questions including whether or not to use ShellB3 (linux only), provide 43 | a preinstalled ShellB3, or build and install secondary polar2grid components. 44 | 45 | 3. Active the conda environment and install "polar2grid" in development mode: 46 | 47 | .. code-block:: bash 48 | 49 | conda activate p2g_dev 50 | pip install --no-deps -e . 51 | 52 | 4. Run "polar2grid.sh" or "geo2grid.sh" to run example commands. These scripts 53 | are made available because you installed the python package above. Any 54 | changes made to the source code should be automatically reflected when you 55 | run these scripts. There are also "polar2grid" and "geo2grid" helper 56 | scripts when on non-bash environments. All of these scripts are simple 57 | wrappers around calling `python -m polar2grid.glue ...` which can be used 58 | as an alternative. 59 | -------------------------------------------------------------------------------- /doc/source/dev_guide/index.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | Developer's Guide 4 | ================= 5 | 6 | This guide is intended to ease the development of additional readers, 7 | writers, or other components to the polar2grid package. 8 | 9 | If you would like to contribute to either Polar2Grid or the Pytroll Satpy 10 | package or have any questions about the collaboration please contact the 11 | CSPP/Polar2Grid team. 12 | 13 | Code repository: https://github.com/ssec/polar2grid 14 | 15 | **Developer's Guide Components:** 16 | 17 | .. toctree:: 18 | :maxdepth: 1 19 | 20 | dev_env 21 | swbundle 22 | json_input 23 | adding_readers 24 | Python API 25 | 26 | Prerequisites 27 | ------------- 28 | 29 | These polar2grid topics should be understood to get the most out of this 30 | guide: 31 | 32 | - The general :doc:`design <../design_overview>` of Polar2Grid 33 | - The responsibilities of a reader 34 | - The responsibilities of a writer 35 | - Package hierarchy and dependencies 36 | 37 | A developer should be familiar with these concepts to develop a new component 38 | for polar2grid: 39 | 40 | - python and numpy programming 41 | - remapping/regridding satellite imagery swaths (including types of projections) 42 | - python packaging, specifically `distribute `_ (setuptools) 43 | - git source code management system and the 'forking' and 'pull request' 44 | features of http://github.com 45 | - Xarray and dask programming and how it is used by the Satpy library 46 | -------------------------------------------------------------------------------- /doc/source/dev_guide/swbundle.rst: -------------------------------------------------------------------------------- 1 | Software Bundle 2 | =============== 3 | 4 | Software bundles are the preferred method of distributing polar2grid by 5 | the |ssec|. Software bundles are gzipped tarballs with a binary installation 6 | of polar2grid and all of its dependencies. Software bundles distributed by 7 | the |ssec| are built for RHEL7 x86_64 systems. 8 | 9 | Note that normal development of Polar2Grid and Geo2Grid does not require 10 | building a software bundle. Building the bundle is generally an automated 11 | processing done by CI services running on the development servers. 12 | 13 | Creating a Software Bundle 14 | -------------------------- 15 | 16 | A conda environment with all necessary dependencies must be activated before running the build process. To create 17 | this environment run the following using the "build_environment.yml" file from the git repository:: 18 | 19 | conda env create -n p2g_build -f build_environment.yml 20 | conda activate p2g_build 21 | 22 | To create a software bundle tarball run the software bundle creation script:: 23 | 24 | cd /path/to/repos/polar2grid/ 25 | ./create_conda_software_bundle.sh /path/to/swbundle 26 | -------------------------------------------------------------------------------- /doc/source/doi_role.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """Create sphinx roles for referencing the DOI of a published paper. 3 | 4 | Extension to add links to DOIs. With this extension you can use e.g. 5 | :doi:`10.1016/S0022-2836(05)80360-2` in your documents. This will 6 | create a link to a DOI resolver 7 | (``https://doi.org/10.1016/S0022-2836(05)80360-2``). 8 | The link caption will be the raw DOI. 9 | You can also give an explicit caption, e.g. 10 | :doi:`Basic local alignment search tool <10.1016/S0022-2836(05)80360-2>`. 11 | 12 | :copyright: Copyright 2015 Jon Lund Steffensen. Based on extlinks by 13 | the Sphinx team. 14 | :license: BSD. 15 | 16 | """ 17 | 18 | from docutils import nodes, utils 19 | from sphinx.util.nodes import split_explicit_title 20 | 21 | 22 | def doi_role(typ, rawtext, text, lineno, inliner, options=None, content=None): 23 | text = utils.unescape(text) 24 | has_explicit_title, title, part = split_explicit_title(text) 25 | full_url = "https://doi.org/" + part 26 | if not has_explicit_title: 27 | title = "DOI:" + part 28 | pnode = nodes.reference(title, title, internal=False, refuri=full_url) 29 | return [pnode], [] 30 | 31 | 32 | def arxiv_role(typ, rawtext, text, lineno, inliner, options=None, content=None): 33 | text = utils.unescape(text) 34 | has_explicit_title, title, part = split_explicit_title(text) 35 | full_url = "https://arxiv.org/abs/" + part 36 | if not has_explicit_title: 37 | title = "arXiv:" + part 38 | pnode = nodes.reference(title, title, internal=False, refuri=full_url) 39 | return [pnode], [] 40 | 41 | 42 | def setup_link_role(app): 43 | app.add_role("doi", doi_role, override=True) 44 | app.add_role("DOI", doi_role, override=True) 45 | app.add_role("arXiv", arxiv_role, override=True) 46 | app.add_role("arxiv", arxiv_role, override=True) 47 | 48 | 49 | def setup(app): 50 | app.connect("builder-inited", setup_link_role) 51 | return {"version": "0.1", "parallel_read_safe": True} 52 | -------------------------------------------------------------------------------- /doc/source/enhancements.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | Enhancements 4 | ============ 5 | 6 | Enhancing is the process where data is scaled to prepare the data for 7 | an output image format. These "enhancements" range from basic linear 8 | scaling for the data to fit in the output image format (ex. unsigned 8-bit 9 | integers), but can also scale the data to bring out certain areas of the 10 | data (ex. brighten dark regions of the image). The enhancement step is 11 | typically embedded as part of the writing process. They are configured 12 | in their own YAML configuration files with logical defaults to produce 13 | high quality images. 14 | 15 | Customizing enhancements is considered an advanced feature. You can find more 16 | information on customizing enhancements in the :doc:`custom_config` section. 17 | For more information on what Python enhancement functions are available see 18 | the :doc:`satpy:enhancements` documentation from Satpy. 19 | 20 | There are additionally some |project| specific enhancements that are used 21 | in special cases or for special products. The enhancements that |project| 22 | actually ends up using is dependent on the builtin YAML configuration files 23 | and any customizations made by the user. 24 | 25 | .. currentmodule:: polar2grid.enhancements 26 | 27 | .. autosummary:: 28 | 29 | ~shared.temperature_difference 30 | -------------------------------------------------------------------------------- /doc/source/examples/abi_example.rst: -------------------------------------------------------------------------------- 1 | Working with ABI Files 2 | ---------------------- 3 | 4 | This example walks through the creation of GOES ABI 5 | GeoTIFF subset image files and adding overlays. 6 | 7 | The Basics of Geo2Grid for ABI GeoTIFF File Creation 8 | **************************************************** 9 | 10 | Find the options available when creating GOES-16, -17 and -18 11 | GeoTIFFs: 12 | 13 | ``geo2grid.sh -r abi_l1b -w geotiff -h`` 14 | 15 | List the products that can be created from your ABI dataset: 16 | 17 | ``geo2grid.sh -r abi_l1b -w geotiff --list-products -f `` 18 | 19 | To create GeoTIFF output files of all bands found in your data set, 20 | including true and natural color full resolution sharpened 24 bit 21 | RGBs in standard satellite projection using 8 worker threads: 22 | 23 | ``geo2grid.sh -r abi_l1b -w geotiff --num-workers 8 -f `` 24 | 25 | Create a subset of ABI band output Geotiff image files for Channels 1, 2, 3 and 5: 26 | 27 | ``geo2grid.sh -r abi_l1b -w geotiff -p C01 C02 C03 C05 true_color -f `` 28 | 29 | Create ABI images over the given latitude/longitude region: 30 | 31 | ``geo2grid.sh -r abi_l1b -w geotiff --ll-bbox -f `` 32 | 33 | 34 | Create a natural color full resolution GeoTIFF from GOES-18 ABI 35 | observations acquired on 15 November 2022, 18:30 UTC over a latitude/ 36 | longitude bounding box of 128W,30N to -118W,40N . This command 37 | assumes that all bands required to create the false color image are available: 38 | 39 | .. code-block:: bash 40 | 41 | geo2grid.sh -r abi_l1b -w geotiff -p natural_color --ll-bbox -128 30 -118 40 -f OR_ABI-L1b-RadF-M6C*_G18_s20223191830*.nc 42 | 43 | The resulting image is displayed below. 44 | 45 | .. raw:: latex 46 | 47 | \newpage 48 | 49 | .. figure:: ../_static/example_images/GOES-18_ABI_RadF_natural_color_20221115_183020_GOES-West_cutout.png 50 | :width: 100% 51 | :align: center 52 | 53 | ABI Natural color subset GeoTIFF image (GOES-18_ABI_RadF_natural_color_20221115_183020_GOES-West.tif) 54 | 55 | .. raw:: latex 56 | 57 | \newpage 58 | 59 | Add coastlines, borders and latitude/longitude grid lines to the image, and write the output to the file "my_goes18_abi_naturalcolor.png": 60 | 61 | .. code-block:: bash 62 | 63 | add_coastlines.sh --add-coastlines --add-borders --borders-resolution=h --borders-outline='red' --add-grid GOES-18_ABI_RadF_natural_color_20221115_183020_GOES-West.tif -o my_goes18_abi_naturalcolor.png 64 | 65 | .. figure:: ../_static/example_images/my_goes18_abi_naturalcolor.png 66 | :width: 100% 67 | :align: center 68 | 69 | GOES-18 natural color image with overlays (my_goes18_abi_naturalcolor.png). 70 | 71 | Convert the natural color GeoTIFF file into a Google Earth compatible 72 | Keyhole Markup language Zipped (KMZ) file. 73 | 74 | .. code-block:: bash 75 | 76 | gtiff2kmz.sh GOES-18_ABI_RadF_natural_color_20221115_183020_GOES-West.tif 77 | 78 | which creates the `GOES-18_ABI_RadF_natural_color_20221115_183020_GOES-West.kmz` 79 | file which can then be displayed easily in the Google Earth GeoBrowser. 80 | -------------------------------------------------------------------------------- /doc/source/examples/ahi_example.rst: -------------------------------------------------------------------------------- 1 | Working with AHI Files 2 | ---------------------- 3 | 4 | This example walks through the creation of Himawari AHI 5 | GeoTIFF subset image files and adding overlays. 6 | 7 | The Basics of Geo2Grid for AHI GeoTIFF File Creation 8 | **************************************************** 9 | 10 | Find the options available when creating AHI HSD 11 | GeoTIFFs: 12 | 13 | ``geo2grid.sh -r ahi_hsd -w geotiff -h`` 14 | 15 | List the products that can be created from your AHI HSD dataset: 16 | 17 | ``geo2grid.sh -r ahi_hsd -w geotiff --list-products -f `` 18 | 19 | To create GeoTIFF output files of all bands found in your data set, 20 | including true and natural color full resolution sharpened 24 bit 21 | RGBs in standard satellite projection using 8 worker threads: 22 | 23 | ``geo2grid.sh -r ahi_hsd -w geotiff --num-workers 8 -f `` 24 | 25 | Create a subset of AHI band output Geotiff image files for Bands 1, 2, 3, 4 and 5: 26 | 27 | ``geo2grid.sh -r ahi_hsd -w geotiff -p B01 B02 B03 B04 B05 natural_color -f `` 28 | 29 | Create AHI images over a Lambert Conic Conformal (LCC) grid centered over 30 | Perth, Australia. 31 | 32 | Run the grid helper script to define the grid center, areal extent, spatial 33 | resolution and projection . 34 | 35 | ``p2g_grid_helper.sh perth 117.9 -32.4 500 500 1500 1500`` 36 | 37 | .. code-block:: bash 38 | 39 | perth: 40 | projection: 41 | proj: lcc 42 | lat_1: -32.4 43 | lat_0: -32.4 44 | lon_0: 117.9 45 | datum: WGS84 46 | units: m 47 | no_defs: null 48 | type: crs 49 | shape: 50 | height: 1500 51 | width: 1500 52 | center: 53 | x: 117.9 54 | y: -32.4 55 | units: degrees 56 | resolution: 57 | dx: 500.0 58 | dy: 500.0 59 | 60 | Copy the output grid projection information into a grid configuration 61 | yaml file (my_grid.yaml). Use the grid to create an HSD AHI true color image from 62 | data observed on 12 November 2017, at 23:30 UTC. 63 | 64 | .. code-block:: bash 65 | 66 | geo2grid.sh -r ahi_hsd -w geotiff -p true_color --grid-configs /geo/hsd/my_grid.yaml -g perth --method nearest -f /data/ahi8/hsd/2330/*FLDK*.DAT 67 | 68 | The resulting image is displayed beow. 69 | 70 | .. raw:: latex 71 | 72 | \newpage 73 | 74 | .. figure:: ../_static/example_images/HIMAWARI-8_AHI_true_color_20181112_233020_perth_example.png 75 | :width: 100% 76 | :align: center 77 | 78 | AHI True color GeoTIFF image centered on Perth, Australia (HIMAWARI-8_AHI_true_color_20181112_233020_perth.tif). 79 | 80 | .. raw:: latex 81 | 82 | \newpage 83 | 84 | Add coastlines, borders and latitude/longitude grid lines and rivers to the image. 85 | 86 | .. code-block:: bash 87 | 88 | add_coastlines.sh --add-coastlines --add-rivers --rivers-resolution=h --add-grid HIMAWARI-8_AHI_true_color_20181112_233020_perth.tif 89 | 90 | .. figure:: ../_static/example_images/HIMAWARI-8_AHI_true_color_20181112_233020_perth.png 91 | :width: 100% 92 | :align: center 93 | 94 | Himawari-8 AHI true color image with overlays (HIMAWARI-8_AHI_true_color_20181112_233020_perth.png) 95 | -------------------------------------------------------------------------------- /doc/source/examples/creating_animations_example.rst: -------------------------------------------------------------------------------- 1 | Using Geo2Grid to Create Animations 2 | ----------------------------------- 3 | 4 | The advantage of Geostationary Satellites is the temporal resolution of the 5 | observations. Geo2Grid offers an easy interface for creating animations from 6 | Geo2Grid GeoTIFF and PNG files. The following example demonstrates how 7 | Geo2Grid software can be used to create an animation of 8 | files from a latitude/longitude subset of GOES-16 ABI CONUS GeoTIFF images 9 | located over the Southeastern United States. 10 | 11 | Create a series of GOES-16 ABI GeoTIFF files from a time sequence of data. In 12 | the bash shell script example below, I use the ABI CONUS Band 1 files to 13 | search for all files we have available from 4 January 2019. The files for 14 | this day are all located in the same directory. I then create true and 15 | natural color images from all time periods that are available. 16 | 17 | .. code-block:: bash 18 | 19 | #!/bin/bash 20 | 21 | # Set GEO2GRID environment variables 22 | 23 | export GEO2GRID_HOME=/home/g2g/geo2grid_v_1_2 24 | export PATH=$PATH:$GEO2GRID_HOME/bin 25 | 26 | # Get input list of files/times based upon ABI Band 1 files 27 | 28 | ls -1 /data/abi16/20190104/OR_ABI-L1b-RadC-M3C01_G16_s2019004*.nc > file_list.txt 29 | 30 | sort_list=$(cat file_list.txt | sort) 31 | 32 | # Make images for each time period available 33 | for file in ${sort_list} ; do 34 | 35 | echo ${file} 36 | # get date/time for geo2grid file search 37 | datetime=`basename $file | cut -c27-38` 38 | echo "datetime :"$datetime 39 | 40 | # Cut out a box with lat/lon bounds of 23N, 105W to 37N 75W 41 | geo2grid.sh -r abi_l1b -w geotiff --ll-bbox -105 23 -75 37 --num-workers 8 -p true_color natural_color -f /data/abi16/20190104/*${datetime}*.nc 42 | 43 | done 44 | 45 | exit 0 46 | 47 | This script created 120 GeoTIFF images for my time period 10:00 UTC through 20:00 UTC, 48 | with a time step of every 5 minutes. 49 | 50 | To create a 120 image animation, I use the Geo2Grid utility script 51 | ``gtiff2mp4.sh``. 52 | 53 | .. code-block:: bash 54 | 55 | gtiff2mp4.sh my_true_color_animation.mp4 *true_color*.tif 56 | 57 | The script wraps the ``ffmpeg`` video software, and combines all of the 58 | ``*true_color*.tif`` files found in the directory into an animation 59 | based upon defaults that make the output animations most compatible 60 | with modern video players. The output frame rate is 24 frames per 61 | second. The images will automatically be resized if they are 62 | large in order to ensure a smooth animation. I chose an output 63 | filename of ``my_true_color_animation.mp4``. The software can also 64 | create animations from input ``.png`` files. 65 | 66 | The figure below is the last image in the 120 loop sequence. The 67 | output MP4 animation is available for viewing at `this site `_. 68 | 69 | .. figure:: ../_static/example_images/GOES-16_ABI_RadC_true_color_20190104_195718_GOES-East.png 70 | :width: 100% 71 | :align: center 72 | 73 | The last GOES-16 ABI image from the 120 frame loop created with data from 4 January 2019. The image observations are from 19:57 UTC. 74 | -------------------------------------------------------------------------------- /doc/source/examples/index.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | .. toctree-filt:: 5 | :maxdepth: 1 6 | 7 | :polar2grid:viirs_example 8 | :polar2grid:modis_example 9 | :polar2grid:acspo_example 10 | :polar2grid:asci_example 11 | :polar2grid:amsr2_example 12 | :geo2grid:abi_example 13 | :geo2grid:abi_l2_example 14 | :geo2grid:ahi_example 15 | :geo2grid:creating_animations_example 16 | -------------------------------------------------------------------------------- /doc/source/examples/modis_example.rst: -------------------------------------------------------------------------------- 1 | .. raw:: latex 2 | 3 | \newpage 4 | 5 | Creating MODIS AWIPS Compatible Files 6 | ------------------------------------- 7 | 8 | This example walks through the creation of MODIS 9 | NetCDF files for display in AWIPS. 10 | 11 | Basic MODIS Level 1B AWIPS compatible file creation 12 | *************************************************** 13 | 14 | Find the options available when creating MODIS AWIPS files: 15 | 16 | ``polar2grid.sh -r modis -w awips_tiled -h`` 17 | 18 | List the products that can be created from your MODIS L1B dataset. For 19 | the new Sectorized Cloud and Moisture Imagery (SCMI) AWIPS writer, include 20 | the sector name (see Section 6.1.3) either Lambert Conformal Conic (LCC), 21 | Pacific, Mercator, or Polar: 22 | 23 | ``polar2grid.sh -r modis -w awips_tiled --sector-id LCC --list-products -f `` 24 | 25 | Follow the command below to create MODIS AWIPS NetCDF files of all 26 | Level 1B products found in your data set for your sector. When 27 | using the ``awips_tiled`` scmi server, it is advised that a specific grid be chosen, and 28 | that the ``--letters`` and ``--compress`` options are used. 29 | In our LCC example, we will use the 1km grid: 30 | 31 | ``polar2grid.sh -r modis -w awips_tiled --sector-id LCC --letters --compress -g lcc_conus_1km -f `` 32 | 33 | Create a subset of MODIS reprojected AWIPS products for a specfic AWIPS grid: 34 | 35 | .. code-block:: bash 36 | 37 | polar2grid.sh -r modis -w awips_tiled -p bt27 vis02 --sector-id LCC --letters --compress -g lcc_conus_1km -f 38 | 39 | 40 | .. figure:: ../_static/example_images/modis_vis02_example.png 41 | :width: 100% 42 | :align: center 43 | 44 | AWIPS display of Aqua MODIS Band 2 (.86 micron) reflectances from 20:52 UTC, 16 October 2022. 45 | 46 | 47 | Create true color and false color Aqua MODIS AWIPS NetCDF files from the 1000m, 500m, 250m and geolocation pass files acquired on 16 October 2022 at 20:52 UTC, reprojected onto the LCC 300m lettered grid. 48 | 49 | .. code-block:: bash 50 | 51 | polar2grid.sh -r modis -w awips_tiled --awips-true-color --awips-false-color --sector-id LCC --letters --compress -g lcc_conus_300 -f l1b/a1.22289.2052.1000m.hdf l1b/a1.22289.2052.250m.hdf l1b/a1.22289.2052.500m.hdf l1b/a1.22289.2052.geo.hdf 52 | 53 | .. figure:: ../_static/example_images/modis_true_color_example.png 54 | :width: 100% 55 | :align: center 56 | 57 | AWIPS display of Polar2Grid MODIS corrected reflectances combined to create a 24 bit true color image. Data was collected from a Aqua MODIS pass at 20:52 UTC, 16 October 2022. 58 | -------------------------------------------------------------------------------- /doc/source/examples/viirs_example.rst: -------------------------------------------------------------------------------- 1 | Creating VIIRS SDR GeoTIFF Files 2 | -------------------------------- 3 | 4 | This example walks through the creation of VIIRS 5 | GeoTIFF output files and adding overlays. 6 | 7 | Basic VIIRS SDR GeoTIFF file creation 8 | ************************************* 9 | 10 | Find the options available when creating VIIRS SDR GeoTIFFs: 11 | 12 | polar2grid.sh -r viirs_sdr -w geotiff -h 13 | 14 | List the supported products that can be created from your VIIRS SDR dataset: 15 | 16 | .. code-block:: bash 17 | 18 | polar2grid.sh -r viirs_sdr -w geotiff --list-products -f 19 | 20 | This will provide a list of standard products that can be created 21 | from the files that are provided to polar2grid.sh. 22 | 23 | To create VIIRS GeoTIFF files of all default products (including true 24 | and false color) found in your data set 25 | and reprojected in default Platte Carrée projection using the default 26 | 4 workers, execute the following command: 27 | 28 | polar2grid.sh -r viirs_sdr -w geotiff -f 29 | 30 | Create a subset of VIIRS I- and M-Band reprojected GeoTIFFs using 8 workers: 31 | 32 | .. code-block:: bash 33 | 34 | polar2grid.sh -r viirs_sdr -w geotiff -p i01 i05 m09 m14 --num-workers 8 -f 35 | 36 | Create only true color and false color GeoTIFFs with a black background (no alpha channel): 37 | 38 | .. code-block:: bash 39 | 40 | polar2grid.sh -r viirs_sdr -w geotiff -p true_color false_color --fill-value 0 -f 41 | 42 | Create a true color image from a S-NPP VIIRS pass acquired on 43 | 19 September 2022, 17:53 UTC, in a US Centric Lambert Conformal Conic 44 | (LCC) projection: 45 | 46 | .. code-block:: bash 47 | 48 | polar2grid.sh -r viirs_sdr -w geotiff -p true_color -g lcc_fit -f /data/viirs_sdr 49 | 50 | .. raw:: latex 51 | 52 | \newpage 53 | 54 | .. figure:: ../_static/example_images/noaa20_viirs_true_color_20220919_175331_lcc_fit.jpg 55 | :width: 80% 56 | :align: center 57 | :class: with-border 58 | 59 | VIIRS True color image in Lambert Conformal Conic (LCC) projection (noaa20_viirs_true_color_20220919_175331_lcc_fit.tif). 60 | 61 | .. raw:: latex 62 | 63 | \newpage 64 | 65 | Add coastlines, borders and latitude/longitude grid lines to the true color image, and write the output to the file "myfile.png". 66 | 67 | .. code-block:: bash 68 | 69 | add_coastlines.sh --add-coastlines --add-borders --borders-resolution=h --borders-outline='red' --add-grid noaa20_viirs_true_color_20220919_175331_lcc_fit.tif -o myfile.png 70 | 71 | .. figure:: ../_static/example_images/noaa20_viirs_true_color_20220919_175331_lcc_fit_overlay.png 72 | :width: 80% 73 | :align: center 74 | 75 | VIIRS True color image with overlays (myfile.png). 76 | 77 | Convert the true color GeoTIFF file into a Google Earth compatible Keyhole Markup language Zipped (KMZ) file. 78 | 79 | .. code-block:: bash 80 | 81 | gtiff2kmz.sh noaa20_viirs_true_color_20220919_175331_lcc_fit.tif 82 | 83 | which creates the `noaa20_viirs_true_color_20220919_175331_lcc_fit.kmz` 84 | file. When displayed in Google Earth this image appears as: 85 | 86 | .. raw:: latex 87 | 88 | \newpage 89 | 90 | .. figure:: ../_static/example_images/noaa20_viirs_true_color_20220919_175331_lcc_fit_in_google_earth.jpg 91 | :width: 100% 92 | :align: center 93 | 94 | VIIRS True color KMZ image displayed in the Google Earth Geobrowser. 95 | 96 | .. raw:: latex 97 | 98 | \newpage 99 | -------------------------------------------------------------------------------- /doc/source/grids.rst: -------------------------------------------------------------------------------- 1 | Grids 2 | ===== 3 | 4 | |project| allows users to remap to one or more projected grids. A grid 5 | defines the uniform geographic area that an output image covers. |project| 6 | comes with various grids to choose from that should suit most users and their 7 | use cases. Some grids are provided for specific writers (like Tiled AWIPS), but 8 | can be used for other writers as well. Users can also specify their own 9 | custom grids. See the :doc:`custom_grids` documentation for help with this. 10 | 11 | Provided Grids 12 | -------------- 13 | 14 | Below are descriptions for a few of the grids provided with |project|. 15 | For information on all of the grids provided by |project| see the 16 | `Grids Configuration YAML File 17 | `_. 18 | 19 | The grids' projections are defined using PROJ.4. Go to 20 | the `PROJ documentation `_ 21 | for more information on what each projection parameter means. 22 | 23 | .. note:: 24 | 25 | If the grid does not have a parameter specified it will be derived from the 26 | data during remapping. This allows for grids that fit to the data (dynamic 27 | grids). 28 | 29 | .. include:: grids_list.rst 30 | -------------------------------------------------------------------------------- /doc/source/index.rst: -------------------------------------------------------------------------------- 1 | |project| 2 | ========= 3 | 4 | .. include:: overview.rst 5 | 6 | .. toctree-filt:: 7 | :maxdepth: 1 8 | :numbered: 9 | 10 | introduction 11 | installation 12 | getting_started 13 | readers/index 14 | :geo2grid:compositors 15 | remapping 16 | writers/index 17 | utilscripts 18 | verification/index 19 | examples/index 20 | :geo2grid:data_access 21 | grids 22 | custom_grids 23 | image_processing_techniques 24 | 25 | .. toctree-filt:: 26 | :caption: Additional Details 27 | :maxdepth: 1 28 | :numbered: 29 | :excludebuilder: latex 30 | 31 | dev_guide/index 32 | :polar2grid:NEWS 33 | :geo2grid:NEWS_GEO2GRID 34 | enhancements 35 | :polar2grid:viirs_day_night_band 36 | :polar2grid:version3_implementation 37 | custom_config 38 | 39 | .. toctree-filt:: 40 | :hidden: 41 | :excludebuilder: latex 42 | 43 | design_overview 44 | :polar2grid:misc_recipes 45 | -------------------------------------------------------------------------------- /doc/source/misc_recipes.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | Third-Party Recipes 4 | =================== 5 | 6 | Third-party tools like those provided by 7 | the Geospatial Data Abstraction Library (GDAL) can be 8 | found in the ``libexec/python_runtime/bin`` directory alongside the Python 9 | executable used by |project|. 10 | 11 | Combining GeoTIFF Images 12 | ------------------------ 13 | 14 | When working with polar orbiter satellite data, it is often 15 | useful to stitch images of neighboring passes together. 16 | The GDAL merge tool can do this easily using |project| 17 | GeoTIFF output files. 18 | 19 | Suppose we have two VIIRS GeoTIFF files created from 20 | two sequential Suomi NPP overpasses. The GeoTIFF 21 | files we use in this example are 22 | false color images from data acquired at 20:43 and 23 | 22:22 UTC on 23 March 2017 created in a 24 | WGS84 projection. The individual images are 25 | displayed side by side below. 26 | 27 | .. raw:: latex 28 | 29 | \newpage 30 | \begin{landscape} 31 | 32 | .. figure:: _static/example_images/VIIRS_False_Color_Side_by_Side_Example_P2G.png 33 | :width: 100% 34 | :align: center 35 | 36 | Suomi-NPP VIIRS False Color Images from two separate passes 37 | (Red:VIIRS M-Band 11 (2.25 μm), Green:VIIRS M-Band 7 (.87 μm) 38 | and Blue:VIIRS M-Band 5 (.67μm)) observed on 23 March 2017. 39 | 40 | .. raw:: latex 41 | 42 | \end{landscape} 43 | \newpage 44 | 45 | To combine these images into a single output GeoTIFF image 46 | I can use the `gdal_merge.py` command that is packaged as 47 | part of |project|: 48 | 49 | .. code-block:: bash 50 | 51 | gdal_merge.py -n 0 -o my_false_color.tif npp_viirs_false_color_20170323_204320_wgs84_fit.tif npp_viirs_false_color_20170323_222255_wgs84_fit.tif 52 | 53 | The `-n 0` is used to set the background data value so 54 | it will not be included in the merge. This is required 55 | because without it, the black regions that border 56 | the second WGS84 GeoTIFF will be overlaid on top of the first 57 | image. 58 | 59 | The resulting image is displayed below. 60 | 61 | .. figure:: _static/example_images/my_false_color.jpg 62 | :width: 100% 63 | :align: center 64 | 65 | Merged S-NPP VIIRS False Color Images created from a pair 66 | of images acquired and processed from two different orbits. 67 | 68 | More than one image can be combined. There are more options 69 | available to `gdal_merge.py`. Execute 70 | 71 | .. code-block:: bash 72 | 73 | gdal_merge.py -h 74 | 75 | for a complete list of options. 76 | -------------------------------------------------------------------------------- /doc/source/overview.rst: -------------------------------------------------------------------------------- 1 | 2 | .. ifconfig:: not is_geo2grid 3 | 4 | |project| is a set of command line tools for extracting data 5 | from earth-observing satellite instrument files, 6 | remapping it to uniform grids if needed, and writing that 7 | gridded data to a new file format. It provides an easy way 8 | to create high quality projected images. |project| was 9 | created by scientists and software developers at the 10 | `SSEC `_. It is distributed as 11 | part of the `CSPP LEO `_ 12 | project for processing of data received via direct broadcast 13 | antennas. Although |project| was created to serve the direct 14 | broadcast community, it can be used on most archived data files. 15 | 16 | .. ifconfig:: is_geo2grid 17 | 18 | |project| is a set of command line tools for extracting data 19 | from earth-observing satellite instrument files, 20 | remapping it to uniform grids if needed, and writing that 21 | gridded data to a new file format. It provides an easy way 22 | to create high quality projected images. |project| was 23 | created by scientists and software developers at the 24 | `SSEC `_. It is distributed as 25 | part of the `CSPP Geo `_ 26 | project for processing of data received via direct broadcast 27 | antennas. Although |project| was created to serve the direct 28 | broadcast community, it can be used on most archived data files. 29 | 30 | The features provided by |project| are accessible via bash scripts and binary 31 | command line tools. This is meant to give scientists an easy way to use and 32 | access features that typically involve complicated programming interfaces. 33 | Linux terminal commands included in these instructions assume the bash shell 34 | is used. 35 | 36 | .. ifconfig:: is_geo2grid 37 | 38 | .. only:: not html 39 | 40 | `Documentation Website `__ 41 | 42 | `GitHub Repository `__ 43 | 44 | `CSPP Geo2Grid Forum `_ 45 | 46 | .. ifconfig:: not is_geo2grid 47 | 48 | .. only:: not html 49 | 50 | `Documentation Website `__ 51 | 52 | `Contact Us `__ 53 | 54 | `GitHub Repository `__ 55 | 56 | `CSPP LEO Forum `_ 57 | -------------------------------------------------------------------------------- /doc/source/readers/abi_l2_nc.rst: -------------------------------------------------------------------------------- 1 | ABI L2 NetCDF Reader 2 | ==================== 3 | 4 | .. automodule:: polar2grid.readers.abi_l2_nc 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.abi_l2_nc 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r abi_l2_nc -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r abi_l2_nc -h 21 | 22 | geo2grid.sh -r abi_l2_nc -w geotiff --list-products -f abi/full_disk/CG_ABI-L2-ACHAF-M6_G17_*.nc 23 | 24 | geo2grid.sh -r abi_l2_nc -w geotiff -p TEMP -f CG_ABI-L2-ACHTF-M6_G17_s20223271830316_e20223271839394_c20223271842100.nc 25 | 26 | geo2grid.sh -r abi_l2_nc -w geotiff -p MVFR_Fog_Prob LIFR_Fog_Prob IFR_Fog_Prob -f ABI-L2-GFLSF-M6_v3r1_g16_s202404231820204_e202404231829524_c202404231836180.nc 27 | 28 | geo2grid.sh -r abi_l2_nc -w geotiff -f /data/conus/CG_ABI-L2-*-M6_G18_s20241141826172*.nc 29 | 30 | geo2grid.sh -r abi_l2_nc -w geotiff -p AOD LST -f /abi/meso1/CG_ABI-L2-AODM1-M6_G18_s2024114182*.nc CG_ABI-L2-LSTM1-M6_G18_s2024114182*.nc 31 | -------------------------------------------------------------------------------- /doc/source/readers/acspo.rst: -------------------------------------------------------------------------------- 1 | ACSPO SST Reader 2 | ================ 3 | 4 | .. automodule:: polar2grid.readers.acspo 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.acspo 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r acspo -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | polar2grid.sh -r aspo -w geotiff -h 21 | 22 | polar2grid.sh -r acspo -w geotiff --list-products -f /noaa20/20220526060927-CSPP-L2P_GHRSST-SSTskin-VIIRS_N20-ACSPO_V2.80-v02.0-fv01.0.nc 23 | 24 | polar2grid.sh -r acspo -w geotiff --grid-coverage=0.0 -f /aqua/20220524205044-CSPP-L2P_GHRSST-SSTskin-MODIS_A-ACSPO_V2.80-v02.0-fv01.0.nc 25 | 26 | mpolar2grid.sh -r acspo -w hdf5 -p sst sea_ice_fraction --compress gzip --add-geolocation -g lcc_fit --grid-coverage=.02 -f /metopc/20220803024121-CSPP-L2P_GHRSST-SSTskin-AVHRRF_MC*.nc 27 | 28 | polar2grid.sh -r acspo -w awips_tiled --num-workers 4 --grid-coverage 0 -g lcc_conus_750 --sector-id LCC --letters --compress -f 20220526060927-CSPP-L2P_GHRSST-SSTskin-VIIRS_N20*.nc 29 | 30 | polar2grid.sh -r acspo -w awips_tiled -g merc_pacific_300 --sector-id Pacific --letters --compress -f *CSPP-L2P_GHRSST-SSTskin-VIIRS_NPP-ACSPO*.nc 31 | -------------------------------------------------------------------------------- /doc/source/readers/agri_fy4a_l1.rst: -------------------------------------------------------------------------------- 1 | AGRI FY-4A L1 Reader 2 | ==================== 3 | 4 | .. automodule:: polar2grid.readers.agri_fy4a_l1 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.agri_fy4a_l1 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r agri_fy4a_l1 -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r agri_fy4a_l1 -h 21 | 22 | geo2grid.sh -r agri_fy4a_l1 -w geotiff --list-products -f /data/fy4a/agri 23 | 24 | geo2grid.sh -r agri_fy4a_l1 -w geotiff --num-workers 8 -f /data/fy4a/agri 25 | 26 | geo2grid.sh -r agri_fy4a_l1 -w geotiff -p C02 C03 C08 C10 C12 -f FY4A-_AGRI--*.HDF 27 | 28 | geo2grid.sh -r agri_fy4a_l1 -w geotiff --ll-bbox 100 20 120 40 -p true_color -f /data/*.HDF 29 | -------------------------------------------------------------------------------- /doc/source/readers/agri_fy4b_l1.rst: -------------------------------------------------------------------------------- 1 | AGRI FY-4B L1 Reader 2 | ==================== 3 | 4 | .. automodule:: polar2grid.readers.agri_fy4b_l1 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.agri_fy4b_l1 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r agri_fy4b_l1 -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r agri_fy4b_l1 -h 21 | 22 | geo2grid.sh -r agri_fy4b_l1 -w geotiff --list-products -f /data/fy4b/agri 23 | 24 | geo2grid.sh -r agri_fy4b_l1 -w geotiff --num-workers 8 -f /data/fy4b/agri 25 | 26 | geo2grid.sh -r agri_fy4b_l1 -w geotiff -p C02 C03 C08 C10 C12 -f FY4B-_AGRI--*.HDF 27 | 28 | geo2grid.sh -r agri_fy4b_l1 -w geotiff --ll-bbox 100 20 120 40 -p true_color -f /data/*.HDF 29 | -------------------------------------------------------------------------------- /doc/source/readers/ahi_hrit.rst: -------------------------------------------------------------------------------- 1 | AHI HimawariCast (HRIT) Reader 2 | ============================== 3 | 4 | .. automodule:: polar2grid.readers.ahi_hrit 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.ahi_hrit 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r ahi_hrit -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r ahi_hrit -h 21 | 22 | geo2grid.sh -r ahi_hrit -w geotiff --list-products -f /ahi8/hcast/2330 23 | 24 | geo2grid.sh -r ahi_hrit -w geotiff -f /ahi8/hcast/IMG_DK01IR4_201811122330 25 | 26 | geo2grid.sh -r ahi_hrit -w geotiff -p B03 B04 B05 B06 B16 natural_color --num-workers 8 -f /hrit/ahi/ 27 | 28 | geo2grid.sh -r ahi_hrit -w geotiff --ll-bbox 125 -15 160 10 -f /data/IMG_DK01* 29 | -------------------------------------------------------------------------------- /doc/source/readers/ahi_hsd.rst: -------------------------------------------------------------------------------- 1 | AHI Himawari Standard Data (HSD) Reader 2 | ======================================= 3 | 4 | .. automodule:: polar2grid.readers.ahi_hsd 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.ahi_hsd 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r ahi_hsd -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r ahi_hsd -h 21 | 22 | geo2grid.sh -r ahi_hsd -w geotiff --list-products -f /ahi8/data/ 23 | 24 | geo2grid.sh -r ahi_hsd -w geotiff -f HS_H08_20181112_2330_B01_R301_R10_S0101.DAT 25 | 26 | geo2grid.sh -r ahi_hsd -w geotiff -p B02 B03 B04 B05 B06 true_color --num-workers 8 -f /data/hsd/2330/*FLDK*.DAT 27 | 28 | geo2grid.sh -r ahi_hsd -w geotiff -p B09 B10 B11 B12 B13 natural_color -f /ahi8/HS_H08_20181112_2330_*R303*.DAT 29 | 30 | geo2grid.sh -r ahi_hsd -w geotiff --ll-bbox 125 -15 160 10 -f /data/hsd/*FLDK*.DAT 31 | 32 | geo2grid.sh -r ahi_hsd -w geotiff -p true_color natural_color --num-workers 4 \ 33 | --grid-configs=/geo/my_grid.conf -g perth --method nearest -f /data/hsd/*FLDK*.DAT 34 | -------------------------------------------------------------------------------- /doc/source/readers/ami_l1b.rst: -------------------------------------------------------------------------------- 1 | AMI L1B Reader 2 | ============== 3 | 4 | .. automodule:: polar2grid.readers.ami_l1b 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.ami_l1b 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r ami_l1b -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r ami_l1b -h 21 | 22 | geo2grid.sh -r ami_l1b -w geotiff --list-products -f /data/gk2a/ami 23 | 24 | geo2grid.sh -r ami_l1b -w geotiff --num-workers 8 -f /data/gk2a/ami 25 | 26 | geo2grid.sh -r ami_l1b -w geotiff -p VI005 VI006 VI008 NR013 NR016 true_color -f gk2a_ami*.nc 27 | 28 | geo2grid.sh -r ami_l1b -w geotiff --ll-bbox 125 -15 160 10 -f /ami_data 29 | -------------------------------------------------------------------------------- /doc/source/readers/amsr2_l1b.rst: -------------------------------------------------------------------------------- 1 | AMSR2 L1B Reader 2 | ================ 3 | 4 | .. automodule:: polar2grid.readers.amsr2_l1b 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.amsr2_l1b 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r amsr2_l1b -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | polar2grid.sh -r amsr2_l1b -w geotiff --list-products-all -f ../data/*L1DLBTBR*.h5 21 | 22 | polar2grid.sh -r amsr2_l1b -w geotiff -f / 23 | 24 | polar2grid.sh -r amsr2_l1b -w geotiff -g lcc_fit --fill-value 0 -f ../data/GW1AM2_202209121053_051D_L1DLBTBR_1110110.h5 25 | 26 | polar2grid.sh -r amsr2_l1b -w geotiff --extra-config-path $POLAR2GRID_HOME/example_enhancements/amsr2_png --fill-value 0 -f ../gcom_data/ 27 | 28 | polar2grid.sh -r amsr2_l1b -w awips_tiled --list-products -f /amsr2/GW1AM2_202209120729_019D_L1DLBTBR_2220220.h5 29 | 30 | polar2grid.sh -r amsr2_l1b -w awips_tiled -g lcc_conus_1km -p btemp_36.5h btemp_89.0av --sector-id LCC --letters --compress -f GW1AM2_201607191903_137A_L1DLBTBR_1110110.h5 31 | -------------------------------------------------------------------------------- /doc/source/readers/avhrr.rst: -------------------------------------------------------------------------------- 1 | AVHRR Reader 2 | ============ 3 | 4 | .. automodule:: polar2grid.readers.avhrr_l1b_aapp 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.avhrr_l1b_aapp 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r avhrr_l1b_aapp -w 14 | :passparser: 15 | 16 | Execution Examples 17 | ----------------------- 18 | 19 | .. code-block:: bash 20 | 21 | polar2grid.sh -r avhrr_l1b_aapp -w awips_tiled --list-products -f /l1b/ 22 | 23 | polar2grid.sh -r avhrr_l1b_aapp -w geotiff -f ../input/hrpt_noaa19_20220917_1236_70145.l1b 24 | 25 | polar2grid.sh -r avhrr -w geotiff -p band3a_vis band4_bt -f /data/hrpt_M03*.l1b 26 | 27 | polar2grid.sh -r avhrr -w awips_tiled -p band3b_bt -g lcc_conus_1km --sector-id LCC --letters --compress -f hrpt_noaa18_20220918_1708_89324.l1b 28 | 29 | polar2grid.sh -r avhrr_l1b_aapp -w awips_tiled --num-workers 6 --grid-coverage .002 -g polar_alaska_1km --sector-id Polar --letters --compress -f /avhrr 30 | 31 | polar2grid.sh -r avhrr -w hdf5 --add-geolocation --grid-configs /home/avhrr/grids/local_grid.yaml -g my_grid -f ../input/hrpt_M01*.l1b 32 | 33 | polar2grid.sh -r avhrr -w binary --num-workers 8 -p band1_vis band4_bt -g lcc_eu -f /data/avhrr/metoba 34 | -------------------------------------------------------------------------------- /doc/source/readers/clavrx.rst: -------------------------------------------------------------------------------- 1 | CLAVR-x Cloud Product Reader 2 | ============================ 3 | 4 | .. automodule:: polar2grid.readers.clavrx 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.clavrx 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r clavrx -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | polar2grid.sh -r clavrx -w geotiff -h 21 | 22 | polar2grid.sh -r clavrx -w awips_tiled --sector-id LCC --list-products -f clavrx_npp_d20220902_t0742031_e0756141_b56210.level2.hdf 23 | 24 | polar2grid.sh -r clavrx -w geotiff -p cld_height_acha cloud_phase cloud_type -f noaa20/clavrx_j01*.hdf 25 | 26 | polar2grid.sh -r clavrx -w hdf5 --grid-coverage 0.002 -p cld_opd_nlcomp cld_reff_nlcomp refl_lunar_dnb_nom -f snpp/night/clavrx_npp*.hdf 27 | 28 | polar2grid.sh -r clavrx -w binary -f clavrx_a1.22245.0759.1000m.level2.hdf 29 | 30 | polar2grid.sh -r clavrx -w awips_tiled --num-workers 6 -g lcc_conus_300 --sector-id LCC --letters --compress --grid-coverage 0.002 -p cld_temp_acha cld_height_acha cloud_phase cld_opd_dcomp -f noaa19/clavrx_hrpt_noaa19_*.hdf 31 | -------------------------------------------------------------------------------- /doc/source/readers/fci_l1c_nc.rst: -------------------------------------------------------------------------------- 1 | FCI L1c NetCDF Reader 2 | ===================== 3 | 4 | .. automodule:: polar2grid.readers.fci_l1c_nc 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.fci_l1c_nc 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r fci_l1c_nc -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r fci_l1c_nc -h 21 | 22 | geo2grid.sh -r fci_l1c_nc -w geotiff --list-products -f /data/mtg/fci 23 | 24 | geo2grid.sh -r fci_l1c_nc -w geotiff --num-workers 8 -f /data/mtg/fci 25 | 26 | geo2grid.sh -r fci_l1c_nc -w geotiff -p vis_04 vis_05 vis_06 vis_08 nir_13 nir_16 true_color -f *_N_JLS_C_0072*.nc 27 | 28 | geo2grid.sh -r fci_l1c_nc -w geotiff --ll-bbox 10 -15 40 10 -f /fci_data 29 | -------------------------------------------------------------------------------- /doc/source/readers/glm_l2.rst: -------------------------------------------------------------------------------- 1 | GLM L2 Reader 2 | ============= 3 | 4 | .. automodule:: polar2grid.readers.glm_l2 5 | :noindex: 6 | 7 | Command Line Usage 8 | ------------------ 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.glm_l2 12 | :func: add_reader_argument_groups 13 | :prog: geo2grid.sh -r glm_l2 -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | geo2grid.sh -r glm_l2 -h 21 | 22 | geo2grid.sh -r glm_l2 -w geotiff --list-products -f /data/goes16/glm 23 | 24 | geo2grid.sh -r glm_l2 -w geotiff --num-workers 8 -f /data/goes16/glm 25 | 26 | geo2grid.sh -r glm_l2 -w geotiff -p flash_extent_density minimum_flash_area -f OR_GLM-L2-GLMC*.nc 27 | 28 | geo2grid.sh -r glm_l2 -w geotiff --ll-bbox -175 -2 -155 18 -f CG_GLM-L2-GLMF-M3_G18*.nc 29 | 30 | geo2grid.sh -r glm_l2 -w geotiff -p average_flash_area total_energy --num-workers 4 --grid-configs=/home/g2g/my_grid.conf -g madison --method nearest -f /data/goes16/glm 31 | -------------------------------------------------------------------------------- /doc/source/readers/index.rst: -------------------------------------------------------------------------------- 1 | Readers 2 | ======= 3 | 4 | Readers are the first component used in |project| processing. Their main 5 | responsibility is to extract input satellite imager data and the associated 6 | metadata from user provided input files. 7 | The data that readers distribute to other |project| components are called 8 | "products" ("datasets" in SatPy terminology). 9 | 10 | The number and type of products that can be created is dependent upon 11 | the input datasets that are provided. Composites, such as RGBs, require a 12 | specific set of band combinations to be present. All products that 13 | can be created for a given input dataset can be determined by 14 | using the ``--list-products`` option. 15 | 16 | .. toctree-filt:: 17 | :maxdepth: 1 18 | 19 | :polar2grid:viirs_sdr 20 | :polar2grid:viirs_l1b 21 | :polar2grid:modis_l1b 22 | :polar2grid:avhrr 23 | :polar2grid:amsr2_l1b 24 | :polar2grid:nucaps 25 | :polar2grid:mirs 26 | :polar2grid:acspo 27 | :polar2grid:clavrx 28 | :polar2grid:viirs_edr_active_fires 29 | :polar2grid:viirs_edr 30 | :polar2grid:mersi2_l1b 31 | :polar2grid:mersi_ll_l1b 32 | :geo2grid:abi_l1b 33 | :geo2grid:abi_l2_nc 34 | :geo2grid:agri_fy4a_l1 35 | :geo2grid:agri_fy4b_l1 36 | :geo2grid:ahi_hsd 37 | :geo2grid:ahi_hrit 38 | :geo2grid:ami_l1b 39 | :geo2grid:glm_l2 40 | :geo2grid:fci_l1c_nc 41 | -------------------------------------------------------------------------------- /doc/source/readers/mersi2_l1b.rst: -------------------------------------------------------------------------------- 1 | MERSI-2 L1B Reader 2 | ================== 3 | 4 | .. automodule:: polar2grid.readers.mersi2_l1b 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.mersi2_l1b 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r mersi2_l1b -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | $POLAR2GRID_HOME/bin/polar2grid.sh -r mersi2_l1b -w geotiff -h 21 | 22 | polar2grid.sh -r mersi2_l1b -w geotiff --list-products -f tf2019259173245.FY3D-X_MERSI*.HDF 23 | 24 | polar2grid.sh -r mersi2_l1b -w geotiff -p 1 2 3 4 6 7 20 25 -f tf2019233172521.FY3D-X_MERSI_0250M_L1B.HDF tf2019233172521.FY3D-X_MERSI_1000M_L1B.HDF tf2019233172521.FY3D-X_MERSI_GEOQK_L1B.HDF tf2019233172521.FY3D-X_MERSI_GEO1K_L1B.HDF 25 | 26 | polar2grid.sh -r mersi2_l1b -w geotiff -p true_color false_color -g lcc_fit -f ../mersi/tf2019259173245.FY3D-X_MERSI*.HDF 27 | 28 | polar2grid.sh -r mersi2_l1b -w hdf5 -p 20 21 22 23 24 25 --grid-configs ${HOME}/my_grid.yaml -g shanghai seoul -f ../data/*.HDF 29 | 30 | polar2grid.sh -r mersi2_l1b -w binary --sza-threshold=90 -p 1 2 3 4 6 7 20 25 -f tf2019226095418.FY3D-X_MERSI_*.HDF 31 | -------------------------------------------------------------------------------- /doc/source/readers/mersi_ll_l1b.rst: -------------------------------------------------------------------------------- 1 | MERSI-LL L1B Reader 2 | =================== 3 | 4 | .. automodule:: polar2grid.readers.mersi_ll_l1b 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.mersi_ll_l1b 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r mersi_ll_l1b -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | $POLAR2GRID_HOME/bin/polar2grid.sh -r mersi_ll_l1b -w geotiff -h 21 | 22 | polar2grid.sh -r mersi_ll_l1b -w geotiff --list-products -f tf2019259173245.FY3E-X_MERSI*.HDF 23 | 24 | polar2grid.sh -r mersi_ll_l1b -w geotiff -p 1 2 3 4 6 7 -f tf2019233172521.FY3E-X_MERSI_0250M_L1B.HDF tf2019233172521.FY3E-X_MERSI_1000M_L1B.HDF tf2019233172521.FY3E-X_MERSI_GEOQK_L1B.HDF tf2019233172521.FY3E-X_MERSI_GEO1K_L1B.HDF 25 | 26 | polar2grid.sh -r mersi_ll_l1b -w geotiff -p 1 2 -g lcc_fit -f ../mersi/tf2019259173245.FY3E-X_MERSI*.HDF 27 | 28 | polar2grid.sh -r mersi_ll_l1b -w hdf5 -p 3 4 5 --grid-configs ${HOME}/my_grid.yaml -g shanghai seoul -f ../data/*.HDF 29 | 30 | polar2grid.sh -r mersi_ll_l1b -w binary --sza-threshold=90 -p 1 -f tf2019226095418.FY3E-X_MERSI_*.HDF 31 | -------------------------------------------------------------------------------- /doc/source/readers/mirs.rst: -------------------------------------------------------------------------------- 1 | MIRS Reader 2 | =========== 3 | 4 | .. automodule:: polar2grid.readers.mirs 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.mirs 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r mirs -w 14 | :passparser: 15 | 16 | Execution Examples 17 | ----------------------- 18 | 19 | .. raw:: latex 20 | 21 | \begin{minipage}{\linewidth} 22 | 23 | .. code-block:: bash 24 | 25 | polar2grid.sh -r mirs -w geotiff --list-products -f /atms/NPR-MIRS-IMG_v11r8_n20_s202208250741413_e202208250753249_c202208250817490.nc 26 | 27 | polar2grid.sh -r mirs -w geotiff --list-products-all -f /atms/NPR-MIRS-IMG_v11r8_npp_s202208250653413_e202208250704529_c202208250730310.nc 28 | 29 | polar2grid.sh -r mirs -w geotiff -p btemp_88v btemp_183h3 swe -g lcc_fit -f /atms/ 30 | 31 | polar2grid.sh -r mirs -w awips_tiled --num-workers 4 --grid-coverage 0 -g merc_pacific_1km --sector-id Pacific --letters --compress -p swe tpw sea_ice rain_rate btemp_89v1 -f /noaa19/NPR-MIRS-IMG_v11r8_n19_s202208250310331_e202208250314143_c202208251718490.nc 32 | 33 | polar2grid.sh -r mirs -w awips_tiled --bt-channels -g lcc_conus_750 --sector-id LCC --letters --compress -f ../input/NPR-MIRS-IMG_v11r1_NPP_s201611111032500_e201611111044016_c201611111121100.nc 34 | 35 | polar2grid.sh -r mirs -w hdf5 --add-geolocation --dtype float32 -f ../metopc/NPR-MIRS-IMG_v11r8_ma3_s202208251542209_e202208251554261_c202208251742030.nc 36 | 37 | .. raw:: latex 38 | 39 | \end{minipage} 40 | -------------------------------------------------------------------------------- /doc/source/readers/nucaps.rst: -------------------------------------------------------------------------------- 1 | NUCAPS Reader 2 | ============= 3 | 4 | .. automodule:: polar2grid.readers.nucaps 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.nucaps 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r nucaps -w 14 | :passparser: 15 | -------------------------------------------------------------------------------- /doc/source/readers/viirs_edr.rst: -------------------------------------------------------------------------------- 1 | VIIRS EDR Reader 2 | ================ 3 | 4 | .. automodule:: polar2grid.readers.viirs_edr 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.viirs_edr 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r viirs_edr -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | polar2grid.sh -r viirs_edr -w geotiff -f / 21 | 22 | polar2grid.sh -r viirs_edr -w geotiff -h 23 | 24 | polar2grid.sh -r viirs_edr -w geotiff --list-products -f ../edr/*.nc 25 | 26 | polar2grid.sh -r viirs_edr -w geotiff -p true_color_surf false_color_surf --num-workers 8 -f ../edr/edr/SurfRefl*.nc 27 | 28 | polar2grid.sh -r viirs_edr -w hdf5 --add-geolocation --dtype float32 -p NDVI EVI --maximum-weight-mode -f SurfRefl*.nc 29 | 30 | polar2grid.sh -r viirs_edr -w awips_tiled -p AOD550 CldTopHght CldTopTemp -g lcc_conus_300 --sector-id LCC --letters --compress -f /viirs/JRR-AOD_v3r0_j01_s202406051854471_e202406051856116_c202406052204237.nc /viirs/JRR-CloudHeight_v3r0_j01_s202406051854471_e202406051856116_c202406052204237.nc 31 | -------------------------------------------------------------------------------- /doc/source/readers/viirs_edr_active_fires.rst: -------------------------------------------------------------------------------- 1 | VIIRS EDR Active Fires Reader 2 | ============================= 3 | 4 | .. automodule:: polar2grid.readers.viirs_edr_active_fires 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.viirs_edr_active_fires 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r viirs_edr_active_fires -w 14 | :passparser: 15 | 16 | Some output GeoTIFF fire products are color enhanced: 17 | 18 | AFIMG 19 | 20 | confidence_cat - Low (Yellow), Nominal (Orange), High (Red) 21 | 22 | power - 1 - 250 and above (MW) Yellow->Red 23 | 24 | AFMOD 25 | 26 | confidence_pct - 1-100% Yellow->Red 27 | 28 | power - 1 - 250 and above (MW) Yellow->Red 29 | 30 | Examples: 31 | 32 | .. code-block:: bash 33 | 34 | $POLAR2GRID_HOME/bin/polar2grid.sh -r viirs_edr_active_fires -w geotiff -h 35 | 36 | polar2grid.sh -r viirs_edr_active_fires -w geotiff --list-products -f ../active_fire_edr/AFIMG*.nc 37 | 38 | polar2grid.sh -r viirs_edr_active_fires -w geotiff --list-products -f ../active_fire_edr/AFMOD*.nc 39 | 40 | polar2grid.sh -r viirs_edr_active_fires -w geotiff -p confidence_cat T4 img_edr/AFIMG*.nc 41 | 42 | polar2grid.sh -r viirs_edr_active_fires -w geotiff -g lcc_aus -p confidence_pct T13 -f AFMOD_j01_d20191120_t1513353_e1514581_b10389_c20191121192444396115_cspp_dev.nc 43 | 44 | **NOTE:** The active fire images can be overlaid onto another GeoTIFF. 45 | See :ref:`util_script_fireoverlay` for instructions. 46 | -------------------------------------------------------------------------------- /doc/source/readers/viirs_edr_flood.rst: -------------------------------------------------------------------------------- 1 | VIIRS EDR Flood Reader 2 | ====================== 3 | 4 | .. automodule:: polar2grid.readers.viirs_edr_flood 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.viirs_edr_flood 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r viirs_edr_flood -w 14 | :passparser: 15 | 16 | The end product GeoTIFF file is color enhanced using the color map 17 | described in the CSPP VIIRS Flood Detection Software Version 1.1 and 18 | shown below. 19 | 20 | .. figure:: ../_static/example_images/Flood_Legend.png 21 | :width: 30% 22 | :align: center 23 | 24 | Please note that since the CSPP VIIRS Flood Detection Product is 25 | a gridded product that has already been reprojected 26 | (cylindrical equidistant), it requires more time to reproject the 27 | data onto any other grid. It is recommended that if users want 28 | to re-grid the output Flood HDF4 product, that they choose small 29 | sections of data. 30 | 31 | Examples: 32 | 33 | .. code-block:: bash 34 | 35 | $POLAR2GRID_HOME/bin/polar2grid.sh -r viirs_edr_flood -w geotiff -h 36 | 37 | polar2grid.sh -r viirs_edr_flood -w geotiff -g lcc_fit -f 38 | -------------------------------------------------------------------------------- /doc/source/readers/viirs_l1b.rst: -------------------------------------------------------------------------------- 1 | VIIRS L1B Reader 2 | ================ 3 | 4 | .. automodule:: polar2grid.readers.viirs_l1b 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.readers.viirs_l1b 12 | :func: add_reader_argument_groups 13 | :prog: polar2grid.sh -r viirs_l1b -w 14 | :passparser: 15 | 16 | Examples: 17 | 18 | .. code-block:: bash 19 | 20 | $POLAR2GRID_HOME/bin/polar2grid.sh -r viirs_l1b -w geotiff -h 21 | 22 | polar2grid.sh -r viirs_l1b -w geotiff --list-products -f ../data/*.nc 23 | 24 | polar2grid.sh -r viirs_l1b -w geotiff -p m01 -f /l1b/VJ102MOD.A2022257.1748.001.2022258055009.nc l1b/VJ103MOD.A2022257.1748.001.2022258054957.nc 25 | 26 | polar2grid.sh -r viirs_l1b -w hdf5 -g lcc_fit --add-geolocation -p i01 i02 -f VNP02IMG.A2022257.1842*.nc VNP03MOD.A2022257.1842*.nc 27 | 28 | polar2grid.sh -r viirs_l1b -w geotiff -p true_color false_color -f VNP02*.A2022257.1842*.nc VNP03*.A2022257.1842*.nc 29 | -------------------------------------------------------------------------------- /doc/source/summary_table.rst: -------------------------------------------------------------------------------- 1 | .. File auto-generated by ``generate_summary_table.py`` 2 | 3 | .. tabularcolumns:: |L|L|L|l|l| 4 | 5 | .. list-table:: Reader/Writer Summary Table (**NOTE: This is Not a Complete List Available Readers**) 6 | :header-rows: 1 7 | 8 | * - **Input Source** 9 | - **Input Filename Pattern** 10 | - **Output Type** 11 | - **Reader Name** 12 | - **Writer Name** 13 | * - **Suomi-NPP VIIRS Sensor Data Records** 14 | - SVI01_npp_*.h5 15 | GITCO_npp_*.h5 16 | - 8-bit single band GeoTIFF 17 | - viirs_sdr 18 | - geotiff 19 | * - " 20 | - " 21 | - AWIPS NetCDF 22 | - viirs_sdr 23 | - awips_tiled 24 | * - " 25 | - " 26 | - HDF5 27 | - viirs_sdr 28 | - hdf5 29 | * - " 30 | - " 31 | - Binary 32 | - viirs_sdr 33 | - binary 34 | * - " 35 | - " 36 | - 24-bit true and false color GeoTIFF 37 | - viirs_sdr 38 | - geotiff 39 | * - **Aqua and Terra MODIS Level 1b (IMAPP or NASA archive files)** 40 | - MOD021KM*.hdf 41 | MOD03*.hdf 42 | 43 | or 44 | 45 | t1.*1000m.hdf 46 | t1.*.geo.hdf 47 | - 8 bit single band GeoTIFF 48 | - modis_l1b 49 | - geotiff 50 | * - " 51 | - " 52 | - AWIPS NetCDF 53 | - modis_l1b 54 | - awips_tiled 55 | * - " 56 | - " 57 | - HDF5 58 | - modis_l1b 59 | - hdf5 60 | * - " 61 | - " 62 | - Binary 63 | - modis_l1b 64 | - binary 65 | * - " 66 | - " 67 | - 24-bit true and false color GeoTIFF 68 | - modis_l1b 69 | - geotiff 70 | * - **NOAA-18, NOAA-19,Metop-A,-B,-C AVHRR AAPP Level 1b** 71 | - hrpt_noaa18_*.l1b 72 | - 8 bit single band GeoTIFF 73 | - avhrr_l1b 74 | - geotiff 75 | * - " 76 | - " 77 | - AWIPS NetCDF 78 | - avhrr_l1b 79 | - awips_tiled 80 | * - " 81 | - " 82 | - HDF5 83 | - avhrr_l1b 84 | - hdf5 85 | * - " 86 | - " 87 | - Binary 88 | - avhrr_l1b 89 | - binary 90 | * - **GCOM-W1 ASMR2 L1B** 91 | - GW1AM2\*L1DLBTBR\*.h5 92 | - 8 bit single band GeoTIFF 93 | - amsr2_l1b 94 | - geotiff 95 | * - " 96 | - " 97 | - AWIPS NetCDF 98 | - amsr2_l1b 99 | - awips_tiled 100 | * - " 101 | - " 102 | - HDF5 103 | - amsr2_l1b 104 | - hdf5 105 | * - " 106 | - " 107 | - Binary 108 | - amsr2_l1b 109 | - binary 110 | * - **CLAVR-x Cloud Retrievals** 111 | - clavrx*.hdf 112 | - 8 bit single band GeoTIFF 113 | - clavrx 114 | - geotiff 115 | * - " 116 | - " 117 | - AWIPS NetCDF 118 | - clavrx 119 | - awips_tiled 120 | * - " 121 | - " 122 | - HDF5 123 | - clavrx 124 | - hdf5 125 | * - " 126 | - " 127 | - Binary 128 | - clavrx 129 | - binary 130 | * - **ACSPO Sea Surface Temperatures** 131 | - \*-STAR-L2P_GHRSST-SSTskin-\*.nc 132 | - 8 bit single band GeoTIFF 133 | - acspo 134 | - geotiff 135 | * - " 136 | - " 137 | - AWIPS NetCDF 138 | - acspo 139 | - awips_tiled 140 | * - " 141 | - " 142 | - HDF5 143 | - acspo 144 | - hdf5 145 | * - " 146 | - " 147 | - Binary 148 | - acspo 149 | - binary 150 | -------------------------------------------------------------------------------- /doc/source/summary_table_geo2grid_readers.rst: -------------------------------------------------------------------------------- 1 | .. File auto-generated by ``generate_summary_table.py`` 2 | 3 | .. tabularcolumns:: |p{2cm}|p{3cm}|p{15cm}| 4 | 5 | .. list-table:: Geo2Grid Reader Summary Table 6 | :header-rows: 1 7 | 8 | * - **Reader Name** 9 | - **Input Source** 10 | - **Input Filename Pattern** 11 | * - abi_l1b 12 | - ABI L1B 13 | - ``OR_ABI-L1b-Rad?-M?C??_G??_s -w awips_tiled 16 | :passparser: 17 | 18 | .. raw:: latex 19 | 20 | \newpage 21 | 22 | Lettered Sectors 23 | ---------------- 24 | 25 | .. figure:: ../_static/example_images/scmi_grid_LCC.png 26 | :width: 100% 27 | :align: center 28 | 29 | `"LCC" Sector Lettered Grid `_ 30 | 31 | .. figure:: ../_static/example_images/scmi_grid_Pacific.png 32 | :width: 100% 33 | :align: center 34 | 35 | `"Pacific" Sector Lettered Grid `_ 36 | 37 | .. figure:: ../_static/example_images/scmi_grid_Mercator.png 38 | :width: 100% 39 | :align: center 40 | 41 | `"Mercator" Sector Lettered Grid `_ 42 | 43 | .. figure:: ../_static/example_images/scmi_grid_Polar.png 44 | :width: 100% 45 | :align: center 46 | 47 | `"Polar" Sector Lettered Grid `_ 48 | 49 | .. raw:: latex 50 | 51 | \newpage 52 | 53 | Examples: 54 | 55 | .. ifconfig:: not is_geo2grid 56 | 57 | .. code-block:: bash 58 | 59 | polar2grid.sh -r viirs_sdr -w awips_tiled --awips-true-color --awips-false-color --num-workers 8 -g lcc_conus_300 --sector-id LCC --letters --compress -f viirs/*.h5 60 | 61 | polar2grid.sh -r modis_l1b -w awips_tiled -p vis01 bt31 -g lcc_conus_1km --sector-id LCC --letters --compress -f a1.22261.1857.250m.hdf a1.22261.1857.1000m.hdf a1.22261.1857.geo.hdf 62 | 63 | polar2grid.sh -r amsr2_l1b -w awips_tiled --num-workers 4 -grid-coverage 0.002 -g polar_alaska_1km --sector-id Polar --letters --compress -f $data_dir/GW1AM2_202209102335_181A_L1DLBTBR_1110110.h5 64 | 65 | polar2grid.sh -r amsr2_l1b -w awips_tiled --grid-coverage 0 -g merc_pacific_1km --sector-id Pacific --letters --compress -f GW1AM2_202209120018_188A_L1DLBTBR_1110110.h5 66 | 67 | polar2grid.sh -r viirs_edr -w awips_tiled -p AOD -g lcc_conus_300 --sector-id LCC --letters --compress --grid-coverage 0.002 -f JRR-AOD_*.nc 68 | 69 | polar2grid.sh -r viirs_edr -w awips_tiled -p NDVI -g lcc_conus_300 --sector-id LCC --letters --compress --grid-coverage 0.002 --maximum-weight-mode -f SurfRefl*.nc 70 | 71 | polar2grid.sh -r acspo -w awips_tiled --num-workers 8 --grid-coverage 0 -g lcc_conus_750 --sector-id LCC --letters --compress --method ewa --weight-delta-max 40.0 --weight-distance-max 1.0 -f $data_dir/202*VIIRS_NPP-ACSPO_V2.80*.nc 72 | 73 | 74 | .. ifconfig:: is_geo2grid 75 | 76 | .. code-block:: bash 77 | 78 | geo2grid.sh -r abi_l1b -w awips_tiled --letters --compress --sector-id GOES_EAST -f /path/to/files*.nc 79 | -------------------------------------------------------------------------------- /doc/source/writers/binary.rst: -------------------------------------------------------------------------------- 1 | Binary Writer 2 | ============= 3 | 4 | .. automodule:: polar2grid.writers.binary 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.writers.binary 12 | :func: add_writer_argument_groups 13 | :prog: polar2grid.sh -r -w binary 14 | :passparser: 15 | -------------------------------------------------------------------------------- /doc/source/writers/geotiff.rst: -------------------------------------------------------------------------------- 1 | GeoTIFF Writer 2 | ============== 3 | 4 | .. automodule:: polar2grid.writers.geotiff 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.writers.geotiff 12 | :func: add_writer_argument_groups 13 | :prog: |script| -r -w geotiff 14 | :passparser: 15 | :nodefaultconst: 16 | -------------------------------------------------------------------------------- /doc/source/writers/hdf5.rst: -------------------------------------------------------------------------------- 1 | HDF5 Writer 2 | =========== 3 | 4 | .. automodule:: polar2grid.writers.hdf5 5 | :noindex: 6 | 7 | Command Line Arguments 8 | ---------------------- 9 | 10 | .. argparse:: 11 | :module: polar2grid.writers.hdf5 12 | :func: add_writer_argument_groups 13 | :prog: polar2grid.sh -r -w hdf5 14 | :passparser: 15 | -------------------------------------------------------------------------------- /doc/source/writers/index.rst: -------------------------------------------------------------------------------- 1 | Writers 2 | ======= 3 | 4 | Writers are the final step in the |project| processing chain. They take 5 | gridded data, scale it to fit in an output format, and write the data to 6 | one or more output files. These files can then be provided to a visualization 7 | tool that is optimized for viewing the data. 8 | 9 | .. toctree-filt:: 10 | :maxdepth: 1 11 | 12 | :polar2grid:awips_tiled 13 | :polar2grid:binary 14 | :polar2grid:geotiff 15 | :polar2grid:hdf5 16 | :geo2grid:geotiff 17 | -------------------------------------------------------------------------------- /integration_tests/README.rst: -------------------------------------------------------------------------------- 1 | How to run the tests in your own environment 2 | ============================================ 3 | 4 | Navigate to your Polar2Grid directory, then run:: 5 | 6 | conda env update -n jenkins_p2g_docs -f build_environment.yml 7 | conda env update -n jenkins_p2g_docs -f jenkins_environment.yml 8 | conda activate jenkins_p2g_docs 9 | pip install . 10 | conda env update -n jenkins_p2g_swbundle -f build_environment.yml 11 | conda activate jenkins_p2g_swbundle 12 | # Creates a folder with the necessary scripts to run the tests. 13 | ./create_conda_software_bundle.sh polar2grid-`date +%Y%m%d-%H%M%S` 14 | conda activate jenkins_p2g_docs 15 | export POLAR2GRID_HOME=polar2grid-`date +%Y%m%d-%H%M%S` 16 | cd integration_tests 17 | # Runs the tests. 18 | behave --no-logcapture --no-capture --no-color -D datapath=/path/to/test/data 19 | 20 | To run a specific test, add the argument ``--name TESTNAME`` when running behave. The test names can be 21 | found in the feature files (for example: ``--name VIIRS_L1B`` would skip all tests except VIIRS_L1B). 22 | 23 | How to add tests 24 | ================ 25 | Tests are found under ``integration_tests/features/``. There are two test files, ``geo2grid.feature`` and 26 | ``polar2grid.feature``. Each is composed hierarchically in this way: A ``Feature`` which contains a 27 | name and description, a ``Scenario Outline`` which details how the tests are ran, and finally ``Examples`` 28 | with each containing a name and the specifics to pass into ``Scenario Outline`` (command, source, output). 29 | `command` should be the full shell command that you want to run with the `-f` flag last. source and output are 30 | directories containing input and expected output files respectively. To add a test, simply add another line to 31 | an existing ``Examples`` block or make a new ``Examples`` block following the format that is already there. 32 | For more information please see the official behave documentation: 33 | https://behave.readthedocs.io/en/latest/tutorial.html 34 | 35 | How Jenkins runs the tests 36 | ========================== 37 | 38 | Jenkins runs a script that follows similar steps as above. The script can be found in ``integration_tests/run.sh``. 39 | 40 | Jenkins home is on bumi.ssec.wisc.edu using port 8080, and data can be found in bumi:/data/test_data 41 | 42 | How to upgrade the version of Python used by Jenkins 43 | ==================================================== 44 | 45 | Jenkins and the released software bundle are based on two conda 46 | environments: ``jenkins_p2g_docs`` and ``jenkins_p2g_docs``. Both 47 | of these environments currently live in: 48 | ``/var/lib/jenkins/mambaforge/envs/``. In order to upgrade the version of 49 | Python that the software bundle will use we must upgrade these environments. 50 | However, a simple ``conda update`` rarely works with an update of Python 51 | itself. To work around this we must delete the environments. 52 | 53 | 1. Update the version of python in the ``build_environment.yml`` file in the 54 | root of this repository. 55 | 2. Login to ``bumi`` and switch to the root account (``sudo -iu root``). 56 | 3. Run ``sudo -u jenkins /var/lib/jenkins/mambaforge/bin/conda update -n base conda`` 57 | to update conda itself. 58 | 4. Run ``sudo -u jenkins /var/lib/jenkins/mambaforge/bin/conda env remove -n jenkins_p2g_docs``. 59 | 5. Run ``sudo -u jenkins /var/lib/jenkins/mambaforge/bin/conda env remove -n jenkins_p2g_swbundle``. 60 | 6. Rerun the CI jobs from the Jenkins web UI. 61 | -------------------------------------------------------------------------------- /integration_tests/features/environment.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Configure behave tests.""" 24 | 25 | import os 26 | import shutil 27 | import sys 28 | import tempfile 29 | 30 | 31 | def before_all(context): 32 | context.html_dst = context.config.userdata.get("html_dst", None) 33 | if context.html_dst is not None: 34 | context.html_dst = os.path.join(context.html_dst, "test_status") 35 | context.datapath = context.config.userdata["datapath"] 36 | if not context.datapath.startswith(os.sep): 37 | context.datapath = os.path.join(os.getcwd(), context.datapath) 38 | os.environ["DATA_PATH"] = context.datapath # for test command replacement 39 | p2g_home = os.environ.get("POLAR2GRID_HOME") 40 | # if POLAR2GRID_HOME isn't defined, assume things are installed in the python prefix 41 | context.p2g_path = os.path.join(p2g_home, "bin") if p2g_home is not None else os.path.join(sys.prefix, "bin") 42 | if p2g_home is None: 43 | # assume development/editable install 44 | import polar2grid 45 | 46 | os.environ["POLAR2GRID_HOME"] = os.path.join(os.path.dirname(polar2grid.__file__), "..", "swbundle") 47 | 48 | 49 | def before_feature(context, feature): 50 | tmpdir = tempfile.gettempdir() 51 | feature_name = os.path.basename(feature.filename).replace("<", "").replace(">", "").replace(".feature", "") 52 | context.base_temp_dir = os.path.join(tmpdir, "p2g_integration_tests", feature_name) 53 | 54 | # remove any previous test results 55 | if os.path.isdir(context.base_temp_dir): 56 | shutil.rmtree(context.base_temp_dir, ignore_errors=True) 57 | os.makedirs(context.base_temp_dir, exist_ok=True) 58 | 59 | 60 | def after_all(context): 61 | pass 62 | -------------------------------------------------------------------------------- /integration_tests/features/geo2grid.feature: -------------------------------------------------------------------------------- 1 | Feature: Test geo2grid output images 2 | This takes test data from source and runs it through the command provided. 3 | It then compares the new image with the expected output. 4 | 5 | Scenario Outline: Test geo2grid images 6 | Given input data from 7 | Given an empty working directory 8 | When runs 9 | Then the output matches with the files in 10 | 11 | Examples: ABI 12 | | command | source | output | 13 | | geo2grid.sh -r abi_l1b -w geotiff --num-workers 8 -vv -f | abi/input/test1 | abi/output/test1 | 14 | | geo2grid.sh -r abi_l1b -w geotiff --num-workers 8 -vv -f | abi/input/test2 | abi/output/test2 | 15 | | geo2grid.sh -r abi_l1b -w geotiff --num-workers 8 -vv -f | abi/input/test3 | abi/output/test3 | 16 | | geo2grid.sh -r abi_l1b -w geotiff --num-workers 8 -vv -f | abi/input/test4 | abi/output/test4 | 17 | 18 | Scenario Outline: Test list products output 19 | Given input data from 20 | Given an empty working directory 21 | When runs with --list-products 22 | Then the printed output includes the products in 23 | 24 | Examples: ABI List Products 25 | | command | source | output | 26 | | geo2grid.sh -r abi_l1b -w geotiff -vv -f | abi/input/test1 | true_color,C01,natural_color | 27 | -------------------------------------------------------------------------------- /integration_tests/features/utilities.feature: -------------------------------------------------------------------------------- 1 | Feature: Test polar2grid utility scripts 2 | This takes test data from source and runs it through the command provided. 3 | It then compares the new image with the expected output. 4 | 5 | Scenario Outline: Test add_colormap.sh 6 | Given input data from 7 | Given an empty working directory 8 | Given input data is copied to the working directory 9 | When runs 10 | Then the output matches with the files in 11 | 12 | Examples: AMSR2_L1B 13 | | command | source | output | 14 | | add_colormap.sh ${POLAR2GRID_HOME}/colormaps/amsr2_89h.cmap | add_colormap/input/test1 | add_colormap/output/test1 | 15 | 16 | Examples: ACSPO 17 | | command | source | output | 18 | | add_colormap.sh ${POLAR2GRID_HOME}/colormaps/p2g_sst_palette.txt | add_colormap/input/test2 | add_colormap/output/test2 | 19 | 20 | Scenario Outline: Test add_coastlines.sh 21 | Given input data from 22 | Given an empty working directory 23 | Given input data is copied to the working directory 24 | When runs 25 | Then the output matches with the files in 26 | 27 | Examples: ACSPO 28 | | command | source | output | 29 | | add_coastlines.sh --add-colorbar --colorbar-text-color="white" --colorbar-units="K" --colorbar-align top --colorbar-title="VIIRS ACSPO SST" --colorbar-text-size 20 --colorbar-height=35 --add-coastlines --add-borders -- | add_coastlines/input/test1 | add_coastlines/output/test1 | 30 | 31 | Scenario Outline: Test gtiff2kmz.sh 32 | Given input data from 33 | Given an empty working directory 34 | Given input data is copied to the working directory 35 | When runs 36 | Then the same filenames as in were produced 37 | 38 | Examples: gtiff2kmz 39 | | command | source | output | 40 | | gtiff2kmz.sh | gtiff2kmz/input/test1 | gtiff2kmz/output/test1 | 41 | -------------------------------------------------------------------------------- /jenkins_environment.yml: -------------------------------------------------------------------------------- 1 | name: jenkins_p2g_docs 2 | channels: 3 | - conda-forge 4 | dependencies: 5 | - behave 6 | - graphviz 7 | - pip 8 | - sphinx>=8.2.2 9 | - pytest 10 | - matplotlib 11 | - pip: 12 | - pytest-lazy-fixtures 13 | - graphviz 14 | # - sphinx-argparse 15 | - git+https://github.com/djhoese/sphinx-argparse.git@bugfix-section-nums 16 | -------------------------------------------------------------------------------- /polar2grid/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese December 2014 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | """Polar2Grid main package.""" 31 | -------------------------------------------------------------------------------- /polar2grid/__main__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese January 2021 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | """Simple wrapper around the Polar2Grid and Geo2Grid glue scripts.""" 31 | 32 | import os 33 | import sys 34 | 35 | 36 | def p2g_main(argv=sys.argv[1:]): 37 | from polar2grid.glue import main 38 | 39 | os.environ["USE_POLAR2GRID_DEFAULTS"] = "1" 40 | return main(argv=argv) 41 | 42 | 43 | def g2g_main(argv=sys.argv[1:]): 44 | from polar2grid.glue import main 45 | 46 | os.environ["USE_POLAR2GRID_DEFAULTS"] = "0" 47 | return main(argv=argv) 48 | 49 | 50 | if __name__ == "__main__": 51 | from polar2grid.glue import main 52 | 53 | sys.exit(main()) 54 | -------------------------------------------------------------------------------- /polar2grid/composites/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Compositors specific to polar2grid and geo2grid products.""" 24 | -------------------------------------------------------------------------------- /polar2grid/composites/enhanced.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Composites that apply enhancements during the compositing phase.""" 24 | 25 | from satpy.composites import SingleBandCompositor, enhance2dataset 26 | 27 | 28 | class SingleEnhancedBandCompositor(SingleBandCompositor): 29 | """Produce a pre-enhanced version of the single provided dependency. 30 | 31 | .. warning:: 32 | 33 | This does **NOT** stop Satpy from enhancing this dataset again. The 34 | metadata provided to this compositor must make the DataArray match 35 | another "no-op" enhancement on the backend. 36 | 37 | """ 38 | 39 | def __call__(self, projectables, nonprojectables=None, **attrs): 40 | """Build the composite.""" 41 | if len(projectables) != 1: 42 | raise ValueError("Can't have more than one band in a single-band composite") 43 | 44 | data = projectables[0] 45 | new_attrs = data.attrs.copy() 46 | data = enhance2dataset(data) 47 | data.attrs = new_attrs 48 | if isinstance(data.attrs.get("sensor"), set) and len(data.attrs["sensor"]) == 1: 49 | data.attrs["sensor"] = list(data.attrs["sensor"])[0] 50 | return super().__call__([data], **attrs) 51 | 52 | 53 | class SubBandCompositor(SingleBandCompositor): 54 | """Get a single band from a provided multi-band DataArray.""" 55 | 56 | def __init__(self, name, prerequisites=None, optional_prerequisites=None, band_index=None, **kwargs): 57 | super().__init__(name, prerequisites=prerequisites, optional_prerequisites=optional_prerequisites, **kwargs) 58 | if band_index is None: 59 | raise ValueError("'band_index' must be provided.") 60 | self._band_index = band_index 61 | 62 | def __call__(self, projectables, nonprojectables=None, **attrs): 63 | """Index the provided DataArray and create a single band composite from it.""" 64 | if len(projectables) != 1: 65 | raise ValueError("Can't have more than one band in a single-band composite") 66 | 67 | data = projectables[0] 68 | if "bands" not in data.dims: 69 | raise ValueError("Provided data has no 'bands' dimension.") 70 | 71 | band_index = self._band_index 72 | if isinstance(band_index, int): 73 | band_index = data.dims["bands"][band_index] 74 | data = data.sel(bands=band_index) 75 | return super().__call__([data], **attrs) 76 | -------------------------------------------------------------------------------- /polar2grid/core/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2014-2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Core package of polar2grid holding constants and base classes.""" 24 | -------------------------------------------------------------------------------- /polar2grid/core/dtype.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Functions that handle polar2grid data types.""" 24 | 25 | import logging 26 | 27 | import numpy as np 28 | 29 | log = logging.getLogger(__name__) 30 | 31 | NUMPY_DTYPE_STRS = [ 32 | "uint8", 33 | "uint16", 34 | "uint32", 35 | "uint64", 36 | "int8", 37 | "int16", 38 | "int32", 39 | "int64", 40 | "float32", 41 | "float64", 42 | ] 43 | 44 | 45 | def str_to_dtype(dtype_str: str) -> np.dtype: 46 | try: 47 | return getattr(np, dtype_str) 48 | except AttributeError: 49 | raise ValueError("Not a valid data type string: %s" % (dtype_str,)) from err 50 | 51 | 52 | def dtype_to_str(numpy_dtype: np.dtype | str) -> str: 53 | if isinstance(numpy_dtype, str) or not hasattr(numpy_dtype, "name"): 54 | numpy_dtype = np.dtype(numpy_dtype) 55 | 56 | try: 57 | return numpy_dtype.name 58 | except KeyError as err: 59 | raise ValueError("Unsupported numpy data type: %r" % (numpy_dtype,)) from err 60 | 61 | 62 | def clip_to_data_type(data, data_type): 63 | if np.issubdtype(np.dtype(data_type), np.floating): 64 | return data 65 | info = np.iinfo(data_type) 66 | rmin = info.min 67 | rmax = info.max 68 | log.debug("Clipping data to a %d - %d data range" % (rmin, rmax)) 69 | return data.clip(rmin, rmax) 70 | 71 | 72 | def int_or_float(val): 73 | """Convert a string to integer or float. 74 | 75 | If we can't make it an integer then make it a float. 76 | 77 | """ 78 | try: 79 | return int(val) 80 | except ValueError: 81 | return float(val) 82 | -------------------------------------------------------------------------------- /polar2grid/enhancements/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Enhancement functions specific to polar2grid.""" 24 | 25 | from .shared import colorize, palettize, temperature_difference # noqa 26 | -------------------------------------------------------------------------------- /polar2grid/enhancements/viirs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2025 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Enhancement functions for VIIRS.""" 24 | 25 | import numpy as np 26 | from trollimage.xrimage import XRImage 27 | from satpy.enhancements import colorize as _colorize, palettize as _palettize, using_map_blocks 28 | 29 | 30 | def cloud_layers_lmh(img: XRImage) -> XRImage: 31 | """Convert bit-mask CloudLayer to Low-Medium-High categories. 32 | 33 | This is done in the CIRA version of the product for easier readability. 34 | 35 | Data is a bit-mask of (0=clear), 1 first layer, 2 second layer, 4 third 36 | layer, 8 fourth layer, 16 fifth layer. The first and second layers are 37 | grouped into a "Low" layer, third and fourth layers are grouped into 38 | a "Mid" layer, and the fifth layer is called "High". This function groups 39 | these 3 layer types with the final output being 40 | Clear (0), Low (1), Mid (2), Mid + Low (3), High (4), High + Low (5), 41 | High + Mid (6), and High + Mid + Low (7). 42 | 43 | """ 44 | return _cloud_layers_lmh(img.data) 45 | 46 | 47 | @using_map_blocks 48 | def _cloud_layers_lmh(data_np: np.ndarray) -> np.ndarray: 49 | data_out = np.zeros_like(data_np) 50 | data_out[data_out & 0b00011] += 1 # Low 51 | data_out[data_out & 0b01100] += 2 # Mid 52 | data_out[data_out & 0b10000] += 4 # High 53 | return data_out 54 | -------------------------------------------------------------------------------- /polar2grid/etc/colormaps/abi_l2_modified_cloud_top.cmap: -------------------------------------------------------------------------------- 1 | 0.0,127,0,127 2 | 17.000001,127,0,127 3 | 17.000002,150,75,20 4 | 34.000001,150,75,20 5 | 34.000002,255,171,127 6 | 51.000001,255,171,127 7 | 51.000002,255,127,0 8 | 68.000001,255,127,0 9 | 68.000002,255,255,50 10 | 85.000001,255,255,50 11 | 85.000002,220,220,40 12 | 102.000001,220,220,40 13 | 102.000002,58,135,0 14 | 119.000001,58,135,0 15 | 119.000002,75,175,0 16 | 136.000001,75,175,0 17 | 136.000002,100,200,130 18 | 153.000001,100,200,130 19 | 153.000002,112,219,147 20 | 170.000001,112,219,147 21 | 170.000002,120,120,240 22 | 187.000001,120,120,240 23 | 187.000002,150,150,245 24 | 204.000001,150,150,245 25 | 204.000002,180,180,250 26 | 221.000001,180,180,250 27 | 221.000002,225,225,255 28 | 238.000001,225,225,255 29 | 238.000002,255,255,255 30 | 255.0,255,255,255 31 | -------------------------------------------------------------------------------- /polar2grid/etc/colormaps/amsr2_36h.cmap: -------------------------------------------------------------------------------- 1 | hsl256_no_black.cmap -------------------------------------------------------------------------------- /polar2grid/etc/colormaps/amsr2_89h.cmap: -------------------------------------------------------------------------------- 1 | tropix_no_white.cmap -------------------------------------------------------------------------------- /polar2grid/etc/colormaps/viirs_edr_flood_water_detection.cmap: -------------------------------------------------------------------------------- 1 | 14,0,0,0,255 2 | 15,0,0,100,255 3 | 16,196,162,114,255 4 | 17,196,162,114,255 5 | 18,0,0,255,255 6 | 20,255,255,255,255 7 | 27,0,255,255,255 8 | 30,200,200,200,255 9 | 31,100,100,100,255 10 | 88,180,0,230,255 11 | 100,50,255,100,255 12 | 120,50,255,100,255 13 | 121,0,255,0,255 14 | 130,0,255,0,255 15 | 131,200,255,0,255 16 | 140,200,255,0,255 17 | 141,255,255,150,255 18 | 150,255,255,150,255 19 | 151,255,255,0,255 20 | 160,255,255,0,255 21 | 161,255,200,0,255 22 | 170,255,200,0,255 23 | 171,255,150,50,255 24 | 180,255,150,50,255 25 | 181,255,100,0,255 26 | 190,255,100,0,255 27 | 191,255,0,0,255 28 | 200,255,0,0,255 29 | 201,0,0,0,255 30 | -------------------------------------------------------------------------------- /polar2grid/etc/composites/abi.yaml: -------------------------------------------------------------------------------- 1 | sensor_name: visir/abi 2 | 3 | composites: 4 | true_color_night: 5 | compositor: !!python/name:satpy.composites.DayNightCompositor 6 | prerequisites: 7 | - true_color 8 | - C14 9 | standard_name: day_night_mix 10 | -------------------------------------------------------------------------------- /polar2grid/etc/composites/ahi.yaml: -------------------------------------------------------------------------------- 1 | sensor_name: visir/ahi 2 | 3 | composites: 4 | true_color_night: 5 | compositor: !!python/name:satpy.composites.DayNightCompositor 6 | prerequisites: 7 | - true_color 8 | - B14 9 | standard_name: day_night_mix 10 | -------------------------------------------------------------------------------- /polar2grid/etc/composites/mersi-2.yaml: -------------------------------------------------------------------------------- 1 | sensor_name: visir/mersi-2 2 | 3 | composites: 4 | false_color: 5 | compositor: !!python/name:satpy.composites.RatioSharpenedRGB 6 | prerequisites: 7 | - name: '7' 8 | modifiers: [sunz_corrected] 9 | - name: '15' 10 | modifiers: [sunz_corrected] 11 | - name: '3' 12 | modifiers: [sunz_corrected] 13 | optional_prerequisites: 14 | - name: '4' 15 | modifiers: [sunz_corrected] 16 | standard_name: false_color 17 | high_resolution_band: green 18 | -------------------------------------------------------------------------------- /polar2grid/etc/enhancements/agri.yaml: -------------------------------------------------------------------------------- 1 | enhancements: 2 | true_color_crefl: 3 | sensor: agri 4 | standard_name: true_color 5 | operations: 6 | - name: reflectance_range 7 | method: !!python/name:satpy.enhancements.stretch 8 | kwargs: {stretch: 'crude', min_stretch: 0., max_stretch: 100.} 9 | - name: Linear interpolation 10 | method: !!python/name:satpy.enhancements.piecewise_linear_stretch 11 | kwargs: 12 | xp: [0., 25., 55., 100., 255.] 13 | fp: [0., 90., 140., 175., 255.] 14 | reference_scale_factor: 255 15 | channel_7_default: 16 | name: C07 17 | operations: 18 | - name: linear 19 | method: !!python/name:satpy.enhancements.stretch 20 | kwargs: {stretch: 'crude', min_stretch: 400.15, max_stretch: 164.15} 21 | channel_8_default: 22 | name: C08 23 | operations: 24 | - name: linear 25 | method: !!python/name:satpy.enhancements.stretch 26 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 27 | channel_9_default: 28 | name: C09 29 | operations: 30 | - name: linear 31 | method: !!python/name:satpy.enhancements.stretch 32 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 33 | channel_10_default: 34 | name: C10 35 | operations: 36 | - name: linear 37 | method: !!python/name:satpy.enhancements.stretch 38 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 39 | -------------------------------------------------------------------------------- /polar2grid/etc/enhancements/ahi.yaml: -------------------------------------------------------------------------------- 1 | enhancements: 2 | true_color_crefl: 3 | sensor: ahi 4 | standard_name: true_color 5 | operations: 6 | - name: reflectance_range 7 | method: !!python/name:satpy.enhancements.stretch 8 | kwargs: {stretch: 'crude', min_stretch: 0., max_stretch: 100.} 9 | - name: Linear interpolation 10 | method: !!python/name:satpy.enhancements.piecewise_linear_stretch 11 | kwargs: 12 | xp: [0., 25., 55., 100., 255.] 13 | fp: [0., 90., 140., 175., 255.] 14 | reference_scale_factor: 255 15 | channel_7_default: 16 | name: B07 17 | operations: 18 | - name: linear 19 | method: !!python/name:satpy.enhancements.stretch 20 | kwargs: {stretch: 'crude', min_stretch: 400.15, max_stretch: 164.15} 21 | channel_8_default: 22 | name: B08 23 | operations: 24 | - name: linear 25 | method: !!python/name:satpy.enhancements.stretch 26 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 27 | channel_9_default: 28 | name: B09 29 | operations: 30 | - name: linear 31 | method: !!python/name:satpy.enhancements.stretch 32 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 33 | channel_10_default: 34 | name: B10 35 | operations: 36 | - name: linear 37 | method: !!python/name:satpy.enhancements.stretch 38 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 39 | -------------------------------------------------------------------------------- /polar2grid/etc/enhancements/ami.yaml: -------------------------------------------------------------------------------- 1 | enhancements: 2 | true_color_crefl: 3 | sensor: ami 4 | standard_name: true_color 5 | operations: 6 | - name: reflectance_range 7 | method: !!python/name:satpy.enhancements.stretch 8 | kwargs: {stretch: 'crude', min_stretch: 0., max_stretch: 100.} 9 | - name: Linear interpolation 10 | method: !!python/name:satpy.enhancements.piecewise_linear_stretch 11 | kwargs: 12 | xp: [0., 25., 55., 100., 255.] 13 | fp: [0., 90., 140., 175., 255.] 14 | reference_scale_factor: 255 15 | channel_7_default: 16 | name: SW038 17 | operations: 18 | - name: linear 19 | method: !!python/name:satpy.enhancements.stretch 20 | kwargs: {stretch: 'crude', min_stretch: 400.15, max_stretch: 164.15} 21 | channel_8_default: 22 | name: WV063 23 | operations: 24 | - name: linear 25 | method: !!python/name:satpy.enhancements.stretch 26 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 27 | channel_9_default: 28 | name: WV069 29 | operations: 30 | - name: linear 31 | method: !!python/name:satpy.enhancements.stretch 32 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 33 | channel_10_default: 34 | name: WV073 35 | operations: 36 | - name: linear 37 | method: !!python/name:satpy.enhancements.stretch 38 | kwargs: {stretch: 'crude', min_stretch: 280., max_stretch: 180.} 39 | -------------------------------------------------------------------------------- /polar2grid/etc/enhancements/mersi-2.yaml: -------------------------------------------------------------------------------- 1 | enhancements: 2 | natural_color_crefl: 3 | standard_name: natural_color 4 | operations: 5 | - name: reflectance_range 6 | method: !!python/name:satpy.enhancements.stretch 7 | kwargs: {stretch: 'crude', min_stretch: -1., max_stretch: 110.} 8 | - name: Linear interpolation 9 | method: !!python/name:satpy.enhancements.piecewise_linear_stretch 10 | kwargs: 11 | xp: [0., 25., 55., 100., 255.] 12 | fp: [0., 90., 140., 175., 255.] 13 | reference_scale_factor: 255 14 | -------------------------------------------------------------------------------- /polar2grid/etc/enhancements/modis.yaml: -------------------------------------------------------------------------------- 1 | enhancements: 2 | pre_enhanced_modis_crefl: 3 | sensor: modis 4 | standard_name: preenhanced_crefl 5 | operations: [] 6 | -------------------------------------------------------------------------------- /polar2grid/etc/pyspectral.yaml: -------------------------------------------------------------------------------- 1 | rsr_dir: !!python/object/apply:os.getenv ['PSP_DATA_ROOT'] 2 | rayleigh_dir: !!python/object/apply:os.getenv ['PSP_DATA_ROOT'] 3 | -------------------------------------------------------------------------------- /polar2grid/etc/readers/mirs.yaml: -------------------------------------------------------------------------------- 1 | reader: 2 | data_files: 3 | - url: "https://zenodo.org/record/10357932/files/limbcoef_atmsland_noaa20.txt" 4 | known_hash: "08deca15afe8638effac9e6ccb442c2c386f5444926129d30a250d5840264c1d" 5 | - url: "https://zenodo.org/record/10357932/files/limbcoef_atmsland_snpp.txt" 6 | known_hash: "4b01543699792306711ef1699244e96186487e8a869e4ae42bf1f0e4d00fd063" 7 | - url: "https://zenodo.org/record/10357932/files/limbcoef_atmssea_noaa20.txt" 8 | known_hash: "07cd7874ff3f069cc3d473bdd0d1d19880ef01ac8d75cb0212a3687c059557f4" 9 | - url: "https://zenodo.org/record/10357932/files/limbcoef_atmssea_snpp.txt" 10 | known_hash: "d0f806051b80320e046bdae6a9b68616152bbf8c2dbf3667b9834459259c0d72" 11 | # Temporary copy of noaa-20 files as noaa-21 files 12 | - url: "https://zenodo.org/record/10357932/files/limbcoef_atmsland_noaa20.txt" 13 | known_hash: "08deca15afe8638effac9e6ccb442c2c386f5444926129d30a250d5840264c1d" 14 | filename: "limbcoef_atmsland_noaa21.txt" 15 | - url: "https://zenodo.org/record/10357932/files/limbcoef_atmssea_noaa20.txt" 16 | known_hash: "07cd7874ff3f069cc3d473bdd0d1d19880ef01ac8d75cb0212a3687c059557f4" 17 | filename: "limbcoef_atmssea_noaa21.txt" 18 | -------------------------------------------------------------------------------- /polar2grid/etc/writers/binary.yaml: -------------------------------------------------------------------------------- 1 | writer: 2 | name: binary 3 | description: Generic Flat Binary File Writer 4 | writer: !!python/name:polar2grid.writers.binary.FlatBinaryWriter 5 | filename: "{platform_name!l}_{sensor!l}_{p2g_name}_{start_time:%Y%m%d_%H%M%S}_{area.area_id}.dat" 6 | -------------------------------------------------------------------------------- /polar2grid/etc/writers/hdf5.yaml: -------------------------------------------------------------------------------- 1 | writer: 2 | name: hdf5 3 | description: Generic hdf5 Writer 4 | writer: !!python/name:polar2grid.writers.hdf5.HDF5Writer 5 | filename: "{platform_name}_{sensor}_{start_time:%Y%m%d_%H%M%S}.h5" 6 | -------------------------------------------------------------------------------- /polar2grid/filters/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Filter components for removing entire datasets from a Scene.""" 24 | 25 | from ._filter_scene import filter_scene # noqa 26 | -------------------------------------------------------------------------------- /polar2grid/fonts/Vera.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssec/polar2grid/0280a81b1998fd226667619a62097d7dd9678a45/polar2grid/fonts/Vera.ttf -------------------------------------------------------------------------------- /polar2grid/fonts/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2016-2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Subpackage for static font files. 24 | 25 | Need this directory to be a module so that pkg_resources.resource_filename properly finds it. 26 | 27 | """ 28 | -------------------------------------------------------------------------------- /polar2grid/grids/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2013 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese January 2013 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | """Grid utility functions and grid configuration files.""" 31 | 32 | from polar2grid.grids.manager import GridManager # noqa 33 | -------------------------------------------------------------------------------- /polar2grid/readers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2016 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese March 2016 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | """SatPy readers wrapped with P2G-specific information.""" 31 | -------------------------------------------------------------------------------- /polar2grid/resample/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese Feb 2021 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | """Functionality related to resampling data or other geolocation specific utilities.""" 31 | 32 | from ._resample_scene import resample_scene # noqa 33 | -------------------------------------------------------------------------------- /polar2grid/tests/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2014-2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for polar2grid.""" 24 | 25 | import os 26 | 27 | TEST_ETC_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "etc")) 28 | -------------------------------------------------------------------------------- /polar2grid/tests/conftest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Test initialization and fixtures.""" 24 | 25 | from __future__ import annotations 26 | 27 | import logging 28 | import os 29 | from pathlib import Path 30 | 31 | import pytest 32 | 33 | PKG_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..")) 34 | root_logger = logging.getLogger() 35 | 36 | pytest_plugins = [ 37 | "polar2grid.tests._abi_fixtures", 38 | "polar2grid.tests._viirs_fixtures", 39 | "polar2grid.tests._avhrr_fixtures", 40 | ] 41 | 42 | 43 | def pytest_configure(config): 44 | from polar2grid.utils.config import add_polar2grid_config_paths 45 | 46 | add_polar2grid_config_paths() 47 | 48 | 49 | @pytest.fixture(autouse=True) 50 | def clear_cached_functions(): 51 | from polar2grid.filters._utils import polygon_for_area 52 | from polar2grid.filters.day_night import _get_sunlight_coverage 53 | 54 | _get_sunlight_coverage.cache_clear() 55 | polygon_for_area.cache_clear() 56 | 57 | 58 | @pytest.fixture 59 | def chtmpdir(tmp_path: Path): 60 | lwd = os.getcwd() 61 | os.chdir(tmp_path) 62 | try: 63 | yield tmp_path 64 | finally: 65 | os.chdir(lwd) 66 | 67 | 68 | @pytest.fixture(scope="session") 69 | def builtin_grids_yaml() -> list[str]: 70 | return [os.path.join(PKG_ROOT, "grids", "grids.yaml")] 71 | 72 | 73 | @pytest.fixture(scope="session") 74 | def builtin_test_grids_conf() -> list[str]: 75 | return [os.path.join(PKG_ROOT, "tests", "etc", "grids.conf")] 76 | 77 | 78 | @pytest.fixture(autouse=True) 79 | def ensure_logging_framework_not_altered(): 80 | """Protect logger handlers to avoid capsys closing files.""" 81 | before_handlers = list(root_logger.handlers) 82 | yield 83 | root_logger.handlers = before_handlers 84 | -------------------------------------------------------------------------------- /polar2grid/tests/etc/colormaps/WV_Chile_Short.cmap: -------------------------------------------------------------------------------- 1 | 0,0,0,0,255 2 | 110,126,126,126,255 3 | 130,0,0,126,255 4 | 145,126,126,126,255 5 | 180,255,255,255,255 6 | 195,0,85,0,255 7 | 200,0,247,0,255 8 | 203,255,255,0,255 9 | 212,255,3,0,255 10 | 217,134,0,0,255 11 | 222,255,255,255,255 12 | 255,127,127,127,255 13 | -------------------------------------------------------------------------------- /polar2grid/tests/etc/colormaps/reds.cmap: -------------------------------------------------------------------------------- 1 | 0,0,0,0,255 2 | 255,255,0,0,255 3 | -------------------------------------------------------------------------------- /polar2grid/tests/etc/enhancements/generic.yaml: -------------------------------------------------------------------------------- 1 | enhancements: 2 | test_arange_default: 3 | standard_name: test_arange 4 | operations: 5 | - name: linear_stretch 6 | method: !!python/name:satpy.enhancements.stretch 7 | kwargs: {stretch: 'crude', min_stretch: 0.0, max_stretch: 500.} 8 | test_temperature_difference: 9 | name: test_temperature_difference 10 | operations: 11 | - name: temp_diff_stretch 12 | method: !!python/name:polar2grid.enhancements.shared.temperature_difference 13 | kwargs: 14 | min_stretch: -10.0 15 | max_stretch: 10.0 16 | test_p2g_palettize: 17 | name: test_p2g_palettize 18 | operations: 19 | - name: add_colormap 20 | method: !!python/name:polar2grid.enhancements.palettize 21 | kwargs: 22 | palettes: 23 | - filename: $POLAR2GRID_HOME/../polar2grid/etc/colormaps/amsr2_36h.cmap 24 | min_value: 180 25 | max_value: 280 26 | test_p2g_palettize2: 27 | name: test_p2g_palettize2 28 | operations: 29 | - name: custom_palette 30 | method: !!python/name:polar2grid.enhancements.palettize 31 | kwargs: 32 | palettes: 33 | - {colors: 34 | [[14, 0.0, 0.0, 0.0], 35 | [201, 1.0, 0.0, 0.0]], 36 | min_value: 0, 37 | max_value: 201} 38 | test_p2g_palettize3: 39 | name: test_p2g_palettize3 40 | operations: 41 | - name: custom_palette 42 | method: !!python/name:polar2grid.enhancements.palettize 43 | kwargs: 44 | palettes: 45 | - {filename: "test_p2g_palettize3.npy", 46 | min_value: 0, 47 | max_value: 201} 48 | test_p2g_palettize4: 49 | name: test_p2g_palettize4 50 | operations: 51 | - name: custom_palette 52 | method: !!python/name:polar2grid.enhancements.palettize 53 | kwargs: 54 | palettes: 55 | - {filename: "colormaps/amsr2_36h.cmap", 56 | min_value: 0, 57 | max_value: 201} 58 | test_p2g_colorize: 59 | name: test_p2g_colorize 60 | operations: 61 | - name: add_colormap 62 | method: !!python/name:polar2grid.enhancements.colorize 63 | kwargs: 64 | palettes: 65 | - filename: $POLAR2GRID_HOME/../polar2grid/etc/colormaps/amsr2_36h.cmap 66 | min_value: 180 67 | max_value: 280 68 | -------------------------------------------------------------------------------- /polar2grid/tests/etc/test_p2g_palettize3.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssec/polar2grid/0280a81b1998fd226667619a62097d7dd9678a45/polar2grid/tests/etc/test_p2g_palettize3.npy -------------------------------------------------------------------------------- /polar2grid/tests/test_add_colormap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Basic usability tests for the add_colormap script.""" 24 | 25 | from __future__ import annotations 26 | 27 | import os 28 | 29 | import pytest 30 | import rasterio 31 | import satpy 32 | 33 | from polar2grid.tests import TEST_ETC_DIR 34 | 35 | from .test_add_coastlines import _create_fake_l_geotiff 36 | 37 | 38 | def test_add_colormap_help(): 39 | from polar2grid.add_colormap import main 40 | 41 | with pytest.raises(SystemExit) as e: 42 | main(["--help"]) 43 | assert e.value.code == 0 44 | 45 | 46 | @pytest.mark.parametrize( 47 | ("cmap_path", "exp_first_color", "exp_middle_color", "exp_last_color"), 48 | [ 49 | ( 50 | os.path.join(TEST_ETC_DIR, "colormaps", "amsr2_36h.cmap"), 51 | (0, 0, 0, 255), 52 | (128, 255, 130, 255), 53 | (128, 0, 0, 255), 54 | ), 55 | (os.path.join("colormaps", "amsr2_36h.cmap"), (0, 0, 0, 255), (128, 255, 130, 255), (128, 0, 0, 255)), 56 | ( 57 | os.path.join(TEST_ETC_DIR, "colormaps", "WV_Chile_Short.cmap"), 58 | (0, 0, 0, 255), 59 | (0, 47, 144, 255), 60 | (127, 127, 127, 255), 61 | ), 62 | (os.path.join(TEST_ETC_DIR, "colormaps", "reds.cmap"), (0, 0, 0, 255), (129, 3, 39, 255), (255, 0, 0, 255)), 63 | ], 64 | ) 65 | def test_add_colormap_basic_l(tmp_path, cmap_path, exp_first_color, exp_middle_color, exp_last_color): 66 | from polar2grid.add_colormap import main 67 | 68 | fp = str(tmp_path / "test.tif") 69 | _create_fake_l_geotiff(fp) 70 | with satpy.config.set(config_path=[TEST_ETC_DIR]): 71 | ret = main([cmap_path, fp]) 72 | assert ret in [None, 0] 73 | 74 | with rasterio.open(fp, "r") as ds: 75 | cmap = ds.colormap(1) 76 | assert len(cmap) == 256 77 | assert cmap[0] == exp_first_color 78 | assert cmap[127] == exp_middle_color 79 | assert cmap[255] == exp_last_color 80 | -------------------------------------------------------------------------------- /polar2grid/tests/test_configs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for polar2grid configuration files.""" 24 | 25 | import os 26 | from glob import glob 27 | 28 | import yaml 29 | 30 | 31 | def pytest_generate_tests(metafunc): 32 | """Generate parametrized tests to run on all YAML files. 33 | 34 | Automatically used by pytest as a hook.. 35 | 36 | """ 37 | if "yaml_config_file" in metafunc.fixturenames: 38 | root_dir = os.path.join(os.path.dirname(__file__), "..") 39 | glob_pat = os.path.join(root_dir, "etc", "**", "*.yaml") 40 | p2g_yaml_files = sorted(glob(glob_pat, recursive=True)) 41 | assert len(p2g_yaml_files) != 0 42 | metafunc.parametrize("yaml_config_file", p2g_yaml_files) 43 | 44 | 45 | def test_valid_yaml_files(yaml_config_file): 46 | """Test basic YAML syntax for all config files.""" 47 | with open(yaml_config_file, "r") as yaml_file: 48 | yaml.load(yaml_file, Loader=yaml.UnsafeLoader) 49 | -------------------------------------------------------------------------------- /polar2grid/tests/test_dtype.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (C) 2025 Space Science and Engineering Center (SSEC), 3 | # University of Wisconsin-Madison. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | # This file is part of the polar2grid software package. Polar2grid takes 19 | # satellite observation data, remaps it, and writes it to a file format for 20 | # input into another program. 21 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 22 | """Test dtype conversions.""" 23 | 24 | import numpy as np 25 | import pytest 26 | 27 | from polar2grid.core.dtype import dtype_to_str, str_to_dtype 28 | 29 | 30 | @pytest.mark.parametrize( 31 | ("input_arg", "exp_str"), 32 | [ 33 | (np.uint8, "uint8"), 34 | ("uint8", "uint8"), 35 | ("u1", "uint8"), 36 | (np.dtype("uint8"), "uint8"), 37 | (np.float32, "float32"), 38 | ("float32", "float32"), 39 | ("f4", "float32"), 40 | (np.dtype("float32"), "float32"), 41 | (np.float64, "float64"), 42 | ("float64", "float64"), 43 | ("f8", "float64"), 44 | (np.dtype("float64"), "float64"), 45 | (np.int8, "int8"), 46 | ("int8", "int8"), 47 | ("i1", "int8"), 48 | (np.dtype("int8"), "int8"), 49 | ], 50 | ) 51 | def test_dtype_to_str(input_arg, exp_str): 52 | """Test conversion from dtype to string.""" 53 | dtype_str = dtype_to_str(input_arg) 54 | assert dtype_str == exp_str 55 | 56 | 57 | @pytest.mark.parametrize( 58 | ("input_arg", "exp_dtype"), 59 | [ 60 | ("uint8", np.uint8), 61 | ("int8", np.int8), 62 | ("float32", np.float32), 63 | ], 64 | ) 65 | def test_str_to_dtype(input_arg, exp_dtype): 66 | """Test conversion from string to dtype.""" 67 | np_dtype = str_to_dtype(input_arg) 68 | assert np_dtype == exp_dtype 69 | -------------------------------------------------------------------------------- /polar2grid/tests/test_filters/__init__.py: -------------------------------------------------------------------------------- 1 | """Tests for polar2grid.filters components.""" 2 | -------------------------------------------------------------------------------- /polar2grid/tests/test_grids/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2015 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese March 2015 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | """Tests for grid related functionality.""" 31 | -------------------------------------------------------------------------------- /polar2grid/tests/test_grids/test_manager.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2015-2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Test grid manager.""" 24 | 25 | from pyresample import AreaDefinition, DynamicAreaDefinition 26 | 27 | from polar2grid.grids import GridManager 28 | 29 | 30 | def test_grid_manager_basic(builtin_test_grids_conf, viirs_sdr_i_swath_def): 31 | """Test basic parsing of .conf files.""" 32 | gm = GridManager(*builtin_test_grids_conf) 33 | for grid_name in gm.grid_information: 34 | grid_def = gm.get_grid_definition(grid_name) 35 | area_def = grid_def.to_satpy_area() 36 | assert isinstance(area_def, (AreaDefinition, DynamicAreaDefinition)) 37 | if isinstance(area_def, DynamicAreaDefinition): 38 | new_area_def = area_def.freeze(viirs_sdr_i_swath_def) 39 | assert new_area_def.shape[0] > 0 40 | assert new_area_def.shape[1] > 0 41 | assert new_area_def.area_extent[0] < new_area_def.area_extent[2] 42 | assert new_area_def.area_extent[1] < new_area_def.area_extent[3] 43 | -------------------------------------------------------------------------------- /polar2grid/tests/test_main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2022 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for the __main__.py script.""" 24 | 25 | import pytest 26 | 27 | from polar2grid.__main__ import g2g_main, p2g_main 28 | 29 | 30 | @pytest.mark.parametrize( 31 | ("main_func", "exp_reader"), 32 | [ 33 | (p2g_main, "viirs_sdr"), 34 | (g2g_main, "abi_l1b"), 35 | ], 36 | ) 37 | def test_main_call(main_func, exp_reader, capsys): 38 | with pytest.raises(SystemExit) as e: 39 | main_func(["-h"]) 40 | assert e.value.code == 0 41 | sout = capsys.readouterr() 42 | assert exp_reader in sout.out 43 | 44 | 45 | def test_call_main_script(): 46 | import subprocess 47 | 48 | subprocess.check_call(["python3", "-m", "polar2grid", "-h"]) 49 | -------------------------------------------------------------------------------- /polar2grid/tests/test_readers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for specific readers.""" 24 | -------------------------------------------------------------------------------- /polar2grid/tests/test_readers/test_base.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for base/shared logic.""" 24 | 25 | import importlib 26 | import os 27 | 28 | import pytest 29 | 30 | PKG_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..")) 31 | READER_BASE = os.path.join(PKG_ROOT, "readers") 32 | ALL_READERS = [os.path.splitext(reader_fn)[0] for reader_fn in os.listdir(READER_BASE) if not reader_fn.startswith("_")] 33 | 34 | 35 | @pytest.mark.parametrize("reader_name", ALL_READERS) 36 | def test_reader_imports(reader_name): 37 | mod = importlib.import_module(f"polar2grid.readers.{reader_name}") 38 | assert hasattr(mod, "ReaderProxy") 39 | 40 | 41 | @pytest.mark.parametrize("reader_name", ALL_READERS) 42 | def test_reader_parser_arguments(reader_name): 43 | import argparse 44 | 45 | mod = importlib.import_module(f"polar2grid.readers.{reader_name}") 46 | assert hasattr(mod, "add_reader_argument_groups") 47 | 48 | parser = argparse.ArgumentParser() 49 | groups = mod.add_reader_argument_groups(parser) 50 | assert len(groups) == 2 51 | -------------------------------------------------------------------------------- /polar2grid/tests/test_resample/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for resampling functionality.""" 24 | -------------------------------------------------------------------------------- /polar2grid/tests/test_utils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for utilities.""" 24 | -------------------------------------------------------------------------------- /polar2grid/tests/test_utils/test_convert_grids_conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for the convert_grids_conf_to_yaml.py script.""" 24 | 25 | from io import StringIO 26 | 27 | import pytest 28 | from pyresample import parse_area_file 29 | from pyresample.geometry import AreaDefinition, DynamicAreaDefinition 30 | 31 | 32 | @pytest.mark.parametrize( 33 | ("conf_content", "num_areas", "area_types"), 34 | [ 35 | ( 36 | """ 37 | wgs84_fit, proj4, +proj=latlong +datum=WGS84 +no_defs, None, None, 0.0057, -0.0057, None, None 38 | """, 39 | 1, 40 | [DynamicAreaDefinition], 41 | ), 42 | ( 43 | """ 44 | 211e, proj4, +proj=lcc +a=6371200 +b=6371200 +lat_0=25 +lat_1=25 +lon_0=-95 +units=m +no_defs, 5120, 5120, 1015.9, -1015.9, -123.044deg, 59.844deg 45 | 211e_10km, proj4, +proj=lcc +a=6371200 +b=6371200 +lat_0=25 +lat_1=25 +lon_0=-95 +units=m +no_defs, 512, 512, 10159, -10159, -123.044deg, 59.844deg 46 | 211e_hi, proj4, +proj=lcc +a=6371200 +b=6371200 +lat_0=25 +lat_1=25 +lon_0=-95 +units=m +no_defs, 10000, 10000, 500, -500, -123.044deg, 59.844deg 47 | """, # noqa 48 | 3, 49 | [AreaDefinition] * 3, 50 | ), 51 | ], 52 | ) 53 | def test_conf_conversion(tmpdir, capsys, conf_content, num_areas, area_types): 54 | from polar2grid.utils.convert_grids_conf_to_yaml import main 55 | 56 | grids_fn = tmpdir.join("test_grids.conf") 57 | with open(grids_fn, "w") as grids_file: 58 | grids_file.write(conf_content) 59 | 60 | main([str(grids_fn)]) 61 | sout = capsys.readouterr() 62 | s = StringIO() 63 | s.write(sout.out) 64 | s.seek(0) 65 | areas = parse_area_file([s]) 66 | assert len(areas) == num_areas 67 | for area_obj, area_type in zip(areas, area_types, strict=True): 68 | assert isinstance(area_obj, area_type) 69 | -------------------------------------------------------------------------------- /polar2grid/tests/test_utils/test_legacy_compat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for legacy handling utilities.""" 24 | 25 | from __future__ import annotations 26 | 27 | import logging 28 | 29 | import pytest 30 | 31 | from polar2grid.utils.legacy_compat import convert_p2g_pattern_to_satpy 32 | 33 | 34 | @pytest.mark.parametrize( 35 | ("input_str", "exp_str", "num_exp_warnings"), 36 | [ 37 | ("{p2g_name}_{start_time:%Y%m%d_%H%M%S}.tif", "{p2g_name}_{start_time:%Y%m%d_%H%M%S}.tif", 0), 38 | ( 39 | "{satellite}_{instrument}_{product_name}_{begin_time}.tif", 40 | "{platform_name}_{sensor}_{p2g_name}_{start_time:%Y%m%d_%H%M%S}.tif", 41 | 4, 42 | ), 43 | ( 44 | "{grid_name}_{product_name}_{begin_time_HHMM}_{end_time_HHMM}.tif", 45 | "{area.area_id}_{p2g_name}_{start_time:%H%M}_{end_time:%H%M}.tif", 46 | 4, 47 | ), 48 | ], 49 | ) 50 | def test_pattern_formatting(input_str, exp_str, num_exp_warnings, caplog): 51 | with caplog.at_level(logging.WARNING): 52 | new_str = convert_p2g_pattern_to_satpy(input_str) 53 | assert new_str == exp_str 54 | legacy_warns = [record for record in caplog.records if "to avoid this warning" in record.message] 55 | assert len(legacy_warns) == num_exp_warnings 56 | -------------------------------------------------------------------------------- /polar2grid/tests/test_writers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for polar2grid-specific writers.""" 24 | -------------------------------------------------------------------------------- /polar2grid/tests/test_writers/test_base.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for base/shared logic.""" 24 | 25 | import importlib 26 | import os 27 | 28 | import pytest 29 | 30 | PKG_ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..")) 31 | WRITER_BASE = os.path.join(PKG_ROOT, "writers") 32 | ALL_WRITERS = [os.path.splitext(writer_fn)[0] for writer_fn in os.listdir(WRITER_BASE) if not writer_fn.startswith("_")] 33 | 34 | 35 | @pytest.mark.parametrize("writer_name", ALL_WRITERS) 36 | def test_writer_imports(writer_name): 37 | mod = importlib.import_module(f"polar2grid.writers.{writer_name}") 38 | assert hasattr(mod, "DEFAULT_OUTPUT_FILENAMES") 39 | assert isinstance(mod.DEFAULT_OUTPUT_FILENAMES, dict) 40 | assert "polar2grid" in mod.DEFAULT_OUTPUT_FILENAMES 41 | assert "geo2grid" in mod.DEFAULT_OUTPUT_FILENAMES 42 | 43 | 44 | @pytest.mark.parametrize("writer_name", ALL_WRITERS) 45 | def test_reader_parser_arguments(writer_name): 46 | import argparse 47 | 48 | mod = importlib.import_module(f"polar2grid.writers.{writer_name}") 49 | assert hasattr(mod, "add_writer_argument_groups") 50 | 51 | parser = argparse.ArgumentParser() 52 | groups = mod.add_writer_argument_groups(parser) 53 | assert len(groups) == 2 54 | -------------------------------------------------------------------------------- /polar2grid/tests/test_writers/test_hdf5.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Tests for the hdf5 writer.""" 24 | 25 | import os 26 | 27 | import pytest 28 | import satpy 29 | 30 | TEST_ETC_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "etc")) 31 | 32 | 33 | class TestHDF5Writer: 34 | def setup_method(self): 35 | """Add P2G configs to the Satpy path.""" 36 | from polar2grid.utils.config import add_polar2grid_config_paths 37 | 38 | self._old_path = satpy.config.get("config_path") 39 | add_polar2grid_config_paths() 40 | # add test specific configs 41 | curr_path = satpy.config.get("config_path") 42 | satpy.config.set(config_path=[TEST_ETC_DIR] + curr_path) 43 | 44 | def teardown_method(self): 45 | """Reset Satpy config path back to the original value.""" 46 | satpy.config.set(config_path=self._old_path) 47 | 48 | @pytest.mark.parametrize("add_geolocation", [False, True]) 49 | def test_hdf5_basic(self, add_geolocation, abi_l1b_c01_scene, tmp_path): 50 | """Test basic writing of gridded data.""" 51 | import h5py 52 | 53 | abi_l1b_c01_scene.load(["C01"]) 54 | abi_l1b_c01_scene.save_datasets( 55 | writer="hdf5", 56 | base_dir=str(tmp_path), 57 | filename="{platform_name}_{sensor}_{start_time:%Y%m%d_%H%M%S}.h5", 58 | add_geolocation=add_geolocation, 59 | ) 60 | exp_fn = tmp_path / "goes16_abi_20210101_120000.h5" 61 | 62 | assert os.path.isfile(exp_fn) 63 | hdf_file = h5py.File(exp_fn, "r") 64 | assert "goes_east" in hdf_file 65 | assert "C01" in hdf_file["goes_east"] 66 | if add_geolocation: 67 | assert "longitude" in hdf_file["goes_east"] 68 | assert "latitude" in hdf_file["goes_east"] 69 | else: 70 | assert "longitude" not in hdf_file["goes_east"] 71 | assert "latitude" not in hdf_file["goes_east"] 72 | -------------------------------------------------------------------------------- /polar2grid/utils/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2014-2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Various utility functions and scripts.""" 24 | -------------------------------------------------------------------------------- /polar2grid/utils/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Helpers for setting up the Polar2Grid environment and configuration.""" 24 | 25 | from __future__ import annotations 26 | 27 | import importlib.metadata as impm 28 | import importlib.resources as impr 29 | import os 30 | import sys 31 | from collections.abc import Mapping, MutableMapping 32 | 33 | import satpy 34 | 35 | 36 | def get_polar2grid_etc(): 37 | p2g_pkg_location = impr.files("polar2grid") 38 | if _is_editable_installation(): 39 | return str(p2g_pkg_location / "etc") 40 | return p2g_pkg_location / "etc" 41 | 42 | 43 | def _is_editable_installation(): 44 | for installed_file in impm.files("polar2grid"): 45 | str_fn = str(installed_file) 46 | if "__editable__" in str_fn or "pyproject.toml" in str_fn: 47 | return True 48 | return False 49 | 50 | 51 | def get_polar2grid_home(): 52 | p2g_home = os.environ.get("POLAR2GRID_HOME") 53 | if p2g_home is None: 54 | # assume development/editable install 55 | import polar2grid 56 | 57 | os.environ["POLAR2GRID_HOME"] = os.path.join(os.path.dirname(polar2grid.__file__), "..", "swbundle") 58 | return os.environ["POLAR2GRID_HOME"] 59 | 60 | 61 | def add_polar2grid_config_paths(): 62 | config_path = satpy.config.get("config_path") 63 | p2g_etc = get_polar2grid_etc() 64 | if p2g_etc not in config_path: 65 | satpy.config.set(config_path=config_path + [p2g_etc]) 66 | 67 | 68 | def recursive_dict_update(d: MutableMapping, u: Mapping) -> None: 69 | """Recursive dictionary update. 70 | 71 | Copied from: 72 | 73 | http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth 74 | 75 | """ 76 | for k, v in u.items(): 77 | if isinstance(v, Mapping): 78 | r = d.get(k, {}) 79 | recursive_dict_update(r, v) 80 | d[k] = r 81 | else: 82 | d[k] = u[k] 83 | -------------------------------------------------------------------------------- /polar2grid/utils/dynamic_imports.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Utilities for dynamically imported and accessing components.""" 24 | 25 | import importlib 26 | from typing import Any 27 | 28 | 29 | def _get_component_attr(component_type: str, component_name: str, attr_name: str, default: Any = None) -> Any: 30 | try: 31 | comp_mod = importlib.import_module(f"polar2grid.{component_type}.{component_name}") 32 | except ModuleNotFoundError: 33 | return default 34 | return getattr(comp_mod, attr_name, default) 35 | 36 | 37 | def get_reader_attr(reader_name: str, attr_name: str, default: Any = None) -> Any: 38 | return _get_component_attr("readers", reader_name, attr_name, default=default) 39 | 40 | 41 | def get_writer_attr(writer_name: str, attr_name: str, default: Any = None) -> Any: 42 | return _get_component_attr("writers", writer_name, attr_name, default=default) 43 | -------------------------------------------------------------------------------- /polar2grid/utils/warnings.py: -------------------------------------------------------------------------------- 1 | """Warnings or utilities for dealing with warnings.""" 2 | 3 | from __future__ import annotations 4 | 5 | import contextlib 6 | import warnings 7 | 8 | 9 | @contextlib.contextmanager 10 | def ignore_no_georef(): 11 | """Wrap operations that we know will produce a rasterio geolocation warning.""" 12 | from rasterio.errors import NotGeoreferencedWarning 13 | 14 | with warnings.catch_warnings(): 15 | warnings.filterwarnings( 16 | "ignore", 17 | "Dataset has no geotransform", 18 | NotGeoreferencedWarning, 19 | ) 20 | yield 21 | 22 | 23 | @contextlib.contextmanager 24 | def ignore_pyproj_proj_warnings(): 25 | """Wrap operations that we know will produce a PROJ.4 precision warning. 26 | 27 | Only to be used internally to Pyresample when we have no other choice but 28 | to use PROJ.4 strings/dicts. For example, serialization to YAML or other 29 | human-readable formats or testing the methods that produce the PROJ.4 30 | versions of the CRS. 31 | 32 | """ 33 | with warnings.catch_warnings(): 34 | warnings.filterwarnings( 35 | "ignore", 36 | "You will likely lose important projection information", 37 | UserWarning, 38 | ) 39 | yield 40 | -------------------------------------------------------------------------------- /polar2grid/writers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | """Wrappers around Satpy writers.""" 24 | -------------------------------------------------------------------------------- /swbundle/GEO2GRID_README.txt: -------------------------------------------------------------------------------- 1 | Geo2Grid software bundle 2 | ======================== 3 | 4 | Copyright (C) 2012-2022 Space Science and Engineering Center (SSEC), University of Wisconsin-Madison. 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | This file is part of the geo2grid software package. Geo2grid takes 20 | satellite observation data, remaps it, and writes it to a file format for 21 | input into another program. 22 | Documentation: http://www.ssec.wisc.edu/software/geo2grid/ 23 | 24 | Written by David Hoese February 2019 25 | University of Wisconsin-Madison 26 | Space Science and Engineering Center 27 | 1225 West Dayton Street 28 | Madison, WI 53706 29 | david.hoese@ssec.wisc.edu 30 | 31 | Original scripts and automation included as part of this package are 32 | distributed under the GNU GENERAL PUBLIC LICENSE agreement version 3. 33 | Binary executable files included as part of this software package are 34 | copyrighted and licensed by their respective organizations, and 35 | distributed consistent with their licensing terms. 36 | 37 | Installation 38 | ============ 39 | 40 | 1. Untar the tarball: 41 | # if you're reading this, this step is probably complete already 42 | tar -xzf geo2grid-swbundle-.tar.gz 43 | 2. Add the following line to your .bash_profile or .bashrc: 44 | export GEO2GRID_HOME=/path/to/untarred-swbundle-dir 45 | 46 | To run a geo2grid script 47 | ======================== 48 | 49 | The geo2grid script can be run directly from the bin directory: 50 | 51 | $GEO2GRID_HOME/bin/geo2grid.sh ... 52 | 53 | or 54 | 55 | $GEO2GRID_HOME/bin/geo2grid.sh --help 56 | 57 | for more help. 58 | 59 | Geo2Grid Documentation: http://www.ssec.wisc.edu/software/geo2grid/ 60 | CSPP Geo Home Page: http://cimss.ssec.wisc.edu/csppgeo/ 61 | -------------------------------------------------------------------------------- /swbundle/POLAR2GRID_README.txt: -------------------------------------------------------------------------------- 1 | Polar2Grid software bundle 2 | ========================== 3 | 4 | Copyright (C) 2012-2022 Space Science and Engineering Center (SSEC), University of Wisconsin-Madison. 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | This file is part of the polar2grid software package. Polar2grid takes 20 | satellite observation data, remaps it, and writes it to a file format for 21 | input into another program. 22 | Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | 24 | Written by David Hoese February 2019 25 | University of Wisconsin-Madison 26 | Space Science and Engineering Center 27 | 1225 West Dayton Street 28 | Madison, WI 53706 29 | david.hoese@ssec.wisc.edu 30 | 31 | Original scripts and automation included as part of this package are 32 | distributed under the GNU GENERAL PUBLIC LICENSE agreement version 3. 33 | Binary executable files included as part of this software package are 34 | copyrighted and licensed by their respective organizations, and 35 | distributed consistent with their licensing terms. 36 | 37 | Installation 38 | ============ 39 | 40 | 1. Untar the tarball: 41 | # if you're reading this, this step is probably complete already 42 | tar -xzf polar2grid-swbundle-.tar.gz 43 | 2. Add the following line to your .bash_profile or .bashrc: 44 | export POLAR2GRID_HOME=/path/to/untarred-swbundle-dir 45 | 46 | To run a polar2grid script 47 | ========================== 48 | 49 | The polar2grid script can be run directly from the bin directory: 50 | 51 | $POLAR2GRID_HOME/bin/polar2grid.sh ... 52 | 53 | or 54 | 55 | $POLAR2GRID_HOME/bin/polar2grid.sh --help 56 | 57 | for more help. 58 | 59 | Polar2Grid Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 60 | CSPP LEO Home Page: http://cimss.ssec.wisc.edu/cspp/ 61 | -------------------------------------------------------------------------------- /swbundle/add_coastlines.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese December 2014 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | 31 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 32 | 33 | # Setup necessary environments 34 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 35 | 36 | # Call the python module to do the processing, passing all arguments 37 | python3 -m polar2grid.add_coastlines "$@" 38 | -------------------------------------------------------------------------------- /swbundle/add_colormap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese December 2014 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | 31 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 32 | 33 | # Setup necessary environments 34 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 35 | 36 | # Call the python module to do the processing, passing all arguments 37 | python3 -m polar2grid.add_colormap "$@" 38 | -------------------------------------------------------------------------------- /swbundle/convert_grids_conf_to_yaml.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | 24 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 25 | 26 | # Setup necessary environments 27 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 28 | 29 | # Call the python module to do the processing, passing all arguments 30 | export PROG_NAME="convert_grids_conf_to_yaml.sh" 31 | python3 -m polar2grid.utils.convert_grids_conf_to_yaml "$@" 32 | -------------------------------------------------------------------------------- /swbundle/download_pyspectral_data.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Copyright (C) 2018 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese December 2014 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | 31 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 32 | 33 | # Setup necessary environments 34 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 35 | 36 | set -e 37 | 38 | ORIG_PSP_DATA_ROOT=${PSP_DATA_ROOT} 39 | if [ -n "${PSP_DATA_CACHE_ROOT}" ]; then 40 | echo "Using pyspectral data cache root: ${PSP_DATA_CACHE_ROOT}" 41 | export PSP_DATA_ROOT=${PSP_DATA_CACHE_ROOT} 42 | fi 43 | 44 | # Call the python module to do the processing, passing all arguments 45 | python3 -c "from pyspectral.rayleigh import check_and_download; import logging; logging.basicConfig(level=logging.DEBUG); check_and_download()" 46 | python3 -c "from pyspectral.rsr_reader import check_and_download; import logging; logging.basicConfig(level=logging.DEBUG); check_and_download()" 47 | 48 | if [ -n "${PSP_DATA_CACHE_ROOT}" ]; then 49 | mkdir -p "${ORIG_PSP_DATA_ROOT}" 50 | cp -r ${PSP_DATA_CACHE_ROOT}/* "${ORIG_PSP_DATA_ROOT}/" 51 | export PSP_DATA_ROOT=${ORIG_PSP_DATA_ROOT} 52 | fi 53 | -------------------------------------------------------------------------------- /swbundle/example_enhancements/amsr2_png/enhancements/generic.yaml: -------------------------------------------------------------------------------- 1 | enhancements: 2 | amsr2_btemp_36.5v: 3 | name: btemp_36.5v 4 | sensor: amsr2 5 | standard_name: toa_brightness_temperature 6 | operations: 7 | - name: linear_stretch 8 | method: !!python/name:satpy.enhancements.stretch 9 | kwargs: {stretch: 'crude', min_stretch: 180.0, max_stretch: 280.0} 10 | amsr2_btemp_36.5h: 11 | name: btemp_36.5h 12 | sensor: amsr2 13 | standard_name: toa_brightness_temperature 14 | operations: 15 | - name: linear_stretch 16 | method: !!python/name:satpy.enhancements.stretch 17 | kwargs: {stretch: 'crude', min_stretch: 180.0, max_stretch: 280.0} 18 | amsr2_btemp_89.0av: 19 | name: btemp_89.0av 20 | sensor: amsr2 21 | standard_name: toa_brightness_temperature 22 | operations: 23 | - name: linear_stretch 24 | method: !!python/name:satpy.enhancements.stretch 25 | kwargs: {stretch: 'crude', min_stretch: 180.0, max_stretch: 280.0} 26 | amsr2_btemp_89.0ah: 27 | name: btemp_89.0ah 28 | sensor: amsr2 29 | standard_name: toa_brightness_temperature 30 | operations: 31 | - name: linear_stretch 32 | method: !!python/name:satpy.enhancements.stretch 33 | kwargs: {stretch: 'crude', min_stretch: 180.0, max_stretch: 280.0} 34 | amsr2_btemp_89.0bv: 35 | name: btemp_89.0bv 36 | sensor: amsr2 37 | standard_name: toa_brightness_temperature 38 | operations: 39 | - name: linear_stretch 40 | method: !!python/name:satpy.enhancements.stretch 41 | kwargs: {stretch: 'crude', min_stretch: 180.0, max_stretch: 280.0} 42 | amsr2_btemp_89.0bh: 43 | name: btemp_89.0bh 44 | sensor: amsr2 45 | standard_name: toa_brightness_temperature 46 | operations: 47 | - name: linear_stretch 48 | method: !!python/name:satpy.enhancements.stretch 49 | kwargs: {stretch: 'crude', min_stretch: 180.0, max_stretch: 280.0} 50 | -------------------------------------------------------------------------------- /swbundle/geo2grid.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese December 2014 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | 31 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 32 | 33 | # Setup necessary environments 34 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 35 | 36 | # Set best known defaults for number of OpenMP threads 37 | export OMP_NUM_THREADS=${OMP_NUM_THREADS:-2} 38 | 39 | # Call the python module to do the processing, passing all arguments 40 | export PROG_NAME="geo2grid.sh" 41 | export USE_POLAR2GRID_DEFAULTS=0 42 | python3 -m polar2grid.glue "$@" -vv 43 | -------------------------------------------------------------------------------- /swbundle/geocat2scmi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # encoding: utf-8 3 | """Convert GEOCAT Level 1 and 2 products to AWIPS SCMI format. 4 | 5 | Run with the following command from the Polar2Grid Software Bundle: 6 | 7 | source /path/to/polar2grid/bin/env.sh 8 | python geocat2scmi.py ... 9 | 10 | Use `-h` flag for help and usage information. 11 | 12 | FUTURE: This script will be included in the functionality of the CSPP Geo2Grid package 13 | 14 | """ 15 | 16 | import logging 17 | import sys 18 | 19 | 20 | def add_scene_argument_groups(parser): 21 | group_1 = parser.add_argument_group(title="Scene Initialization") 22 | group_1.add_argument("reader", help="Name of reader used to read provided files") 23 | group_1.add_argument("-f", "--filenames", nargs="+", help="Input files to read") 24 | group_2 = parser.add_argument_group(title="Scene Load") 25 | group_2.add_argument("-d", "--datasets", nargs="+", help="Names of datasets to load from input files") 26 | return group_1, group_2 27 | 28 | 29 | def main(): 30 | import argparse 31 | 32 | from satpy import Scene 33 | 34 | from polar2grid.writers.awips_tiled import add_writer_argument_groups 35 | 36 | parser = argparse.ArgumentParser(description="Convert GEOCAT Level 1 and 2 to AWIPS SCMI files") 37 | parser.add_argument( 38 | "-v", 39 | "--verbose", 40 | dest="verbosity", 41 | action="count", 42 | default=0, 43 | help="each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG (default INFO)", 44 | ) 45 | parser.add_argument("-l", "--log", dest="log_fn", default=None, help="specify the log filename") 46 | subgroups = add_scene_argument_groups(parser) 47 | subgroups += add_writer_argument_groups(parser) 48 | args = parser.parse_args() 49 | 50 | scene_args = {ga.dest: getattr(args, ga.dest) for ga in subgroups[0]._group_actions} 51 | load_args = {ga.dest: getattr(args, ga.dest) for ga in subgroups[1]._group_actions} 52 | writer_init_args = {ga.dest: getattr(args, ga.dest) for ga in subgroups[2]._group_actions} 53 | writer_call_args = {ga.dest: getattr(args, ga.dest) for ga in subgroups[3]._group_actions} 54 | 55 | levels = [logging.ERROR, logging.WARN, logging.INFO, logging.DEBUG] 56 | logging.basicConfig(level=levels[min(3, args.verbosity)], filename=args.log_fn) 57 | 58 | scn = Scene(**scene_args) 59 | scn.load(load_args["datasets"]) 60 | writer_args = {} 61 | writer_args.update(writer_init_args) 62 | writer_args.update(writer_call_args) 63 | scn.save_datasets(writer="scmi", **writer_args) 64 | 65 | 66 | if __name__ == "__main__": 67 | sys.exit(main()) 68 | -------------------------------------------------------------------------------- /swbundle/gtiff2kmz.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Usage: gtiff2kmz.sh input.tif [output.kmz] 4 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 5 | # University of Wisconsin-Madison. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | # 20 | # This file is part of the polar2grid software package. Polar2grid takes 21 | # satellite observation data, remaps it, and writes it to a file format for 22 | # input into another program. 23 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 24 | # 25 | # Written by David Hoese December 2014 26 | # University of Wisconsin-Madison 27 | # Space Science and Engineering Center 28 | # 1225 West Dayton Street 29 | # Madison, WI 53706 30 | # david.hoese@ssec.wisc.edu 31 | 32 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 33 | 34 | # Setup necessary environments 35 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 36 | 37 | # Call the python module to do the processing, passing all arguments 38 | # Similar, but not as nice of an image: 39 | # ${P2G_SHELLB3_DIR}/bin/gdal_translate -of KMLSUPEROVERLAY -co FORMAT=JPEG $@ 40 | 41 | if [ $# -eq 1 ]; then 42 | input_fn=$1 43 | tile_dir=${input_fn/.tif/} 44 | output_fn=${input_fn/.tif/.kmz} 45 | elif [ $# -eq 2 ]; then 46 | input_fn=$1 47 | output_fn=$2 48 | tile_dir=${input_fn/.tif/} 49 | else 50 | echo "Usage: gtiff2kmz.sh input.tif [output.kmz]" 51 | exit 1 52 | fi 53 | 54 | if [ $input_fn = "-h" ] || [ $input_fn = "--help" ] || [ $output_fn = "-h" ] || [ $output_fn = "--help" ]; then 55 | echo "Usage: gtiff2kmz.sh input.tif [output.kmz]" 56 | exit 1 57 | fi 58 | 59 | # Create a tiled KML directory 60 | echo "Creating temporary tiled KML directory..." 61 | gdal2tiles.py -p geodetic $input_fn $tile_dir || { echo "ERROR: Could not create tiled KML"; exit 1; } 62 | 63 | # Zip the KML directory in to a KMZ file 64 | echo "Zipping KML directory in to a KMZ..." 65 | abs_output_fn=$(readlink -f $output_fn) 66 | cd $tile_dir 67 | zip -r ${abs_output_fn} ./* || { echo "ERROR: Could not create zipped KMZ"; exit 1; } 68 | cd .. 69 | 70 | echo "Removing temporary tiled KML directory" 71 | rm -r $tile_dir 72 | 73 | echo "Done" 74 | -------------------------------------------------------------------------------- /swbundle/p2g_compare.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ### Verify simple test products with known products ### 3 | # 4 | # Copyright (C) 2021 Space Science and Engineering Center (SSEC), 5 | # University of Wisconsin-Madison. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | # 20 | # This file is part of the polar2grid software package. Polar2grid takes 21 | # satellite observation data, remaps it, and writes it to a file format for 22 | # input into another program. 23 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 24 | 25 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 26 | 27 | # Setup necessary environments 28 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 29 | 30 | # Run tests for each test data directory in the base directory 31 | python3 -m polar2grid.compare -vv "$@" 32 | -------------------------------------------------------------------------------- /swbundle/p2g_grid_helper.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ### Run simple python script to print out a valid polar2grid grid 3 | ### configuration line. 4 | # 5 | # Copyright (C) 2013 Space Science and Engineering Center (SSEC), 6 | # University of Wisconsin-Madison. 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 3 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | # 21 | # This file is part of the polar2grid software package. Polar2grid takes 22 | # satellite observation data, remaps it, and writes it to a file format for 23 | # input into another program. 24 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 25 | # 26 | # Written by David Hoese April 2013 27 | # University of Wisconsin-Madison 28 | # Space Science and Engineering Center 29 | # 1225 West Dayton Street 30 | # Madison, WI 53706 31 | # david.hoese@ssec.wisc.edu 32 | 33 | if [ -z "$POLAR2GRID_HOME" ]; then 34 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 35 | fi 36 | 37 | # Setup necessary environments 38 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 39 | 40 | # Call the script 41 | export PROG_NAME="p2g_grid_helper.sh" 42 | python3 -m polar2grid.grids.config_helper "$@" 43 | -------------------------------------------------------------------------------- /swbundle/polar2grid.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 4 | # University of Wisconsin-Madison. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # This file is part of the polar2grid software package. Polar2grid takes 20 | # satellite observation data, remaps it, and writes it to a file format for 21 | # input into another program. 22 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 23 | # 24 | # Written by David Hoese December 2014 25 | # University of Wisconsin-Madison 26 | # Space Science and Engineering Center 27 | # 1225 West Dayton Street 28 | # Madison, WI 53706 29 | # david.hoese@ssec.wisc.edu 30 | 31 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 32 | 33 | # Setup necessary environments 34 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 35 | 36 | # Set best known defaults for number of OpenMP threads 37 | export OMP_NUM_THREADS=${OMP_NUM_THREADS:-2} 38 | 39 | # Call the python module to do the processing, passing all arguments 40 | export PROG_NAME="polar2grid.sh" 41 | export USE_POLAR2GRID_DEFAULTS=1 42 | python3 -m polar2grid.glue "$@" -vv 43 | -------------------------------------------------------------------------------- /swbundle/polar2grid_env.sh: -------------------------------------------------------------------------------- 1 | env.sh -------------------------------------------------------------------------------- /swbundle/reproject_goes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # encoding: utf-8 3 | # Usage: reproject_goes.sh input1.tif input2.tif ... 4 | # Copyright (C) 2014 Space Science and Engineering Center (SSEC), 5 | # University of Wisconsin-Madison. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program. If not, see . 19 | # 20 | # This file is part of the polar2grid software package. Polar2grid takes 21 | # satellite observation data, remaps it, and writes it to a file format for 22 | # input into another program. 23 | # Documentation: http://www.ssec.wisc.edu/software/polar2grid/ 24 | # 25 | # Written by David Hoese November 2018 26 | # University of Wisconsin-Madison 27 | # Space Science and Engineering Center 28 | # 1225 West Dayton Street 29 | # Madison, WI 53706 30 | # david.hoese@ssec.wisc.edu 31 | 32 | export POLAR2GRID_HOME="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && cd .. && pwd )" 33 | 34 | # Setup necessary environments 35 | # __SWBUNDLE_ENVIRONMENT_INJECTION__ 36 | set -e 37 | 38 | if [[ $# -lt 1 ]]; then 39 | >&2 echo "Usage: reproject_goes.sh input1.tif input2.tif" 40 | exit 1 41 | fi 42 | 43 | INPUT_FILES="$@" 44 | for fn in $INPUT_FILES; do 45 | new_fn=${fn/.tif/-y.tif} 46 | current_proj=`gdalinfo -proj4 $fn | grep -A 1 "PROJ.4 string is:" | tail -n 1` 47 | new_proj=${current_proj/+sweep=x/+sweep=y} 48 | echo "Reprojecting $fn to $new_proj..." 49 | gdalwarp -t_srs "$new_proj" -multi -wo "NUM_THREADS=4" -co "COMPRESS=DEFLATE" $fn $new_fn 50 | done 51 | --------------------------------------------------------------------------------