9. Utility Scripts

The following are scripts that can be used to help analyze and/or verify polar2grid operations.

9.1. Grid Config. Helper

This script is meant to help those unfamiliar with PROJ.4 and projections in general. By providing a few grid parameters this script will provide a grid configuration line that can be added to a user’s custom grid configuration. Based on a center longitude and latitude, the script will choose an appropriate projection.

usage: p2g_grid_helper.sh [-h] [-p PROJ_STR]
                          grid_name center_longitude center_latitude
                          pixel_size_x pixel_size_y grid_width grid_height
Positional arguments:
grid_name Unique grid name
center_longitude
 Decimal longitude value for center of grid (-180 to 180)
center_latitude
 Decimal latitude value for center of grid (-90 to 90)
pixel_size_x Size of each pixel in the X direction in grid units, meters for default projections.
pixel_size_y Size of each pixel in the Y direction in grid units, meters for default projections.
grid_width Grid width in number of pixels
grid_height Grid height in number of pixels
Options:
-p PROJ.4 projection string to override the default

Example:

$POLAR2GRID_HOME/bin/p2g_grid_helper.sh my_grid_name -150.1 56.3 250 -250 1000 1000
# Will result in:
my_grid_name, +proj=lcc +datum=WGS84 +ellps=WGS84 +lat_0=56.300 +lat_1=56.300 +lon_0=-150.100 +units=m +no_defs, 1000, 1000, 250.000, -250.000, -125000.000, 125000.000

The above example creates a grid named ‘my_grid_name’ at a 250m resolution, 1000 pixels wide and heigh, and centered at -150.1 degrees longitude and 56.3 degrees latitude. The projection is a lambert conic conformal projection chosen based on the center longitude and latitude.

9.2. Python Proj

Convert lon/lat points to X/Y values

usage: p2g_proj.sh [-h] [-i] proj4_str lon_point lat_point
Positional arguments:
proj4_str PROJ.4 projection string (in quotes)
lon_point Longitude of the point to be converted (single value only)
lat_point Latitude of the point to be converted (single value only)
Options:
-i=False, --inverse=False
 Convert X/Y values to lon/lat

Example:

$POLAR2GRID_HOME/bin/p2g_proj.sh "+proj=lcc +datum=NAD83 +ellps=GRS80 +lat_1=25 +lon_0=-95" -105.23 38.5
# Will result in:
-878781.238459 4482504.91307

9.3. Plot AWIPS NC Data

This script will read a series of NetCDF3 files created using the AWIPS backend and plot the data on a b/w color scale. It searches for any NetCDF files with the prefix SSEC_AWIPS_.

usage: plot_ncdata.sh [-h] [--vmin VMIN] [--vmax VMAX] [-p BASE_PAT] [-d DPI]
                      [-c]
                      [search_dir [search_dir ...]]
Positional arguments:
search_dir Directory to search for NetCDF3 files, default is ‘.’
Options:
--vmin Specify minimum brightness value. Defaults to minimum value of data.
--vmax Specify maximum brightness value. Defaults to maximum value of data.
-p=SSEC_AWIPS_*, --pat=SSEC_AWIPS_*
 Specify the glob pattern of NetCDF files to look for. Defaults to ‘SSEC_AWIPS_*’
-d=100, --dpi=100
 Specify the dpi for the resulting figure, higher dpi will result in larger figures and longer run times
-c=False Include this flag if you wish to compare two specific files