Tidied up documentation. This is more or less ready for others to play with.
This commit is contained in:
parent
91343b9c10
commit
507a365682
15 changed files with 337 additions and 40 deletions
|
|
@ -11,12 +11,12 @@ partial data.
|
||||||
The 'packet', in the terminology of this library, is a map which has bindings
|
The 'packet', in the terminology of this library, is a map which has bindings
|
||||||
for some of the following keywords:
|
for some of the following keywords:
|
||||||
|
|
||||||
1. `:actual-humidity`
|
1. `:absolute-humidity`
|
||||||
2. `:actual-vapour-pressure
|
2. `:actual-vapour-pressure` *not yet implemented*
|
||||||
1. `:dew-point`
|
1. `:dew-point`
|
||||||
2. `:pressure-pascals`
|
2. `:pressure-pascals`
|
||||||
3. `:pressure-millibars`
|
3. `:pressure-millibars`
|
||||||
4. `:saturation-pressure`
|
4. `:saturation--vapour-pressure`
|
||||||
5. `:relative-humidity`
|
5. `:relative-humidity`
|
||||||
6. `:temperature`
|
6. `:temperature`
|
||||||
7. `:temperature-celsius`
|
7. `:temperature-celsius`
|
||||||
|
|
|
||||||
23
project.clj
23
project.clj
|
|
@ -1,7 +1,18 @@
|
||||||
(defproject humidity "0.1.0-SNAPSHOT"
|
(defproject humidity "0.1.0-SNAPSHOT"
|
||||||
:description "FIXME: write description"
|
:cloverage {:output "docs/cloverage"
|
||||||
:url "http://example.com/FIXME"
|
:ns-exclude-regex [#"beowulf\.gendoc" #"beowulf\.scratch"]}
|
||||||
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
|
:codox {:metadata {:doc "**TODO**: write docs"
|
||||||
:url "https://www.eclipse.org/legal/epl-2.0/"}
|
:doc/format :markdown}
|
||||||
:dependencies [[org.clojure/clojure "1.11.1"]]
|
:output-path "docs/codox"
|
||||||
:repl-options {:init-ns humidity.core})
|
: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")
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,33 @@
|
||||||
(ns ^{:doc "Function to calculate wet bulb temperature (in ° C) given temperature in
|
(ns ^{:doc "Function to calculate absolute humidity in grammes per
|
||||||
° C and relative-humidity percentage (0...100).
|
metre<sup>3</sup> given temperature in ° K, saturation vapour pressure
|
||||||
|
in Pascals, and relative humidity as a percentage (0...100)."
|
||||||
See [authority](https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/)"}
|
:authority "https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/"
|
||||||
|
:author "simon"}
|
||||||
humidity.absolute
|
humidity.absolute
|
||||||
(:require
|
(:require
|
||||||
[humidity.constants :refer [Rw]]))
|
[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.
|
||||||
|
;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;; Absolute Humidity (grams/m3) = 6.112 × e^[(17.67 × T)/(T+243.5)] × rh × 2.1674
|
;; Absolute Humidity (grams/m3) = 6.112 × e^[(17.67 × T)/(T+243.5)] × rh × 2.1674
|
||||||
;; -----
|
;; -----
|
||||||
;; (273.15+T)
|
;; (273.15+T)
|
||||||
|
|
@ -18,20 +40,14 @@
|
||||||
|
|
||||||
(def C magic-numbers)
|
(def C magic-numbers)
|
||||||
|
|
||||||
;; (defn abs-humidity
|
(defn abs-humidity
|
||||||
;; "Returns absolute humidity in grammes per cubic metre given this
|
"calculate and return absolute humidity in grammes per metre<sup>3</sup>
|
||||||
;; `temperature` in ° C and `relative-hunidity` percentage (0...100).
|
given temperature in ° K, saturation vapour pressure in Pascals, and
|
||||||
;; "
|
relative humidity as a percentage (0...100)."
|
||||||
;; [temperature relative-humidity]
|
[& {:keys [relative-humidity saturation-vapour-pressure temperature-kelvin]}]
|
||||||
;; (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)
|
(when (and relative-humidity saturation-vapour-pressure temperature-kelvin)
|
||||||
;; I don't know why I'm having to multiply by a thousand here...
|
;; 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)))
|
||||||
|
|
|
||||||
|
|
@ -1 +1,23 @@
|
||||||
(ns humidity.actual-vp)
|
(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.
|
||||||
|
;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,26 @@
|
||||||
(ns humidity.constants)
|
(ns ^{:doc "Constants used in humidity calculations."
|
||||||
|
:author "simon"} 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
|
(def ^:const celsius-offset
|
||||||
"Value of 0° Celsius in ° Kelvin"
|
"Value of 0° Celsius in ° Kelvin"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
(ns humidity.core
|
(ns ^{:doc "Central resolver function for humidity calculations"
|
||||||
|
:author "simon"}
|
||||||
|
humidity.core
|
||||||
(:require [humidity.absolute :refer [abs-humidity]]
|
(:require [humidity.absolute :refer [abs-humidity]]
|
||||||
[humidity.constants :refer [celsius-offset Pa]]
|
[humidity.constants :refer [celsius-offset Pa]]
|
||||||
[humidity.relative :refer [rel-humidity]]
|
[humidity.relative :refer [rel-humidity]]
|
||||||
|
|
@ -6,6 +8,27 @@
|
||||||
[humidity.utils :refer [?assoc]]
|
[humidity.utils :refer [?assoc]]
|
||||||
[humidity.wet-bulb :as wb]))
|
[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.
|
||||||
|
;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defn resolve-humidity
|
(defn resolve-humidity
|
||||||
"Resolve humidity equations given the data in this packet."
|
"Resolve humidity equations given the data in this packet."
|
||||||
[& {:keys [absolute-humidity pressure-pascals pressure-millibars
|
[& {:keys [absolute-humidity pressure-pascals pressure-millibars
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,27 @@
|
||||||
(:require [humidity.constants :refer [e Rw]]
|
(:require [humidity.constants :refer [e Rw]]
|
||||||
[humidity.utils :refer [expt]]))
|
[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
|
(def ^:const magic-numbers
|
||||||
"The magic numbers (empirical constants) from the derived expression. It
|
"The magic numbers (empirical constants) from the derived expression. It
|
||||||
bothers me that all these formulae depend on 'empirical constants', *and*
|
bothers me that all these formulae depend on 'empirical constants', *and*
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,27 @@
|
||||||
(:require [clojure.math :refer [pow]]
|
(:require [clojure.math :refer [pow]]
|
||||||
[humidity.constants :refer [celsius-offset e]]))
|
[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
|
(defn saturation-vp-tetens
|
||||||
"Calculate and return saturation vapour pressure in Pa using Tetens'
|
"Calculate and return saturation vapour pressure in Pa using Tetens'
|
||||||
formula, given temerature in ° Celsius."
|
formula, given temerature in ° Celsius."
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,27 @@
|
||||||
(ns ^{:doc "Utility functions for humidity calculation"} humidity.utils
|
(ns ^{:doc "Utility functions for humidity calculation"
|
||||||
|
:author "simon"} humidity.utils
|
||||||
(:require [clojure.math :refer [pow]]))
|
(: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
|
(defmacro expt
|
||||||
"Clojure.math `pow` function does not allow ratios as exponents;
|
"Clojure.math `pow` function does not allow ratios as exponents;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,27 @@
|
||||||
(:require [clojure.math :refer [atan]]
|
(:require [clojure.math :refer [atan]]
|
||||||
[humidity.utils :refer [expt]]))
|
[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
|
(def ^:const magic-numbers
|
||||||
"The magic numbers (empirical constants) from the derived expression. It
|
"The magic numbers (empirical constants) from the derived expression. It
|
||||||
bothers me that all these formulae depend on 'empirical constants', *and*
|
bothers me that all these formulae depend on 'empirical constants', *and*
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,26 @@
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[humidity.constants :refer [celsius-offset]]
|
[humidity.constants :refer [celsius-offset]]
|
||||||
[humidity.absolute :refer [abs-humidity]]))
|
[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
|
(deftest absolute-humidity-test
|
||||||
(testing "definitional"
|
(testing "definitional"
|
||||||
|
|
|
||||||
38
test/humidity/core_test.clj
Normal file
38
test/humidity/core_test.clj
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
(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))))
|
||||||
|
|
@ -3,6 +3,27 @@
|
||||||
[humidity.constants :refer [celsius-offset]]
|
[humidity.constants :refer [celsius-offset]]
|
||||||
[humidity.relative :refer [rel-humidity rel-humidity]]))
|
[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
|
(deftest relative-humidity-test
|
||||||
(testing "definitional"
|
(testing "definitional"
|
||||||
(let [min-expected 99
|
(let [min-expected 99
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,27 @@
|
||||||
(ns humidity.saturation-vp-test(:require [clojure.test :refer [deftest is testing]]
|
(ns humidity.saturation-vp-test
|
||||||
[humidity.constants :refer [celsius-offset]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[humidity.saturation-vp :refer [saturation-vp saturation-vp-tetens]]))
|
[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.
|
||||||
|
;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(deftest saturation-vp-test
|
(deftest saturation-vp-test
|
||||||
(testing "from online sources"
|
(testing "from online sources"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,26 @@
|
||||||
(:require [clojure.test :refer [deftest is testing]]
|
(:require [clojure.test :refer [deftest is testing]]
|
||||||
[humidity.wet-bulb :refer [wet-bulb-temperature]]))
|
[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
|
(deftest wet-bulb-test
|
||||||
(testing "Example from paper"
|
(testing "Example from paper"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue