star-meteo

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

commit c50e00a8fc570651dcc4b6c77332d1e29e5ffa1d
parent 7a9edf7ae51d128c65e0cbc73471224d08fc17e1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 27 Oct 2025 11:25:01 +0100

Remove the time zone from the Star-Meteo file format

The dates indicated in a Star-Meteo file are expressed in UTC +00:00,
not in local time. The time zone is therefore unnecessary since no
conversion is required between the Star-Meteo date and the
Star-CElestialMechanics date, both of which are expressed in UTC +00:00.

Diffstat:
MMakefile | 1-
Mdoc/smeteo.5 | 6++----
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-
Dsamples/missing_timezone.txt | 8--------
Msamples/star-meteo_input.txt | 2--
Msamples/variable_time_period.txt | 1-
Msrc/smeteo.c | 3---
Msrc/smeteo.h | 3+--
Msrc/smeteo_c.h | 1-
Msrc/smeteo_load.c | 47+++++------------------------------------------
Msrc/stardis_smeteo.c | 13++++---------
Msrc/stardis_smeteo_library.c | 40+---------------------------------------
Msrc/test_smeteo_load.c | 14++++----------
39 files changed, 17 insertions(+), 149 deletions(-)

diff --git a/Makefile b/Makefile @@ -226,7 +226,6 @@ 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 @@ -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 October 8, 2025 +.Dd October 27, 2025 .Dt SMETEO 5 .Os .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -35,6 +35,7 @@ data averaged over a time interval. For the same file, the duration of the intervals is constant. The date indicated for each interval corresponds to the middle of the time interval. +Date are given in Coordinated Universal Time, i.e. UTC +00:00. The lines must be sorted in ascending chronological order. .Pp Empty lines are ignored, as are comments, which are strings beginning @@ -60,7 +61,6 @@ 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,8 +68,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ -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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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,7 +1,6 @@ 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 @@ -1,8 +0,0 @@ -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,8 +4,6 @@ 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,7 +1,6 @@ 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,7 +34,6 @@ 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); } @@ -64,7 +63,6 @@ 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: @@ -97,7 +95,6 @@ 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 @@ -50,7 +50,7 @@ struct smeteo_entry { double H; /* Convection coefficient [W/K/m^2] */ double LE; /* Latent flux >0 from ground to atmosphere [W/m^2] */ - /* Time as a fraction of a day since 00:00 on 1 january 1859 */ + /* Time as a fraction of a day since 00:00 on 1 january 1850, UTC +00:00 */ double day_1850; }; #define SMETEO_ENTRY_NULL__ {0} @@ -58,7 +58,6 @@ 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,7 +39,6 @@ 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,42 +259,6 @@ 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; @@ -310,8 +274,6 @@ 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 @@ -436,10 +398,11 @@ load_stream(struct smeteo* smeteo, FILE* fp, const char* name) if(i == 0) { /* Calculate the reference of the interval duration. * - * The dates of the intervals are relative to midnight on January 1, 1850. - * In addition, their time is defined at the center of the interval. Thus, - * for the first interval, calculate its duration by multiplying its date - * relative to January 1, 1850 by 2. This will be the reference duration*/ + * The dates of the intervals are relative to midnight on January 1, 1850 + * UTC +00:00. In addition, their time is defined at the center of the + * interval. Thus, for the first interval, calculate its duration by + * multiplying its date relative to January 1, 1850 by 2. This will be the + * reference duration*/ duration_ref = darray_entry_cdata_get(&smeteo->entries)[i].day_1850 * 2; } else { diff --git a/src/stardis_smeteo.c b/src/stardis_smeteo.c @@ -13,7 +13,7 @@ * 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 _POSIX_C_SOURCE 199606L /* localtime_r support */ +#define _POSIX_C_SOURCE 200112L /* localtime_r & getopt support */ #include "smeteo.h" #include "stardis_smeteo.h" @@ -200,7 +200,7 @@ spherical_to_cartesian_dir static void compute_sun_position (const struct boundary_condition* bcond, - const double time, /* [s] */ + const double time, /* UTC +00:00 [s] */ struct scem_sun_pos* sun) { /* Star-CElestial-Mechanics */ @@ -214,13 +214,8 @@ compute_sun_position ASSERT(bcond && sun); /* The limit condition stores the number of seconds elapsed since the epoch - * until January 1, 1850, local time. In other words, since the epoch is - * expressed in UTC+00:00, it defines an offset in seconds between local - * time and UTC+00:00 time coordinates. Thus, add this offset to the - * number of seconds elapsed since January 1, 1850, local time, to convert - * this number of seconds to UTC+00:00. */ - time_since_jan_1_1850_utc0 = /* [s] */ - (time_t)((double)bcond->lib_desc.jan_1_1850 + time); + * until January 1, 1850, UTC +00:00 */ + time_since_jan_1_1850_utc0 = (time_t)time; /* [s] */ /* Convert time in number of seconds into a broken-down time as expected by * the Star-CElestial-Mechanics library */ diff --git a/src/stardis_smeteo_library.c b/src/stardis_smeteo_library.c @@ -13,7 +13,7 @@ * 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 */ +#define _POSIX_C_SOURCE 200112L /* getopt support */ #include "smeteo.h" #include "stardis_smeteo.h" @@ -37,14 +37,6 @@ struct stardis_smeteo_lib { /* Algorithm for computing the solar position */ enum scem_sun_algo algo; - /* 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; }; @@ -115,33 +107,6 @@ 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, @@ -167,8 +132,6 @@ setup_smeteo /* Load meteorological data */ 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; lib->algo = args->algo; /* Retrieve the maximum convection coefficient from meteorological data */ @@ -282,6 +245,5 @@ stardis_smeteo_lib_get_desc desc->Tsrf_range[1] = lib->Tsrf_range[1]; desc->Trad_range[0] = lib->Trad_range[0]; desc->Trad_range[1] = lib->Trad_range[1]; - desc->jan_1_1850 = lib->jan_1_1850; desc->algo = lib->algo; } diff --git a/src/test_smeteo_load.c b/src/test_smeteo_load.c @@ -33,7 +33,6 @@ check_api(struct smeteo* smeteo) const double albedo = 0.314; 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); @@ -58,7 +57,6 @@ 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); @@ -87,7 +85,6 @@ 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] */ @@ -113,7 +110,6 @@ 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) { @@ -178,7 +174,6 @@ 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"; @@ -194,9 +189,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, timezone, 1, - &date, &Tsrf, &Tatm, &Ahum, &Rhum, &SWdn_direct, &SWdn_diffuse, &SWup, - &Trad, &H, &LE, &day_1850); + check_n_time_intervals(smeteo, albedo, longitude, latitude, 1, &date, &Tsrf, + &Tatm, &Ahum, &Rhum, &SWdn_direct, &SWdn_diffuse, &SWup, &Trad, &H, &LE, + &day_1850); } static void @@ -206,7 +201,6 @@ 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[] = { @@ -225,7 +219,7 @@ 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, timezone, 4, date, + check_n_time_intervals(smeteo, albedo, longitude, latitude, 4, date, Tsrf, Tatm, Ahum, Rhum, SWdn_direct, SWdn_diffuse, SWup, Trad, H, LE, day_1850); }