#!/usr/bin/perl ############################################################################ # zsolt.szabo@noaa.gov # # use: buildpage [model name] [cycle] [size] # # # # model name={nam,gfs,...} # # cycle={0,6,12,18} # # size={s,m,l} # # Note: for the HiRES, the graphics are always large, so in this case # # the size parameter is used instead to indicate the model type, # # where "m" = ARW and "l" = NMM # # # ############################################################################ # Turn on/off debug printing. # # 0 = No debugging # 1 = Some debugging # 2 = Verbose debugging #$DEBUG=0; #$DEBUG=1; $DEBUG=2; if ($ENV{USHgempak}) { $scriptdir=$ENV{USHgempak}; } else { die "Please define ENV USHgempak.\n"; } sub init_defs; sub get_fp_vars; sub get_cr; sub ch_col_name; sub do_main_hdr; sub do_main_hd2; sub do_stat_pge; sub do_fp_hdr; sub do_tp_hdr; sub pr_col_name; sub pr_col_nam2; sub gen_body_rtma; sub gen_body; sub gen_bod2; sub gen_body_gens; sub build_fp_page; sub pr_col_name2; sub pr_col_nam22; sub createLoopHTML; sub createLoopHTMLIndex; init_defs; # initialize default variables, etc. get_cr; # determine rows and column names if ($model =~ "hiresw") { if ($clnv == 0) { print "No gifs present for WRF \n"; do_stat_pge; exit; } } $cln2=0; if ($ENV{REGION}) {$region=$ENV{REGION}; } else { die "You must define environment variable REGION.\n"; } $mod=$model; if ($model =~ "storm") { if($region =~ /hur/) { $mod= "hur"; } if($region =~ /hwrf/) { $mod= "hwrf"; } } if ($model =~ "gfs") { if ($region =~ "epac") { $cln2=8; $colnm=8; } else { $cln2=10; $colnm=10; } } ch_col_name; # change column names to descriptive titles # Here we build the web page and write it out to $ofile (which is # defined above as $modhtml/model_[size].shtml) $ofa="$modhtms/model_${siz}.shtml"; # HTML output filename, relative to root directory for website $ofile="${ofa}"; # Fully-qualified HTML output filename if ($model =~ "gfs") { # GFS model is split across 2 web pages $ofb="$modhtms/model_${siz}u.shtml"; $ofil2="${ofb}"; } $fpcf="$modhtms/fpc.shtml"; # HTML output filename for 4-panel chart $tpcf="$modhtms/tpc.shtml"; # HTML output filename for 2-panel chart print " opening MFF ${ofile}\n"; open (MFF, ">${ofile}"); if ($model =~ "gfs") { print " opening MF2 ${ofil2}\n"; open (MF2, ">${ofil2}"); } open (FPC, ">${fpcf}"); if($model =~ "sto" ) { open (TPC, ">${tpcf}"); } if ($DEBUG > 0) { print " fpcf is $fpcf \n"; } get_fp_vars; # do_main_hdr; # print main html header do_fp_hdr; # print four panel html header if($model =~ "sto" ) { do_tp_hdr; } pr_col_name; # print column names in main page # generate the main page if ($model =~ "rtma" ) { gen_body_rtma; } else { if ($model =~ "gens") { gen_body_gens; } else { gen_body; } if ($model =~ "gfs"){ do_main_hd2; pr_col_nam2; gen_bod2; } # # Create the 2 panel html files for the # if($model =~ "sto"){ @args_s=("$scriptdir/make2p_html.sh $model"); if (system(@args_s) != 0) { $mstrg="Couldn't build html files \nAborted.\n"; } } exit 0; ############################################################################ ######################################################################### # Initial definitions and tests # Define some constants, make sure we have the right number and type of # arguments. sub init_defs { # turn off I/O buffering $| = 1; if ($DEBUG > 1) { print "Entering init_defs...\n"; } if ($#ARGV != 2) { die "Usage: build_model_page [model name] [cycle] [size]\n"; } $model=$ARGV[0]; $cycle=$ARGV[1]; $siz=$ARGV[2]; # siz=image size (different pages created for each # image size: small, medium, large) # basep - the root directory, up to the location where the model dirs live # model - the name of the model (gfs,nam, etc.) # title - the title given for the table; it is derived from the model name # cycle - (00,06, etc.) # siz - three web pages are built, one for each size (s,m,l) if ($ENV{envir}) { $envir=$ENV{envir}; } else { die "You must define environment variable envir.\n"; } if ($ENV{DATA}) { $data=$ENV{DATA}; } else { die "You must define environment variable DATA.\n"; } if ($ENV{BASEDIR}) { $basep=$ENV{BASEDIR}; } else { die "You must define environment variable BASEDIR.\n"; } # if ($ENV{BASEPROD}) { $basep_gif=$ENV{BASEPROD}; } # else { die "You must define environment variable BASEPROD.\n"; } if ($ENV{FIXgempak}) { $fixgem=$ENV{FIXgempak}; } else { die "You must define environment variable FIXgempak.\n"; } if ($ENV{REGION}) {$region=$ENV{REGION}; } else { die "You must define environment variable REGION.\n"; } $mod=$model; if ($model =~ "storm") { if($region =~ /hur/) { $mod= "hur"; } if($region =~ /hwrf/) { $mod= "hwrf"; } } if ($region =~ /namer/) { if ($model =~ /hiresw/) { if ($cycle=~/00/) { $regtitle="Eastern US"; } elsif ($cycle =~ /06/) { $regtitle="Western US"; } elsif ($cycle =~ /12/) { $regtitle="Eastern US"; } elsif ($cycle =~ /18/) { $regtitle="Alaska"; } } else { $regtitle="North America"; } } elsif ($region =~ /samer/ ) { $regtitle="South America"; } elsif ($region =~ /npac/ ) { $regtitle="North Pacific"; } elsif ($region =~ /carib/ ) { $regtitle="Western North Atlantic"; } elsif ($region =~ /epac/ ) { $regtitle="Eastern Pacific"; } elsif ($region =~ /africa/ ) { $regtitle="Africa"; } elsif ($region =~ /hur/ ) { $regtitle="GHM Hurricane"; } elsif ($region =~ /hwrf/ ) { $regtitle="WRF Hurricane"; } $basep="$basep/$region"; #if ($ENV{DEVELOP}) { $basep="$basep/temp"; } $title=uc $mod; # title for table if ($region =~ "hur") { $unregion="Inner Nest "; $unmod="hur_nested"; } if ($region =~ "hur_") { $title="Inner Nest"; $unregion="Atlantic/Pacific"; $unmod="hur"; } if ($region =~ "hwrf") { $unregion="Inner Nest "; $unmod="hwrf_nested"; } if ($region =~ "hwrf_") { $title="Inner Nest"; $unregion="Atlantic/Pacific"; $unmod="hwrf"; } if ($model =~ "hiresw") { if ($siz =~ "l") { $modtpe="NMM"; } else { $modtpe="ARW"; } $title=$title . " " . $modtpe; } else { $modtpe=""; } $cho=substr($title,0,3); if($cho =~ /sto/) { if ($region =~ /hur/) { $title = "GHM Hurricane"; } if ($region =~ /hwrf/) { $title = "WRF Hurricane"; } } $htmltmp="$basep/$model/$cycle"; if ($siz =~ /[sl]/) { if ($region =~ /epac/ ) { exit; } } if ($siz !~ /[sml]/) { die "Size must be [sml]\n"; } if ($cycle !~ /00|06|12|18/) { if ( $model !~ /ruc|rtma/ ) { die "cycle must be [00|06|12|18]\n"; } } $ofile="$htmltmp/model_${siz}.shtml"; print "ofile= $ofile\n"; print "model= $model\n"; $fpcf="$htmltmp/fpc.shtml"; $tpcf="$htmltmp/tpc.shtml"; if ( ${model} =~ "wave" ) { $fpdef="$fixgem/webgif_fpdef_ww3"; } elsif ( ${model} =~ "gfs" ) { if ( ${region} =~ /samer/ ) { $fpdef="$fixgem/webgif_fpdef_gfs.samer"; } else { $fpdef="$fixgem/webgif_fpdef_gfs"; } } elsif ( ${model} =~ "storm" ) { if ( ${region} =~ /hur/ ) { $fpdef="$fixgem/webgif_fpdef_hur"; } else { $fpdef="$fixgem/webgif_fpdef_hwrf"; } } elsif ( $model =~ /gefs|gens/ ) { print "model = $model\n"; $fpdef="$fixgem/webgif_fpdef_gefs"; } elsif ( $model =~ "rtma" ) { $fpdef="$fixgem/webgif_fpdef_rtma"; } else { $fpdef="$fixgem/webgif_fpdef"; } if ($ENV{RELPATH}) {$hrf=$ENV{RELPATH}; } else { $hrf="/pmb/nw${envir}/analysis"; } # imagedir - relative location of the images directory # gifdir - location of the GIF files, based on model and cycle # htmdir - location of the html files # basep and gifdir together make up a complete path to the images of a # particular model/cycle # looplistdir - location of the image loop lists # $htmdir="/${model}/${cycle}"; $imagedir = "images"; $gifdir="${htmdir}/${imagedir}"; $modhtms=$htmltmp; $modgifs="${basep}${gifdir}"; if ($DEBUG > 0) { print " modgifs is $modgifs\n "; print " basep is $basep\n"; print " gifdir is $gifdir\n"; } $looplistdir = "loop_lists"; # Relative to the $htmdir. $full_looplistdir = "$basep$htmdir/$looplistdir"; if ( ! -e $full_looplistdir ) { mkdir("$full_looplistdir") || die "Error creating directory $full_looplistdir: $!.\n"; } if ($DEBUG > 0) { print "Base GIF directory(\$basep\$gifdir): $basep$gifdir \n"; print " basep: $basep\n"; print " gifdir: $gifdir\n"; print " htmdir: $htmdir\n"; print " modhtms: $modhtms\n"; print " looplistdir: $looplistdir (Relative to htmdir)\n"; print " imagedir: $imagedir (Relative to htmdir)\n"; print " modgifs : $modgifs\n"; } $cln=""; $clnv=0; # cln = column name; clnv = number of columns $tsn=""; $tsnv=0; # tsn = time slice name; tsnv = number of t.s. @cln=""; @tsn=""; # same as the variables, except these are arrays @cln1=""; # descriptive column names, corresponds to @cln $colnm=""; # number of columns in table #RRomero# Constants for the HTML code $HTML_website_title = "Model Analyses and Forecasts"; $HTML_table_border = "1"; $HTML_table_bgcolor = "#ffffff"; $HTML_table_cellpadding = "2"; $HTML_table_cellspacing = "0"; $HTML_table_width = "100%"; #RRomero# Set image looper variables. $HTML_loop_codebase = "/java/AniS"; $HTML_loop_archive = "aniscode.jar"; $HTML_loop_code = "AniS.class"; $HTML_loop_param_controls = "startstop, looprock, step, speed, firstlast, refresh, show, toggle"; $HTML_loop_param_active_zoom = "3"; $HTML_loop_param_backcolor = "xCCCCCC"; $HTML_loop_param_forecolor = "x000000"; $HTML_loop_param_pause = "2000"; $HTML_loop_param_pause_percent = "500"; $HTML_loop_param_toggle_size = "8,8,2"; #RRomero# Set the image size parameter for the image looper SWITCH: { $siz =~ /l/ && do { $HTML_loop_image_width = "1280"; $HTML_loop_image_height = "1124"; last SWITCH; }; $siz =~ /m/ && do { if ($model =~ /hiresw/) { # For the HiRes WRF, the gif graphics are always made using large # values, and the $siz parameter is instead used to differentiate # between model types, where "m" = ARW and "l" = NMM. $HTML_loop_image_width = "1280"; $HTML_loop_image_height = "1124"; } else { $HTML_loop_image_width = "1024"; $HTML_loop_image_height = "868"; } last SWITCH; }; DEFAULT: do { $HTML_loop_image_width = "640"; $HTML_loop_image_height = "580"; }; } if ($DEBUG > 1) { print "HTML_loop_image_width: $HTML_loop_image_width, HTML_loop_image_height: $HTML_loop_image_height\n"; } if ($DEBUG > 1) { print "Leaving init_defs.\n"; } return; } ######################################################################### ############################################################################ ############################################################################ ######################################################################### # The next routine opens the directory given by $basep/$gifdir. It finds all # the images belonging to a particular image size and determines the column # headers as well as the number of rows and time slices based on the # file names. The nomenclature of the images is # "[model]_[type]_[time][size].gif". # Based on this information, all the different types and times can be # established. # # $cln and $tsn hold the (orderless) column names and times, respectively. # @cln and @tsn are lists that hold the ordered entries # $clnv and $tsnv contain the number of entries for each sub get_cr { if ($DEBUG > 1) { print "Entering get_cr...\n"; } if ($DEBUG > 0) { print " Opening GIF directory $modgifs...\n"; } opendir(MODR, $modgifs) || die "Error opening directory $modgifs: $!.\n"; if ($DEBUG > 0) { print " Reading GIF directory $modgifs...\n"; } @fnames = readdir MODR; if ($DEBUG > 1) { print " GIF filenames: @fnames\n"; } if ($DEBUG > 0) { print " Closing GIF directory $modgifs...\n"; } closedir MODR || die "Error closing directory $modgifs: $!.\n"; while ($curfl = (shift @fnames)) { if ($DEBUG > 1) { print " Checking $curfl...\n"; } if ($curfl =~ /.*_.*_(\d{3,3}|[a-z]{3,3})${siz}\.gif/o) { if ($DEBUG > 1) { print " Parsing $curfl...\n"; } ($mn, $clnn, $rest) = split /_/, $curfl, 3; if ($DEBUG > 1) { print " Column name is $clnn...\n"; } ($tsnn, $rest) = split /${siz}\./, $rest, 2; if ($DEBUG > 1) { print " cln is $cln...\n"; } if ($cln !~ /$clnn/i) { if ($DEBUG > 1) { print " Made it here...\n"; } $cln = "$clnn:$cln"; $clnv++; } if ($tsn !~ /$tsnn/i) { $tsn = "$tsnn:$tsn"; $tsnv++; } } } if ( $model =~ "gfs" ) { # The GFS graphics will be split across two pages. # List the upperair graphics, in the order in which they are to appear on the upperair page. if ( $region =~ "epac" ) { @cln = qw( slp 200 250 300 500 700 850 85v ); } else { if ( $region =~ "samer" ) { @cln = qw( slp sl8 sl7 200 250 300 500 700 850 85p ); } else { @cln = qw( slp sl8 sl7 200 250 300 500 700 850 85v ); } } # Count the number of upperair graphics. $sidx_sfc = @cln; # Add the surface graphics to the list, in the order in which they are to appear on the surface page. print "region = $region"; if ( $region =~ "amer" ) { push( @cln, qw( ten pcp p06 p12 p24 p36 p48 p60 tpp ) ); } elsif ( $region =~ "africa" ) { push( @cln, qw( ten pcp p06 p12 p24 p36 p48 p60 tpp ) ); } elsif ( $region =~ "carib" ) { push( @cln, qw( ten pcp tpp ) ); } else { push( @cln, qw( ten pcp ) ); } } else { # The graphics will all be on one page, in sorted order based on the name. @cln = sort reverse (split /:/, $cln); } @tsn = sort (split /:/, $tsn); # sorted list of time slices $colnm=@cln + 1 ; # number of columns in table = # of column names + 1 if ($DEBUG > 1) { print <<"ENDOFTEXT"; cln = @cln tsn = @tsn colnm = $colnm ENDOFTEXT } if ($DEBUG > 1) { print "Leaving get_cr.\n"; } return; } ######################################################################### ############################################################################ ############################################################################ ######################################################################### # Change some of the column names we recognize to something more descriptive sub ch_col_name { if ($DEBUG > 1) { print "Entering ch_col_name...\n"; } open (MTR, "<$fixgem/webgif_mtrans") || die "Error opening $fixgem/webgif_mtrans: $!.\n"; while () { chomp; if ($_ =~ /^\w/) { ($coln, $desc) = split /:/, $_, 2; $table{$coln}="$desc"; } } for ($i=0;$i<$clnv;$i++) { $sub=$cln[$i]; if ($table{$sub} =~ /.{1,}/) { $cln1[$i] = $table{$sub}; } } close MTR || die "Error closing $fixgem/webgif_mtrans: $!.\n"; if ($DEBUG > 1) { print "Leaving ch_col_name.\n"; } return; } ######################################################################### ############################################################################ sub do_main_hd2 { if ($DEBUG > 1) { print "Entering do_main_hd2...\n"; } print MF2 <<"ENDOFTEXT"; NCEP ${title} Model Forecasts

${HTML_website_title}
${title} ${cycle} UTC

ENDOFTEXT $opst=""; if ($model =~ "gfs") { $opst="Upper Air GFS Graphics "; } print MF2 << "ENDOFTEXT"; ENDOFTEXT if ($DEBUG > 1) { print "Leaving do_main_hd2.\n"; } return; } ############################################################################ ######################################################################### # Creating header for model html page sub do_main_hdr { if ($DEBUG > 1) { print "Entering do_main_hdr...\n"; } print MFF <<"ENDOFTEXT"; NCEP ${title} Model Forecasts

${HTML_website_title}
${title} ${cycle} UTC

ENDOFTEXT $opst=""; if ($model =~ "gfs") { $opst="Surface GFS Graphics"; print MFF << "ENDOFTEXT";

[Surface GFS Graphics][${opst}]

 
ENDOFTEXT } else { print MFF << "ENDOFTEXT";

[${opst}][Upper Air GFS Graphics]

 
ENDOFTEXT } if ($model =~ "sto") { print MFF << "ENDOF2";

Go to $unregion hurricane graphics

ENDOF2 } if ($DEBUG > 1) { print "Leaving do_main_hdr.\n"; } return; } ######################################################################### ############################################################################ ######################################################################## # Creating header for model html page sub do_stat_pge { print " Entering static_page \n"; if ($DEBUG > 1) { print "Entering do_stat_pge...\n"; } $ofile="$modhtms/model_${siz}.shtml"; print " opening MFF "; open (MFF, ">${ofile}"); print MFF <<"ENDOFTEXT"; NCEP ${title} Model Forecasts

