Page 1 of 1

Winter total rainfall?

Posted: Thu Jun 05, 2014 3:31 pm
by panos1981
Hi,

I wonder if there is any way to have a math which can give the total rainfall of the current winter. Such a variable should start the rainfall counting from 01/10 of a year and will stop it on 30/09 of the following year ("winter period" --> e.g. October 2013 to September 2014). Every 1st of October it should start counting again the new winter total.

Any idea on it?

Thanks

Re: Winter total rainfall?

Posted: Thu Jun 05, 2014 6:21 pm
by wvdkuil
panos1981 wrote:Hi,
I wonder if there is any way to have a math which can give the total rainfall of the current winter. Such a variable should start the rainfall counting from 01/10 of a year and will stop it on 30/09 of the following year ("winter period" --> e.g. October 2013 to September 2014). Every 1st of October it should start counting again the new winter total.
Any idea on it?

Thanks
I am just curious.
How do you define winter?
On the northern part af the world winter goes from December 1 to (but not including) March 1.
On the southern part of the world they have the meteorological winter from June 1 to (but not including) September 1.

===

Maybe this is a solution for your question?

In meteohub there are so called seq<timeframe> tags which are recorded with different intervals.

seqmonth1 contains the Last 14 months in steps of 1 month(last month .. today -14 months)
Example from my Meteohub:
seqmonth1_rain0_total_mm 54.00_10.00_15.80_53.20_43.80_47.00_78.00_59.20_54.20_24.60_64.00_34.40_64.40_

You can calculate the rain values for any combination of months this way, I think.

Hope this helps,

Wim

Re: Winter total rainfall?

Posted: Thu Jun 05, 2014 11:04 pm
by panos1981
Thank you for your reply.

I wasn't clear enough about the "winter period". Actually I meant the period which starts with the Autumn (beginning of raining) and ends when the new Autumn comes (new beginning of raining). It is just a technical division, not really corresponding to actual seasons.

About seq??? <time frame>, can you give me a more specific example of how I can calculate rain values of some given months (e.g. I want to calculate the rainfall sum of the three last months of 2013 - can I do something like this?).

Thanks

Re: Winter total rainfall?

Posted: Fri Jun 06, 2014 11:40 am
by wvdkuil
panos1981 wrote:Thank you for your reply.

I wasn't clear enough about the "winter period". Actually I meant the period which starts with the Autumn (beginning of raining) and ends when the new Autumn comes (new beginning of raining). It is just a technical division, not really corresponding to actual seasons.

About seq??? <time frame>, can you give me a more specific example of how I can calculate rain values of some given months (e.g. I want to calculate the rainfall sum of the three last months of 2013 - can I do something like this?).

Thanks
This is more a programming than a weather-program question.

Code: Select all

<?php
# this scripts calculates the total rain value for a season starting at the month oktober
#
# 1. put this html file in meteohub graphs folder
# 2. let meteouhub upload this file once a day with the new name seqmonth.php
# 3. include this seqmonth.php script in your current web site scripts.
#
# the value returned contains the rain value for the CURRENT season, so in oktober only the amount of the month oktober.
#
$stringSeq				= "[seqmonth1_rain0_total_mm]"; // tags to be filled with data by meteohub
$valueRainSeason		= [month1_rain0_total_mm];		// here we will put the rain-value for the CURRENT rain season

if (trim($stringSeq) == '') {echo 'error, seasons data not available'; return $valueRainSeason;}

$currentMonth 			= date('m',time());
if ($currentMonth == '10') {return $valueRainSeason;}	// oktober is the first month of the rain-season

# calculate the first month of oktober in the seqmonth1 'array'
# data in the seqmonth string is:	54.00_10.00_15.80_53.20_43.80_47.00_78.00_59.20_54.20_24.60_64.00_34.40_64.40_
# it is now june, the months are:   may   apr   mar   feb   jan   dec   nov   okt   sep    aug  jul   jun   may
#
$oktInArray				= $currentMonth	- 10;
if ($oktInArray < 0) {$oktInArray = $oktInArray + 12;}

$arrMonths				= explode (' ', $stringSeq);	// put the seqmonth1 data in an array;

for ($counter = 0; $counter < $oktInArray; $counter++) {
	$valueRainSeason	= $valueRainSeason + $arrMonths[$counter];
}
echo "<!-- Calculated for month: $currentMonth. Input: $stringSeq. Value:  $valueRainSeason. -->".PHP_EOL;
return $valueRainSeason;

?>

I attached the html / php script also.
Succes, Wim