rain sunny dry-cloudy rain 0.6 0.2 0.2 sunny 0.3 0.5 0.2 dry-cloudy 0.4 0.3 0.3 #### $ ./2.icons.pl { "\@context" => [], "icons" => { bkn => { description => "Mostly cloudy" }, blizzard => { description => "Blizzard" }, cold => { description => "Cold" }, dust => { description => "Dust" }, few => { description => "A few clouds" }, fog => { description => "Fog/mist" }, fzra => { description => "Freezing rain" }, haze => { description => "Haze" }, hot => { description => "Hot" }, hurricane => { description => "Hurricane conditions" }, ovc => { description => "Overcast" }, rain => { description => "Rain" }, rain_fzra => { description => "Rain/freezing rain" }, rain_showers => { description => "Rain showers (high cloud cover)" }, rain_showers_hi => { description => "Rain showers (low cloud cover)" }, rain_sleet => { description => "Rain/sleet" }, rain_snow => { description => "Rain/snow" }, sct => { description => "Partly cloudy" }, skc => { description => "Fair/clear" }, sleet => { description => "Sleet" }, smoke => { description => "Smoke" }, snow => { description => "Snow" }, snow_fzra => { description => "Freezing rain/snow" }, snow_sleet => { description => "Rain/sleet" }, tornado => { description => "Tornado" }, tropical_storm => { description => "Tropical storm conditions" }, tsra => { description => "Thunderstorm (high cloud cover)" }, tsra_hi => { description => "Thunderstorm (low cloud cover)" }, tsra_sct => { description => "Thunderstorm (medium cloud cover)" }, wind_bkn => { description => "Mostly cloudy and windy" }, wind_few => { description => "A few clouds and windy" }, wind_ovc => { description => "Overcast and windy" }, wind_sct => { description => "Partly cloudy and windy" }, wind_skc => { description => "Fair/clear and windy" }, }, } ======================== Stochastic Matrix with side: hurricane rain_showers_hi few fzra rain_snow bkn snow_fzra snow snow_sleet wind_ovc blizzard cold smoke tropical_storm skc haze wind_few sct rain sleet ovc tsra tornado tsra_sct hot fog wind_bkn rain_fzra dust wind_sct tsra_hi rain_showers rain_sleet wind_skc ======================== URL = https://api.weather.gov/icons/land/day/tsra_sct,20/tsra_sct,40?size=medium tsra_sct => 'Thunderstorm (medium cloud cover)' URL = https://api.weather.gov/icons/land/day/rain_showers,30/tsra_hi,30?size=medium tsra_hi => 'Thunderstorm (low cloud cover)' URL = https://api.weather.gov/icons/land/night/rain_showers,30/rain_showers?size=medium rain_showers => 'Rain showers (high cloud cover)' URL = https://api.weather.gov/icons/land/day/bkn?size=medium bkn => 'Mostly cloudy' $ cat 2.icons.pl #!/usr/bin/perl -w use strict; use LWP::UserAgent; use Data::Dump; use JSON::Parse 'parse_json'; use 5.016; my $ua = LWP::UserAgent->new( 'send_te' => '0' ); my $r = HTTP::Request->new( 'GET' => 'https://api.weather.gov/icons', [ 'Cache-Control' => 'max-age=0', 'Connection' => 'keep-alive', 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding' => 'gzip, x-gzip, deflate, x-bzip2, bzip2', 'Accept-Language' => 'en-US,en;q=0.5', 'Host' => 'api.weather.gov:443', 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0', 'Upgrade-Insecure-Requests' => '1', ], ); my $out; my $res = $ua->request( $r, ); if ( $res->is_success ) { my $json = $res->decoded_content; $out = parse_json $json; } else { print "Error: " . $res->status_line . "\n"; } dd $out; my %xlated_abbrev; #simple abbreviation table => description foreach my $key ( keys %{ $out->{icons} } ) #gen simple xlate table { $xlated_abbrev{$key} = $out->{icons}{$key}{description}; } my @keys2 = keys %xlated_abbrev; say "========================"; say "Stochastic Matrix with side: "; for (@keys2){ say "$_"; }; say "========================"; my @urls = ( 'https://api.weather.gov/icons/land/day/tsra_sct,20/tsra_sct,40?size=medium', 'https://api.weather.gov/icons/land/day/rain_showers,30/tsra_hi,30?size=medium', 'https://api.weather.gov/icons/land/night/rain_showers,30/rain_showers?size=medium', 'https://api.weather.gov/icons/land/day/bkn?size=medium' ); foreach my $url (@urls) { my $last_path = ( split( '/', $url ) )[-1]; my ($abbrev_to_xlate) = $last_path =~ /^(\w+)/; print "URL = $url\n"; print " $abbrev_to_xlate => \'$xlated_abbrev{$abbrev_to_xlate}\'\n\n"; } __END__ Created from curl command line curl 'https://api.weather.gov/icons' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'Cache-Control: max-age=0' $