${HTML_website_title}
${regtitle} ${cycle} UTC ${title}

 


WRF $modtpe preempted by the hurricane model. No WRF $modtpe graphics available for this hour

\n"; print MFF "\n"; for ( $i=$cln2;$i<$clnv;$i++ ) { $cln=$cln[$i]; $flnm2="${model}_"; $strm=substr($flnm2,0,3); #print " strm is $strm"; if($strm =~ "sto" ) { $region=$ENV{REGION}; if($region =~ /hur/) { $flnm2="hur_"; } if($region =~ /hwrf/) { $flnm2="hwrf_"; } } $flnm2="${flnm2}${cln}_"; $looplistfilename = "${looplistdir}/${cln}_${siz}_loop.list"; $loophtml="${cln}_${siz}_loop.shtml"; $loophtmlindex="index_${cln}_${siz}_loop.shtml"; if ($DEBUG > 1) { print <"; print MFF "Loop"; print MFF "\n"; } print MFF "\n"; if ($model =~ "sto") { print TPC "\n"; } #RRomero# End printing the HTML row containing the "loop" links. while ($j < $tsnv) { $stepcnt=0; # stepcnt keeps track of how many steps we have in each day while (($tsn[$j] <= $day*24) && ($j < $tsnv) ) { unshift @hrofday, $tsn[$j]; $j++; $stepcnt++; } if ($DEBUG > 1) { print " hrofday=@hrofday\n"; } if ($DEBUG > 1) { print " j=$j, tsnv=$tsnv, stepcnt=$stepcnt\n"; } # @hrofday contains the number of hours within the day # given by $day, starting with day 0 (initial). for ($n = 0; $n < $stepcnt; $n++) { $tstp = pop @hrofday; if ($DEBUG > 1) { print " tstp=$tstp\n"; } if ($bgc == 0) { print MFF "\n"; print FPC "\n"; if ($model =~ "sto") { print TPC "\n"; } $bgc=1; } else { print MFF "\n"; print FPC "\n"; if ($model =~ "sto") { print TPC "\n"; } $bgc=0; } if ($tstp == 0) { print MFF "\n"; print FPC "\n"; if ($model =~ "sto") { print TPC "\n"; } } if ($n == 0 && $tstp != 0) { print MFF "\n"; print FPC "\n"; if ($model =~ "sto") { print TPC "\n"; } } #RRomero# for ($i = $cln2; $i < $clnv; $i++) { print MFF "\n"; if($model =~ "sto" ) { print TPC "\n"; } } # Print all appropriate columns on the 4-panel page #print "$fpcn\n"; for ($i=0;$i<$fpcn;$i++) { print FPC ""; build_fp_page($i,$tstp); } print MFF ""; print FPC ""; if ($model =~ "sto") { print TPC ""; } } # $day++; if ($day == 5) { pr_col_name2; } if ($day == 9) { pr_col_name2; } $day++; } ######################################################################## # If model is ruc, do not build the "4-Panel Charts (Hours)" section # in the model_[s/m/l].shtml ruc html page ######################################################################## if ($model !~ /ruc/) { print MFF "\n"; print MFF "\n\n"; # Print out column names for all existing files print MFF "\n"; print MFF "\n"; for ($i=$cln2;$i<$clnv;$i++) { print MFF "\n"; } print MFF "\n"; print MFF "\n"; #$csp=int ($tsnv/4.0) + 1; #print MFF "\n"; } else { print MFF "\n"; } $cnt=0; @fprow=(); $slc=0; # count off at most four images at a time while ($cnt < 4 && $i < $tsnv) { #print "$tsn[$i] "; push @fprow, $tsn[$i++]; $cnt++; } # @fprows now contains the panels that are to be shown # print MFF "\n"; if ($j > 0 && $j%($clnv-1) == 0) { print MFF "\n"; } open (FPV, ">$modhtms/$flnm3"); print FPV "

