#!/bin/ksh -l #dis #dis Open Source License/Disclaimer, Forecast Systems Laboratory #dis NOAA/OAR/FSL, 325 Broadway Boulder, CO 80305 #dis #dis This software is distributed under the Open Source Definition, #dis which may be found at http://www.opensource.org/osd.html. #dis #dis In particular, redistribution and use in source and binary forms, #dis with or without modification, are permitted provided that the #dis following conditions are met: #dis #dis - Redistributions of source code must retain this notice, this #dis list of conditions and the following disclaimer. #dis #dis - Redistributions in binary form must provide access to this #dis notice, this list of conditions and the following disclaimer, and #dis the underlying source code. #dis #dis - All modifications to this software must be clearly documented, #dis and are solely the responsibility of the agent making the #dis modifications. #dis #dis - If significant modifications or enhancements are made to this #dis software, the FSL Software Policy Manager #dis (softwaremgr@fsl.noaa.gov) should be notified. #dis #dis THIS SOFTWARE AND ITS DOCUMENTATION ARE IN THE PUBLIC DOMAIN #dis AND ARE FURNISHED "AS IS." THE AUTHORS, THE UNITED STATES #dis GOVERNMENT, ITS INSTRUMENTALITIES, OFFICERS, EMPLOYEES, AND #dis AGENTS MAKE NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE USEFULNESS #dis OF THE SOFTWARE AND DOCUMENTATION FOR ANY PURPOSE. THEY ASSUME #dis NO RESPONSIBILITY (1) FOR THE USE OF THE SOFTWARE AND #dis DOCUMENTATION; OR (2) TO PROVIDE TECHNICAL SUPPORT TO USERS. #dis #dis ########################################################################## # #Script Name: ncl.ksh # # Author: Christopher Harrop # Forecast Systems Laboratory # 325 Broadway R/FST # Boulder, CO. 80305 # # Released: 10/30/2003 # Version: 1.0 # Changes: None # # Purpose: This script generates NCL graphics from wrf output. # # EXE_ROOT = The full path of the ncl executables # MOAD_DATAROOT = Top level directory of wrf output and # configuration data. # START_TIME = The cycle time to use for the initial time. # If not set, the system clock is used. # FCST_TIME = The two-digit forecast that is to be ncled # # A short and simple "control" script could be written to call this script # or to submit this script to a batch queueing system. Such a "control" # script could also be used to set the above environment variables as # appropriate for a particular experiment. Batch queueing options can # be specified on the command line or as directives at the top of this # script. A set of default batch queueing directives is provided. # ########################################################################## . ${FIM_HOME}/FIMrun/chem_functions.ksh chem_on && CHEMFLAG="true" || CHEMFLAG="false" chem_opt_value=$(get_chem_opt_value) echo "chem_opt_value: $chem_opt_value" echo "************** in ncl MODL: $MODL" # Make sure we are using GMT time zone for time computations export TZ="GMT" # Execute module command to use newest version of NCL # module switch ncarg ncl export UDUNITS2_XML_PATH=${NCARG_ROOT}/lib/ncarg/udunits/udunits2.xml # Set up paths to shell commands LS=/bin/ls LN=/bin/ln RM=/bin/rm MKDIR=/bin/mkdir CP=/bin/cp MV=/bin/mv ECHO=/bin/echo CAT=/bin/cat GREP=/bin/grep CUT=/bin/cut AWK="/bin/gawk --posix" SED=/bin/sed DATE=/bin/date BC=/usr/bin/bc NCL=ncl CTRANS=ctrans PS2PDF=/usr/bin/ps2pdf CONVERT=/usr/bin/convert MONTAGE=/usr/bin/montage PATH=${NCARG_ROOT}/bin:${PATH} #. /work/01033/harrop/jettools.sh # Set ISDIR if [ ${IS} -eq 1 ]; then ISDIR="NAT" elif [ ${IS} -eq 2 ]; then ISDIR="PRS" else echo "Unsupported vertical coordinate option: ${IS}" exit 1 fi # Location of NCL graphics scripts NCL_ROOT=${FIM_HOME}/FIMwfm/ncl/fimall typeset -Z3 FCST_TIME # Get yyjjjHHMM datestr=`echo ${yyyymmddhhmm} | sed 's/^\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1\/\2\/\3 \4\:\5/'` yyjjjhhmm=`date +%y%j%H%M -d "${datestr}"` # Generate the ATCFNAME for this member #ATCFNAME=`echo ${ATCFNAME} | sed 's/NN/${MEMBER_ID}/'` ATCFNAME=`echo ${ATCFNAME} | sed "s/NN/${MEMBER_ID}/"` FCST_TIME=${T} # Print run parameters ${ECHO} ${ECHO} "nclfim.ksh started at `${DATE}`" ${ECHO} ${ECHO} " GLVL=${GLVL}" ${ECHO} " NVL=${NVL}" ${ECHO} " PES=${PES}" ${ECHO} " FCST_TIME=${FCST_TIME}" ${ECHO} " ISDIR=${ISDIR}" ${ECHO} # Set up the work directory and cd into it workdir=${FIM_HOME}/FIMrun/fim_${GLVL}_${NVL}_${PES}_${yyyymmddhhmm}/ncl_${MEMBER_ID}/${GRID_NAME}/${ISDIR}_${FCST_TIME} ${RM} -rf ${workdir} ${MKDIR} -p ${workdir} cd ${workdir} # Link to input file ${LN} -s ${FIM_HOME}/FIMrun/fim_${GLVL}_${NVL}_${PES}_${yyyymmddhhmm}/post_${MEMBER_ID}/${GRID_NAME}/${ISDIR}/grib1/${yyjjjhhmm}0${FCST_TIME} fim.grb ${ECHO} "fim.grb" > arw_file.txt # Setup domain file ${ECHO} ${GRID_NAME} > domain.txt # Link to tracker file if [ -s ${FIM_HOME}/FIMrun/fim_${GLVL}_${NVL}_${PES}_${yyyymmddhhmm}/tracker_${MEMBER_ID}/${T}/track.${yyyymmddhhmm}.${ATCFNAME} ]; then ${CAT} ${FIM_HOME}/FIMrun/fim_${GLVL}_${NVL}_${PES}_${yyyymmddhhmm}/tracker_${MEMBER_ID}/${T}/track.${yyyymmddhhmm}.${ATCFNAME} | ${SED} 's/\*\*\*/ 0/' > ./track.${yyyymmddhhmm} ${ECHO} ./track.${yyyymmddhhmm} > track_file.txt fi modelFound=0 if [ "${ISDIR}" == "NAT" ]; then if [[ "$MODL" = *FIMCES* ]]; then echo "This is FIMCES" modelFound=1 set -A ncgms sfc_temp \ sfc_Cs1 \ sfc_Cs2 \ int_Cs1 \ int_Cs2 \ int_Cs1b \ int_Cs2b \ ua_wind \ ua_wmag \ sfc_pwtr \ sfc_mslp \ 500_temp \ 700_temp \ 850_temp \ 925_temp \ 500_hgt \ ua_rh \ ua_rh8 \ ua_vort \ sfc_shtfl \ sfc_lhtfl \ sfc_swr \ 2m_temp \ 2ds_temp \ 2m_dewp \ 10m_wind \ sfc_totp \ sfc_acp \ sfc_acpcp \ sfc_weasd \ ua_ceil \ ua_ctop set -A pngs sfc_temp.png \ sfc_Cs1.png \ sfc_Cs2.png \ int_Cs1.png \ int_Cs2.png \ int_Cs1b.png \ int_Cs2b.png \ ua_wind-0.png \ ua_wind-1.png \ ua_wmag-0.png \ ua_wmag-1.png \ sfc_pwtr.png \ sfc_mslp.png \ 500_temp.png \ 700_temp.png \ 850_temp.png \ 925_temp.png \ 500_hgt.png \ ua_rh.png \ ua_rh8.png \ ua_vort.png \ sfc_shtfl.png \ sfc_lhtfl.png \ sfc_swr.png \ 2m_temp.png \ 2ds_temp.png \ 2m_dewp.png \ 10m_wind.png \ sfc_totp.png \ sfc_acp.png \ sfc_acpcp.png \ sfc_weasd.png \ ua_ceil.png \ ua_ctop.png set -A monpngs montage.png set -A webnames temp_sfc \ Cs1_sfc \ Cs2_sfc \ Cs1_int \ Cs2_int \ Cs1b_int \ Cs2b_int \ wind_850 \ wind_250 \ wmag_850 \ wmag_250 \ pwtr_sfc \ mslp_sfc \ temp_500 \ temp_700 \ temp_850 \ temp_925 \ hgt_500 \ rh_500 \ rh_850 \ vort_500 \ shtfl_sfc \ lhtfl_sfc \ swr_sfc \ temp_2m \ temp_2ds \ dewp_2m \ wind_10m \ totp_sfc \ 3hap_sfc \ acpcp_sfc \ weasd_sfc \ ceil \ ctop set -A webmon montage fi if [[ "$MODL" = *FIMCO2* ]]; then echo "This is FIMCO2" modelFound=1 set -A ncgms sfc_temp \ sfc_CO2 \ 3m1_CO2 \ ua_wind \ ua_wmag \ sfc_pwtr \ sfc_mslp \ 500_temp \ 700_temp \ 850_temp \ 925_temp \ 500_hgt \ ua_rh \ ua_rh8 \ ua_vort \ sfc_shtfl \ sfc_lhtfl \ sfc_swr \ 2m_temp \ 2ds_temp \ 2m_dewp \ 10m_wind \ sfc_totp \ sfc_acp \ sfc_acpcp \ sfc_weasd \ ua_ceil \ ua_ctop set -A pngs sfc_temp.png \ sfc_CO2.png \ 3m1_CO2.png \ ua_wind-0.png \ ua_wind-1.png \ ua_wmag-0.png \ ua_wmag-1.png \ sfc_pwtr.png \ sfc_mslp.png \ 500_temp.png \ 700_temp.png \ 850_temp.png \ 925_temp.png \ 500_hgt.png \ ua_rh.png \ ua_rh8.png \ ua_vort.png \ sfc_shtfl.png \ sfc_lhtfl.png \ sfc_swr.png \ 2m_temp.png \ 2ds_temp.png \ 2m_dewp.png \ 10m_wind.png \ sfc_totp.png \ sfc_acp.png \ sfc_acpcp.png \ sfc_weasd.png \ ua_ceil.png \ ua_ctop.png set -A monpngs montage.png set -A webnames temp_sfc \ CO2_sfc \ CO2_3m1 \ wind_850 \ wind_250 \ wmag_850 \ wmag_250 \ pwtr_sfc \ mslp_sfc \ temp_500 \ temp_700 \ temp_850 \ temp_925 \ hgt_500 \ rh_500 \ rh_850 \ vort_500 \ shtfl_sfc \ lhtfl_sfc \ swr_sfc \ temp_2m \ temp_2ds \ dewp_2m \ wind_10m \ totp_sfc \ 3hap_sfc \ acpcp_sfc \ weasd_sfc \ ceil \ ctop set -A webmon montage fi # FIMCO2 if [[ "$MODL" = *FIMX* ]]; then modelFound=1 echo "This is FIMX" set -A ncgms sfc_temp \ ua_wind \ ua_wmag \ sfc_pwtr \ sfc_mslp \ 500_temp \ 700_temp \ 850_temp \ 925_temp \ 500_hgt \ ua_rh \ ua_rh8 \ ua_vort \ sfc_shtfl \ sfc_lhtfl \ 2m_temp \ 2ds_temp \ 2m_dewp \ 10m_wind \ sfc_totp \ sfc_acp \ sfc_acpcp \ sfc_weasd \ ua_ceil \ ua_ctop \ int_PM25 \ int_ash \ int_bc \ int_fd \ int_oc \ int_sulf \ ua_ash \ sfc_aod set -A pngs sfc_temp.png \ ua_wind-0.png \ ua_wind-1.png \ ua_wind-2.png \ ua_wind-3.png \ ua_wind-4.png \ ua_wind-5.png \ ua_wmag-0.png \ ua_wmag-1.png \ ua_wmag-2.png \ ua_wmag-3.png \ ua_wmag-4.png \ ua_wmag-5.png \ sfc_pwtr.png \ sfc_mslp.png \ 500_temp.png \ 700_temp.png \ 850_temp.png \ 925_temp.png \ 500_hgt.png \ ua_rh.png \ ua_rh8.png \ ua_vort.png \ sfc_shtfl.png \ sfc_lhtfl.png \ 2m_temp.png \ 2ds_temp.png \ 2m_dewp.png \ 10m_wind.png \ sfc_totp.png \ sfc_acp.png \ sfc_acpcp.png \ sfc_weasd.png \ ua_ceil.png \ ua_ctop.png \ int_PM25.png \ int_ash.png \ int_bc.png \ int_fd.png \ int_oc.png \ int_sulf.png \ ua_ash-0.png \ ua_ash-1.png \ ua_ash-2.png \ sfc_aod.png set -A monpngs montage.png set -A webnames temp_sfc \ wind_850 \ wind_250 \ wind_25 \ wind_20 \ wind_10 \ wind_5 \ wmag_850 \ wmag_250 \ wmag_25 \ wmag_20 \ wmag_10 \ wmag_5 \ pwtr_sfc \ mslp_sfc \ temp_500 \ temp_700 \ temp_850 \ temp_925 \ hgt_500 \ rh_500 \ rh_850 \ vort_500 \ shtfl_sfc \ lhtfl_sfc \ temp_2m \ temp_2ds \ dewp_2m \ wind_10m \ totp_sfc \ 3hap_sfc \ acpcp_sfc \ weasd_sfc \ ceil \ ctop \ PM25_int \ ash_int \ bc_int \ fd_int \ oc_int \ sulf_int \ ash_sfc20 \ ash_2035 \ ash_3550 \ aod_sfc set -A webmon montage fi # FIMX if [[ $modelFound -eq 0 ]]; then echo "This is FIM" set -A ncgms sfc_temp \ ua_wind \ ua_wmag \ sfc_pwtr \ sfc_mslp \ 500_temp \ 700_temp \ 850_temp \ 925_temp \ 500_hgt \ ua_rh \ ua_rh8 \ ua_vort \ sfc_shtfl \ sfc_lhtfl \ sfc_swr \ 2m_temp \ 2ds_temp \ 2m_dewp \ 10m_wind \ sfc_totp \ sfc_acp \ sfc_acpcp \ sfc_weasd \ sfc_rhpw \ ua_ceil \ ua_ctop set -A pngs sfc_temp.png \ ua_wind-0.png \ ua_wind-1.png \ ua_wind-2.png \ ua_wind-3.png \ ua_wind-4.png \ ua_wind-5.png \ ua_wmag-0.png \ ua_wmag-1.png \ ua_wmag-2.png \ ua_wmag-3.png \ ua_wmag-4.png \ ua_wmag-5.png \ sfc_pwtr.png \ sfc_mslp.png \ 500_temp.png \ 700_temp.png \ 850_temp.png \ 925_temp.png \ 500_hgt.png \ ua_rh.png \ ua_rh8.png \ ua_vort.png \ sfc_shtfl.png \ sfc_lhtfl.png \ sfc_swr.png \ 2m_temp.png \ 2ds_temp.png \ 2m_dewp.png \ 10m_wind.png \ sfc_totp.png \ sfc_acp.png \ sfc_acpcp.png \ sfc_weasd.png \ sfc_rhpw.png \ ua_ceil.png \ ua_ctop.png set -A monpngs montage.png set -A webnames temp_sfc \ wind_850 \ wind_250 \ wind_25 \ wind_20 \ wind_10 \ wind_5 \ wmag_850 \ wmag_250 \ wmag_25 \ wmag_20 \ wmag_10 \ wmag_5 \ pwtr_sfc \ mslp_sfc \ temp_500 \ temp_700 \ temp_850 \ temp_925 \ hgt_500 \ rh_500 \ rh_850 \ vort_500 \ shtfl_sfc \ lhtfl_sfc \ swr_sfc \ temp_2m \ temp_2ds \ dewp_2m \ wind_10m \ totp_sfc \ 3hap_sfc \ acpcp_sfc \ weasd_sfc \ rhpw_sfc \ ceil \ ctop set -A webmon montage fi # FIM fi # nat == 1 ncl_error=0 # Run the NCL scripts for each plot i=0 while [ ${i} -lt ${#ncgms[@]} ]; do plot=${ncgms[${i}]} ${ECHO} "Starting fim_${plot}.ncl at `${DATE}`" ${NCL} < ${NCL_ROOT}/fim_${plot}.ncl error=$? if [ ${error} -ne 0 ]; then ${ECHO} "ERROR: ${plot} crashed! Exit status=${error}" ncl_error=${error} fi ${ECHO} "Finished fim_${plot}.ncl at `${DATE}`" (( i=i + 1 )) done # Run ctrans on all the .ncgm files to translate them into Sun Raster files # NOTE: ctrans ONLY works for 32-bit versions of NCL i=0 while [ ${i} -lt ${#ncgms[@]} ]; do plot=${ncgms[${i}]} ${ECHO} "Starting ctrans for ${plot}.ncgm at `${DATE}`" # normal image ${CTRANS} -d sun ${plot}.ncgm -resolution 1132x906 > ${plot}.ras error=$? if [ ${error} -ne 0 ]; then ${ECHO} "ERROR: ctrans ${plot}.ncgm crashed! Exit status=${error}" ncl_error=${error} fi if [ "${ISDIR}" == "NAT" ]; then # montage image ${CTRANS} -d sun ${plot}.ncgm -resolution 2176x1360 > ${plot}_mon.ras error=$? if [ ${error} -ne 0 ]; then ${ECHO} "ERROR: ctrans ${plot}.ncgm crashed! Exit status=${error}" ncl_error=${error} fi ls -al ${plot}_mon.ras if [ -s ${plot}_mon.ras ]; then ${CONVERT} -trim -border 30x12 -bordercolor black ${plot}_mon.ras ${plot}_mon.ras error=$? if [ ${error} -ne 0 ]; then ${ECHO} "ERROR: convert ${plot}_mon.ras crashed! Exit status=${error}" ncl_error=${error} fi else ${ECHO} "No file to convert, exit gracefully" ncl_error=0 fi fi ${ECHO} "Finished ctrans for ${plot}.ncgm at `${DATE}`" (( i=i + 1 )) done # Convert the .ras files into .png files i=0 while [ ${i} -lt ${#ncgms[@]} ]; do plot=${ncgms[${i}]} ${ECHO} "Starting convert for ${plot}.ras at `${DATE}`" # normal image ls -al ${plot}.ras if [ -s ${plot}.ras ]; then ${CONVERT} -colors 128 -trim -border 25x25 -bordercolor black ${plot}.ras ${plot}.png error=$? if [ ${error} -ne 0 ]; then ${ECHO} "ERROR: convert ${plot}.ras crashed! Exit status=${error}" ncl_error=${error} fi else ${ECHO} "No file to convert, exit gracefully" ncl_error=0 fi if [ "${ISDIR}" == "NAT" ]; then # montage image ls -al ${plot}_mon.ras if [ -s ${plot}_mon.ras ]; then ${CONVERT} ${plot}_mon.ras ${plot}_mon.png error=$? if [ ${error} -ne 0 ]; then ${ECHO} "ERROR: convert ${plot}_mon.ras crashed! Exit status=${error}" ncl_error=${error} fi else ${ECHO} "No file to convert, exit gracefully" ncl_error=0 fi fi ${ECHO} "Finished convert for ${plot}.ras at `${DATE}`" (( i=i + 1 )) done if [ "${ISDIR}" == "NAT" ]; then # put together the montage images # -geometry formerly 1240x775+20+1 if [[ -s ua_wind_mon-1.png || -s sfc_pwtr_mon.png || -s 850_temp_mon.png || -s sfc_totp_mon.png ]]; then ${MONTAGE} ua_wind_mon-1.png sfc_pwtr_mon.png 850_temp_mon.png sfc_totp_mon.png -tile 2x2 -geometry 1240x775+21+4 -background black montage.png error=$? if [ ${error} -ne 0 ]; then ${ECHO} "ERROR: montage crashed! Exit status=${error}" ncl_error=${error} fi else ${ECHO} "No files available to montage, exit gracefully" ncl_error=0 fi fi # Copy png files to their proper names i=0 while [ ${i} -lt ${#pngs[@]} ]; do pngfile=${pngs[${i}]} webfile=${FIM_HOME}/FIMrun/fim_${GLVL}_${NVL}_${PES}_${yyyymmddhhmm}/ncl_${MEMBER_ID}/${GRID_NAME}/${webnames[${i}]}_f${FCST_TIME}.png ${MV} ${pngfile} ${webfile} (( i=i + 1 )) done if [ "${ISDIR}" == "NAT" ]; then # Copy montage files to their proper names i=0 while [ ${i} -lt ${#monpngs[@]} ]; do pngfile=${monpngs[${i}]} webfile=${FIM_HOME}/FIMrun/fim_${GLVL}_${NVL}_${PES}_${yyyymmddhhmm}/ncl_${MEMBER_ID}/${GRID_NAME}/${webmon[${i}]}_f${FCST_TIME}.png ${MV} ${pngfile} ${webfile} (( i=i + 1 )) done fi # Remove the workdir cd ../ ${RM} -rf ${workdir} # Hack to prevent errors for analysis file from crashing the whole thing if [[ ${FCST_TIME} -eq 0 ]]; then ncl_error=0 fi ${ECHO} "ncl.ksh completed at `${DATE}`" exit ${ncl_error}