WXSYS
Weather Lore + Fuzzy Logic = Weather Forecasts

© 1997 by Walter Maner and Sean Joyce
Presented at the 1997 CLIPS Virtual Conference
Distributed with Girratano and Riley, Expert Systems Principles and Programming, 3rd edition

  1. Back Top Next
    Why try to improve on official forecasts?

    Over the past ten years, weather predictions have improved greatly in accuracy because of the convergence of satellite data, numerical models, and real-time computer processing power. These forecast engines, while impressive, have some important limitations.

    First, commonly available public forecasts are issued for relatively large "zones" covering perhaps a dozen counties and a half-dozen major cities. Local weather can vary considerably within a forecast zone. Our local terrain is very flat, for example, which reduces wind abatement and allows rainwater to soak deeply into the soil. Depending on wind direction and season, our local atmosphere may have been hydrated and moderated by passing over Lake Erie to the northeast. During winter daylight hours, the sun shines less than 40% of the time. Local winds tend to be from the west southwest or southwest, except during April, when they are easterly.

    Because every region is exceptional to some degree, we believe that computer-assisted forecasting could be improved if, as a last step, the process were refined by an expert system that could take better account of local climatic modifiers.

    Second, commonly available public forecasts are based on observations that may be as much as eight hours old. Indeed, base data for some of the widely-used atmospheric models could be as much as twelve hours old. Given this lag time, we conclude that data obsolescence will continue to be a compromising factor for the foreseeable future, and that this lag will continue to limit the validity of forecasts, especially toward the end of the forecast window.

    Given this situation, we believe that commonly available public forecasts could become more reliable if, as a last step, they were adjusted by an expert system that could take better account of current and changing local conditions.

    In Phase I of our study (reported here), we wish to determine whether data regarding current local conditions, combined with forecasting rules that embody local "weather lore," can produce useful short-term forecasts. While some researchers report good success with expert systems that rely on local measurements alone [SCH97], our ultimate goal, in Phase II, is to sharpen, refine and correct publicly available forecasts.

    For Phase I, we constructed a rule-based fuzzy expert system, WXSYS, that predicts local weather changes for a portion of northwest Ohio by applying commonsense forecasting guidelines selected from those appearing in books that emphasize weather lore. The program, which embodies 46 forecasting rules within about 2000 lines of FuzzyCLIPS code, may be the first rule-based fuzzy expert system that attempts to predict local weather based on conventional wisdom.

  2. Back Top Next
    Why use fuzzy logic to predict the weather?

    There are at least three reasons why fuzzy logic seems ideally suited for weather forecasting.

    First, even a shallow analysis of language used in conventional forecasts will be more than sufficient to demonstrate that they are inherently and intentionally fuzzy. Consider, for example, these commonly occurring phrases:

    All of these values, along with characteristic "hedge" words like "increasing" and "mostly," map nicely into the architecture of fuzzy sets.

    Second, fuzzy logic is known to work in this domain. Bjarne Hansen, for example, has built two fuzzy weather systems, one that correctly predicts ceiling and visibility [HAN98], and another (SIGMAR) that critiques marine forecasts [HAN97]. Gottfried Shaffar built a fuzzy system, HS4Cast, that forecasts icing conditions on roadways based on fuzzy temperature estimates that are accurate with 0.75 degrees or less [SCH97].

    Finally, and more philosophically, the weather domain meets the general conditions under which a fuzzy solution is thought to be appropriate:

  3. Back Top Next
    Why turn to "weather lore" as a source for fuzzy rules?

    Expert systems derive their expertise from real experts, but where are the experts who forecast weather based on direct observation? In the recent past, professional meteorologists presumably had this kind of expertise. Today, we believe this expertise derives mainly from the collective experience of persons whose lives and livelihood depend on their ability to predict changing local weather: anglers, hunters, farmers, sailors, bush pilots, mountaineers, campers, balloonists, and persons living permanently in the backcountry. Fortunately, many of their insights have been passed from one generation to the next as "weather lore" and collected in various weather almanacs.

    An additional advantage of weather lore, for us, is that it is nearly always expressed in rules of thumb that embody prototypically fuzzy input/output relationships. Goldsack [GOL86] gives this example:

    When the wind sets in from points between south and southeast and the barometer falls steadily, a storm is approaching from the west or northwest, and its center will pass near or north of the observer within 12 to 24 hours.

    Weather proverbs, especially those relating to the actions of animals and the condition of vegetation, are of little value. On the other hand, many proverbs relating to the condition of the atmosphere are worth testing. We concede that proverbs, even those that have a scientific basis, may be valid in only one locale, or during one season of the year, or in only one hemisphere, or only at sea. This is not a problem for us because we specifically seek ways to introduce local modifiers into a local model. Testing is needed to determine which commonsense rules are likely to be helpful in any particular area.

  4. Back Top Next
    What is included in our forecasts?

    Given sufficient data, our system issues one forecast for the next 12 hours and a separate forecast for the next 12-24 hours. Within each of these two time periods, given sufficient data, our system forecasts a "general trend" and "detailed weather." Each element of the forecast is listed with an associated fuzzily-determined probability. For the general trend, possible forecast elements include:

    For the detailed weather, possible forecast elements include:

    It is important to note that, in a fuzzy system, these forecast elements are not mutually exclusive. In fact, to a casual observer, our forecasts may occasionally appear to be self-contradictory. We plan to address these seeming inconsistencies in Phase II by adding rules about the sequencing of events. So, instead of forecasting both wet and dry weather for some 12-hour period, we can instead forecast wet weather first, following by dry.

  5. Back Top Next
    How was "weather lore" used to build forecast rules?

    From all of the "weather lore" available to us, we chose to base our forecasts on four primary sources: (1) F. Forrester's book, 1001 Questions Answered about the Weather, (2) W. Kotsch's book, Weather for the Mariner, (3) an article from USA Today giving forecast rules for amateur meteorologists, and (4) R. Wells' Science-hobby Book of Weather Forecasting. We favored these sources because they seemed grounded in science rather than superstition, and because they contained rules (or decision tables) that were expressed clearly enough to allow unambiguous translation into code.

    Following are four rules typical of those we constructed, one taken from each of these sources. Given our use of long self-documenting identifiers, we hope most readers will find the code sufficiently readable. In any case, explaining fuzzy logic and CLIPS syntax is beyond the scope of this paper. Note: In the examples, "ff" means "fuzzy fact".

    1. Example from F. Forrester, 1001 Questions Answered About the Weather [FOR81]

      • Original version in plain English

        If altocumulus movement is from the south or southwest with surface winds veering and easterly, then precipitation is probable within 6 to 12 hours.

      • Translated version in FuzzyCLIPS
             (ff-current-primary-cloud-base middle)
             (ff-wind-direction-trend veering)
             (or
               (ff-current-primary-clouds-moving-from south)
               (ff-current-primary-clouds-moving-from southwest))
             (ff-current-wind-direction east)
             =>
             (assert
               (immediate-general-trend
                 (forecast change-in-weather))
               (immediate-detailed
                 (forecast wet))
               (future-detailed
                 (forecast wet)))
        

    2. Example from W. Kotch, Weather for the Mariner [KOT83]

      • Original version in plain English

        Weather will be generally clear when the wind shifts to a westerly direction. The greatest change occurs when the wind shifts from east through south to west.

      • Translated version in FuzzyCLIPS
             (or
               (ff-earlier-wind-direction east)
               (ff-earlier-wind-direction southeast)
               (ff-earlier-wind-direction south))
             (ff-current-wind-direction west)
             =>
             (assert
               (immediate-general-trend
                 (forecast change-in-weather))
               (immediate-detailed
                 (forecast dry-period)))
        

    3. Example from "Amateur forecasting: Predictions based on the barometer, wind direction," USA Today [USA96]

      • Original version in plain English

        If the current wind is blowing from S to SW and the current barometric pressure is rising from 30.00 or below, then the weather will be clearing within a few hours, then fair for several days.

      • Translated version in FuzzyCLIPS
             (or
               (ff-current-wind-direction south)
               (ff-current-wind-direction southwest)
             (current-barometric-pressure ?press)
             (test (<= 30.00 ?press))
             (ff-barometric-pressure-trend rising-slowly)
             =>
             (assert
               (immediate-general-trend
                 (forecast change-in-weather))
               (immediate-detailed
                 (forecast wet-period-ending))
               (immediate-detailed
                 (forecast dry-period))
               (future-detailed
                 (forecast dry-period))
        

    4. Example from R. Wells' Science-hobby Book of Weather Forecasting [WEL68]

      • Original version in plain English

        Generally, if the barometer falls steadily and the wind comes from an easterly quarter, expect foul weather.

      • Translated version in FuzzyCLIPS
             (ff-barometric-pressure-trend falling)
             (or
               (ff-current-wind-direction northeast)
               (ff-current-wind-direction east)
               (ff-current-wind-direction southeast))
             =>
             (assert
               (immediate-detailed
                 (forecast wet)))
        

  6. Back Top Next
    How does WXSYS work overall?

    Most types of data input by the program are assumed to come from sensors connected to a computerized home weather station. All remaining data are assumed to come from amateur observation of local clouds by the user. For trend analysis, two sets of data are used, one current and another three hours old.

    Following is a diagram showing how data flows through the various processes that make up our system:

    Data-flow Diagram of WXSYS

    The deliberate fuzzification of crisp sensor data in the process FUZZIFY-WEATHER-FACTS deserves explanation.

    First of all, the particular inference engine we use requires that all information be expressed fuzzily, even if it were initially crisp. The issue is: Does fuzzification introduce error? We admit that fuzzification, carelessly used, could introduce small amounts of error into a model. However, in our case, we have used fuzzification to express the normal error of measurement associated with crisp values. If the barometric pressure sensor readout is 30.06 inches of mercury, then the actual pressure is really 30.06 plus or minus some small margin of error. So we fuzzify barometric pressure by re-introducing the margin of error that is presumably present in the actual sensor reading.

    Secondly, we fuzzify crisp data so it can better match antecedent conditions of fuzzy rules. A sensor may be telling us the wind speed is 27 mph from 168 compass degrees, but a fuzzy forecasting rule may say only, "If the wind is strong and southerly, then expect a change in weather within 24 hours." Such a rule should fire with a strength proportional to how nearly southerly the wind is, and how strong. Perhaps common sense is enough to tell us that, even when we measure the wind instantaneously at 27 mph, actual wind speed probably fluctuates high and low of that point. Fuzzification re-introduces some of this behavior into the crisp measurement.

    Trends ("barometric pressure falling rapidly") are at the heart of many of our forecasting rules, so we thoroughly compare current with previous data in the module IDENTIFY-TRENDS. Where there exist established criteria for the proper use of descriptive language (e.g., "falling rapidly" or "increasing cloudiness"), we have built these criteria into the rules found in IDENTIFY-TRENDS.

  7. Back Top Next
    Why is user input confined to cloud observations?

    Clouds hold endless fascination for members of the human species, so it is not surprising that they figure very prominently in weather lore. Indeed, entire books [RUB84] have been devoted to predicting weather by "reading the clouds." It is probably fair to say that clouds contain more implicit meteorological information than all other weather phenomena combined. Absent technology, they are our only direct source of data about the atmosphere layered over our heads.

    Frankly, we would also like to believe that "reading the clouds" still requires a practiced human observer. Satellite pictures can give a synoptic view, and weather radar can distinguish between ice crystals and ordinary moisture, but only a human observer can distinguish between cirrostratus and cirrocumulus.

    Of course, reading the clouds can be difficult during nighttime hours and, during overcast conditions, high clouds are obscured. For these reasons, in Phase II, we expect to enlarge our system to allow entry of other types of user input. Thunder and lightening come to mind, and sky color, especially at sunrise and sunset, can be an important weather indicator.

  8. Back Top Next
    How does one use WXSYS?

    At present, because our program is not connected to a computerized weather monitor, it is necessary to feed such data to the program manually, in a batch file. User input can also be placed in the batch file but, if it is omitted, the system will prompt for the missing data.

    Input data is expressed as a set of FuzzyCLIPS assertions. Preparing data is as simple as filling in the slots:

    (assert
      (old-data-from-user
        (primary-cloud-base _____)            ; e.g., low
                                              ;       middle
                                              ;       high
        (primary-cloud-orientation _____)     ; e.g., vertical
                                              ;       horizontal
        (primary-clouds-moving-from _____)    ; e.g., not-applicable
                                              ;       unknown
                                              ;       north
                                              ;       northeast
                                              ;       east
                                              ;       southeast
                                              ;       south
                                              ;       southwest
                                              ;       west
                                              ;       northwest
        (secondary-cloud-base _____)          ; same
        (secondary-cloud-orientation _____)   ; same
        (secondary-clouds-moving-from _____)  ; same
        (cloud-cover _____))                  ; e.g., clear
                                              ;       partly-cloudy
                                              ;       cloudy
                                              ;       mostly-cloudy
                                              ;       overcast
      (new-data-from-user
        (primary-cloud-base _____)
        (primary-cloud-orientation _____)
        (primary-clouds-moving-from _____)
        (secondary-cloud-base _____)
        (secondary-cloud-orientation _____)
        (secondary-clouds-moving-from _____)
        (cloud-cover overcast))
    
      (old-data-from-computer
        (time-of-day _____)                   ; 0 .. 23
        (month _____)                         ; 1 .. 12
        (day-of-month _____)                  ; 1 .. 31
        (wind-speed _____)                    ; 0 .. 150
        (wind-from _____)                     ; 0 .. 359
        (barometric-pressure _____)           ; 28.0 .. 32.0
        (relative-humidity _____))            ; 0 .. 100
    
      (new-data-from-computer
        (time-of-day _____)
        (month _____)
        (day-of-month _____)
        (wind-speed _____)
        (wind-from _____)
        (barometric-pressure _____)
        (relative-humidity _____)))
    

    Facts grouped as new-data reflect current conditions; facts grouped as old-data reflect conditions three hours previously. Data from the user is fuzzy; data from the computer is crisp.

    Once the slots have been filled with proper values, the information can be saved to a batch file for input into the program. If you wish to automate the entire process, then your input file should look like this:

    (batch "HEDGES.BAT")
    (load "WXSYS.CLP")
    (reset)
    
    ; THE BIG ASSERT, WITH ALL SLOTS FILLED, GOES HERE
    
    (run)
    

    Then, assuming you save all of this to a file named MYDATA.BAT, you would simply type

    (batch "MYDATA.BAT")
    

    after launching FuzzyCLIPS. Consult the file TESTDATA.BAT for several interesting examples of input data sets.

  9. Back Top Next
    Does WXSYS make valid forecasts?

    We know the system makes reasonable forecasts much of the time, but we have much work remaining before we can begin formal validation. As an indicator of current performance, we provide the file TESTDATA.BAT. As it runs, the file generates several forecasts and lists them side-by-side with the actual weather conditions that were observed for the forecast period. Output from this case, for example, seems dead on:

    -----------------------------------------
    |   Earlier Weather Data/Observations   |
    -----------------------------------------
    Primary cloud base:            middle
    Primary cloud orientation:     very vertical
    Primary clouds moving from:    west
    Secondary cloud base:          middle
    Secondary cloud orientation:   horizontal
    Secondary clouds moving from:  west
    Cloud cover:                   mostly-cloudy
    Time of day (0-23):            9 hours Month (1-12): 1
    Day of month (1-31):           10
    Wind speed (0-150):            4 miles per hour
    Wind blowing from:             330 compass degrees
    Barometric pressure:           31.0 inches of mercury
    Relative humidity:             45 percent
    -----------------------------------------
    |   Current Weather Data/Observations   |
    -----------------------------------------
    Primary cloud base:            low
    Primary cloud orientation:     vertical
    Primary clouds moving from:    east
    Secondary cloud base:          low
    Secondary cloud orientation:   vertical
    Secondary clouds moving from:  west
    Cloud cover:                   overcast
    Time of day (0-23):            12 hours Month (1-12): 1
    Day of month (1-31):           10
    Wind speed (0-150):            4 miles per hour
    Wind blowing from:             80 compass degrees
    Barometric pressure:           30.0 inches of mercury
    Relative humidity:             99 percent
    -------------------------------------------
    |   FORECAST:  WITHIN THE NEXT 12 HOURS   |
    -------------------------------------------
    GENERAL TREND:
     no-change-in-weather     89.6%
     change-in-weather        11.7%
    DETAILED WEATHER:
     dry-period               20.9%
     stormy-period            11.7%
     wet                      100.0%
    -------------------------------------------
    |  FORECAST:  WITHIN THE NEXT 12-24 HOURS |
    -------------------------------------------
    GENERAL TREND:
     change-in-weather        1.7%
     no-change-in-weather     89.6%
    DETAILED WEATHER:
     dry-period               1.7%
     stormy-period-ending     1.7%
     wet                      89.6%
    ;
    ; =====================================================
    ; | ACTUAL CONDITIONS OBSERVED DURING FORECAST PERIOD |
    ; | Continued wet                                     |
    ; =====================================================
    ;
    

    In the following case, however, the program generates mixed signals for the first 12-hour period. The forecast for the second 12-hour period is reasonable.

    -----------------------------------------
    |   Earlier Weather Data/Observations   |
    -----------------------------------------
    Primary cloud base:            middle
    Primary cloud orientation:     vertical
    Primary clouds moving from:    west
    Secondary cloud base:          middle
    Secondary cloud orientation:   horizontal
    Secondary clouds moving from:  west
    Cloud cover:                   partly-cloudy
    Time of day (0-23):            9 hours Month (1-12): 5
    Day of month (1-31):           10
    Wind speed (0-150):            4 miles per hour
    Wind blowing from:             187 compass degrees
    Barometric pressure:           29.5 inches of mercury
    Relative humidity:             45 percent
    -----------------------------------------
    |   Current Weather Data/Observations   |
    -----------------------------------------
    Primary cloud base:            middle
    Primary cloud orientation:     vertical
    Primary clouds moving from:    west
    Secondary cloud base:          low
    Secondary cloud orientation:   very vertical
    Secondary clouds moving from:  west
    Cloud cover:                   partly-cloudy
    Time of day (0-23):            12 hours Month (1-12): 5
    Day of month (1-31):           10
    Wind speed (0-150):            4 miles per hour
    Wind blowing from:             190 compass degrees
    Barometric pressure:           30.3 inches of mercury
    Relative humidity:             60 percent
    -------------------------------------------
    |   FORECAST:  WITHIN THE NEXT 12 HOURS   |
    -------------------------------------------
    GENERAL TREND:
     no-change-in-weather     90.1%
     change-in-weather        89.6%
    DETAILED WEATHER:
     stormy-period            89.6%
     wet-period-ending        89.6%
     dry-period               90.1%
     wet                      0.4%
    -------------------------------------------
    |  FORECAST:  WITHIN THE NEXT 12-24 HOURS |
    -------------------------------------------
    GENERAL TREND:
    DETAILED WEATHER:
     dry-period               89.6%
    ;
    ; =====================================================
    ; | ACTUAL CONDITIONS OBSERVED DURING FORECAST PERIOD |
    ; | Dry but thunderstorms nearby                      |
    ; =====================================================
    
    
  10. Back Top Next
    What are our plans for WXSYS?

    Most importantly, we wish to discover how best to determine which rules are effective and which are not. Beyond that, we wish to develop a theoretical framework that will allow us to judge the validity of the complete system. For example, assume A and B were both forecast but A carried a higher likelihood. How valid was the forecast if only one but not the other event occurred? How valid was the forecast if the predicted event occurred, but was of short duration or of low intensity? How valid is a forecast that predicts the correct events but in the wrong time frame or in the wrong order? How valid is a forecast that predicts stormy weather but actual weather was merely wet and windy? It appears to us that we will need to write a separate validation module to make a fuzzy comparison of expected and actual weather data.

    Other plans include the following:

  11. Back Top Next
    Bibliography

    Following is a list of references we cited or consulted.  Additional sources are available on a separate page.

    [DAB81] Dabberdt, W. Weather for Outdoorsmen: A complete guide to understanding and predicting weather in mountains and valleys, on the water, and in the woods. Scribner, New York, 1981.

    [DUN87] Dunlop, S., and Wilson, F. Weather and Forecasting. Macmillan, New York, 1987.

    [FOR81] Forrester, F. 1001 Questions Answered about the Weather. Dover, New York, 1981.

    [GIR94] Girratano, J. and Riley, G. Expert Systems: Principles and Programming. Boston: PWS Publishing, 1994.

    [GOL86] Goldsack, P. Weatherwise. Newton Abbot, North Pomfret, Vermont, 1986.

    [HAN97] Hansen, B. SIGMAR: A fuzzy expert system for critiquing marine forecasts. AI Applications 11, 1 (1997).

    [HAN98] Hansen, B., and Riordan, D. Fuzzy case-based prediction of ceiling and visibility. First Conference on Artificial Intelligence of the American Meteorological Society, Phoenix, Arizona, January, 1998. http://chebucto.ns.ca/~bjarne/fuzzy_cbr

    [KOT83] Kotsch, W. Weather for the Mariner (3rd Ed). Annapolis, Naval Institute Press, 1983.

    [MUR95] Murtha, J. Applications of fuzzy logic in operational meteorology. Scientific Services and Professional Development Newsletter, Canadian Forces Weather Service. (1995).

    [ORC95] Orchard, R. A. FuzzyCLIPS Version 6.04: User's Guide. National Research Council, Canada, 1995. http://www.iit.nrc.ca/IR_public/fuzzy/fuzzyClips/fuzzyCLIPSIndex.html

    [RUB84] Rubin, L. and Duncan, J. Weather Wizard's Cloud Book: How You Can Forecast the Weather Accurately and Easily by Reading the Clouds. Algonquin Books, Chapel Hill, N.C., 1984.

    [SCH 97] Schaffar, G. HS4Cast - a reliable and automatic ice warning and weather forecast. http://www.Retzer-Land.co.at/zik-schaffar/e_1shs4.htm

    [USA96] Amateur forecasting: Predictions based on the barometer, wind direction. USA Today. (December 31, 1996). http://www.usatoday.com/weather/wfbarrow.htm

    [WAT67] Watts, A. Weather Forecasting, Ashore and Afloat. Adlard Coles, London, 1967.

    [WAT68] Watts, A. Instant Weather Forecasting. Adlard Coles, London, 1968.

    [WEL68] Wells, R. The Science-hobby Book of Weather Forecasting. Lerner, Minneapolis, 1968.