<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="https://ctavs.cc/feed.xml" rel="self" type="application/atom+xml" /><link href="https://ctavs.cc/" rel="alternate" type="text/html" /><updated>2025-03-31T13:49:20-06:00</updated><id>https://ctavs.cc/feed.xml</id><title type="html">ctavs.cc</title><subtitle>The personal website of Connor Taverner; The home for all my projects and errant thoughts!</subtitle><author><name>Connor Taverner</name></author><entry><title type="html">Air Pressure Shenanigans</title><link href="https://ctavs.cc/2025/03/31/air-pressure.html" rel="alternate" type="text/html" title="Air Pressure Shenanigans" /><published>2025-03-31T00:00:00-06:00</published><updated>2025-03-31T00:00:00-06:00</updated><id>https://ctavs.cc/2025/03/31/air-pressure</id><content type="html" xml:base="https://ctavs.cc/2025/03/31/air-pressure.html"><![CDATA[<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>I&#8217;ve always been fairly sensitive to air pressure, and experiencing the winters here out West has really exacerbated the effects beyond what I&#8217;m used to.</p>
</div>
<div class="paragraph">
<p>I set out to find out why that is, and used the subsequent discovery as the basis of a little Python project.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="low-pressure-blues">Low pressure blues</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Central to the issue is the high altitude of Calgary: a happy little side effect of being so close to the Rockies. I knew going in that the altitude would affect things like cooking, and I was warned in advance about the weather&#8212;&#8203;chinooks in particular. What I wasn&#8217;t prepared for was even the slightest hint of overcast weather and the subsequent low pressure dropping my energy levels to the point where even caffeine and ADHD medication can&#8217;t (fully) overcome it.</p>
</div>
<div class="paragraph">
<p>I wasn&#8217;t having this issue nearly as much back in Halifax: overcast weather would decline my mood, sure, but almost never to the point of actively sapping my energy. To top it off, the chinooks that rolled in and spiked the air pressure provided me an almost immediate relief to these issues; I could really <em>feel</em> my energy coming back when they hit.</p>
</div>
<div class="paragraph">
<p>There had to be a reason for this, so I set out to research exactly what the cause might be.</p>
</div>
<div class="paragraph">
<p>Turns out that the altitude affected the apparent barometric pressure, as well.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="some-pressure-is-more-equal-than-others">Some pressure is more equal than others</h2>
<div class="sectionbody">
<div class="paragraph">
<p>When I became suspicious of the pressure changes, I started to track air pressure changes to map out when the good and bad days were happening. But this became confusing for me on account of my weather sources reporting <em>wildly</em> different values: Environment Canada&#8217;s values differed from Open-Meteo&#8217;s values by 10-20 kPa!</p>
</div>
<div class="paragraph">
<p>Upon interrogating Open-Meteo to see what was going on, I discovered that they were using <em>two</em> different values of barometric pressure: sea level, and surface level. To Open-Meteo&#8217;s credit, <a href="https://open-meteo.com/en/docs?latitude=51.0501&amp;longitude=-114.0853&amp;hourly=temperature_2m,pressure_msl,surface_pressure,cloud_cover">their data graph was very useful</a> for highlighting the differences between the two.</p>
</div>
<div class="paragraph">
<p>Their values for sea level pressure largely matched Environment Canada&#8217;s data for pressure, which begged the question of how exactly they came up with this "surface level" pressure. This led me down the path of discovering a little thing called the <a href="https://en.wikipedia.org/wiki/Barometric_formula">barometric formula</a>:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/assets/images/barometric-formula.svg" alt="Barometric Formula">
</div>
</div>
<div class="paragraph">
<p>In short, given a different altitude and temperature, the air pressure can feel dramatically different than at sea level. Plugging the numbers into the formula&#8212;&#8203;and feeding it the sea level pressures&#8212;&#8203;gave me the "surface level" pressures that Open-Meteo was providing!</p>
</div>
<div class="paragraph">
<p>Mystery solved. And <em>boy,</em> were those pressures low: small wonder I kept feeling so lethargic!</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="no-pressure-right">No pressure, right?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now, me being me, I wanted a way to calculate these values without requiring an Internet connection, such that I could figure out the values from whatever offline source of pressure I obtain in the future. <em>(Pending testing, of course!)</em></p>
</div>
<div class="paragraph">
<p>And since I&#8217;ve been dipping my toes into Python as of late&#8212;&#8203;better late than never&#8212;&#8203;I thought it would be a nice little starter project to get a feel for how it all works!</p>
</div>
<div class="listingblock">
<div class="title">Python code:</div>
<div class="content">
<pre class="highlight"><code class="language-python" data-lang="python">#!/usr/bin/env python3
# Calculate air pressure at higher altitudes
# Formula: P = (P0)*e^(((-g)*M*(h-h0))/(R*T))
# Where:   P  =  Current pressure being solved for (usually pascals)
#          h  =  Current altitude (in metres)
#          T  =  Current temperature (in Kelvin)
#          P0 =  Reference pressure (usually sea level -- 101325Pa or 101.325kPa nominal)
#          h0 =  Reference altitude (usually sea level -- 0m)
# Consts:  e  =  2.718281828 (natural log base, used for exponential function)
#          g  =  9.80665 (m/s)^2 (gravity acceleration)
#          M  =  0.0289644 kg/mol (molar mass of air)
#          R  =  8.31432 N.m/(mol/K) (universal gas constant)

### Setup
import argparse

