Message Boards Message Boards

0
|
9525 Views
|
8 Replies
|
1 Total Likes
View groups...
Share
Share this post:

WeatherData

Posted 10 years ago

I have already generate a list of dates and mean temperatures with WeatherData. It is a list of roughly 17000 pairs . Each pair is as follow : {{year,month,day},T°}. As an example:{1946, 11, 13}, 17.78} How I can obtain maximum and minimum temperature from this list . Thanks for advice.

POSTED BY: Daniel Cross
8 Replies
Posted 10 years ago

David, Thanks for your advice. I have being trying with cases and patterns ; however I did not succeed. Seeing your example tell me that patterns should be assembled carefully. Now again in the road!

POSTED BY: Daniel Cross

Let's call the data list in your notebook weatherData.

Then you can use Cases (an alternative is Select, but Cases is more natural here) to pull out the data in your list that corresponds to the pattern with a June date (advice--time to start learning about patterns: go here and start with the tutorial links at the bottom; this is also in Mathematica itself in the Documentation Ceneter and it's better to learn it there as all the notebooks are Live-- http://reference.wolfram.com/language/ref/Pattern.html ).

juneWeatherData = Cases[weatherData, {{_, 6, _}, _}];

then you can use the earlier approach to pull out just the temperatures from this:

juneTemperatures=juneWeatherData[[All, 2]];

and then compute the mean using:

 Mean[juneTemperatures]

Which, for the data in your notebook gives 10.296

POSTED BY: David Reiss

Hi Daniel,

Could you post a notebook with a subset of your data (say, 6 months) and I will take a look at it in the next day or two and show you how to do what you are asking...? (Use the "Attachments: add a file to this post" button to upload the notebook

Best, David

POSTED BY: David Reiss
Posted 10 years ago

David, Notebook attached. Thanks!

Attachments:
POSTED BY: Daniel Cross

Tale a look at how I used the Max function above. Note that I am selecting out the temperatures from the top level data structure rather than acting on the full data. Using Max on all the data will return 2015 because that is the largest number in the full top level data structure.

POSTED BY: David Reiss
Posted 10 years ago

David , works perfect! Thanks! The other problem is that since is a list with dates and real numbers (date in Date format) I not know how I can sort certain dates.For example within that list only looks for mean T in June. How I can Select dates with June within this large list and geenrate a new list only with June data over the timespan considered. I am just learning!!

POSTED BY: Daniel Cross
Posted 10 years ago

David, Thanks for your replay . I just have Mathematica 9, and I have try Max function but it just output 2015, that is maximum value of the list of course.

POSTED BY: Daniel Cross

If your data is in a parameter called weatherData then the largest temperature value will be

Max[weatherData[[All,2]]]

If you have Mathematica version 10.1 you can also use TakeLargestBy to get the largest value for temperature along with the associated date.

TakeLargestBy[weatherData,Last,1]

That 1 in the expression tells TakeLargestBy to only give you the largest value. If you want more of them then change it to another integer.

Of course if your list has more than one date with the same largest value then you will only get one of the values.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract