Re: weather blog and ListStreamPlot sampling
- To: mathgroup at smc.vnet.net
- Subject: [mg96354] Re: weather blog and ListStreamPlot sampling
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Thu, 12 Feb 2009 06:35:56 -0500 (EST)
- References: <gmu8ll$gh8$1@smc.vnet.net>
Hi Peter, I have tried to make a temperature map of the Netherlands before. My code is below. I feel it's important to make a check of the date range of the stations, because a considerable number of stations have stopped reporting. Hence, the last reported value is not always the most current value. When you make a current temperature map it make sense to have all values measured at about the same time. I use a margin of 1.5 hours. Doing this removes most, if not all, Missing["NotAvailable"] values as well. Cheers -- Sjoerd In[1]:= stationsRaw = (WeatherData[{#, 20}] & /@ DeleteCases[ (CityData[#, "Coordinates"] & /@ CityData[{All, "Netherlands"}]), {x_, y_} /; ! NumericQ[x] && ! NumericQ[y] ] ) // Flatten // Union Out[1]= {"AP614", "AP669", "AP973", "AR303", "AR351", "AR423", \ "AS079", "AS204", "AS631", "AS943", "AS990", "AS998", "C0007", \ "C0009", "C0025", "C0275", "C0360", "C0449", "C0539", "C0937", \ "C0949", "C1160", "C1260", "C1278", "C1555", "C1652", "C1675", \ "C1880", "C1923", "C2248", "C2597", "C2651", "C2811", "C3001", \ "C3114", "C3305", "C3471", "C3753", "C3755", "C3859", "C4043", \ "C4235", "C4341", "C4417", "C4745", "C4796", "C4799", "C5002", \ "C5113", "C5263", "C5597", "C5716", "C5771", "C5799", "C5907", \ "C5923", "C5927", "C6077", "C6175", "C6238", "C6767", "C6784", \ "C6809", "C6856", "C6933", "C7002", "C7457", "C7481", "C7674", \ "C7998", "C8011", "C8014", "C8107", "C8189", "C8191", "C8250", \ "C8392", "C8400", "C8407", "C8416", "C8482", "C8526", "C8546", \ "C8794", "C8961", "C8968", "C8972", "C9059", "C9063", "C9073", \ "C9273", "C9417", "C9433", "C9484", "C9741", "C9827", "C9838", \ "D0053", "D0088", "D0182", "D0198", "D0247", "D0252", "D0402", \ "D0700", "D0727", "D0811", "D0875", "D0881", "D1461", "D1462", \ "D1466", "EBAW", "EBBE", "EBBL", "EBDT", "EBGT", "EBLB", "EBLG", \ "EBOS", "EBSP", "EBSZ", "EDDG", "EDDL", "EDLN", "EDLV", "EDLW", \ "EDWE", "EHAM", "EHBK", "EHDB", "EHDL", "EHEH", "EHGG", "EHGR", \ "EHKD", "EHLW", "EHRD", "EHSB", "EHTW", "EHVB", "EHVK", "EHVL", \ "EHWO", "ETGM", "ETHE", "ETNG", "ETNN", "WMO06207", "WMO06494", \ "WMO10004", "WMO10113", "WMO10305", "WMO10317", "WMO10501"} In[2]:= station = DeleteCases[stationsRaw, x_ /; WeatherData[x, "DateRange"] == $Failed || AbsoluteTime[TimeZone -> 0] - AbsoluteTime[WeatherData[x, "DateRange"][[2]]] > 3/2 3600] Out[2]= {"AP614", "AP669", "AP973", "AR303", "AR351", "AS204", \ "AS631", "AS998", "C0007", "C0009", "C0275", "C0360", "C0539", \ "C0949", "C1278", "C1555", "C1652", "C1675", "C1923", "C2248", \ "C2597", "C2651", "C2811", "C3001", "C3114", "C3755", "C3859", \ "C4043", "C4235", "C4341", "C4417", "C4745", "C4796", "C4799", \ "C5002", "C5113", "C5771", "C5923", "C6175", "C6767", "C6784", \ "C6809", "C7457", "C7674", "C8011", "C8014", "C8250", "C8400", \ "C8968", "C9059", "C9273", "C9417", "C9433", "C9827", "D0198", \ "D0247", "D0402", "D0700", "D0727", "D0875", "D1461", "D1462", \ "D1466", "EBAW", "EBBE", "EBBL", "EBDT", "EBLB", "EBLG", "EBOS", \ "EDDG", "EDDL", "EDLN", "EDLV", "EDLW", "EHAM", "EHBK", "EHDL", \ "EHEH", "EHGG", "EHGR", "EHKD", "EHLW", "EHRD", "EHVB", "EHVK", \ "EHVL", "EHWO", "ETNG", "ETNN", "WMO10113", "WMO10501"} In[5]:= WeatherData[#, "Temperature"] & /@ station Out[5]= {5., 3.9, 4.4, 3.9, 5.6, 4.4, 0.6, 5., 4.4, 4.4, 3.3, 5.6, \ 3.9, 6.1, 5.6, 2.8, 3.9, 4.4, 5.6, 5.6, 1.7, 5., 5., 5., 5.6, 5., \ 5.6, 2.2, 3.9, 4.4, 4.4, 4.4, 3.3, 6.1, 3.3, 3.3, 2.8, 5., 3.9, 4.4, \ 5., 5., 3.3, 3.9, 5., 2.8, 3.9, 4.4, 2.8, 2.8, 4.4, 4.4, 4.4, 5., 5., \ 3.9, 5., 4.4, 4.4, 5., 4.4, 4.4, 5., 6., 5., 5., 5., -0.9, 3., 5., \ 4.3, 5., 5., 5., 3., 4., 4., 4., 5., 3., 5., 2., 2., 5., 4., 5., 4., \ 4., 4., 4., 1.5, 3.3} tempsPos = DeleteCases[ Append[(Reverse[WeatherData[#, "Coordinates"]] & /@ station)\[Transpose], WeatherData[#, "Temperature"] & /@ station]\[Transpose], {_, _, Missing["NotAvailable"]}]; Show[ { ListContourPlot[tempsPos, ColorFunctionScaling -> False, ColorFunction -> Function[{f}, ColorData["ThermometerColors"][Rescale[f, {-10, 10}, {0, 1}]]], Frame -> False, ContourLabels -> (Text[#3, {#1, #2}] &), InterpolationOrder -> 3], Graphics[{FaceForm[], CountryData["Netherlands", {"Shape", "Equirectangular"}][[1]], Point[Reverse[WeatherData[#, "Coordinates"]] & /@ station]}] }, PlotRange -> All, ImageSize -> 600 ] On Feb 11, 12:18 pm, P_ter <petervansumme... at gmail.com> wrote: > Hello Sjoerd, > I am also very much interested in the blog about weatherdata, especially = for the Netherlands. > I used FullPolygon because the Polygon missed to much: > netherlands = ((CountryData[#, {"FullPolygon", "Mercator"}] & /@ {"= Netherlands"}) /. Polygon -> Line); > The Dutch cities are not all tabled with their coordinates: > nedsteden = CityData[{All, "Netherlands"}]; > nedstedencoords = {#, CityData[#, "Coordinates"]} & /@ nedsteden ; > rr = DeleteCases[nedstedencoords, {{_, _, _}, {_Missing, _Missing}}] ; > With the cities which do have coordinates, I want to know where the weath= er stations are within shortest reach of the Dutch cities. Some of them are= in Belgium, Germany. > dutchstations = WeatherData[#] & /@ rr[[All, 2]]; > Not all the weather stations do have a temperature record: > data = {#, WeatherData[#, "Temperature"]} & /@ dutchstations; > data1 = DeleteCases[data, {_, _Missing}]; > data2 = {WeatherData[#[[1]], "Coordinates"], #[[2]]} & /@ data1; > ( I splitted in smallest steps) > The weatherstations with available temperature and coordinates are now fo= r use: > Graphics[{Gray, CountryData["Netherlands", "FullPolygon"], {PointSize[Lar= ge], Hue[WeatherData[#, "Temperature"]/30],Tooltip[Point[Reverse[WeatherDat= a[#, "Coordinates"]]], WeatherData[#]]} & /@ ds}] > > To make your first point: yes, the weatherstations are not uniformly spre= ad. How to make a nice plot of the temperature, which we can see every day = on the Royal Dutch Meteorological Institute? It is certainly not that simpl= e for a small country. > with friendly greetings, > P_ter