star-meteo

Time varying meteorological data
git clone git://git.meso-star.fr/star-meteo.git
Log | Files | Refs | README | LICENSE

commit 68d605de8f82a93c4221a039452e835e770e4385
parent 86dbcfc34a97508bb8e0d88a2632a4183abdc9f1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  8 Oct 2025 16:39:57 +0200

Add the time zone to the header of the smeteo format

It defines the time zone corresponding to the local position defined in
the header by the longitude and latitude coordinates. In all cases, this
time zone could be found automatically from these coordinates without
asking the user to ensure their consistency. But there is nothing
trivial about finding the time zone of a GPS coordinate. It would
require an external library or writing a large amount of code. That is
why no checks are performed to ensure consistency between the location
and its time zone, or the validity of the time zone itself, because,
again, there seems to be no simple way to guarantee it. Letting the user
ensure that the time zone is correct and that it corresponds to the
given location seems to be the least bad solution.

The time zone is used to calculate the difference between January 1,
1850 in that time zone and the current time, i.e., January 1, 1970 at
UTC+00:00. This will serve as the time origin for converting the
local dates of an entry to UTC time, based on its field defining the
number of seconds elapsed since January 1, 1850, local time. Thus,
having a time expressed in UTC will make it possible to retrieve the
solar position relative to the position from these universal time
coordinates.

