static void GetVariousDataFromApi() { var st = new[] { 50300, 50310 }; var ds = new MetDataService(); var types = ds.getTimeserieTypesProperties("", ""); var timeseriesTypeObs = "T_ELEM_OBS"; var timeseriesTypeObsId = "2"; var stations = ds .getStationsFromTimeserieType("2", "") .Where(s => st.Any(x => x == s.stnr)) .OrderBy(x => x.name) .ToArray(); foreach (var s in stations) { Console.WriteLine($"{s.name} {s.fromYear}-{s.toYear} {s.stnr}"); } Console.WriteLine(); var parameters = ds .getElementsFromTimeserieType(timeseriesTypeObsId) .Where(x => x.description.ToLower().Contains("snø")) //snow .ToArray(); foreach (var p in parameters) { Console.WriteLine($"{p.name} {p.elemNo}"); } Console.ReadLine(); }
static no_met_metdata_Metdata GetSnowDepths(int startYear, int endYear) { //http://eklima.met.no/met/MetService?invoke=getMetData×erietypeID=2&format=&from=1950-01-01&to=2017-01-01&stations=50310&elements=SA&hours=0%2C1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9&months=0%2C1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%2C10%2C11&username= var snowDepthParameter = "SA"; var stations = new[] { 50300, 50310 }; //var timeseriesTypeObs = "T_ELEM_OBS"; //var timeseriesTypeObsId = "2"; var timeseriesTypeObs = "T_DIURNAL"; var timeseriesTypeObsId = "0"; var hours = Enumerable.Range(0, 23); var months = new[] { 10, 11, 12, 1, 2, 3, 4, 5 }; var from = startYear + "-01-01"; var to = endYear + "-31-12"; var ds = new MetDataService(); var result = ds.getMetData( timeseriesTypeObsId, "yyyy-MM-dd", from, to, string.Join(",", stations), snowDepthParameter.ToString(), string.Join(",", hours), string.Join(",", months), ""); return(result); }
public Station[] GetStationsByElement(string element, string timeseriesType = defaultTimeseriesType) { var ds = new MetDataService(); return(ds.getStationsFromTimeserieTypeElemCodes(timeseriesType, element, "") .Select(x => x.ToStation()) .ToArray()); }
public object GetStations(string timeseriesType = defaultTimeseriesType) { var ds = new MetDataService(); return(ds.getStationsFromTimeserieType(timeseriesType, "") .Select(x => x.ToStation()) .ToArray()); }
private void LoadStations() { var service = new MetDataService(); var result = service.getStationsFromTimeserieType(TimeSeriesType.DailyValues, ""); var stations = result.Select(s => new Station(s.stnr, s.name, s.department)); FindViewById <ExpandableListView>(Resource.Id.stations) .SetAdapter(new StationAdapter(this, stations)); }
public object GetSeriesType(string lang = defaultLanguage) { var ds = new MetDataService(); return(ds.getTimeserieTypesProperties(lang, "").Select(x => new { x.serieTypeID, x.serieTypeName, x.serieTypeDescription }).ToArray()); }
public object GetElements(string timeseriesType = defaultTimeseriesType) { var ds = new MetDataService(); return(ds.getElementsFromTimeserieType(defaultTimeseriesType).Select(x => new { x.elemCode, x.elemGroup, x.elemNo, x.unit, x.description })); }
public object[] GetQualityFlat(string lang = defaultLanguage) { var ds = new MetDataService(); return(ds.getFlagProperties(lang, "") .Select(x => new { x.flagCode, x.flagDescription, x.flagName, flagId = x.flagID }) .ToArray()); }
private StationEntry[] GetLatesDailyObsInner(string element = defaultElement, int limit = 10000) { var timeseriesTypeDailyId = "0"; var ds = new MetDataService(); var st = GetStationsByElement(element, timeseriesTypeDailyId) .Where(x => x.to == null) .ToArray(); var stIdx = st.ToDictionary(x => x.stationId, x => x); var stations = string.Join(",", st.Select(x => x.stationId).ToArray()); var result = ds.getMetData( timeseriesTypeDailyId, "yyyy-MM-dd", DateTime.UtcNow.AddDays(-1).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), stations, element, string.Join(",", hours), allMonths, userName); //flatten var entries = result.timeStamp.SelectMany(timestamp => timestamp.location.SelectMany(location => location.weatherElement.Select(weatherElement => new StationEntry { from = timestamp.from, to = timestamp.to.Year == 1 ? default(DateTime?) : timestamp.to, stationId = location.id, elementId = weatherElement.id, elementValue = weatherElement.value, elementQuality = weatherElement.quality, stationName = stIdx.ContainsKey(location.id) ? stIdx[location.id].name : default(string), lat = stIdx.ContainsKey(location.id) ? stIdx[location.id].lat : default(double?), lon = stIdx.ContainsKey(location.id) ? stIdx[location.id].lon : default(double?) }))) .Where(x => x.elementValue != noValue) .GroupBy(x => x.stationId) .Select(g => g.OrderByDescending(x => x.from).First()) .ToArray(); return(entries .OrderByDescending(x => x.elementValue.ToNullableDouble()) .Take(limit) .ToArray()); }
private static Entry[] GetTimeSeriesInner(DateTime from, DateTime to, string element, string stations) { var timeseriesTypeDailyId = "0"; //get result var ds = new MetDataService(); var result = ds.getMetData( timeseriesTypeDailyId, "yyyy-MM-dd", from.ToString("yyyy-MM-dd"), to.ToString("yyyy-MM-dd"), stations, element, string.Join(",", hours), //applies only to timeserietypeID=2, 8, 9, 13, 14, 15 og 16 allMonths, userName); //flatten var entries = result.timeStamp.SelectMany(timestamp => timestamp.location.SelectMany(location => location.weatherElement.Select(weatherElement => new Entry { from = timestamp.from, to = timestamp.to.Year == 1 ? default(DateTime?) : timestamp.to, stationId = location.id, elementId = weatherElement.id, elementValue = weatherElement.value, elementQuality = weatherElement.quality }))) .Where(x => x.elementValue != noValue) .ToArray(); return(entries .GroupBy(x => x.from) .Select(x => x.First()) .OrderBy(x => x.from) .ToArray()); }