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

Normalize floating point values #15

Closed newbthenewbd closed 7 months ago

newbthenewbd commented 7 months ago

I have normalized the exponent test values with the following Python script:

import re

tofix = ["p-mbar", "p-mmHg", "density", "ppn", "rhorhon", "sqrt-rhorhon", "dynamic-viscosity", "kinematic-viscosity", "thermal-conductivity", "specific-weight", "air-number-density", "frequency", "mean-free-path"]

currexp = {}

for fix in tofix:
    currexp[fix] = "0"

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

for filename in filenames:
    input = open(filename, "r")
    output = open("fixed-" + filename, "w")
    for line in input:
        noneMatched = True
        for fix in tofix:
            if line.startswith("    " + fix + ": "):
                match = re.search(r'( (\+|-)[0-9]*)$', line)
                if match is not None:
                    currexp[fix] = "e" + match.group(0)[1:]
                    output.write(line[:-len(currexp[fix])-1] + currexp[fix] + "\n")
                else:
                    output.write(line[:-1] + currexp[fix] + "\n")
                noneMatched = False
                break
        if noneMatched:
            output.write(line)
    input.close()
    output.close()

Line 14830 of iso-2533-1975-table5.yaml has bad data (lowercase L character in place of a number: p-mmHg: 9.4785le+0, I noticed during comparison since it tripped up the former version of my script), but I don't know what the correct value should be.

Metanorma PR checklist

newbthenewbd commented 7 months ago

Suppose it's 1, and that there will be more, albeit more subtle errors to correct anyways... With the aid of the very tool?!? :)

newbthenewbd commented 7 months ago

OK, actually, maybe let's get it merged like this? Fixes #11.

ronaldtse commented 7 months ago

@newbthenewbd thank you! Let's get this merged. Next we want to move these values into one large test file... (or split for practicality)