Diffstat:
MMakefile | 1+
Mdoc/smeteo.5 | 3+++
Msamples/invalid_Ahum.txt | 1+
Msamples/invalid_H.txt | 1+
Msamples/invalid_LE.txt | 1+
Msamples/invalid_Rhum.txt | 1+
Msamples/invalid_Rhum2.txt | 1+
Msamples/invalid_SWdn.txt | 1+
Msamples/invalid_SWdn_diffuse.txt | 1+
Msamples/invalid_SWdn_direct.txt | 1+
Msamples/invalid_SWup.txt | 1+
Msamples/invalid_Tatm.txt | 1+
Msamples/invalid_Trad.txt | 1+
Msamples/invalid_Tsrf.txt | 1+
Msamples/invalid_albedo.txt | 1+
Msamples/invalid_albedo2.txt | 1+
Msamples/invalid_date.txt | 1+
Msamples/invalid_date2.txt | 1+
Msamples/invalid_date3.txt | 1+
Msamples/invalid_date4.txt | 1+
Msamples/invalid_day_1850.txt | 1+
Msamples/invalid_hour.txt | 1+
Msamples/invalid_hour2.txt | 1+
Msamples/invalid_hour3.txt | 1+
Msamples/invalid_latitude.txt | 1+
Msamples/invalid_latitude2.txt | 1+
Msamples/invalid_longitude.txt | 1+
Msamples/invalid_longitude2.txt | 1+
Msamples/missing_data.txt | 1+
Asamples/missing_timezone.txt | 8++++++++
Msamples/star-meteo_input.txt | 2++
Msamples/variable_time_period.txt | 1+
Msrc/smeteo.c | 3+++
Msrc/smeteo.h | 1+
Msrc/smeteo_c.h | 1+
Msrc/smeteo_load.c | 38++++++++++++++++++++++++++++++++++++++
Msrc/stardis_smeteo_library.c | 40++++++++++++++++++++++++++++++++++++++++
Msrc/test_smeteo_load.c | 21++++++++++++++-------
38 files changed, 139 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -222,6 +222,7 @@ TEST_FILES_INVALID =\ samples/invalid_LE.txt\ samples/invalid_day_1850.txt\ samples/missing_data.txt\ + samples/missing_timezone.txt\ samples/variable_time_period.txt INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys smeteo-local.pc) diff --git a/doc/smeteo.5 b/doc/smeteo.5 @@ -61,6 +61,7 @@ The file format is as follows: .It Ao Va header Ac Ta ::= Ta Ao Va albedo Ac .It Ta Ta Ao Va longitude Ac .It Ta Ta Ao Va latitude Ac +.It Ta Ta Ao Va timezone Ac .It Ta Ta Ao Va #intervals Ac .It Ta Ta .It Ao Va albedo Ac Ta ::= Ta Va real No # in [0, 1] @@ -68,6 +69,8 @@ The file format is as follows: # 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 timezone Ac Ta :: Ta Va string +# e.g.: Europe/Paris .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_Ahum.txt b/samples/invalid_Ahum.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_H.txt b/samples/invalid_H.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_LE.txt b/samples/invalid_LE.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_Rhum.txt b/samples/invalid_Rhum.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_Rhum2.txt b/samples/invalid_Rhum2.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_SWdn.txt b/samples/invalid_SWdn.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_SWdn_diffuse.txt b/samples/invalid_SWdn_diffuse.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_SWdn_direct.txt b/samples/invalid_SWdn_direct.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_SWup.txt b/samples/invalid_SWup.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_Tatm.txt b/samples/invalid_Tatm.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_Trad.txt b/samples/invalid_Trad.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_Tsrf.txt b/samples/invalid_Tsrf.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_albedo.txt b/samples/invalid_albedo.txt @@ -1,6 +1,7 @@ -1e-1 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_albedo2.txt b/samples/invalid_albedo2.txt @@ -1,6 +1,7 @@ 1.0000000001 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_date.txt b/samples/invalid_date.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_date2.txt b/samples/invalid_date2.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_date3.txt b/samples/invalid_date3.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_date4.txt b/samples/invalid_date4.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_day_1850.txt b/samples/invalid_day_1850.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_hour.txt b/samples/invalid_hour.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_hour2.txt b/samples/invalid_hour2.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_hour3.txt b/samples/invalid_hour3.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_latitude.txt b/samples/invalid_latitude.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] -90.00001 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_latitude2.txt b/samples/invalid_latitude2.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 90.00001 # Latitude [deg] +Africa/Ndjamena # Timezone 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,6 +1,7 @@ 0.31659812657071051 # Albedo -180.00000001 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count# Longitude [deg] # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/invalid_longitude2.txt b/samples/invalid_longitude2.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 180.00001 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count# Longitude [deg] # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/missing_data.txt b/samples/missing_data.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 1 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/missing_timezone.txt b/samples/missing_timezone.txt @@ -0,0 +1,8 @@ +0.31659812657071051 # Albedo +10.428827285766602 # Longitude [deg] +16.388128280639648 # Latitude [deg] + # Timezone +1 # Time interval count + +# Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 +01-Jan-1850 01:30:00 287.85 289.62 4.23 12.28 0.00 0.00 0.00 0.00 271.21 12.60 0.51 0.0625 diff --git a/samples/star-meteo_input.txt b/samples/star-meteo_input.txt @@ -4,6 +4,8 @@ 10.428827285766602 # Latitude [deg] : 16.388128280639648 +# Timezone + Africa/Ndjamena # Ndata : 733408 # Date Heure Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/samples/variable_time_period.txt b/samples/variable_time_period.txt @@ -1,6 +1,7 @@ 0.31659812657071051 # Albedo 10.428827285766602 # Longitude [deg] 16.388128280639648 # Latitude [deg] +Africa/Ndjamena # Timezone 2 # Time interval count # Date Hour Tsrf Tatm Ahum Rhum SWdn direct diffus SWup Trad h LE day/1850 diff --git a/src/smeteo.c b/src/smeteo.c @@ -34,6 +34,7 @@ release_smeteo(ref_T* ref) struct smeteo* smeteo = CONTAINER_OF(ref, struct smeteo, ref); ASSERT(smeteo); str_release(&smeteo->filename); + str_release(&smeteo->timezone); darray_entry_release(&smeteo->entries); MEM_RM(smeteo->allocator, smeteo); } @@ -63,6 +64,7 @@ smeteo_create smeteo->logger = args->logger ? args->logger : LOGGER_DEFAULT; smeteo->verbose = args->verbose; str_init(smeteo->allocator, &smeteo->filename); + str_init(smeteo->allocator, &smeteo->timezone); darray_entry_init(smeteo->allocator, &smeteo->entries); exit: @@ -95,6 +97,7 @@ smeteo_get_desc(const struct smeteo* smeteo, struct smeteo_desc* desc) desc->albedo = smeteo->albedo; desc->longitude = smeteo->longitude; desc->latitude = smeteo->latitude; + desc->timezone = str_cget(&smeteo->timezone); desc->nentries = darray_entry_size_get(&smeteo->entries); if(str_len(&smeteo->filename)) desc->filename = str_cget(&smeteo->filename); diff --git a/src/smeteo.h b/src/smeteo.h @@ -58,6 +58,7 @@ static const struct smeteo_entry SMETEO_ENTRY_NULL = SMETEO_ENTRY_NULL__; struct smeteo_desc { const char* filename; + const char* timezone; /* In [-180,180] decimal degree relative to Greenwitch. * Positive toward the east */ diff --git a/src/smeteo_c.h b/src/smeteo_c.h @@ -39,6 +39,7 @@ struct smeteo { struct str filename; + struct str timezone; /* File header */ double longitude; /* Longitude of geographical position [deg] */ diff --git a/src/smeteo_load.c b/src/smeteo_load.c @@ -259,6 +259,42 @@ error: } static res_T +parse_timezone(struct smeteo* smeteo, struct txtrdr* txtrdr) +{ + char* line = NULL; + char* tk = NULL; + char* tk_ctx = NULL; + + res_T res = RES_OK; + ASSERT(smeteo && txtrdr); + + if((res = txtrdr_read_line(txtrdr)) != RES_OK) { + ERROR_READ_LINE(smeteo, txtrdr, res); + goto error; + } + + if((line = txtrdr_get_line(txtrdr)) == NULL) { + ERROR(smeteo, "%s:%zu: missing timezone\n", + txtrdr_get_name(txtrdr), txtrdr_get_line_num(txtrdr)); + res = RES_BAD_ARG; + goto error; + } + + tk = strtok_r(line, " \t", &tk_ctx); + if((res = str_set(&smeteo->timezone, tk)) != RES_OK) { + ERROR(smeteo, "%s:%zu: error copying time zone '%s' -- %s\n", + txtrdr_get_name(txtrdr), txtrdr_get_line_num(txtrdr), + tk, res_to_cstr(res)); + goto error; + } + +exit: + return res; +error: + goto exit; +} + +static res_T parse_header(struct smeteo* smeteo, struct txtrdr* txtrdr) { double ndate = 0; @@ -274,6 +310,8 @@ parse_header(struct smeteo* smeteo, struct txtrdr* txtrdr) PARSE_VAR("longitude", -180, 180, &smeteo->longitude); PARSE_VAR("latitude", -90, 90, &smeteo->latitude); + if((res = parse_timezone(smeteo, txtrdr)) != RES_OK) goto error; + /* To simplify, parse the number of intervals in double precision and ensure * that it can encode an integer. The representation of doubles allows all * integers up to 2^48 to be represented. This is therefore the upper limit of diff --git a/src/stardis_smeteo_library.c b/src/stardis_smeteo_library.c @@ -13,6 +13,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#define _DEFAULT_SOURCE /* tm.tm_zone support */ + #include "smeteo.h" #include "stardis_smeteo.h" #include "stardis_smeteo_library.h" @@ -30,6 +32,15 @@ struct stardis_smeteo_lib { double max_convection_coef; double Tsrf_range[2]; /* Range of the surface temperatures [K] */ double Trad_range[2]; /* Range of the radiative temperatures [K] */ + + /* Number of seconds elapsed since the epoch until January 1, 1850, local time + * at the location of the smeteo file. Since the epoch is defined in + * UTC+00:00, this number of seconds is also defined in UTC+00:00. The + * day_1850 field in the smeteo file can therefore be used to calculate the + * number of seconds to add to this member variable in order to convert the + * smeteo time to UTC+00:00 */ + time_t jan_1_1850; + ref_T ref; }; @@ -66,6 +77,33 @@ error: goto exit; } +/* Retrieve the number of seconds elapsed since the epoch until January 1, 1850, + * local time at the timezone of the smeteo file. */ +static res_T +setup_utc_reference(struct stardis_smeteo_lib* lib) +{ + struct tm date = {0}; + struct smeteo_desc desc = SMETEO_DESC_NULL; + res_T res = RES_OK; + ASSERT(lib); + + if((res = smeteo_get_desc(lib->smeteo, &desc)) != RES_OK) return res; + + date.tm_mday = 1; + date.tm_mon = 0; /* January */ + date.tm_year = 1850 - 1900; + date.tm_min = 0; + date.tm_hour = 0; + date.tm_sec = 0; + date.tm_isdst = -1; /* Daylight saving time is unknown */ + date.tm_zone = desc.timezone; + + lib->jan_1_1850 = mktime(&date); + if(lib->jan_1_1850 == (time_t)-1) return RES_UNKNOWN_ERR; + + return RES_OK; +} + static res_T setup_smeteo (struct stardis_smeteo_lib* lib, @@ -92,6 +130,8 @@ setup_smeteo if((res = smeteo_load(lib->smeteo, args->filename)) != RES_OK) goto error; if((res = smeteo_get_desc(lib->smeteo, &desc)) != RES_OK) goto error; + if((res = setup_utc_reference(lib)) != RES_OK) goto error; + /* Retrieve the maximum convection coefficient from meteorological data */ FOR_EACH(i, 0, desc.nentries) max_H = MMAX(desc.entries[i].H, max_H); lib->max_convection_coef = max_H; diff --git a/src/test_smeteo_load.c b/src/test_smeteo_load.c @@ -31,8 +31,9 @@ check_api(struct smeteo* smeteo) struct smeteo_desc desc = SMETEO_DESC_NULL; const char* filename = "test.txt"; const double albedo = 0.314; - const double longitude = 10.42; /* [deg] */ - const double latitude = 16.01; /* [deg] */ + const double latitude = 43.559962; /* [deg] */ + const double longitude = 1.468150; /* [deg] */ + const char* timezone = "Europe/Paris"; FILE* fp = NULL; CHK((fp = fopen(filename, "w+")) != NULL); @@ -57,6 +58,7 @@ check_api(struct smeteo* smeteo) CHK(fprintf(fp, "%a # Albedo\n", albedo) > 0); CHK(fprintf(fp, "%a # Longitude [deg]\n", longitude) > 0); CHK(fprintf(fp, "%a # Latitude [deg]\n", latitude) > 0); + CHK(fprintf(fp, "%s # timezone\n", timezone) > 0); CHK(fprintf(fp, "0 # Date count\n") > 0); CHK(fflush(fp) == 0); @@ -85,6 +87,7 @@ check_n_time_intervals const double albedo, const double longitude, /* [deg] */ const double latitude, /* [deg] */ + const char* timezone, const size_t nintervals, const char* date[], const double Tsrf[], /* [K] */ @@ -110,6 +113,7 @@ check_n_time_intervals CHK(fprintf(fp, "%a # albedo\n", albedo) > 0); CHK(fprintf(fp, "%a # longitude [deg]\n", longitude) > 0); CHK(fprintf(fp, "%a # latitude [deg]\n", latitude) > 0); + CHK(fprintf(fp, "%s # timezone\n", timezone) > 0); CHK(fprintf(fp, "%lu # Date count\n", (unsigned long)nintervals) > 0); FOR_EACH(i, 0, nintervals) { @@ -174,6 +178,7 @@ check_1_time_interval(struct smeteo* smeteo) const double albedo = 1; const double longitude = 91.1; /* [deg] */ const double latitude = 46.2; /* [deg] */ + const char* timezone = "Asia/Hovd"; /* Time interval data */ const char* date = "01-JAN-1850 01:30:00"; @@ -189,9 +194,9 @@ check_1_time_interval(struct smeteo* smeteo) const double LE = 0.51; /* [W/m^2] */ const double day_1850 = 0.0625; - check_n_time_intervals(smeteo, albedo, longitude, latitude, 1, &date, &Tsrf, - &Tatm, &Ahum, &Rhum, &SWdn_direct, &SWdn_diffuse, &SWup, &Trad, &H, &LE, - &day_1850); + check_n_time_intervals(smeteo, albedo, longitude, latitude, timezone, 1, + &date, &Tsrf, &Tatm, &Ahum, &Rhum, &SWdn_direct, &SWdn_diffuse, &SWup, + &Trad, &H, &LE, &day_1850); } static void @@ -201,6 +206,7 @@ check_4_time_intervals(struct smeteo* smeteo) const double albedo = 0.31659812657071051; const double longitude = 10.428827285766602; /* [deg] */ const double latitude = 16.388128280639648; /* [deg] */ + const char* timezone = "Africa/Ndjamena"; /* Time interval data */ const char* date[] = { @@ -219,8 +225,9 @@ check_4_time_intervals(struct smeteo* smeteo) const double LE[] = { 0.51, 0.52, 0.87, 1.78 }; /* [W/m^2] */ const double day_1850[] = { 0.0625, 0.1875, 0.3125, 0.4375 }; - check_n_time_intervals(smeteo, albedo, longitude, latitude, 4, date, Tsrf, - Tatm, Ahum, Rhum, SWdn_direct, SWdn_diffuse, SWup, Trad, H, LE, day_1850); + check_n_time_intervals(smeteo, albedo, longitude, latitude, timezone, 4, date, + Tsrf, Tatm, Ahum, Rhum, SWdn_direct, SWdn_diffuse, SWup, Trad, H, LE, + day_1850); } /*******************************************************************************