ENDOFTEXT print MFF "

"; print MFF "\n"; close MFF; if ($DEBUG > 1) { print "Leaving do_stat_pge.\n"; } return; } ############################################################################ ######################################################################### # Creating header for 4-panel graphics html page sub do_fp_hdr { if ($DEBUG > 1) { print "Entering do_fp_hdr...\n"; } print FPC <<"ENDOFTEXT"; NCEP ${title} Model Forecasts

${HTML_website_title}
${regtitle} ${cycle} UTC ${title}

ENDOFTEXT print FPC << "ENDOFTEXT"; ENDOFTEXT if ($DEBUG > 1) { print "Leaving do_fp_hdr.\n"; } return; } ######################################################################### ######################################################################### # Creating header for 2-panel graphics html page sub do_tp_hdr { if ($DEBUG > 1) { print "Entering do_tp_hdr...\n"; } print TPC <<"ENDOFTEXT"; NCEP ${title} Model Forecasts

${HTML_website_title}
${regtitle} ${cycle} UTC ${title}

ENDOFTEXT print TPC << "ENDOFTEXT";
4 Panel Charts
ENDOFTEXT if ($DEBUG > 1) { print "Leaving do_tp_hdr.\n"; } return; } ######################################################################### ############################################################################ # Print out column names for all existing files sub pr_col_name { if ($DEBUG > 1) { print "Entering pr_col_name...\n"; } $fpcn=@fpcols; # number of columns in 4 panel chart + 1 print FPC ""; print FPC "\n"; for ($i=0;$i<$fpcn;$i++) { @cnms=split /:/,$fpcols[$i]; print FPC ""; } print FPC "\n"; if($clnv != 0 ) { $prc=int (96/$clnv); } else { if ($DEBUG > 1) { print "clvn = $clvn. Therefore no images in GIF dir\n"; } } if ($model =~ "gens" ) { $prc=5; } if ( ${model} =~ "gfs" ) { $prc=5 ; } if($model =~ "sto" ) { print TPC ""; print TPC ""; } for ($i=$cln2;$i<$clnv;$i++) { print MFF "\n"; if ($model =~ "sto") { print TPC "\n"; } } print MFF "\n"; if ($model =~ "sto") { print TPC "\n"; } if ($DEBUG > 1) { print "Leaving pr_col_name.\n"; } return; } ######################################################################### ############################################################################ # Print out embedded column names sub pr_col_name2 { if ($DEBUG > 1) { print "Entering pr_col_name2...\n"; } $fpcn=@fpcols; # number of columns in 4 panel chart + 1 print MFF ""; print MFF "\n"; $prc=int (96/$clnv); if ($model =~ "gens") { $prc=5; } for ($i=$cln2;$i<$clnv;$i++) { print MFF "\n"; if ($DEBUG > 1) { print "pr_col_name2: cln1[i] = $cln1[$i] \n";} } print MFF "\n"; if ($DEBUG > 1) { print "Leaving pr_col_name2.\n"; } return; } ######################################################################### # Print out embedded column names sub pr_col_nam22 { if ($DEBUG > 1) { print "Entering pr_col_nam22...\n"; } $fpcn=@fpcols; # number of columns in 4 panel chart + 1 print MF2 ""; print MF2 "\n"; $prc=int (96/$clnv); for ($i=0;$i<$sidx_sfc;$i++) { print MF2 "\n"; if ($DEBUG > 1) { print "pr_col_nam22: cln1[i] = $cln1[$i]\n";} } print MF2 "\n"; if ($DEBUG > 1) { print "Leaving pr_col_nam22.\n"; } return; } ######################################################################## # Print out column names for all existing files sub pr_col_nam2 { if ($DEBUG > 1) { print "Entering pr_col_nam2...\n"; } $prc=int (96/$clnv); for ($i=0;$i<$sidx_sfc;$i++) { print MF2 "\n"; } print MF2 "\n"; if ($DEBUG > 1) { print "Leaving pr_col_nam2.\n"; } return; } ############################################################################ ######################################################################### # The get_fp_vars routine checks the file fpdef for four panel definitions. # Each definition describes what columns should be included in each # four panel display. Valid definitions contain four entries that are # colon separated and are all contained within the $cln variable. # @fields is the array that contains all valid definitions, colon-delimited. sub get_fp_vars { if ($DEBUG > 1) { print "Entering get_fp_vars...\n"; } $j=0; open (FPD, "<$fpdef"); while () { chomp; $bad=0; @fields=split /:/; for ($i=0;$i<=$#days;$i++) { if ($cln !~ /$fields[$i]/) { $bad=1; } } if ($bad == 0) { $fpcols[$j++] = $_; } } if ($DEBUG > 1) { print "Leaving get_fp_vars.\n"; } return; } ######################################################################### ############################################################################ # Generate the content of the main RTMA page sub gen_body_rtma { if ($DEBUG > 1) { print "Entering gen_body_rtma...\n"; } $bgc=0; # set background to 0 # $bgc keeps alternating between 0 and 1 and determines # the background color for any particular row. # open and read the map backgrounds table open (RTR, "<$fixgem/rtma_regions.tbl") || die "Error opening $fixgem/rtma_regions.tbl: $!.\n"; while () { chomp; if (/GAREA/) { /(\w+)\W+(.*?)\s*GAREA/; $bgnames{$1}="$2"; } } close RTR || die "Error closing $fixgem/rtma_regions.tbl $!.\n"; # j loops through all of the map backgrounds for ( $j=0; $j<$tsnv; $j++ ) { $tsn=$tsn[$j]; if ($bgc == 0) { print MFF "\n"; $bgc=1; } else { print MFF "\n"; $bgc=0; } print MFF "\n"; # i loops through all of the column headings for ( $i=$cln2; $i<$clnv; $i++ ) { $cln=$cln[$i]; $flnm2="${model}_${cln}_${tsn}${siz}.gif"; if (-e "$modgifs/$flnm2") { print MFF "\n"; } else { print MFF "\n"; } } print MFF "\n"; } print MFF "
2 Panel Charts
 "; foreach $cnm (@cnms) { print FPC "$table{$cnm}
