forked from AlienDwarf/open-meteo-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from colinnuk/model_update_timestamps
Add method to get weather forecast model update timestamps from OpenMeteo
- Loading branch information
Showing
9 changed files
with
194 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace OpenMeteo; | ||
|
||
public record MetadataApiModel | ||
{ | ||
public long data_end_time { get; init; } | ||
public long last_run_availability_time { get; init; } | ||
public long last_run_initialisation_time { get; init; } | ||
public long last_run_modification_time { get; init; } | ||
public int temporal_resolution_seconds { get; init; } | ||
public int update_interval_seconds { get; init; } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace OpenMeteo; | ||
public record MetadataModel( | ||
DateTime DataEndTime, | ||
DateTime LastRunAvailabilityTime, | ||
DateTime LastRunInitialisationTime, | ||
DateTime LastRunModificationTime, | ||
int TemporalResolutionSeconds, | ||
int UpdateIntervalSeconds | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace OpenMeteo; | ||
internal static class MetadataNameHelper | ||
{ | ||
public static string GetPrefixForWeatherModel(WeatherModelOptionsParameter weatherModel) => weatherModel switch | ||
{ | ||
WeatherModelOptionsParameter.ecmwf_ifs025 => "ecmwf_ifs025", | ||
WeatherModelOptionsParameter.ecmwf_aifs025 => "ecmwf_aifs025", | ||
WeatherModelOptionsParameter.icon_global => "dwd_icon", | ||
WeatherModelOptionsParameter.icon_eu => "dwd_icon_eu", | ||
WeatherModelOptionsParameter.icon_d2 => "dwd_icon_d2", | ||
WeatherModelOptionsParameter.meteofrance_arpege_world => "meteofrance_arpege_world025", | ||
WeatherModelOptionsParameter.meteofrance_arpege_europe => "meteofrance_arpege_europe", | ||
WeatherModelOptionsParameter.meteofrance_arome_france => "meteofrance_arome_france0025", | ||
WeatherModelOptionsParameter.ukmo_uk_deterministic_2km => "ukmo_uk_deterministic_2km", | ||
WeatherModelOptionsParameter.ukmo_global_deterministic_10km => "ukmo_global_deterministic_10km", | ||
WeatherModelOptionsParameter.gfs_global => "ncep_gfs013", | ||
WeatherModelOptionsParameter.gfs_graphcast025 => "ncep_gfs_graphcast025", | ||
WeatherModelOptionsParameter.gfs_hrrr => "ncep_hrrr_conus", | ||
WeatherModelOptionsParameter.gem_global => "cmc_gem_gdps", | ||
WeatherModelOptionsParameter.gem_hrdps_continental => "cmc_gem_hrdps", | ||
WeatherModelOptionsParameter.gem_regional => "cmc_gem_rdps", | ||
WeatherModelOptionsParameter.jma_gsm => "jma_gsm", | ||
_ => throw new ArgumentOutOfRangeException(nameof(weatherModel), weatherModel, null) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenMeteo; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenMeteoTests; | ||
|
||
[TestClass] | ||
public class MetadataTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow(WeatherModelOptionsParameter.ecmwf_ifs025)] | ||
[DataRow(WeatherModelOptionsParameter.ecmwf_aifs025)] | ||
[DataRow(WeatherModelOptionsParameter.icon_global)] | ||
[DataRow(WeatherModelOptionsParameter.icon_eu)] | ||
[DataRow(WeatherModelOptionsParameter.icon_d2)] | ||
[DataRow(WeatherModelOptionsParameter.meteofrance_arpege_world)] | ||
[DataRow(WeatherModelOptionsParameter.meteofrance_arpege_europe)] | ||
[DataRow(WeatherModelOptionsParameter.meteofrance_arome_france)] | ||
[DataRow(WeatherModelOptionsParameter.ukmo_uk_deterministic_2km)] | ||
[DataRow(WeatherModelOptionsParameter.ukmo_global_deterministic_10km)] | ||
[DataRow(WeatherModelOptionsParameter.gfs_global)] | ||
[DataRow(WeatherModelOptionsParameter.gfs_graphcast025)] | ||
[DataRow(WeatherModelOptionsParameter.gfs_hrrr)] | ||
[DataRow(WeatherModelOptionsParameter.gem_global)] | ||
[DataRow(WeatherModelOptionsParameter.gem_hrdps_continental)] | ||
[DataRow(WeatherModelOptionsParameter.gem_regional)] | ||
[DataRow(WeatherModelOptionsParameter.jma_gsm)] | ||
public async Task Metadata_Async_Test(WeatherModelOptionsParameter model) | ||
{ | ||
var historicalDateTime = DateTime.UtcNow.AddDays(-2); | ||
OpenMeteoClient client = new(); | ||
var res = await client.QueryWeatherForecastMetadata(model); | ||
|
||
Assert.IsNotNull(res); | ||
Assert.IsTrue(res.DataEndTime > historicalDateTime); | ||
Assert.IsTrue(res.LastRunInitialisationTime > historicalDateTime); | ||
Assert.IsTrue(res.LastRunAvailabilityTime > historicalDateTime); | ||
Assert.IsTrue(res.LastRunModificationTime > historicalDateTime); | ||
Assert.IsTrue(res.UpdateIntervalSeconds > 0); | ||
Assert.IsTrue(res.TemporalResolutionSeconds > 0); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters