[Xfce4-commits] <xfce4-weather-plugin:master> Guess amount of snow precipitation from rain.

Harald Judt noreply at xfce.org
Sat Jan 12 09:00:01 CET 2013


Updating branch refs/heads/master
         to dcfe3722370cde78a4e633b21629818958751fad (commit)
       from 79ea5fa89e54d37366bbaf9cd8bb4f1e15e7a08b (commit)

commit dcfe3722370cde78a4e633b21629818958751fad
Author: Harald Judt <h.judt at gmx.at>
Date:   Sat Jan 12 08:55:18 2013 +0100

    Guess amount of snow precipitation from rain.
    
    While it may not be correct at all times, let's assume it works in most
    cases, and it may be more useful than the amount of precipitations in
    liquid state.

 panel-plugin/weather-config.c |   24 +++++++++++++++++++++++-
 panel-plugin/weather-data.c   |   23 ++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 343de44..2cc80cf 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -1558,7 +1558,29 @@ options_datatypes_set_tooltip(GtkWidget *optmenu)
     case PRECIPITATIONS:
         text = _("The amount of rain, drizzle, sleet, hail, snow, graupel "
                  "and other forms of water falling from the sky over a "
-                 "specific period.");
+                 "specific period.\n\n"
+                 "The values reported by met.no are those of precipitations "
+                 "in the liquid state - or in other words: of rain -, so if "
+                 "snow is expected (but not sleet), then the amount of snow "
+                 "will be <i>guessed</i> by multiplying the original value by "
+                 "a ratio dependent on the air temperature:\n\n<tt><small>"
+                 "                   T < -11.1 °C (12 °F) => 1:12\n"
+                 "-11.1 °C (12 °F) < T <  -4.4 °C (24 °F) => 1:10\n"
+                 " -4.4 °C (24 °F) < T <  -2.2 °C (28° F) => 1:7\n"
+                 " -2.2 °C (28 °F) < T <  -0.6 °C (31 °F) => 1:5\n"
+                 " -0.6 °C (31 °F) < T                    => 1:3\n\n"
+                 "</small></tt>"
+                 "Example: If temperature is -5 °C (12 °F), then snow "
+                 "density will be low and a rain to snow ratio of 1:10 will "
+                 "be used for calculation. Assuming the reported value is "
+                 "5 mm, then the calculated amount of snow precipitation is "
+                 "50 mm.\n\n"
+                 "<b>Note</b>: While air temperature is an important factor "
+                 "in this calculation, there are other influencing factors "
+                 "that the plugin doesn't know about like the type of snow "
+                 "and ground temperature. Because of that, these rules will "
+                 "only lead to rough estimates and may not represent the "
+                 "real amount of snow.");
         break;
     }
 
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index e8d434f..e217fb4 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -287,7 +287,7 @@ get_data(const xml_time *timeslice,
          const gboolean night_time)
 {
     const xml_location *loc = NULL;
-    gdouble val;
+    gdouble val, temp;
 
     if (timeslice == NULL || timeslice->location == NULL || units == NULL)
         return g_strdup("");
@@ -398,6 +398,27 @@ get_data(const xml_time *timeslice,
 
     case PRECIPITATIONS:   /* source is in millimeters */
         val = string_to_double(loc->precipitation_value, 0);
+
+        /* For snow, adjust precipitations dependent on temperature. Source:
+           http://answers.yahoo.com/question/index?qid=20061230123635AAAdZAe */
+        if (loc->symbol_id == SYMBOL_SNOWSUN ||
+            loc->symbol_id == SYMBOL_SNOW ||
+            loc->symbol_id == SYMBOL_SNOWTHUNDER ||
+            loc->symbol_id == SYMBOL_SNOWSUN_POLAR ||
+            loc->symbol_id == SYMBOL_SNOWSUNTHUNDER) {
+            temp = string_to_double(loc->temperature_value, 0);
+            if (temp < -11.1111)      /* below 12 °F, low snow density */
+                val *= 12;
+            else if (temp < -4.4444)  /* 12 to 24 °F, still low density */
+                val *= 10;
+            else if (temp < -2.2222)  /* 24 to 28 °F, more density */
+                val *= 7;
+            else if (temp < -0.5556)  /* 28 to 31 °F, wet, dense, melting */
+                val *= 5;
+            else                      /* anything above 31 °F */
+                val *= 3;
+        }
+
         if (units->precipitations == INCHES) {
             val /= 25.4;
             return g_strdup_printf("%.2f", val);


More information about the Xfce4-commits mailing list