metanorma / atmospheric

International Standard Atmosphere / ICAO Standard Atmosphere (ISA) from ICAO 7488 / ISO 2533
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

Put values from tables in test file #20

Closed newbthenewbd closed 7 months ago

newbthenewbd commented 7 months ago

Fixes #17. Converted with the following Python script:

import re

filenames = ["iso-2533-1975-table5.yaml", "iso-2533-1975-table6.yaml", "iso-2533-1975-table7.yaml"]

inputs = [0 for x in range(len(filenames))]
output = open("tests.yml", "w")

for i, name in enumerate(filenames):
    inputs[i] = open(name, "r")

entries = [{} for x in range(2032)] # count of "  - "

for i in range(len(entries)):
    for f in inputs:
        match = None
        while match is None:
            line = f.readline()
            match = re.search(r'^  (-| ) (.+):(.*)', line)
        while match is not None:
            entries[i][match.group(2)] = match.group(3)
            line = f.readline()
            match = re.search(r'^  (-| ) (.+):(.*)', line)

sortedentries = res_list = {frozenset(item.items()) : 
            item for item in sorted(entries, key = lambda e: int(e["geopotential-altitude"]))}.values()

output.write("---\n")

for e in sortedentries:
    output.write("- H: " + str(float(e["geopotential-altitude"])) + "\n")
    output.write("  h: " + str(float(e["geometrical-altitude"])) + "\n")
    output.write("  TK: " + str(float(e["temperature-K"])/1000) + "\n")
    output.write("  TC: " + str(float(e["temperature-C"])/1000) + "\n")
    output.write("  p_mbar:" + e["p-mbar"] + "\n")
    output.write("  p_mmhg:" + e["p-mmHg"] + "\n")
    output.write("  rho:" + e["density"] + "\n")
    output.write("  g:" + e["acceleration"] + "\n")
    output.write("  p_p_n:" + e["ppn"] + "\n")
    output.write("  rho_rho_n:" + e["rhorhon"] + "\n")
    output.write("  root_rho_rho_n:" + e["sqrt-rhorhon"] + "\n")
    output.write("  a: " + str(float(e["speed-of-sound"])/1000) + "\n")
    output.write("  mu:" + e["dynamic-viscosity"] + "\n")
    output.write("  v:" + e["kinematic-viscosity"] + "\n")
    output.write("  lambda:" + e["thermal-conductivity"] + "\n")
    output.write("  H_p:" + e["pressure-scale-height"] + "\n")
    output.write("  gamma:" + e["specific-weight"] + "\n")
    output.write("  n:" + e["air-number-density"] + "\n")
    output.write("  v_bar:" + e["mean-speed"] + "\n")
    output.write("  omega:" + e["frequency"] + "\n")
    output.write("  l:" + e["mean-free-path"] + "\n")
    output.write("\n")

for f in inputs:
    f.close()

output.close()

Metanorma PR checklist

ronaldtse commented 7 months ago

@newbthenewbd you can also commit the python script so you don't need to paste it in the description 😉

newbthenewbd commented 7 months ago

It's a different one every time :-) Doesn't it then end in someone's ruby gems?

Edit: as in to mean, I just create them for ad-hoc purposes, but if you find them useful :)

newbthenewbd commented 7 months ago

Anyways, hold on with this, I guess, for what's going on over at #19...

newbthenewbd commented 7 months ago

Since, if we're only using rows-H, might as well force push that variant to the PR :) Do we, @ronaldtse?

ronaldtse commented 7 months ago

Since, if we're only using rows-H, might as well force push that variant to the PR :) Do we, @ronaldtse?

Later on we have to also create tables that use lookup with "small h" (geometric altitude), so we should add those methods.

Table 5

Screenshot 2024-02-09 at 10 47 23 AM Screenshot 2024-02-09 at 10 47 33 AM

Table 6 <img width="644" alt="Screenshot 2024-02-09 at 10 48 07 AM" src="https://github.com/metanorma/atmospheric/assets/11865/5b474ef3-047b-49fa-8aa8-f64519393042">

Screenshot 2024-02-09 at 10 48 37 AM

Table 7

Screenshot 2024-02-09 at 10 49 39 AM Screenshot 2024-02-09 at 10 50 04 AM
newbthenewbd commented 7 months ago

Hmm, so something like two separate test files? That can be done :)

ronaldtse commented 7 months ago

@newbthenewbd sounds like a reasonable idea?

ronaldtse commented 7 months ago

You might prefer to use a YAML library to write out the values?

newbthenewbd commented 7 months ago

Well sure, that's why the scripts are ad-hoc :-) Do we need better-made ones?

newbthenewbd commented 7 months ago

Like, I'd kind of been spending the better mental on trying to think up why the remaining tests fail, realize this is horrendous... :)

ronaldtse commented 7 months ago

Any broad categories of failures do you see?

Well sure, that's why the scripts are ad-hoc :-) Do we need better-made ones?

This is fine… it’s a one time processing.

The goal is really to regenerate the tables through code.

newbthenewbd commented 7 months ago

Any broad categories of failures do you see?

Too imprecise computation, bad assumptions about the test data (like what I am working on right now, adding support for rounding to significant digits), algorithmic errors (increasingly getting fixed, I don't see one at this time)...

newbthenewbd commented 7 months ago

And another funny category, these missing p_mmhg values :) image

newbthenewbd commented 7 months ago

I think/hope that with the commit above, only:

failures should remain...

newbthenewbd commented 7 months ago

So, I think now would be a good time to merge this PR, if it hadn't gotten just too crazy :) Gets us close!

ronaldtse commented 7 months ago

@newbthenewbd next time could you please rebase the PRs on top of main, I've done it this time. Thanks!

newbthenewbd commented 7 months ago

OK, sorry :) I'd merged them earlier with the fancy button on github, more commits, more repo, but that will work too

ronaldtse commented 7 months ago

No problem. This works great!