*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

RemediateSolarTime

Starting with DB v11.5 vproweather v1.0.8

Sets the MinutesRad column in the Solar table to the new format starting in
DB v11.5 i.e. mmm.ss where mmm = Minutes ss = Seconds

Run this after to have upgraded the DB to v11.5 and are using vproweather
v1.0.8 or later

You can run this at anytime thereafter it will only update the MinutesRad
column if it is found to differ. 

If you have data from mutltiple Vantage Pro Consoles stored in the DB you 
will need to run it for each Console ID. This updates Console ID 0 by 
default:
    ./RemediateSolarTime 1
    ./RemediateSolarTime 2

You may need to set your "$password" in RemediateSolarTime

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

RemediateRainTable

Starting with DB v11.5 vproweather v1.0.8

This populates the new PerMinute column in the Rain table starting with DB 
v11.5 and will set the IncrementalRain column if necessary using data
stored in the database.

Run this after to have upgraded the DB to v11.5 and are using vproweather 
v1.0.8 or later

You can run this at anytime thereafter it will only update the 
IncrementalRain column and PerMinute column if they are found to differ. 

If you have data from mutltiple Vantage Pro Consoles stored in the DB you
will need to run it for each Console ID. This updates Console ID 0 by
default:
      ./RemediateRainTable 1
      ./RemediateRainTable 2

This may take a bit of time to run if you have years of data in the DB. 
You can pipe the STDERR output to a log which will show everthing it 
updates.

You may need to set your $password in "RemediateRainTable"


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

convertToCSV

Starting with DB v11.1 vproweather v1.0.0

The "convertToCSV" Perl script and its associated configuration file
"convertToCSV.conf" can be used to convert any existing Weather data in 
CSV (comma separated fields or single character deliminated fields) to a 
format that the "LoadWeatherData" "-C" option can then use load into the 
Weather DB. See the "convertToCSV.conf" file for more information on how 
to do that.

The "set*" perl scripts below will populate the new columns in the 11.0 
and 11.1 versions of the Weather DB. It order for all of them to work 
properly the WeatherDB needs to be at version 11.1.

So do the 10 --> 11.1 or the 11 --> 11.1 DB upgrade before attempting to
run these scripts. You will also need to edit each script and provide 
your root mysql password in the $password variable. As of DB Version 11.5
you should also set the "vpID" variable to the Vantage Pro Console ID 
you want to run these for if you have data for multiple Vantage Pro 
Consoles in the DB. If you do not then the "vpID" is set by default to
Console ID "0" (zero).

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

setDTttTime

For DB v11.1 and vproweather only before v0.9.9

Update the new rtTT & wxTT columns using the values in the rtCaptureTime & 
wxCaptureTime collumns respectively. vproweather v0.9.9 and above will 
update this column going forward. You may to set your $password in 
"setDTttTime".

If you have data from mutltiple Vantage Pro Consoles stored in the DB you 
will need to run it for each Console ID. If updates Console ID 0 by default:
    ./setDTttTime 1
    ./setDTttTime 2


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

setIndexDTttTimes

For DB v11.1 and vproweather only before v0.9.9

This script will do the same operation as the setDTttTime except it will 
populate the new bTT column in the DT Table. vproweather v0.9.9 and above
will update the bTT column going forward. You may need to set your 
$password in "setIndexDTttTimes".

If you have data from mutltiple Vantage Pro Consoles stored in the DB you 
will need to run it for each Console ID. If updates Console ID 0 by 
default:
    ./setIndexDTttTimes 1
    ./setIndexDTttTimes 2


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

setIncrementalRain

For DB v11.1 and vproweather only before v1.0.0

added new IncrementalRain column in the Rain table. This script will 
update that new column using the StormAmount or RainDay values already 
in the Rain table. vproweather 1.0.0 and above will update the 
IncrementalRain column going forward. You may need to set your $password 
in "setIncrementalRain".

If you have data from mutltiple Vantage Pro Consoles stored in the DB you 
will need to run it for each Console ID. If updates Console ID 0 by 
default:
    ./setIncrementalRain 1
    ./setIncrementalRain 2


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

setStormsTimes

For DB v11.1 and vproweather only before v1.0.0

two new columns were added to the Storms table, rain storm start time and 
rain storm end time. This script will update those two columns using the 
data from the Storms, Rain & DT tables. vproweather 1.0.0 and above will 
update these two columns going forward. You may need to set your $password 
in "setStormsTimes".

If you have data from mutltiple Vantage Pro Consoles stored in the DB you 
will need to run it for each Console ID. If updates Console ID 0 by 
default:
    ./setStormsTimes 1
    ./setStormsTimes 2


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

RemediateRainTable.OLD -

Starting with DB v11.1 vproweather v1.0.0

Correct data in the Rain table due to the vPro not having the correct 
Daylight Savings Time setting. This script will not change any data 
unless you uncomment the lines near the end of the script, the two pair 
of "prepare" & "execute" statements. You can use the UPDATE statements 
that are output to do the updating manually just remove the whitespace 
before any # (pound sign) and anything after those deliminators in the 
lines. Those comments are included as a sanity check. You can also run 
this script as just a integrity check on the Rain table by noting its 
output. You may have to run this a number of times making the corrections
listed after each run to fully remediate the data in the Rain table if 
there are gaps in the data due to not running vproweathe every minute and 
storing the data.

This started out being a simple fix to fix any NULL values for DayAmount, 
StormAmount, Rate, and ET that may have been caused by DST, data loads, 
or interruptions in the data gathering. But it soon progressed to what it 
is based on data patterns it reported. If you got a few hours sometime 
I'll sit down and explain it to you... Oh how I now have a distaste for 
Daylight Savings Time...

This script will create a file named "ReconcileHourly.dat" which contains 
dates where the Hourly table may also need remediation due to a Daylight
Savings Time issue. This is on the TODO list so save that file.

It is HIGHLY RECOMMENDED that you make a copy of your Rain table in case
anything goes awry:
CREATE TABLE Weather.RainSAVE LIKE Weather.Rain;
INSERT Weather.RainSAVE SELECT * FROM Weather.Rain;

Then create a temporary table and use that for testing. Use the following 
commands to create the "RainTmp" table then set $RainTableName = "RainTmp";
in "RemediateRainTable" ("RainTmp" is the default in "RemediateRainTable"):
CREATE TABLE Weather.RainTmp LIKE Weather.Rain;
INSERT Weather.RainTmp SELECT * FROM Weather.RainSAVE;

Change the "$OverallStartDateTime" to the date you want to start
from if not from the very beginning

Change the "$ETstartDateTime" to the datetime if you installed your Solar 
Rad detector later i.e. if you didn't have it from the beginning

If you are satisfied with the changes that the UPDATE statements show
you can substitute table "Rain" for all the "RainTmp"'s in the UPDATE
statements and execute them to make the changes

If you have data from mutltiple Vantage Pro Consoles stored in the DB you 
will need to run it for each Console ID. if updates Console ID 0 by 
default:
    ./RemediateRainTable.OLD 1
    ./RemediateRainTable.OLD 2

If you run this script you should then also run "RemediateRainTable"
because "RemediateRainTable.OLD" will not update the "PerMinute" column
in the "Rain" table

You may need to set your "$password" in "RemediateRainTable.OLD"

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
