Author Topic: Synthetic Channel Problem  (Read 5818 times)

Blicj11

  • Storm
  • *****
  • Posts: 4078
    • EW3808
    • KUTHEBER6
    • Timber Lakes Weather
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP Data Logger | iMac (2019), 3.6 GHz Intel Core i9, 40 GB RAM, macOS Sonoma 14.8.5 | WeatherCat 3.3.3 | Supportive Wife
Synthetic Channel Problem
« on: October 02, 2014, 09:44:59 PM »
I want WeatherCat to track the number of days where the Exterior High Temperature does not climb above freezing during the entire day. I created a simple Synthetic Channel called Ice Day. It only uses one parameter where Ext Temperature is set to Daily High. The Apple Script function is:

set ExteriorH to Param1 -- Convert parameters into names that make code easier to read.

if (ExteriorH > 32) then -- If exterior temperature exceeds 32˚F it is not an ice day
   return (0) -- Return 0 in those cases.
else -- Otherwise the exterior temperature does not exceed 32˚F so it is an ice day
   return (1)
end if

Screenshot is attached.

Next, I created a Day Type called Ice Days. An Ice Day occurs if the Synthetic Channel called Ice Day exceeds 0.

Screenshot attached.

Last night the temperature dropped below freezing at 20:54 and did not climb above freezing until this morning at 8:52. The Synthetic Channel registered a 1 beginning at midnight and it recorded a 1 until 8:52 this morning, when it changed back to 0.

In Year Over Year Statistics, I am showing 1 Ice Day (which is today). This is incorrect because the High Temp did not remain below freezing for the entire day.

I can see why my Synthetic Channel failed to do what I hoped. Because the Exterior Daily High Temp was below freezing for part of the day, beginning at midnight, it recorded a 1 during part of the day.

Can anyone see how I can get WeatherCat to record Ice Days correctly?
Blick


elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6686
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Maintaining state - I hear ya' calling! (Re: Synthetic Channel Problem)
« Reply #1 on: October 03, 2014, 09:47:14 PM »
Dear Blick and WeatherCat AppleScript "schemers" . . . . .

I can see why my Synthetic Channel failed to do what I hoped. Because the Exterior Daily High Temp was below freezing for part of the day, beginning at midnight, it recorded a 1 during part of the day.

Can anyone see how I can get WeatherCat to record Ice Days correctly?

I scratched my head a bit, but the only thing I can come up with is some sort of way to store the previous state of the synthetic channel.  What you want isn't that it was freezing anytime during the day but it was freezing every time the channel ran that day.  I can't imagine any way to do that without storing the value of the previous run somewhere.

You can do it, you could create a tiny file with a 1 or 0 in it.  On reach run it would store the result of the current value and the value in the file.  The resulting value would then have to be written back to the file.  If at any time during the day the temperature went above 0 then the value in the file would become 0 and at the end of that day that is what would be returned.

Alas, it is complicated and a bit risky.  You might be better off to "wait in joyful hope" for an even mor' better WeatherCat 2.x (or 3.x?)

Cheers, Edouard  [cheers1]

Bull Winkus

  • Storm
  • *****
  • Posts: 783
  • 2013 iMac 2 x 27", OS Ver. 10.15.7
    • EW0095
    • KARHORSE2
    • WU for Horseshoe Bend, Arkansas
  • Station Details: Davis Wireless Vantage Pro 2, iMac 2 x 27"
Re: Synthetic Channel Problem
« Reply #2 on: October 04, 2014, 01:32:28 AM »
The problem, as I see it, is that determining the "Ice Day" as you've defined it, is not really a channel function. It is an after the fact assessment of the day that only needs to run one time. So, if you could schedule the operation to execute only once per day, or if you could structure the query as a series of parameters to match that included one that could query the time, it could be done.

For instance, in Day Type with multiple queries:

If External Temp (Daily High) < 32 and
if Time = 23:59 then
set DayType to string "Ice Day"

But, in any case where the question is being asked by WeatherCat all day, you're going to get false positives.

I'll bet Stu can make it happen.

I wonder if an Applescript could run once a day and do the query and set the DayType? If it was scheduled to run at 23:55, it would only have to ask for the Daily High and compare it to the setpoint for determining DayType, then record it in the right spot.

Edouard? Can Applescript go that far?
Herb

Blicj11

  • Storm
  • *****
  • Posts: 4078
    • EW3808
    • KUTHEBER6
    • Timber Lakes Weather
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP Data Logger | iMac (2019), 3.6 GHz Intel Core i9, 40 GB RAM, macOS Sonoma 14.8.5 | WeatherCat 3.3.3 | Supportive Wife
Re: Synthetic Channel Problem
« Reply #3 on: October 04, 2014, 09:19:53 AM »
Thanks guys. I think the answer does not lie in a Synthetic Channel. I have added Ice Day tracking as a feature request.
Blick


WCDev

  • WeatherCat Developer
  • Administrator
  • Storm
  • *****
  • Posts: 2987
    • CW9739
    • IIBSTO2
    • Trixology
  • Station Details: Main Station: Vantage Pro-2, 24hr fars, solar, extra temp stations, no U.V. WeatherLinkLive.
Re: Synthetic Channel Problem
« Reply #4 on: October 04, 2014, 12:35:33 PM »
Yep, currently a day type will be true if the condition is true at any point in the day; what's needed here is if it was true for the whole day. I'll add it to the feature request list.

Blicj11

  • Storm
  • *****
  • Posts: 4078
    • EW3808
    • KUTHEBER6
    • Timber Lakes Weather
  • Station Details: Davis Vantage Pro2 Plus | WeatherLinkIP Data Logger | iMac (2019), 3.6 GHz Intel Core i9, 40 GB RAM, macOS Sonoma 14.8.5 | WeatherCat 3.3.3 | Supportive Wife
Re: Synthetic Channel Problem
« Reply #5 on: October 04, 2014, 07:35:50 PM »
Thanks Stu.
Blick