Added volume.
This commit is contained in:
parent
115e3d65b5
commit
ce32cd285e
6 changed files with 90 additions and 20 deletions
|
|
@ -1,7 +1,7 @@
|
|||
(ns humidity.core-test
|
||||
(:require
|
||||
[clojure.test :refer [deftest is testing]]
|
||||
[humidity.core :refer [resolution]]))
|
||||
[clojure.test :refer [deftest is testing]]
|
||||
[humidity.core :refer [resolution]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
|
|
@ -27,12 +27,13 @@
|
|||
(deftest resolution-test
|
||||
(testing "resolution")
|
||||
(let [expected {:relative-humidity 100,
|
||||
:temperature-celsius 35,
|
||||
:pressure-pascals 101325,
|
||||
:pressure-millibars 4053/4,
|
||||
:saturation-vapour-pressure 5622.488734516426,
|
||||
:temperature-kelvin 308.15,
|
||||
:absolute-humidity 3953.618101887827}
|
||||
packet {:relative-humidity 100 :temperature-celsius 35}
|
||||
actual (resolution packet)]
|
||||
(is (= actual expected))))
|
||||
:temperature-celsius 35,
|
||||
:pressure-pascals 101325,
|
||||
:pressure-millibars 1013.25,
|
||||
:saturation-vapour-pressure 5622.488734516426,
|
||||
:temperature-kelvin 308.15,
|
||||
:absolute-humidity 3953.618101887827,
|
||||
:volume 1.1281347245103424}
|
||||
packet {:relative-humidity 100 :temperature-celsius 35}
|
||||
actual (resolution packet)]
|
||||
(is (= actual expected))))
|
||||
|
|
|
|||
41
test/humidity/volume_test.clj
Normal file
41
test/humidity/volume_test.clj
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
(ns humidity.volume-test
|
||||
(:require [clojure.test :refer [deftest is testing]]
|
||||
[humidity.constants :refer [celsius-offset Pa]]
|
||||
[humidity.volume :refer [volume-fn]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;
|
||||
;;; Copyright (C) 2026 Simon Brooke
|
||||
;;;
|
||||
;;; This program is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU General Public License
|
||||
;;; as published by the Free Software Foundation; either version 2
|
||||
;;; of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
;;; USA.
|
||||
;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(deftest relative-humidity-test
|
||||
(testing "definitional"
|
||||
(let [min-expected 0.99
|
||||
max-expected 1.01
|
||||
actual (volume-fn :pressure-pascals Pa :temperature-kelvin celsius-offset)]
|
||||
(is (< min-expected actual max-expected))))
|
||||
(testing "Example from metoffice 26th May data."
|
||||
(let [min-expected 1.14
|
||||
max-expected 1.15
|
||||
actual (volume-fn :pressure-pascals 102600 :temperature-kelvin (+ 35.1 celsius-offset))]
|
||||
(is (< min-expected actual max-expected)))
|
||||
(testing "Missing data returns nil"
|
||||
(let [expected nil
|
||||
actual (volume-fn :pressure-pascals 102600 :temperature-celsius 35.1)]
|
||||
(is (= actual expected))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue