{"id":54030,"date":"2023-08-18T18:55:12","date_gmt":"2023-08-18T18:55:12","guid":{"rendered":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/?p=54030"},"modified":"2023-08-18T19:20:45","modified_gmt":"2023-08-18T19:20:45","slug":"creating-customized-brightness-temperature-ranges-in-polar2grid","status":"publish","type":"post","link":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/archives\/54030","title":{"rendered":"Creating customized brightness temperature ranges in Polar2Grid"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison-1024x768.png\" alt=\"\" class=\"wp-image-54031\" srcset=\"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison-1024x768.png 1024w, https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison-300x225.png 300w, https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison-768x576.png 768w, https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison.png 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">NOAA-21 I05 Infrared (11.45 \u00b5m) Brightness Temperatures scaled from 230-300 K (Click to enlarge)<\/figcaption><\/figure>\n\n\n\n<p>Polar2Grid is a powerful software package that enables a user to take Sensor Data Record (SDR) files from JPSS satellites (Suomi-NPP, NOAA-20, NOAA-21) and create high-quality georeferenced imagery that can be color-enhanced.  (Polar2Grid also works with data from other polar orbiting satellites!) This blog post details how to scale an infrared image to specific brightness temperature bounds that are then shown with a colorbar embedded into the image.  This is similar to what is done with ACSPO Sea Surface Temperatures as discussed in <a href=\"https:\/\/www.ssec.wisc.edu\/software\/polar2grid\/examples\/acspo_example.html\">this online documentation<\/a>.  Data for this example were downloaded from the CIMSS Direct Broadcast site.  I wanted to show I05 VIIRS imagery (11.45 \u00b5m) so I downloaded both the SVI05 and GIMGO hdf files on 16 August 2023 covering the times 0832 and 0840 UTC.  These data, <a href=\"https:\/\/www.ssec.wisc.edu\/datacenter\/polar_orbit_tracks\/data\/NOAA21\/2023\/2023_08_16_228\/NA.gif\">from NOAA-21<\/a>, can came from the directory <a href=\"https:\/\/bin.ssec.wisc.edu\/pub\/eosdb\/j02\/viirs\/2023_08_16_228_0828\/sdr\/\">https:\/\/bin.ssec.wisc.edu\/pub\/eosdb\/j02\/viirs\/2023_08_16_228_0828\/sdr\/<\/a> (this directory will be purged on 8\/23).    You can also get these data from NOAA CLASS, or from online web services such as Amazon Web Services (<a href=\"https:\/\/noaa-nesdis-n21-pds.s3.amazonaws.com\/index.html\">AWS link for NOAA-21<\/a>).  Before invoking the Polar2Grid commands to create the imagery, you must specify the I05 Brightness Temperatures of interest, done by adding the following snippet of code to the <code>viirs.yaml<\/code> file that can be found in this directory:  <code>$POLAR2GRID_HOME\/etc\/polar2grid\/enhancements\/<\/code>  In the case below, I&#8217;m interested initially just in the values between 170 and 330 Kelvin, using a linear stretch.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> I05:\n    name: I05\n    sensor: viirs\n    operations:\n      - name: linear_stretch\n        method: !!python\/name:satpy.enhancements.stretch\n        kwargs: {stretch: 'crude', min_stretch: 170., max_stretch: 330.}<\/code><\/pre>\n\n\n\n<p>Next, run the Polar2Grid commands to specify (optionally) a region of interest, and to generate the tif file of the imagery in that specified domain.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$POLAR2GRID_HOME\/bin\/p2g_grid_helper.sh Madison -89.0 43.8 375.0 -375.0 1280 960 &gt; $POLAR2GRID_HOME\/bin\/MSN.yaml\n\n$POLAR2GRID_HOME\/bin\/polar2grid.sh -r viirs_sdr -w geotiff -p i05 -g Madison --grid-configs $POLAR2GRID_HOME\/bin\/MSN.yaml -f \/path\/to\/downloaded\/SVI05andGIMGOFiles.h5<\/code><\/pre>\n\n\n\n<p>The commands above create a tif file:  <code>noaa21_viirs_i05_20230816_083259_Madison.tif<\/code>.  The first of the two commands below adds a color enhancement to the tif file; the second adds coastlines and a colorbar to the tif file and outputs a png file: <code>noaa21_viirs_i05_20230816_083259_Madison.png<\/code> .  That image, scaled from 170 to 330 K, is shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n$POLAR2GRID_HOME\/bin\/add_colormap.sh $POLAR2GRID_HOME\/colormaps\/p2g_sst_palette.txt noaa21_viirs_i05_20230816_083259_Madison.tif \n\n$POLAR2GRID_HOME\/bin\/add_coastlines.sh --add-coastlines --coastlines-resolution f --add-colorbar noaa21_viirs_i05_20230816_083259_Madison.tif \n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison_170to330.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison_170to330-1024x768.png\" alt=\"\" class=\"wp-image-54032\" style=\"width:1086px;height:768px\" width=\"1086\" height=\"768\"\/><\/a><figcaption class=\"wp-element-caption\">NOAA-21 I05 Infrared (11.45 \u00b5m) Brightness Temperatures scaled from 170-330 K (Click to enlarge)<\/figcaption><\/figure>\n\n\n\n<p>It&#8217;s apparent above that the range chosen for the image above is too broad.  So, edit the I05 definition in the viirs.yaml file shown up top, changing the one line to this: <code>kwargs: {stretch: 'crude', min_stretch: 230., max_stretch: 300.}<\/code>.  Then, rerun the <code>polar2grid, add_colorbar <\/code>and<code> add_coastlines<\/code> commands above.  The result below shows a toggle between those two results.  Note how things change as you might expect.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison_170to330_230to300_toggle.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"960\" src=\"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-content\/uploads\/sites\/5\/2023\/08\/noaa21_viirs_i05_20230816_083259_Madison_170to330_230to300_toggle.gif\" alt=\"\" class=\"wp-image-54034\"\/><\/a><figcaption class=\"wp-element-caption\">NOAA-21 I05 Infrared (11.45 \u00b5m) Brightness Temperatures scaled two different ways (Click to enlarge)<\/figcaption><\/figure>\n\n\n\n<p>The image with more color contrast from cold to warm shown above is the same one as shown at the top of the image, but I&#8217;ve modified the presentation of the coastlines and colorbar in the add_coastlines command:  <code>$POLAR2GRID_HOME\/bin\/add_coastlines.sh --add-coastlines --coastlines-resolution f --add-colorbar --colorbar-text-size 16 --colorbar-height 32 noaa21_viirs_i05_20230816_083259_Madison.tif<\/code><\/p>\n\n\n\n<p>Polar2Grid software can be downloaded from <a href=\"https:\/\/cimss.ssec.wisc.edu\/cspp\/download\/\">this website<\/a>;  Polar2Grid documentation is <a href=\"https:\/\/www.ssec.wisc.edu\/software\/polar2grid\/\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Polar2Grid is a powerful software package that enables a user to take Sensor Data Record (SDR) files from JPSS satellites (Suomi-NPP, NOAA-20, NOAA-21) and create high-quality georeferenced imagery that can be color-enhanced. (Polar2Grid also works with data from other polar orbiting satellites!) This blog post details how to scale an infrared image to specific brightness [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":54031,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[131,109,39],"tags":[],"class_list":["post-54030","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-noaa-21","category-software","category-training"],"acf":[],"_links":{"self":[{"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/posts\/54030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/comments?post=54030"}],"version-history":[{"count":7,"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/posts\/54030\/revisions"}],"predecessor-version":[{"id":54041,"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/posts\/54030\/revisions\/54041"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/media\/54031"}],"wp:attachment":[{"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/media?parent=54030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/categories?post=54030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cimss.ssec.wisc.edu\/satellite-blog\/wp-json\/wp\/v2\/tags?post=54030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}