**cliplot & climonthplot -- Climate Plots**

Part A: Program Information

**1.0 Program Name**: cliplot & climonthplot AAL ID:

Revision no.:

2.  **Purpose**:

cliplot and climonthplot read climate information from the PostgreSQL
database on AWIPS and generate a yearly or monthly plot of the observed
temperatures respectively. cliplot includes observed precipitation in
the chart. The plots contain observed data, normal data, and extreme
temperature data if available in the PostgreSQL database. The programs
generate a chart for each station in the climate database. Optionally
the climonthplot will create a text file with all the values for the
given month printed in a coma delimited format. Examples of each of the
plots are given in appendix A. These charts are also available on the
WFO Boise public web site at...

<http://www.wrh.noaa.gov/climate/temp_graphs.php?wfo=boi>

**3.0 Program Information**

Development Programmer: Paul Flatt

Location: WFO Boise, Idaho

Phone: (208) 334-9861 x223

e-mail: <paul.flatt@noaa.gov>

Maintenance Programmer: Paul Flatt

Location: WFO Boise, Idaho

Phone: (208) 334-9861 x223

e-mail: <paul.flatt@noaa.gov>

Programming Language: C

Executable Type: executable usually ran through a shell script to
control where output is placed and to transfer the output to an external
computer for display on a web site.

Host Machine: Any AWIPS linux computer with access to the PostgreSQL
database

**4.0 AWIPS Data File/Data Base Access**

**4.1 Data File Usage (flat files)**

\*.png files are created that have the following pattern...

ssssYEARplot.png

ssssYEARplot-2.png

ssssYEARbMOplot.png

ssssYEARbMOplot-2.png

ssssYEARplotline.png

ssssYEARMOplot.png

ssssYEARMOplot-2.png

sssscurrent#.png

\*.txt files are optionally created that have the following pattern...

ssssYEARMO.txt

where ssss is the 4 letter station ID (e.g. KBOI)

YEAR is the year of the plot (e.g. 2006)

MO is the month of the plot (e.g. 06)

\# can be either 1 or 2 depending on the zoom scale

Accesses AWIPS System/HydroMet Data Files: No

## 4.2 AFOS/Text Database Product Usage

Accesses AWIPS Text Database: No

## 4.3 AWIPS RDBMS Database/Table Usage

Accesses AWIPS PostgreSQL Database Tables: Yes

The programs access the following tables for read only

cli_sta_setup

daily_climate

day_climate_norm

**5.0 Portability**

Requires: libgd Version 2.0 or higher

libpq Version 3.1 or higher

**cliplot & climonthplot -- Climate Plots**

Part B: Program File and Database Information

## 1.0 Program File Information

## 1.1 Source File Inventory

Directory Name: /awips/dev/src/localapps/cliplot/

File Listing:

# Size Date/Time Filename File Type

23278 Apr 28 13:36 climonthplot executable

4483 Apr 28 13:35 climonthplot.c c source code

31706 Apr 28 13:36 cliplot executable

4721 Apr 22 08:06 cliplot.c c source code

1354 Apr 28 13:36 cliplot.h c Header file

1541 Apr 24 17:19 cliplot.sh shell script

256000 Apr 28 13:39 cliplot.tar Tar file

10136 Apr 22 10:02 getcli.c c source code

2086 Apr 22 10:03 getStationList.c c source code

714 Apr 17 08:45 Makefile Makefile

3142 Sep 20 2006 NOAAbug.png small image of a NOAA logo

20894 Apr 22 09:53 plotcli.c c source code

9494 Apr 24 18:36 plotmonthcli.c c source code

122880 Apr 28 13:37 Verdana.ttf True type font used in images

## 1.2 Application-Specific Data File Inventory

Uses Application-Specific Data Files: No

**1.3 File Disposition**

## 2.0 RDBMS Information

## 2.1 Database/Table Usage

Uses Application-Specific PostgreSQL Database Tables: Yes.

This program reads data from the following files in the hmdb database

cli_sta_setup

daily_climate

day_climate_norm

## 2.2 Database Schema

**2.3 Data Dictionary**

**cliplot & climonthplot -- Climate Plots**

Part C: Program Creation and Installation Procedures

**1.0 Tar File Information**

Tar file provided: Yes

Medium:

Download from AWIPS Local Application Database