parser = argparse.ArgumentParser(prog='AirPressure', description='Calculates the equivalent sea level air pressure from the given surface air pressure, altitude, and temperature.')
parser.add_argument('pressure', type=float, help='Current air pressure (any unit)')
parser.add_argument('altitude', type=float, help='Current altitude (in metres)')
parser.add_argument('temperature', type=float, help='Current temperature (in celsius)')
parser.add_argument('-r', '--reverse', action='store_true', help='Calculate equivalent surface air pressure from given sea pressure instead')

### Declarations
const_e = 2.718281828
const_g = -9.80665
const_M = 0.0289644
const_R = 8.31432
const_TK = 273.15           # Can +/- any *C temperature to this to get equivalent Kelvin value
args = parser.parse_args()
var_P = args.pressure
var_h = args.altitude
var_T = const_TK + args.temperature

### Code
if args.reverse == True:
    # Get sea level pressure from surface pressure
    out_P = var_P / const_e ** ((const_g * const_M * var_h) / (const_R * var_T))
    print(out_P)
else:
    # Get surface pressure from sea level pressure
    out_P = var_P * const_e ** ((const_g * const_M * var_h) / (const_R * var_T))
    print(out_P)</code></pre>
</div>
</div>
<div class="paragraph">
<p>The code is fairly self-explanatory, but I&#8217;ll summarize it anyways:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>It converts sea level to surface level pressure, given:</p>
<div class="ulist">
<ul>
<li>
<p>The provided pressure (in any unit&#8212;&#8203;it&#8217;s completely agnostic)</p>
</li>
<li>
<p>The provided altitude (in metres&#8212;&#8203;here in Calgary, that&#8217;s 1025m)</p>
</li>
<li>
<p>The provided temperature (in celsius&#8212;&#8203;it has a small but noticeable effect on the pressure change!)</p>
</li>
</ul>
</div>
</li>
<li>
<p>Optionally, it can calculate the <em>reverse</em> instead; deriving sea level pressure from the surface pressure.</p>
<div class="ulist">
<ul>
<li>
<p>This was mostly added to check my work, and because the formula was really easy to rearrange for the other value.</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The barometric pressure is just one component of my issues with the effects the weather has on me, but it&#8217;s proven to be a pretty substantial component. It&#8217;s been good, figuring that component of the equation out. Now I just have to tackle the rest of the equation!</p>
</div>
<div class="paragraph">
<p>With regards to the program, I could have gone full bore and automatically pulled from Open-Meteo&#8212;&#8203;it <em>does</em> provide Python example code, after all. But I wanted something quick, simple, and offline. For what it does, I&#8217;m fairly happy with the result.</p>
</div>
</div>
</div>]]></content><author><name>Connor Taverner</name></author><summary type="html"><![CDATA[I&#8217;ve always been fairly sensitive to air pressure, and experiencing the winters here out West has really exacerbated the effects beyond what I&#8217;m used to. I set out to find out why that is, and used the subsequent discovery as the basis of a little Python project.]]></summary></entry><entry><title type="html">Hello, Jekyll!</title><link href="https://ctavs.cc/2025/03/06/hello-jekyll.html" rel="alternate" type="text/html" title="Hello, Jekyll!" /><published>2025-03-06T00:00:00-07:00</published><updated>2025-03-06T00:00:00-07:00</updated><id>https://ctavs.cc/2025/03/06/hello-jekyll</id><content type="html" xml:base="https://ctavs.cc/2025/03/06/hello-jekyll.html"><![CDATA[<div class="paragraph">
<p>It&#8217;s about time I started diving into SSG. And AsciiDoc support wasn&#8217;t negotiable.</p>
</div>
<div class="paragraph">
<p>To make a long story short, I wasn&#8217;t wholly satisfied with my previous framework of generating websites using AsciiDoctor and a shell script. I won&#8217;t lie: a lot of this was due to my relative lack of HTML and CSS knowledge, but I can&#8217;t say I was happy with the documentation of AsciiDoctor and it&#8217;s CSS stylesheets, either.</p>
</div>
<div class="paragraph">
<p>That knowledge can be remedied in time, however, so I certainly won&#8217;t rule out moving back to that framework once I have some more webdev knowledge under my belt. In the interim, however, I opted to "join the herd", so to speak, and start getting up and running with static site generators.</p>
</div>
<div class="paragraph">
<p>One of my hard requirements for a generator, however, is AsciiDoc support. And wanting to keep things relatively lightweight on the output&#8212;&#8203;especially where JavaScript is concerned&#8212;&#8203;was certainly something I desired as well. Fortunately for me, <a href="https://gist.github.com/briandominick/e5754cc8438dd9503d936ef65fffbb2d">somebody went and made a very convenient list of AsciiDoc SSGs,</a> and given it&#8217;s use in GitHub Pages, I decided to try Jekyll as my first real SSG.</p>
</div>
<div class="paragraph">
<p>Setting it up was fairly straightforward, as was getting the AsciiDoc plugin installed and operational. Less straightforward was futzing with several smaller pain points in the AsciiDoc converter, and the continuing theme of lacking documentation. So it was something of a journey to dial in my settings, includes, and AsciiDoc attributes to make everything render well for me.</p>
</div>
<div class="paragraph">
<p>Some things are still not fully complete, and I plan to address them in due time. But for now, everything works fairly well, and I particularly like the dated URL system Jekyll employs for blogposts. The default Minima theme is very nice to my eyes as well, and it took only minor adjustments to get things spread across the page to my liking.</p>
</div>
<div class="paragraph">
<p>Overall, a good result. There are still some oddities and wrinkles present, but hopefully I&#8217;ll find the time to further refine the end result! And, perhaps more importantly, document the process further down the line.</p>
</div>]]></content><author><name>Connor Taverner</name></author><summary type="html"><![CDATA[It&#8217;s about time I started diving into SSG. And AsciiDoc support wasn&#8217;t negotiable.]]></summary></entry></feed>