commit 86dbcfc34a97508bb8e0d88a2632a4183abdc9f1
parent 3983f8985e3b422c393af9dbb9cca9c4ab6a5ba7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 8 Oct 2025 16:32:26 +0200
Update the validity ranges for longitude & latitude
They were not correctly defined. Update the comments and documentation
accordingly.
Diffstat:
5 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/doc/smeteo.5 b/doc/smeteo.5
@@ -12,7 +12,7 @@
.\"
.\" You should have received a copy of the GNU Lesser General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
-.Dd August 12, 2025
+.Dd October 8, 2025
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Dt SMETEO 5
.Os
@@ -64,8 +64,10 @@ The file format is as follows:
.It Ta Ta Ao Va #intervals Ac
.It Ta Ta
.It Ao Va albedo Ac Ta ::= Ta Va real No # in [0, 1]
-.It Ao Va longitude Ac Ta ::= Ta Va real No # in [0, 180] [deg]
-.It Ao Va latitude Ac Ta ::= Ta Va real No # in [0, 90] [deg]
+.It Ao Va longitude Ac Ta ::= Ta Va real
+# In [\&-180, 180] deg. + towards the east
+.It Ao Va latitude Ac Ta ::= Ta Va real
+# In [\&-90, 90] deg. + towards the north
.It Ao Va #intervals Ac Ta ::= Ta Va integer
.It Ta Ta
.It Ao Va data-set Ac Ta ::= Ta
diff --git a/samples/invalid_latitude.txt b/samples/invalid_latitude.txt
@@ -1,6 +1,6 @@
0.31659812657071051 # Albedo
10.428827285766602 # Longitude [deg]
--1.e-12 # Latitude [deg]
+-90.00001 # Latitude [deg]
1 # Time interval count
# Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850
diff --git a/samples/invalid_longitude.txt b/samples/invalid_longitude.txt
@@ -1,5 +1,5 @@
0.31659812657071051 # Albedo
-1-e-12 # Longitude [deg]
+-180.00000001 # Longitude [deg]
16.388128280639648 # Latitude [deg]
1 # Time interval count# Longitude [deg]
diff --git a/src/smeteo.h b/src/smeteo.h
@@ -59,8 +59,13 @@ static const struct smeteo_entry SMETEO_ENTRY_NULL = SMETEO_ENTRY_NULL__;
struct smeteo_desc {
const char* filename;
- double longitude; /* Longitude of geographical position [deg] */
- double latitude; /* Latitude of geographical position [deg] */
+ /* In [-180,180] decimal degree relative to Greenwitch.
+ * Positive toward the east */
+ double longitude;
+
+ /* In [-90, 90] decimal degree relative to the equator.
+ * Positive toward the north */
+ double latitude;
double albedo; /* Ground albedo, for shortwave radiation */
diff --git a/src/smeteo_load.c b/src/smeteo_load.c
@@ -271,8 +271,8 @@ parse_header(struct smeteo* smeteo, struct txtrdr* txtrdr)
} (void)0
PARSE_VAR("albedo", 0, 1, &smeteo->albedo);
- PARSE_VAR("longitude", 0, 180, &smeteo->longitude);
- PARSE_VAR("latitude", 0, 90, &smeteo->latitude);
+ PARSE_VAR("longitude", -180, 180, &smeteo->longitude);
+ PARSE_VAR("latitude", -90, 90, &smeteo->latitude);
/* To simplify, parse the number of intervals in double precision and ensure
* that it can encode an integer. The representation of doubles allows all