"; if ($DEBUG > 1) { print "pr_col_name: table{cnm} = $table{$cnm}...\n"; } } print FPC "
 $cln1[$i]$cln1[$i]
 $cln1[$i]
 $cln1[$i]
$cln1[$i]
$bgnames{$tsn}ImageN/A
\n\n"; close MFF; if ($DEBUG > 1) { print "Leaving gen_body_rtma.\n"; } return; } ############################################################################ ######################################################################### # Generate the content of the main and 4-panel pages sub gen_body { if ($DEBUG > 1) { print "Entering gen_body...\n"; } $bgc=0; # set background to 0 # $bgc keeps alternating between 0 and 1 and determines # the background color for any particular row. $day=0; # $day keeps track of the day we're looking at, # starting with 0 at 0Z $j=0; # j goes through all time steps that are given in tsn #RRomero# Begin printing the HTML row containing the "loop" links. print MFF "

 
InitialInitialInitial"; print MFF "Day ${day}"; print FPC "Day ${day}"; print TPC "Day ${day}"; if ( $model =~ "sto") { print TPC ""; } $cln = $cln[$i]; $flnm2 = "${model}_"; $strm=substr($flnm2,0,3); if($strm =~ "sto" ) { $region=$ENV{REGION}; if($region =~ /hur/) { $flnm2="hur_"; } if($region =~ /hwrf/) { $flnm2="hwrf_"; } } $flnm2 = "${flnm2}${cln}_"; ## $looplist = "${DATA}/web/output/loop_lists/${cln}_${siz}_loop.list"; $looplist = "${modhtms}/${looplistdir}/${cln}_${siz}_loop.list"; $flnm2 = "${flnm2}${tstp}${siz}.gif"; if ($DEBUG > 1) { print <<"ENDOFTEXT"; cln2=$cln2 clnv=$clnv cln=$cln[$i] flnm2=${model}_ $strm=substr($flnm2,0,3); #print " strm is $strm"; if($strm =~ "sto" ) { $region=$ENV{REGION}; if($region =~ /hur/) { $flnm2="hur_"; } if($region =~ /hwrf/) { $flnm2="hwrf_"; } } flnm2=${flnm2}${cln}_ flnm2=${flnm2}${tstp}${siz}.gif ### GIF File: $basep$gifdir/$flnm2 --Zhu GIF File: $modgifs/$flnm2 looplist: $looplist ENDOFTEXT } if ( $j == 1 && -e $looplist ) { if ($DEBUG > 0) { print " Deleting previous loop image listing file $looplist.\n"; } if ($DEBUG > 0) { print " Running \"rm -f $looplist\".\n"; } #system("rm -f $looplist"); unlink($looplist) || die "Error deleting $looplist: $!\n"; } if ( $DEBUG > 0 ) { print "Fully qualified GIF filename: $basep$gifdir/$flnm2\n"; } ###if (-e "$basep$gifdir/$flnm2") { --Zhu if (-e "$modgifs/$flnm2") { #RRomero# Begin open and write this image to the loop file list. open (LOOPLIST, ">> $looplist") || die "Error opening $looplist: $!\n"; print LOOPLIST "$imagedir/$flnm2\n"; #RR#TESTING PURPOSES#print LOOPLIST "/pmb/nw${envir}/analysis/namer/$gifdir/$flnm2\n"; close LOOPLIST || die "Error closing $looplist: $!\n"; #RRomero# End open and write this image to the loop file list. print MFF "$tstp"; if($model =~ "sto" ) { print TPC "$tstp"; } } else { print MFF "$tstp"; if($model =~ "sto" ) { print TPC "$tstp"; } } print MFF ""; print FPC "$tstp"; print FPC "
\n"; print MFF "4-Panel Charts (Hours)
 $cln1[$i]
