Trixology
WeatherCat => WeatherCat General Discussion => Topic started by: vetenskapsman on November 09, 2016, 04:44:19 PM
-
Hello all, I keep seeing my id, ventenskapsman, on the Welcome our Newest Member tag at the top of the forum index and felt bad I haven't introduced myself. As I finally have questions I thought I'd do just that!
I've been using WC since I first acquired a Davis Vantage Pro as a (very nice) Christmas present in 2012. I've happily been using the station and WC all these years which covered about 2.5 years in San Jose, CA and now 2.5 years in Corrales, NM (just outside Albuquerque). Other than reporting to Wunderground, ID=KNMCORRA6, I haven't had much time to look into creating a personal weather page.
I recently upgraded to V2.4 and have navigated OS Sierra issues thanks to many forum posters (all I had to do was turn off the sleep setting and that solved the hangs). I also see we have synthetic channels now (very cool) and a more feature rich tag set than was available in 2012! If you don't upgrade for a while you miss out on a lot :-[ . I'm now considering putting my toe in the waters of making a personal web page and since I don't have any previous experience with this I am starting slow and simple by playing the venerable atkins template and saving to local disk for learning and testing.
On to my question ... With a synthetic channel I can finally make a data channel to report the daily temperature range (Highest Temp - Lowest Temp) which is something I've wanted to do for a long time. What I'd also like to be able to report is the Lowest High Temperature over a period (e.g. Monthly) as well as the Highest Low Temperature over a period.
I've looked through the forums and the Weather Cat tags reference and can't figure a way to do it. I've come to the conclusion that either 1.) It can't be (easily) done or 2.) The answer is so simple I'll be embarrassed once you point it out to me.
Not quite sure why I find temperature range and coolest days and warmest nights so interesting but I certainly do! Thanks for any insight you can give and I certainly will be posting more novice questions as I journey down the path to making a personal weather page.
best, -carl
-
Hi Carl - warm welcome!
In here you surely will find someone that can help you out with your (very specific) task. For me I am not sure if this is possible, lets wait for the brave *synthetic channelours* and their input. :)
-
Welcome to the forum Carl. Edouard is our resident custom channel expert. If it can be done, he will know how to do it.
-
Thank you Reinhard and Blick! Appreciate the welcomes very much.
If I understand synthetic channels correctly I don't think it can be done as those channels deal with the manipulation of incoming data in one of four ways, Current Value, Daily High, Low and Average.
To solve my problem of finding the coolest day or warmest night I think it is more of a "query" the data log issue which can be done in a number of interesting ways with Tags, such as, find the Highest Temp in the last Month, Year or even time period. But I couldn't see any way to do a similar thing to find the Lowest High Temp (basically the coolest Day, or similarly, the warmest night, over a given time period (Week, Month, Year etc).
best, -carl
-
Dear Carl, Reinhard, Blick, and WeatherCat welcome wagon, . . . (http://www.canebas.org/WeatherCat/Forum_support_documents/Custom_emoticons/welcomewagon.gif)
First things first, Welcome to the WeatherCat forum! (http://www.canebas.org/WeatherCat/Forum_support_documents/Custom_emoticons/welcome_smiley.gif)
On to my question ... With a synthetic channel I can finally make a data channel to report the daily temperature range (Highest Temp - Lowest Temp) which is something I've wanted to do for a long time.
Edouard is our resident custom channel expert. If it can be done, he will know how to do it.
;) . . . . *Sigh*, how did I get myself volunteered into this one! . . . . lol(1)
Okay it isn't difficult to create a synthetic channel that will report in real time what is the daily temperature range. The actual AppleScript is just one line:
return(Param1 - Param2)
Honestly, you could just have the subtraction of the two parameters, but I use the return to make it a little more clear what is going on. You then would need to set up the synthetic channel like this:
(http://www.canebas.org/misc/Capto_images/Difference%20high%20low%202016-11-09.png)
The only problem with this scheme is that it would return values through the day and would not give you the final value you want until after the high temperature has been reached. After the high temperature is reached the value would be correct until midnight when it would reset once more. However, I don't think you could do better than that.
What I'd also like to be able to report is the Lowest High Temperature over a period (e.g. Monthly) as well as the Highest Low Temperature over a period.
This would be extremely difficult and risky do to as a synthetic channel. However, I thought the WeatherCat STAT$ tag could do this sort of thing. Anybody know? I'm not particularly good with that tag.
Once more welcome!
Cheers, Edouard [cheers1]
P.S. I hope the title of the synthetic channel doesn't confuse anyone. I "hijacked" one of my existing channels temporarily to show what changes were needed.
-
After the high temperature is reached the value would be correct until midnight when it would reset once more. However, I don't think you could do better than that.
If you can gather the data, then you can create a small script to write it to a database. Then the DB can be queried as needed for the statistics. Perhaps AS/Automator can handle doing the DB parts, even if it's just using Numbers (still comes with every Mac, AFAIK) and creating a flat "database".
-
Thanks Edouard! And appreciate the Welcome Wagon [cheers1]
Yes, finding the lowest high temperature (or warmest low temperature) during the month, or year etc seems to be a job for the $STAT tag but I couldn't figure it out and that is where I am stuck. If anyone has a solution I'd love to know.
I was able to figure out the simple solution to the daily temperature Range as you describe. And you are correct it will have a daily reset at midnight but that is OK and also that the correct value isn't reached until the high temperature is reached for the day but that is what I want. Mostly I am interested in the Max/Min temp range for a given month or year and now that I have a synthetic channel generating the data I can easily get it.
xairbusdriver, what you describe would certainly do the job but unfortunately is well beyond my ability. The values I seek (highest low, lowest high) are sitting right there in the Monthly Reports that are generated but I don't think I can get at it (easily) unless the $STAT tag has the ability.
-carl
-
Hi carl,
here is simply all that is possible with tags: http://live.trixology.com/custom/
Scroll down to the section shown in the attached screenshot - maybe the solution is hidden in there.
Good luck,
-
Dear Carl, Reinhard, and WeatherCat troubleshooters,
Thanks Edouard! And appreciate the Welcome Wagon [cheers1]
Well, you see I have this certain - thing - about wagons. In particular a certain adventurous 1965 Buick Special wagon . . . . .
(https://photos.smugmug.com/Biquette/Photos-of-Biquette/Biquettes-Jan-1-2016-outing/i-PL3tHtC/0/XL/Biquette%20next%20to%20caboose%20-%20front-XL.jpg) (https://canebas.smugmug.com/Biquette/Photos-of-Biquette/Biquettes-Jan-1-2016-outing/i-PL3tHtC/A)
Yes, finding the lowest high temperature (or warmest low temperature) during the month, or year etc seems to be a job for the $STAT tag but I couldn't figure it out and that is where I am stuck.
Okay, since nobody else could figure this out. I gave it another look and it seems to me that this works. This will give you the hottest temperature this month:
STAT$TEMPERATURE:MAX:THISMONTH$
The coldest is just a small change:
STAT$TEMPERATURE:MIN:THISMONTH$
You can use AppleScript to test a STAT$ query. Here is a small AppleScript that returns the max for the month:
set highTemp to ""
tell application "WeatherCat"
set Query to "STAT$TEMPERATURE:MAX:THISMONTH$"
set highTemp to QueryResult
end tell
"Hottest temperature this month was: " & highTemp
Here is the corresponding coldest temperature this month AppleScript:
set lowTemp to ""
tell application "WeatherCat"
set Query to "STAT$TEMPERATURE:MIN:THISMONTH$"
set lowTemp to QueryResult
end tell
"Coldest temperature this month was: " & lowTemp
You could cut and paste these examples into the AppleScript editor and give them a try. It is easier to use AppleScript to make sure that your STAT$ query is correct than to put it into a webpage and have it fail without any understanding of why.
I hope that gets you going in the right direction! [tup]
Cheers, Edouard [cheers1]
-
What I'd also like to be able to report is the Lowest High Temperature over a period (e.g. Monthly) as well as the Highest Low Temperature over a period.
I would have sworn that what he he wanted was the lowest high and the highest low. Not the hi set high nor the lowest low. And for each week, month, year, decade, century, ... OK, maybe not the century, he probably doesn't have that much data...
The "query" then, would only need to look at the week's/month's/etc highs and lows and then sort numerically. The lowest high is at the bottom, the highest low is at the top.
I assume your AS could run in a loop and create a list (database) for each year/month/week from the data already in WC?
Of course, he may have something completely different in mind ... Monty Python's Flying Circus?
-
xairbusdriver, you swear correctly :) And I fear I have created a circus of confusion with my query (pun intended). You have it exactly correct. I'd like to find, and report in a web page the coolest (high) temperature over a given period (say monthly) and also the warmest low temperature over a period (say monthly).
And your description of the method is also correct - I just don't know how to do that. I was hoping to do this with tags but I am beginning to see that isn't possible with the current set and that if I really want to do this I'll have to dig into AppleScript more to learn how to do that.
Edouard, I really appreciate the time you took to look into this. I did learn one really neat thing - you can put tags in the AppleScript editor. Very neat. That will save me a lot of time testing while I learn the ropes. Oh and your real life wagon? Your coolness factor just went up 100 fold 8).
best, -carl
-
I think I've found what your need, Carl! <R (https://en.wikipedia.org/wiki/R_(programming_language))> It's made exactly handling data/statistics! And it's open-source! ThU5:-)
-
I think I've found what your need, Carl! <R (https://en.wikipedia.org/wiki/R_(programming_language))>
That's what pirates use when programming...
Thank you very much. I'll be here all week.
-
Steve +1 But don't quit your day job!
-
Dear Carl and WeatherCat tinkerers,
xairbusdriver, you swear correctly :) And I fear I have created a circus of confusion with my query (pun intended). You have it exactly correct. I'd like to find, and report in a web page the coolest (high) temperature over a given period (say monthly) and also the warmest low temperature over a period (say monthly).
Okay my misunderstanding. Unfortunately as others have pointed out. This won't be very easy to do. WeatherCat can export data to an SQL database. Perhaps that is your best bet.
Edouard, I really appreciate the time you took to look into this. I did learn one really neat thing - you can put tags in the AppleScript editor. Very neat. That will save me a lot of time testing while I learn the ropes. Oh and your real life wagon? Your coolness factor just went up 100 fold 8).
Well my trusty wagon continues to be adventurous . . . . This morning she was a little - too - adventurous! However, for those of us as old as I am, you'll just have to wait for the "11 O'Clock news" for those details! . . . . ;D
Cheers, Edouard [cheers1]
-
I'm overly proud of myself but I did manage to coax applescript to spit out the values I'm looking for. The last "programming" I did was for a beginning FORTRAN class using punchcards in 1978! Let's just say my attempt is a bit a random walk. Mostly I searched for snippets of code that I could copy and adapt and then I would spend and hour or two trying trying different things until the syntax was accepted.
Basically I feed the script the number of days in the past I want to search over. Then I query WC data using the tag STAT$TEMPERATURE:MAX:DAYSAGO(x)$ to build a List with all the Maximum temperatures. (Thanks to Edourard who taught me you can query WC using applescript in the Applescript Editor). Finally I call a subroutine? (not sure what they are called in applescript) that searches that List of daily maximum temps to find the *Lowest* one.
Finding the warmest night over a period I just have to alter the script to find the Maximum of a List of Minimum Daily Temps.
So I can do this in the script editor but I kind of lost sight of my overall goal of updating a web page with that value. I'll have to think if there is a way to employ a version of this script in a synthetic channel somehow so I can then use a STAT$SYN1 type tag to easily push the value to a web page.
A better way as some of you have pointed out would be put the whole of the data into a database and then query that - but learning how to do all of that probably (likely. It does.) exceed my motivation level to just report these values. Just a few days ago it was a huge step for me just to use the atkins template [biggrin].
I think I'll take a step back and play with kids my own age. I should fool around with really simple html and focus on putting up basic web page. After that I can perhaps consider taking on some of these more complicated tasks.
Thanks to all who have helped with ideas. I've learned a ton in just a few days. I'll probably let this specific challenge rattle around and see if a simple solution pops into existence that I can implement using my currently meager skills.
-carl
-
Congratulations, Carl! I guarantee you've already done the hard part. Your solution may not be 'dynamic' (letting the viewer pick starting and ending dates, for example) but it should serve you well! [cheer]
You'll be happy to know that html is many times easier than AS! It is not even actually a "programming language". It's really only a 'mark-up' method describing now to display text and or graphics in a web browser. If you've ever used the 'full' post editor here (not the "Quick Reply" text box at the bottom of a page), you've actually been using a hybrid version of html! There are only a few dozen 'key words' you'll ever use and they always have the "<" and ">" characters surrounding them.
An html file is nothing more than plain text, so don't create it in a "word processor", doing that will add special codes that will only confuse a web browser. Unfortunately, adding html to most templates can be problematic. Most templates are collections of scripting 'codes' from PHP, javascript, etc. That can sometimes make it difficult to see what is actually html. Many template devs will probably offer some help, however.
-
Dear Carl and WeatherCat "mature" coders, . . . .
I'm overly proud of myself but I did manage to coax applescript to spit out the values I'm looking for. The last "programming" I did was for a beginning FORTRAN class using punchcards in 1978!
Hey, you only beat me by 2 years! I also started programming my second year at U.C. Berkeley in an introductory FORTRAN class using punched cards! For better or worse I continued to dabble in programming although I've never really gotten very good at it.
So I can do this in the script editor but I kind of lost sight of my overall goal of updating a web page with that value. I'll have to think if there is a way to employ a version of this script in a synthetic channel somehow so I can then use a STAT$SYN1 type tag to easily push the value to a web page.
Speaking of never having gotten very good at programming, I can point you a way of converting AppleScript values into web page tags, but . . . . it is crude and complicated at best. I wrote a batch of AppleScripts to support WeatherCat some years back and they still work if barely:
http://athena.trixology.com/index.php?topic=1039.0 (http://athena.trixology.com/index.php?topic=1039.0)
You can certainly download them and see if that would be of any interest. If you have succeeded this far, you might have a fighting chance to make the work.
Good luck! Edouard
-
Dear Carl and WeatherCat "mature" coders, . . . .
I'm overly proud of myself but I did manage to coax applescript to spit out the values I'm looking for. The last "programming" I did was for a beginning FORTRAN class using punchcards in 1978!
Hey, you only beat me by 2 years! I also started programming my second year at U.C. Berkeley in an introductory FORTRAN class using punched cards! For better or worse I continued to dabble in programming although I've never really gotten very good at it.
I never took programming classes in college. Those were only for CompSci majors. I did get to play "Moonlander" on the teletype deck at Bowling Green on a rented line to University of Toledo. :) That was in 1972. I didn't touch a computer for nearly ten years until I started doing BASIC programming on a Commodore VIC-20 in 1980. Man, what a wild ride it has been!
-
The only "computers" we had in college were built from a couple of foot-long, plastic coated pieces of wood! One slid inside the other and the "cursor" slid along the wider one. But when I got to pilot training, we were given a round one made out of aluminum! It was much better aerodynamically, of course!
[removed link to the now castly photobucket.com site]
-
At the risk of dating myself, I started on an IBM 7094 in college. Undergrads ran their punch card decks from 2 a.m. - 6 a.m. I could never have imagined we'd have laptops running MATLAB in the future. Or, for that matter, that my slide rule would be replaced by a series of HP pocket calculators over the next so many years.