diff --git a/README.md b/README.md index a8f8bf4..e49136e 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ partial data. The 'packet', in the terminology of this library, is a map which has bindings for some of the following keywords: -1. `:absolute-humidity` -2. `:actual-vapour-pressure` *not yet implemented* +1. `:actual-humidity` +2. `:actual-vapour-pressure 1. `:dew-point` 2. `:pressure-pascals` 3. `:pressure-millibars` -4. `:saturation--vapour-pressure` +4. `:saturation-pressure` 5. `:relative-humidity` 6. `:temperature` 7. `:temperature-celsius` diff --git a/project.clj b/project.clj index b3bb11c..326d174 100644 --- a/project.clj +++ b/project.clj @@ -1,18 +1,7 @@ (defproject humidity "0.1.0-SNAPSHOT" - :cloverage {:output "docs/cloverage" - :ns-exclude-regex [#"beowulf\.gendoc" #"beowulf\.scratch"]} - :codox {:metadata {:doc "**TODO**: write docs" - :doc/format :markdown} - :output-path "docs/codox" - :source-uri "https://github.com/simon-brooke/humidity/blob/master/{filepath}#L{line}"} - :dependencies [[org.clojure/clojure "1.12.5"]] - :description "Functions to compute relative humidity, absolute humidity, wet bulb - temperature, and other values related to humidity of air, given - partial data." - :license {:name "GPL-2.0-or-later" - :url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"} - :repl-options {:init-ns humidity.core} - :plugins [[lein-ancient "1.0.0"] - [lein-cloverage "1.2.2"] - [lein-codox "0.10.8"]] - :url "https://git.journeyman.cc/simon/humidity") + :description "FIXME: write description" + :url "http://example.com/FIXME" + :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" + :url "https://www.eclipse.org/legal/epl-2.0/"} + :dependencies [[org.clojure/clojure "1.11.1"]] + :repl-options {:init-ns humidity.core}) diff --git a/src/humidity/absolute.clj b/src/humidity/absolute.clj index 8de3650..d686e7c 100644 --- a/src/humidity/absolute.clj +++ b/src/humidity/absolute.clj @@ -1,32 +1,10 @@ -(ns ^{:doc "Function to calculate absolute humidity in grammes per - metre3 given temperature in ° K, saturation vapour pressure - in Pascals, and relative humidity as a percentage (0...100)." - :authority "https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/" - :author "simon"} +(ns ^{:doc "Function to calculate wet bulb temperature (in ° C) given temperature in + ° C and relative-humidity percentage (0...100). + + See [authority](https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/)"} humidity.absolute (:require - [humidity.constants :refer [Rw]])) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + [humidity.constants :refer [Rw]])) ;; Absolute Humidity (grams/m3) = 6.112 × e^[(17.67 × T)/(T+243.5)] × rh × 2.1674 ;; ----- @@ -40,14 +18,20 @@ (def C magic-numbers) -(defn abs-humidity - "calculate and return absolute humidity in grammes per metre3 - given temperature in ° K, saturation vapour pressure in Pascals, and - relative humidity as a percentage (0...100)." - [& {:keys [relative-humidity saturation-vapour-pressure temperature-kelvin]}] +;; (defn abs-humidity +;; "Returns absolute humidity in grammes per cubic metre given this +;; `temperature` in ° C and `relative-hunidity` percentage (0...100). +;; ![function for absolute humidity given temperature and relative humidity](https://carnotcycle.wordpress.com/wp-content/uploads/2014/09/ah3.gif)" +;; [temperature relative-humidity] +;; (when (empty? (filter false? (map number? [temperature relative-humidity]))) +;; (let [T temperature +;; RHP relative-humidity] +;; (/ (* (C 1) (pow (* (/ (C 2) T) (+ T (C 3))) e) RHP (C 4)) +;; (+ celsius-offset temperature))))) + +;; AH=(RH × Ps)​​/(Rw ​× T × 100) + +(defn abs-humidity [& {:keys [relative-humidity saturation-vapour-pressure temperature-kelvin]}] (when (and relative-humidity saturation-vapour-pressure temperature-kelvin) ;; I don't know why I'm having to multiply by a thousand here... - (* - (/ - (* relative-humidity saturation-vapour-pressure) Rw temperature-kelvin) - 1000))) + (* (/ (* relative-humidity saturation-vapour-pressure) Rw temperature-kelvin) 1000))) diff --git a/src/humidity/actual_vp.clj b/src/humidity/actual_vp.clj index 2776a94..3e742f5 100644 --- a/src/humidity/actual_vp.clj +++ b/src/humidity/actual_vp.clj @@ -1,23 +1 @@ (ns humidity.actual-vp) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/src/humidity/constants.clj b/src/humidity/constants.clj index 2173cc6..29ac6d1 100644 --- a/src/humidity/constants.clj +++ b/src/humidity/constants.clj @@ -1,26 +1,5 @@ -(ns ^{:doc "Constants used in humidity calculations." - :author "simon"} humidity.constants) +(ns humidity.constants) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (def ^:const celsius-offset "Value of 0° Celsius in ° Kelvin" diff --git a/src/humidity/core.clj b/src/humidity/core.clj index ed9700e..6267107 100644 --- a/src/humidity/core.clj +++ b/src/humidity/core.clj @@ -1,71 +1,42 @@ -(ns ^{:doc "Central resolver function for humidity calculations" - :author "simon"} - humidity.core +(ns humidity.core (:require [humidity.absolute :refer [abs-humidity]] [humidity.constants :refer [celsius-offset Pa]] [humidity.relative :refer [rel-humidity]] - [humidity.saturation-vp :refer [saturation-vp]] + [humidity.saturation-vp :as saturation-vp] [humidity.utils :refer [?assoc]] - [humidity.wet-bulb :as wb])) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + [humidity.wet-bulb :refer [wet-bulb-temperature]])) (defn resolve-humidity "Resolve humidity equations given the data in this packet." - [& {:keys [absolute-humidity pressure-pascals pressure-millibars - relative-humidity saturation-vapour-pressure temperature - temperature-celsius temperature-kelvin wet-bulb-temperature] :as packet}] + [& {:keys [temperature temperature-celsius temperature-kelvin relative-humidity + pressure-pascals pressure-millibars saturation-vapour-pressure] :as packet}] (println packet) - (if temperature (resolve-humidity - (assoc (dissoc packet :temperature) - :temperature-celsius temperature)) + (if temperature (resolve-humidity (assoc (dissoc packet :temperature) :temperature-celsius temperature)) (?assoc packet - :absolute-humidity (when-not absolute-humidity - (abs-humidity packet)) - :pressure-pascals (when-not pressure-pascals - (if pressure-millibars - (* pressure-millibars 100) Pa)) - :pressure-millibars (when-not pressure-millibars - (if pressure-pascals - (/ pressure-pascals 100) (/ Pa 100))) - :relative-humidity (when-not relative-humidity - (rel-humidity packet)) - :saturation-vapour-pressure (when-not saturation-vapour-pressure - (saturation-vp packet)) :temperature-celsius (when - (and temperature-kelvin - (not temperature-celsius)) + (and temperature-kelvin (not temperature-celsius)) (- temperature-kelvin celsius-offset)) :temperature-kelvin (when - (and temperature-celsius - (not temperature-kelvin)) + (and temperature-celsius (not temperature-kelvin)) (+ temperature-celsius celsius-offset)) - :wet-bulb-temperature (when-not wet-bulb-temperature - (wb/wet-bulb-temperature packet))))) + :wet-bulb-temperature (when + (and temperature-celsius relative-humidity) + (wet-bulb-temperature temperature-celsius relative-humidity)) + :absolute-humidity (abs-humidity :relative-humidity relative-humidity + :saturation-vapour-pressure saturation-vapour-pressure + :temperature-kelvin temperature-kelvin) + :pressure-pascals (when-not pressure-pascals + (if pressure-millibars (* pressure-millibars 100) Pa)) + :pressure-millibars (when-not pressure-millibars + (if pressure-pascals (/ pressure-pascals 100) (/ Pa 100))) + :relative-humidity (when-not relative-humidity (rel-humidity packet)) + :saturation-vapour-pressure (saturation-vp/saturation-vp packet)))) + (defn resolution "Repeatedly run `resolve-humidity`, q.v., until we can infer no further information." - [& {:keys [] :as packet}] + [packet] (loop [p packet] (let [p' (resolve-humidity p)] (if (= (keys p) (keys p')) p diff --git a/src/humidity/relative.clj b/src/humidity/relative.clj index 63ba264..1f8c3c2 100644 --- a/src/humidity/relative.clj +++ b/src/humidity/relative.clj @@ -4,27 +4,6 @@ (:require [humidity.constants :refer [e Rw]] [humidity.utils :refer [expt]])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (def ^:const magic-numbers "The magic numbers (empirical constants) from the derived expression. It bothers me that all these formulae depend on 'empirical constants', *and* diff --git a/src/humidity/saturation_vp.clj b/src/humidity/saturation_vp.clj index 31081ac..b48aa47 100644 --- a/src/humidity/saturation_vp.clj +++ b/src/humidity/saturation_vp.clj @@ -5,27 +5,6 @@ (:require [clojure.math :refer [pow]] [humidity.constants :refer [celsius-offset e]])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (defn saturation-vp-tetens "Calculate and return saturation vapour pressure in Pa using Tetens' formula, given temerature in ° Celsius." diff --git a/src/humidity/utils.clj b/src/humidity/utils.clj index 11475c9..d0a0569 100644 --- a/src/humidity/utils.clj +++ b/src/humidity/utils.clj @@ -1,27 +1,6 @@ -(ns ^{:doc "Utility functions for humidity calculation" - :author "simon"} humidity.utils +(ns ^{:doc "Utility functions for humidity calculation"} humidity.utils (:require [clojure.math :refer [pow]])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro expt "Clojure.math `pow` function does not allow ratios as exponents; @@ -37,4 +16,4 @@ (partition 2) (filter second) (map vec) - (into m))) + (into m))) \ No newline at end of file diff --git a/src/humidity/wet_bulb.clj b/src/humidity/wet_bulb.clj index c5ca18f..ffed146 100644 --- a/src/humidity/wet_bulb.clj +++ b/src/humidity/wet_bulb.clj @@ -5,27 +5,6 @@ (:require [clojure.math :refer [atan]] [humidity.utils :refer [expt]])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - (def ^:const magic-numbers "The magic numbers (empirical constants) from the derived expression. It bothers me that all these formulae depend on 'empirical constants', *and* @@ -38,13 +17,11 @@ (defn wet-bulb-temperature "Returns wet bulb temperature (in ° C) given this `temperature` in ° C and `relative-humidity` percentage (0...100)" - [&{:keys [temperature relative-humidity]}] - (when - (and temperature relative-humidity) - (let [T temperature + [temperature relative-humidity] + (let [T temperature RHP relative-humidity] (+ (* T (atan (* (C 1) (expt (+ RHP (C 2)) 1/2)))) (atan (+ T RHP)) (- 0 (atan (- RHP (C 3)))) (* (C 4) (expt RHP 3/2) (atan (* (C 5) RHP))) - (- 0 (C 6)))))) + (- 0 (C 6))))) diff --git a/test/humidity/absolute_test.clj b/test/humidity/absolute_test.clj index 9f768be..9a13e6f 100644 --- a/test/humidity/absolute_test.clj +++ b/test/humidity/absolute_test.clj @@ -2,26 +2,6 @@ (:require [clojure.test :refer [deftest is testing]] [humidity.constants :refer [celsius-offset]] [humidity.absolute :refer [abs-humidity]])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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 absolute-humidity-test (testing "definitional" diff --git a/test/humidity/core_test.clj b/test/humidity/core_test.clj deleted file mode 100644 index ef48072..0000000 --- a/test/humidity/core_test.clj +++ /dev/null @@ -1,38 +0,0 @@ -(ns humidity.core-test - (:require - [clojure.test :refer [deftest is testing]] - [humidity.core :refer [resolution]])) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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 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)))) diff --git a/test/humidity/relative_test.clj b/test/humidity/relative_test.clj index b154401..d729791 100644 --- a/test/humidity/relative_test.clj +++ b/test/humidity/relative_test.clj @@ -3,27 +3,6 @@ [humidity.constants :refer [celsius-offset]] [humidity.relative :refer [rel-humidity rel-humidity]])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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 99 diff --git a/test/humidity/saturation_vp_test.clj b/test/humidity/saturation_vp_test.clj index 5d10592..84db41b 100644 --- a/test/humidity/saturation_vp_test.clj +++ b/test/humidity/saturation_vp_test.clj @@ -1,31 +1,10 @@ -(ns humidity.saturation-vp-test - (:require [clojure.test :refer [deftest is testing]] - [humidity.saturation-vp :refer [saturation-vp]])) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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. -;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(ns humidity.saturation-vp-test(:require [clojure.test :refer [deftest is testing]] + [humidity.constants :refer [celsius-offset]] + [humidity.saturation-vp :refer [saturation-vp saturation-vp-tetens]])) (deftest saturation-vp-test (testing "from online sources" (let [min-expected 5622 - max-expected 5629 - actual (saturation-vp {:temperature-celsius 35})] - (is (< min-expected actual max-expected))))) + max-expected 5629 + actual (saturation-vp {:temperature-celsius 35})] + (is (< min-expected actual max-expected))))) diff --git a/test/humidity/wet_bulb_test.clj b/test/humidity/wet_bulb_test.clj index 21cec52..6dc802b 100644 --- a/test/humidity/wet_bulb_test.clj +++ b/test/humidity/wet_bulb_test.clj @@ -2,33 +2,13 @@ (:require [clojure.test :refer [deftest is testing]] [humidity.wet-bulb :refer [wet-bulb-temperature]])) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; -;;; 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 wet-bulb-test (testing "Example from paper" (let [expected 13.7 temperature 20 rel-humidity 50 - actual (wet-bulb-temperature :temperature temperature :relative-humidity rel-humidity)] + actual (wet-bulb-temperature temperature rel-humidity)] (println (format "Expected: %s; actual: %s" expected actual)) (is (< (abs (- expected actual)) 0.001)))) @@ -37,7 +17,7 @@ max-expected 33 temperature 37 rel-humidity 70 - actual (wet-bulb-temperature :temperature temperature :relative-humidity rel-humidity)] + actual (wet-bulb-temperature temperature rel-humidity)] (println (format "Expected: %s...%s; actual: %s" min-expected max-expected actual)) (is (< min-expected actual max-expected))) @@ -45,7 +25,7 @@ max-expected 36 temperature 39.7 rel-humidity 70 - actual (wet-bulb-temperature :temperature temperature :relative-humidity rel-humidity)] + actual (wet-bulb-temperature temperature rel-humidity)] (println (format "Expected: %s...%s; actual: %s" min-expected max-expected actual)) (is (< min-expected actual max-expected))) @@ -54,7 +34,7 @@ max-expected 34 temperature 40 rel-humidity 60 - actual (wet-bulb-temperature :temperature temperature :relative-humidity rel-humidity)] + actual (wet-bulb-temperature temperature rel-humidity)] (println (format "Expected: %s...%s; actual: %s" min-expected max-expected actual)) (is (< min-expected actual max-expected))) @@ -62,6 +42,6 @@ max-expected 35 temperature 51 rel-humidity 30 - actual (wet-bulb-temperature :temperature temperature :relative-humidity rel-humidity)] + actual (wet-bulb-temperature temperature rel-humidity)] (println (format "Expected: %s...%s; actual: %s" min-expected max-expected actual)) - (is (< min-expected actual max-expected))))) + (is (< min-expected actual max-expected))))) \ No newline at end of file