\n"; #print MFF " \n"; $i=0; while (1) { $fpday=(($tsn[$i]/24.0) - (int ($tsn[$i]/24.0)) > 0 ? (int ($tsn[$i]/24.0)) + 2 : (int $tsn[$i]/24.0)+1); if ($model =~ /hiresw/) { $fpday = int($tsn[$i]/24.) + 1 ; if ($tsn[$i] >= 48.){ $fpday = 2 ; } } if ($model =~ /mrf/) { print MFF "Day $fpdayDay $fpday\n"; $low=$fprow[0]; $high=$fprow[$cnt-1]; # print "low=$low high=$high\n"; for ($j=$cln2;$j<$clnv;$j++) { @slices=@fprow; $flnm3="${model}_$cln[$j]${low}${high}_${siz}.shtml"; print MFF ""; if ($model =~ /hiresw/ || $model =~ /stor/ ) { print MFF "$low-$high"; } elsif ($low !~ /$high/) { if ( ( ( $high =~ "018" || $high =~ "036" ) && $cln[$j] =~ /p12|p24|p36|p48|p60/ ) || ( $high =~ "042" && $cln[$j] =~ /p36|p48|p60/ ) || ( $high =~ "066" && $cln[$j] =~ /p60/ ) || ( $high =~ "084" && $cln[$j] =~ /p60/ && $model !~ /nam/ ) ) { print MFF "$low-$high"; } else { print MFF "$low-$high"; } } else { print MFF "$low Hour"; } print MFF "
"; print FPV "\n\n"; for ($m=0;$m<$cnt;$m++) { $crow=shift @slices; $flnm4="${mod}_$cln[$j]_${crow}${siz}.gif"; #print "--$modgifs/$flnm4\n"; #print "\$i=$i \$j=$j\n"; if (-e "$modgifs/$flnm4") { #print "found\n"; print FPV "\n"; } else { print FPV "\n"; } if ($m > 0 && $m%2!=0) { print FPV "\n"; } } print FPV "\n

$title $cycle "; print FPV "UTC - $fprow[$m] Hours

"; print FPV "

N/A

\n\n"; close FPV; } last if ($i >= $tsnv); } } @ctime=localtime(time); $ctime[4]++; if ($ctime[2] < 10) { $ctime[2]="0$ctime[2]"; } if ($ctime[1] < 10) { $ctime[1]="0$ctime[1]"; } print MFF ""; print MFF "\n\n"; close MFF; print FPC ""; print FPC "\n"; close FPC; if ($model =~ "stor") { print TPC ""; print TPC "\n"; close TPC; } if ($DEBUG > 1) { print "Leaving gen_body.\n"; } return; } ######################################################################### # Generate the content of the main/4-panel pages sub gen_bod2 { if ($DEBUG > 1) { print "Entering gen_bod2...\n"; } $bgc=0; # set background to 0 # $bgc keeps alternating between 0 and 1 and determines # the background color for any particular row. # print MF2 " \n"; $day=0; # $day keeps track of the day we're looking at, # starting with 0 at 0Z $j=0; # j goes through all time steps that are given in tsn $colnm=11; #RRomero# Begin printing the HTML row containing the "loop" links. print MF2 "\n"; print MF2 " \n"; for ( $i=0;$i<$sidx_sfc;$i++ ) { $cln=$cln[$i]; $flnm2="${model}_"; $flnm2="${flnm2}${cln}_"; $looplistfilename = "${looplistdir}/${cln}_${siz}u_loop.list"; $loophtml="${cln}_${siz}u_loop.shtml"; $loophtmlindex="index_${cln}_${siz}u_loop.shtml"; if ($DEBUG > 1) { print <"; print MF2 "Loop"; print MF2 "\n"; } print MF2 "\n"; #RRomero# End printing the HTML row containing the "loop" links. while ( $j < $tsnv) { # stepcnt keeps track of how many steps we have in each # day $stepcnt=0; while ( ($tsn[$j] <= $day*24) && ($j < $tsnv) ) { unshift @hrofday, $tsn[$j]; $j++; $stepcnt++; } # @hrofday contains the number of hours within the day # given by $day, starting with day 0 (initial). for ($n=0;$n<$stepcnt;$n++) { $tstp=pop @hrofday; if ($bgc==0) { print MF2 "\n"; $bgc=1; } else { print MF2 "\n"; $bgc=0; } if ( $tstp == 0) { print MF2 "Initial\n"; } if ($n==0 && $tstp != 0) { print MF2 ""; print MF2 "Day ${day}\n"; } #RRomero# for ($i = 0; $i < $sidx_sfc; $i++) { $cln = $cln[$i]; $flnm2 = "${model}_"; $flnm2 = "${flnm2}${cln}_"; ## $looplist = "${DATA}/web/output/loop_lists/${cln}_${siz}u_loop.list"; $looplist = "${modhtms}/${looplistdir}/${cln}_${siz}u_loop.list"; $flnm2 = "${flnm2}${tstp}${siz}.gif"; if ($DEBUG > 1) { print <<"ENDOFTEXT"; cln2=$cln2 clnv=$clnv cln=$cln[$i] flnm2=${model}_ flnm2=${flnm2}${cln}_ flnm2=${flnm2}${tstp}${siz}.gif GIF File: $modgifs/$flnm2 looplist: $looplist ENDOFTEXT } if ( $j == 1 && -e $looplist ) { if ($DEBUG > 0) { print " Deleting previous loop image listing file $looplist.\n"; } if ($DEBUG > 0) { print " Running \"rm -f $looplist\".\n"; } #system("rm -f $looplist"); unlink($looplist) || die "Error deleting $looplist: $!\n"; } } # Print all appropriate columns on the main page for ($i=0;$i<$sidx_sfc;$i++) { print MF2 ""; $cln=$cln[$i]; $flnm2="${model}_"; $flnm2="${flnm2}${cln}_"; $flnm2="${flnm2}${tstp}${siz}.gif"; $looplist = "${modhtms}/${looplistdir}/${cln}_${siz}u_loop.list"; if ($DEBUG > 0) { print <<"ENDOFTEXT"; clnv=$clnv cln=$cln[$i] flnm2=${model}_ flnm2=${flnm2}${cln}_ flnm2=${flnm2}${tstp}${siz}.gif GIF File: $modgifs/$flnm2 looplist: $looplist ENDOFTEXT } #print "$basep/$gifdir/$flnm2\n"; ###if (-e "$basep/$gifdir/$flnm2") { --Zhu if (-e "$modgifs/$flnm2") { #RRomero# Begin open and write this image to the loop file list. open (LOOPLIST, ">> $looplist") || die "Error opening $looplist: $!\n"; print LOOPLIST "$imagedir/$flnm2\n"; #RR#TESTING PURPOSES#print LOOPLIST "/pmb/nw${envir}/analysis/namer/$gifdir/$flnm2\n"; close LOOPLIST || die "Error closing $looplist: $!\n"; #RRomero# End open and write this image to the loop file list. print MF2 "$tstp"; } else { print MF2 "$tstp"; } print MF2 "\n"; } print MF2 ""; } $day++; if ($day == 5) { pr_col_nam22; } if ($day == 9) { pr_col_nam22; } } print MF2 "\n"; print MF2 "\n"; print MF2 "4-Panel Charts (Hours)\n\n"; # Print out column names for all existing files print MF2 "\n"; print MF2 " \n"; for ($i=0;$i<$sidx_sfc;$i++) { print MF2 "$cln1[$i]\n"; } print MF2 "\n\n"; #$csp=int ($tsnv/4.0) + 1; #print MF2 "\n"; #print MF2 " \n"; $i=0; while (1) { $fpday=(($tsn[$i]/24.0) - (int ($tsn[$i]/24.0)) > 0 ? (int ($tsn[$i]/24.0)) + 2 : (int $tsn[$i]/24.0)+1); print MF2 "Day $fpday\n"; $cnt=0; @fprow=(); $slc=0; # count off at most four images at a time while ($cnt < 4 && $i < $tsnv) { #print "@tsn[$i] "; push @fprow, $tsn[$i++]; $cnt++; } # @fprows now contains the panels that are to be shown $low=$fprow[0]; $high=$fprow[$cnt-1]; #print "low=$low high=$high\n"; for ($j=0;$j<$sidx_sfc;$j++) { @slices=@fprow; $flnm3="${model}_$cln[$j]${low}${high}_${siz}.shtml"; print MF2 ""; if ($low !~ /$high/) { if ( ( ( $high =~ "018" || $high =~ "036" ) && $cln[$j] =~ /p12|p24|p36|p48|p60/ ) || ( $high =~ "042" && $cln[$j] =~ /p36|p48|p60/ ) || ( $high =~ "066" && $cln[$j] =~ /p60/ ) || ( $high =~ "084" && $cln[$j] =~ /p60/ && $model !~ /nam/ ) ) { print MF2 "$low-$high"; } else { print MF2 "$low-$high"; } } else { print MF2 "$low Hour"; } print MF2 "\n"; if ( $j == ($sidx_sfc - 1) ) { print MF2 "\n"; } open (FP2, ">$modhtms/$flnm3"); print FP2 ""; print FP2 "\n\n"; for ($m=0;$m<$cnt;$m++) { $crow=shift @slices; $flnm4="${mod}_$cln[$j]_${crow}${siz}.gif"; #print "--$modgifs/$flnm4\n"; #print "\$i=$i \$j=$j\n"; if (-e "$modgifs/$flnm4") { #print "found\n"; print FP2 "\n"; } else { print FP2 "\n"; } if ($m > 0 && $m%2!=0) { print FP2 "\n"; } } print FP2 "\n

$title $cycle "; print FP2 "UTC - $fprow[$m] Hours

"; print FP2 "

N/A

\n\n"; close FP2; } last if ($i >= $tsnv); } @ctime=localtime(time); $ctime[4]++; if ($ctime[2] < 10) { $ctime[2]="0$ctime[2]"; } if ($ctime[1] < 10) { $ctime[1]="0$ctime[1]"; } print MF2 ""; print MF2 "\n\n"; close MF2; if ($DEBUG > 1) { print "Leaving gen_bod2.\n"; } return; } ######################################################################### ############################################################################ sub build_fp_page { if ($DEBUG > 1) { print "Entering build_fp_page...\n"; } $cll=$_[0]; $tmm=$_[1]; @fields=split /:/, $fpcols[$cll]; $fname5="$htmltmp/fp${cll}_${tmm}.shtml"; if ($DEBUG > 1) { print <<"ENDOFTEXT"; cll = $_[0], tmm = $_[1] fields = @fields fname5 = $fname5 ENDOFTEXT } if ($region =~ /epac/ ) { $size = "m"; } else { $size = "s"; } open (FPF,">$fname5"); print FPF <<"ENDOFTEXT"; 4-panel chart of $table{$fields[0]}, $table{$fields[1]}, $table{$fields[2]}, $table{$fields[3]}

4-panel chart of $table{$fields[0]}, $table{$fields[1]}, $table{$fields[2]}, $table{$fields[3]}

$table{$fields[0]} hour: $tmm

image of $table{$fields[0]}

$table{$fields[1]} hour: $tmm

image of $table{$fields[1]}

$table{$fields[2]} hour: $tmm

image of $table{$fields[2]}

$table{$fields[3]} hour: $tmm

image of $table{$fields[3]}
ENDOFTEXT close FPF; if ($DEBUG > 1) { print "Leaving build_fp_page.\n"; } return; } ######################################################################### ############################################################################ sub createLoopHTML { my $MYNAME = "createLoopHTML"; if ($DEBUG > 1) { print "Entering $MYNAME.\n"; } my($model_html_dir, $loophtml, $looplistfilename, $cycle, $model, $cln, $siz) = @_; if ($DEBUG > 1) { print <<"ENDOFTEXT"; Variables Passed: model_html_dir = $model_html_dir loophtml = $loophtml looplistfilename = $looplistfilename cycle = $cycle model = $model cln = $cln siz = $siz ENDOFTEXT } #RR#Override for testing purposes #RR#$model_html_dir = "${DATA}/web/output"; $loophtml_full_path = "$model_html_dir/$loophtml"; open(LOOPHTML, "> $loophtml_full_path") || die "Error opening $loophtml_full_path for writing: $!\n"; $model = uc $model; $caption = "$cycle $model $cln Image Loop"; print LOOPHTML <<"ENDOFTEXT";
$caption
ENDOFTEXT close(LOOPHTML) || die "Error closing $loophtml_full_path: $!\n"; if ($DEBUG > 1) { print "Leaving $MYNAME.\n"; } } ######################################################################### ############################################################################ sub createLoopHTMLIndex { my $MYNAME = "createLoopHTMLIndex"; if ($DEBUG > 1) { print "Entering $MYNAME.\n"; } my($model_html_dir, $loophtml, $loophtmlindex, $model) = @_; if ($DEBUG > 1) { print <<"ENDOFTEXT"; Variables Passed: model_html_dir = $model_html_dir loophtml = $loophtml loophtmlindex = $loophtmlindex model = $model ENDOFTEXT } #RR#Override for testing purposes #RR#$model_html_dir = "${DATA}/web/output"; $loophtmlindex_full_path = "$model_html_dir/$loophtmlindex"; open(LOOPHTMLINDEX, "> $loophtmlindex_full_path") || die "Error opening $loophtmlindex_full_path for writing: $!\n"; $model = uc $model; #NOTE: #NOTE: The below HTML implements the NWS corporate web image for the image loop web page. #NOTE: DO NOT MODIFY WITHOUT CONSULTING THE NCEP WEBMASTER. #NOTE: print LOOPHTMLINDEX <<"ENDOFTEXT"; NCEP Model Analyses and Forecasts
NCEP Home > NCEP Central Operations > Production Management Branch > Model Analyses and Forecasts > $model
Page last modified:
ENDOFTEXT close(LOOPHTMLINDEX) || die "Error closing $loophtml_full_path: $!\n"; if ($DEBUG > 1) { print "Leaving $MYNAME.\n"; } } ############################################################################ ######################################################################### # Generate the content of the main and 4-panel pages sub gen_body_gens { if ($DEBUG > 1) { print "Entering gen_body...\n"; } $bgc=0; # set background to 0 # $bgc keeps alternating between 0 and 1 and determines # the background color for any particular row. $day=0; # $day keeps track of the day we're looking at, # starting with 0 at 0Z $j=0; # j goes through all time steps that are given in tsn #RRomero# Begin printing the HTML row containing the "loop" links. print MFF "\n"; print MFF " \n"; for ( $i=$cln2;$i<$clnv;$i++ ) { $cln=$cln[$i]; $flnm2="${model}_"; $strm=substr($flnm2,0,3); $flnm2="${flnm2}${cln}_"; $looplistfilename = "${looplistdir}/${cln}_${siz}_loop.list"; $loophtml="${cln}_${siz}_loop.shtml"; $loophtmlindex="index_${cln}_${siz}_loop.shtml"; if ($DEBUG > 1) { print <"; print MFF "Loop"; print MFF "\n"; } print MFF "\n"; #RRomero# End printing the HTML row containing the "loop" links. while ($j < $tsnv) { $stepcnt=0; # stepcnt keeps track of how many steps we have in each day while (($tsn[$j] <= $day*24) && ($j < $tsnv) ) { unshift @hrofday, $tsn[$j]; $j++; $stepcnt++; } if ($DEBUG > 1) { print " hrofday=@hrofday\n"; } if ($DEBUG > 1) { print " j=$j, tsnv=$tsnv, stepcnt=$stepcnt\n"; } # @hrofday contains the number of hours within the day # given by $day, starting with day 0 (initial). for ($n = 0; $n < $stepcnt; $n++) { $tstp = pop @hrofday; if ($DEBUG > 1) { print " tstp=$tstp\n"; } if ($bgc == 0) { print MFF "\n"; $bgc=1; } else { print MFF "\n"; $bgc=0; } if ($tstp == 0) { print MFF "Initial\n"; } if ($n == 0 && $tstp != 0) { print MFF ""; print MFF "Day ${day}\n"; } #RRomero# for ($i = $cln2; $i < $clnv; $i++) { print MFF ""; $cln = $cln[$i]; $flnm2 = "${model}_"; $strm=substr($flnm2,0,3); $flnm2 = "${flnm2}${cln}_"; ## $looplist = "${DATA}/web/output/loop_lists/${cln}_${siz}_loop.list"; $looplist = "${modhtms}/${looplistdir}/${cln}_${siz}_loop.list"; $flnm2 = "${flnm2}${tstp}${siz}.gif"; if ($DEBUG > 1) { print <<"ENDOFTEXT"; cln2=$cln2 clnv=$clnv cln=$cln[$i] flnm2=${model}_ $strm=substr($flnm2,0,3); #print " strm is $strm"; flnm2=${flnm2}${cln}_ flnm2=${flnm2}${tstp}${siz}.gif ### GIF File: $basep$gifdir/$flnm2 --Zhu GIF File: $modgifs/$flnm2 looplist: $looplist ENDOFTEXT } if ( $j == 1 && -e $looplist ) { if ($DEBUG > 0) { print " Deleting previous loop image listing file $looplist.\n"; } if ($DEBUG > 0) { print " Running \"rm -f $looplist\".\n"; } #system("rm -f $looplist"); unlink($looplist) || die "Error deleting $looplist: $!\n"; } if ( $DEBUG > 0 ) { print "Fully qualified GIF filename: $basep$gifdir/$flnm2\n"; } ###if (-e "$basep$gifdir/$flnm2") { --Zhu if (-e "$modgifs/$flnm2") { #RRomero# Begin open and write this image to the loop file list. open (LOOPLIST, ">> $looplist") || die "Error opening $looplist: $!\n"; print LOOPLIST "$imagedir/$flnm2\n"; #RR#TESTING PURPOSES#print LOOPLIST "/pmb/nw${envir}/analysis/namer/$gifdir/$flnm2\n"; close LOOPLIST || die "Error closing $looplist: $!\n"; #RRomero# End open and write this image to the loop file list. print MFF "$tstp"; } else { print MFF "$tstp"; } print MFF "\n"; } print MFF ""; } $day++; if ($day == 5) { pr_col_name2; } if ($day == 9) { pr_col_name2; } } } } #########################################################################