{"id":646,"date":"2024-10-12T19:06:19","date_gmt":"2024-10-12T19:06:19","guid":{"rendered":"http:\/\/theshanty.us\/?p=646"},"modified":"2024-10-12T19:07:46","modified_gmt":"2024-10-12T19:07:46","slug":"updates-to-the-weather-page","status":"publish","type":"post","link":"http:\/\/blog.theshanty.us\/index.php\/2024\/10\/12\/updates-to-the-weather-page\/","title":{"rendered":"Updates to the Weather page"},"content":{"rendered":"\n<p>I did some work to the <a href=\"http:\/\/theshanty.us\/index.php\/weather-stuff\/\">weather page<\/a> of the blog.<\/p>\n\n\n\n<p>It now outputs exactly what it used to output, but with 33% less code.<\/p>\n\n\n\n<p>I changed four iterations of the code on the left to one of the code on the right and added calls to the new class instead of just brute forcing my way through the images. It doesn&#8217;t speed it up measurably because the program spend most of the time waiting for matplotlib.pyplot to generate the images. I more just wanted a task to prove to myself that I&#8217;ve still got the skills. <\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><code>speedTitle = current_time + ' - ' + datalist[3] + ' MPH'<br>print(speedTitle)<\/code><\/p>\n\n\n\n<p><code>fig, ax = plt.subplots(figsize=(10,8))<br>df4.plot.line(x='time', y='value',color='crimson', ax=ax)<br>plt.title(speedTitle)<br>plt.ylabel(\"Wind Speed in MPH\")<br>plt.xlabel(\"Time of reading\")<br>plt.savefig('\/var\/www\/html\/image\/speed.png')<\/code><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><code>class ImageOut:<br>def __<strong>init__<\/strong>(self, chartTitle, rawVal, unit, valList, outFile):<br>self.chartTitle = chartTitle<br>self.rawVal = rawVal<br>self.unit = unit<br>self.valList = valList<br>self.outFile = outFile<\/code><\/p>\n\n\n\n<p><br><code>def createImage(self):<br>now_time = time.ctime()<br>printTitle = now_time + ' - ' + self.rawVal + self.unit<br>fig, ax = plt.subplots(figsize=(10,8))<br>self.valList.plot.line(x='time', y='value',color='crimson', ax=ax)<br>plt.title(printTitle)<br>plt.ylabel(self.chartTitle)<br>plt.xlabel(\"Time of reading\")<br>plt.savefig(outDir + self.outFile)<\/code><\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-2 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n<\/div>\n\n\n\n<p>You can find the code <a href=\"https:\/\/github.com\/chuckularone\/WeatherCharts\">out on my github<\/a> if you are curious about it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I did some work to the weather page of the<\/p>\n","protected":false},"author":1,"featured_media":645,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,49,54],"tags":[],"class_list":["post-646","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding","category-github","category-weather"],"featured_image_urls":{"full":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature.webp",1000,800,false],"thumbnail":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature-150x150.webp",150,150,true],"medium":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature-300x240.webp",300,240,true],"medium_large":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature-768x614.webp",640,512,true],"large":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature.webp",640,512,false],"1536x1536":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature.webp",1000,800,false],"2048x2048":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature.webp",1000,800,false],"chromenews-featured":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature.webp",1000,800,false],"chromenews-large":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature-825x575.webp",825,575,true],"chromenews-medium":["http:\/\/blog.theshanty.us\/wp-content\/uploads\/2024\/10\/temperature-590x410.webp",590,410,true]},"author_info":{"display_name":"chuck","author_link":"http:\/\/blog.theshanty.us\/index.php\/author\/chuck-2\/"},"category_info":"<a href=\"http:\/\/blog.theshanty.us\/index.php\/category\/coding\/\" rel=\"category tag\">Coding<\/a> <a href=\"http:\/\/blog.theshanty.us\/index.php\/category\/github\/\" rel=\"category tag\">Github<\/a> <a href=\"http:\/\/blog.theshanty.us\/index.php\/category\/weather\/\" rel=\"category tag\">Weather<\/a>","tag_info":"Weather","comment_count":"0","_links":{"self":[{"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/posts\/646"}],"collection":[{"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/comments?post=646"}],"version-history":[{"count":3,"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/posts\/646\/revisions"}],"predecessor-version":[{"id":649,"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/posts\/646\/revisions\/649"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/media\/645"}],"wp:attachment":[{"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/media?parent=646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/categories?post=646"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.theshanty.us\/index.php\/wp-json\/wp\/v2\/tags?post=646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}