Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

With following code I am trying to show the mean wind speed patterns for a few geographic locations.

cords = Select[ 
           Reverse[CityData[#, "Coordinates"]] & /@ {"Oslo", "Vadso","Hammerfest"}, 
           Head@# == List &
        ]; 
ListContourPlot[
  Join @@ {#,List@WeatherData[#,
                              "MeanWindSpeed", 
                              {{2013, 1, 25}, {2013, 5, 1}, "Day"}
                  ][[1,2]]} & /@ cords
]

How can I improve the code to solve following problems:

  1. Even if the requested date window is wider (a few days), it only takes one day data from WeatherData and when I am changing the partitioning part to [[All,2]] the plot doesn't work and says the format it wrong.

  2. For even wider data range (a few years), there are some missing data for some days. How can I also filter that bad data in the code?

Remember, I need them exactly on the geographic location no matter how wide my data range is.

share|improve this question
1  
This kind of questions don't show a real interest in learning the language. You're throwing in a whole problem's coding and asking for a solution. Perhaps you should break it up in pieces, and ask about your doubts. Neither of your questions are related to a Plotting problem. –  belisarius Jun 1 '13 at 21:57
1  
1) Your [[1,2]] takes the first windspeed from every location. So, it doesn't help to increase the data range. 2. [[All,2]] results in passing a list of windspeeds for every location to ListContourPlot. However, ListContourPlot expects a single dependent value for each point not a list. How would you interpret that? You need to apply Mean on that list to get a single, average value. 3) You can delete Missing[...] data points using DeleteCases. –  Sjoerd C. de Vries Jun 1 '13 at 22:26
    
@belisarius with many thanks for your previous hint; but frankly I am struggling with this language for around two days. I have to admit that it was very constructive hint of you and made me to look a the Join and List functionality thoroughly.I advanced the code considerably and knew the`ListContourPlot` better now but those problems are really hindering me of any progress. –  Alex Jun 1 '13 at 22:32
1  
Using the Mean is making use of all recorded data. I'm afraid you are being rather unclear here. What do you want ListContourPlot to show on each location based on that set of windspeeds? You need a single color there. So, what should that depict? –  Sjoerd C. de Vries Jun 1 '13 at 22:45
1  
That's because you used Reverse to get your coordinates. That's OK for plotting, but not for getting information from WeatherData, which expects latlong, not longlat. –  Sjoerd C. de Vries Jun 1 '13 at 23:53
show 5 more comments

1 Answer

up vote 2 down vote accepted
  1. Your [[1,2]] takes the first windspeed from every location. So, it doesn't help to increase the data range.
  2. [[All,2]] results in passing a list of windspeeds for every location to ListContourPlot. However, ListContourPlot expects a single dependent value for each point not a list. How would you interpret that? You need to apply Mean on that list to get a single, average value.
  3. You can delete Missing[...] data points using DeleteCases.

Something like the following should work:

ListContourPlot[
 Append[#,
    Mean[
     DeleteCases[
      WeatherData[
        #,
        "MeanWindSpeed",
        {{2013, 1, 25}, {2013, 5, 1}, "Day"}
        ][[All, 2]],
      Missing["NotAvailable"]
      ]
     ]
    ] & /@ cords
 ]

enter image description here

If I were you, I'd increase the number of locations in the plot. As it is, it looks rather boring.

share|improve this answer
    
manay thanks for advices but I don't want to make mean. It is very easy to make mean of those data.But I need the ListContourPlot to make the plot based on the all recorded data?I need the intensity of colors based on the analysis of previous data. Is it possible? –  Alex Jun 1 '13 at 22:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.