File Listing:

# Size Date/Time Filename

68128 Apr 28, 2008 cliplot.tar.gz

256000 Apr 28, 2008 cliplot.tar

**2.0 Program Creation and Installation**

> Store the cliplot.tar.gz file into its own directory under the
> /awips/dev or other local application source directory. ***Various
> parts of the program expect to find information in
> /awips/dev/localapps/cliplot/. If you choose another destination, the
> program must be recompiled.*** Unzip the zipped file with the
> following command:

unzip cliplot.tar.gz

> Untar the file with the following command:
>
> tar --xvf cliplot.tar
>
> The cliplot and climonthplot files are executable and should be ready
> for use as is. If they must be recompiled, use the following command:
>
> make cliplot
>
> make climonthplot
>
> ***cliplot and climonthplot expect to find the NOAAbug.png file and
> the Verdana.ttf font file in the /awips/dev/localapps/cliplot
> directory. If you place these files in a different directory, the
> programs must be modified where appropriate (usually in the cliplot.h
> file) and recompiled.***
>
> ***When AWIPS is upgraded, frequently a new library required (gd or
> pq) will need to be relinked into the program. Simply run the above
> two "make" commands to make new executables and all new libraries
> should be found.***
>
> Likewise, the cliplot.sh script is written to run cliplot and
> climonthplot from the /awips/dev/localapps/cliplot directory. If you
> choose to use a different directory, modify cliplot.sh to point to the
> correct location.
>
> Cliplot.sh must be modified if you wish to move the image files out of
> AWIPS to an external computer like a web server. Cliplot.sh is self
> documented to show you where to make modifications to accomplish an
> ftp to an external computer.

**2.1 Makefiles**

Makefile

**2.2 Application Environment**

Operating System: linux -- Used with OB6

Compiler/Interpreter: gcc

Environment Variables: The programs need access to the environment
variables associated with PostgreSQL access. For this reason, a script
where the proper environment variables are set is the preferred method
of program execution.

**2.3 Detailed Installation Procedures**

The only file needed to run the program is the executable generated via
the makefile instructions given above under section 2.0.

**2.4 Installation Scripts**

None

**Cliplot & climonthplot -- Climate Plots**

Part D: Program Execution and Error Conditions

Program Name: cliplot & climonthplot AAL ID:

Revision no.:

Program Execution

cliplot \[ -a yyyymm -h -n -o /output/dir -s KSTN -t -w -y year \]

Where...

> -a yyyymm is the beginning year month for a 12 month chart. Without
> this option the chart runs from Jan 1 through Dec 31. This option can
> create a water year chart running from Oct 1 through Sep 30, or any
> chart for one year beginning on the first of any month. The name of
> the file generated will be in the form KSTNYYYYbMOplot.png, where KSTN
> is the station id, YYYY is the beginning Year, MO is the beginning
> month.
>
> -h Print usage instructions, do not generate any charts.
>
> -n This switch, if present, will cause the station NAME, ST as it
> appears in the cccCLIxxx product to be at the top of the chart.
> Without the --n switch, the 4 letter station identifier will be
> printed (e.g. without --n "KBOI" is printed, with the --n switch
> "BOISE, ID" is printed).
>
> -o /output/dir is the directory to place the generated images into.
> Default is to place the images in the current directory.
>
> -s KSTN is a specific station to plot. Only charts for that one
> station will be made
>
> -t tells it to make plots with filled lines and colors, without the
> --t a line plot is created.
>
> -w Include Snowfall information on the bottom of the chart. Without
> the --w option, no snowfall information is plotted.
>
> -y year tells it to plot data for a specific year. Default is to plot
> the data for the current day minus one day (e.g. on june 30 it plots
> data for the current year, on January 1 it plots data for the previous
> year).
>
> climonthplot \[ -c -m month -o output/dir -y year -z \# \]

Where...

> -c This switch tells the software to create a chart for 31 days with
> the ending day 5 days in the future. In other words, this is a
> "current" chart. The name of the output file will be aaaacurrentZ.png
> where aaaa is the 4 letter station identifier, and Z is the zoom level
> (see below).
>
> -o This switch tells the software to use the output/dir as the output
> directory to place the generated images into. Default is to place the
> images in the current directory.
>
> -y year tells it to plot data for a specific year. Default is to plot
> the data for the current day minus one day (e.g. on June 30 it plots
> data for the current year, on January 1 it plots data for the previous
> year).
>
> -m month tells it to plot data for a specific month. Default is to
> plot the data for the current day minus one day (e.g. on June 30 it
> plots data for June, on July 1 it plots data for June).
>
> -x If included, output a table of coma delimited data for the
>
> entire month. The format of the data is...
>
> day,min,max,nmin,nmax,xmin,yrmin,xmax,yrmax,pcp,npcp,sno,nsno
>
> Where day = day of the month, min=min temp, max=max temp, nmin=normal
> min, nmax=normal max, xmin=extreme min, yrmin=year of extreme min,
> xmax=extreme max, yrmax=year of extreme max, pcp=daily precip,
> npcp=normal precip for the day, sno=snow fall for the day, nsno=normal
> snow fall for the day.
>
> -z \# where \# is either 1 or 2. This is the zoom level, 1 is the
> default and generates a small image, 2 generates an image twice the
> size as the small image. For zoom level 2, the zoom level will be
> appended to the file name following a dash.

1.  Each of these program generates \*.png files that are stored in the
    current directory (unless the -o option is used). It is best to run
    each of these programs from within a shell script so that the \*.png
    image files can be placed where desired, transferred outside AWIPS,
    and deleted if desired.

2.  When run, each program reads the cli_sta_setup table to collect the
    list of stations stored in the climate database. The station_info
    table is then read to collect further information on the stations to
    be plotted.

3.  Charts are created for each station found in the cli_sta_setup table
    (unless the --s KSTN option is provided, then only charts for that
    station are created).

4.  cliplot generates a full size and half size version of the yearly
    chart.

5.  climonthplot generates a small chart of the current month minus one
    day.

6.  Each program generates a plot for the current period minus one day
    (e.g. on June 30, 2006 the cliplot will create a chart for 2006,
    climonthplot will create a chart for June 2006, on January 1, 2006
    cliplot will create a chart for 2005, climonthplot will create a
    chart for December 2005).

7.  The program is normally run once/day via cron after the previous
    days climate data has been quality controlled (e.g. around 6am local
    time).

8.  Error Conditions:

Error conditions are sent to stderr when they occur and the program is
terminated. The following return values are used to diagnose the
error...

Return Value Error Condition

1.  No Errors

2.  The program was unable to read the cli_sta_setup table to collect a
    list of stations.

3.  The -s KSTN option was used and station KSTN could not be found in
    the database.

4.  The program could not allocate memory to store data.

Appendix A -- cliplot & cliimonthplot examples

![](media/image1.png){width="2.3541666666666665in"
height="1.7291666666666667in"}

Figure 1 - Output from climonthplot containing month to day data
(KBOI200607plot.png).

![](media/image3.png){width="2.9993055555555554in"
height="2.009027777777778in"}

Figure 3 -- A monthly chart like above with the zoom scale set to 2.

Figure 2 - Output from climonthplot containing data for the while month
(KBOI200603plot.png).

![](media/image4.png){width="2.3541666666666665in"
height="1.7291666666666667in"}

Figure 2 - A current monthly chart.

![](media/image5.png){width="6.495138888888889in"
height="4.8694444444444445in"}

Figure 3 - Output from cliplot showing year to date data using the --t
command line option. Both normal and extreme data are in the database
for each day for this station (KBOI2006plot.png).

![](media/image6.png){width="4.822916666666667in" height="3.59375in"}

Figure 4 - Output from cliplot with the -t option, half size version
(KBOI2006plot-2.png).

![](media/image7.png){width="6.495138888888889in"
height="4.8694444444444445in"}

Figure 5 - Output from cliplot without the -t command line option
(KBOI2006plotline.png).

![](media/image8.png){width="6.495138888888889in"
height="4.8694444444444445in"}

Figure 6 - Output from cliplot using the -t option for a station where
extreme data has not been stored (KMYL2006plot.png).

![](media/image9.png){width="6.495138888888889in"
height="5.654861111111111in"}

Figure 7 - Yearly chart with snowfall included.

![](media/image10.png){width="6.495138888888889in"
height="5.654861111111111in"}

Figure 8 - Yearly chart with the beginning month changed to correspond
to the water year.

**Figure 9: A table of data output from climonthplot using the --x
option.**