I am trying to calculate heating degree days and cooling degree days and output that information to a table. I am using mathematica's curated data to do this. In text this is what I would like to do. Use a city name to collect weather data (the mean temp for every day of a certain year), then calculate the HDD and CDD and to create a cumulative value of hdd and cdd for the entire year. I want to use the city name to collect a value for country name, country gdp, and city population. I have used a demonstration project to try and figure this out but I am stuck at this point. I have the following already worked out.
Module[
{dateRange, mean, cdd, hdd, station, country, location, population,
GDPPerCapita,
reference = (65 - 32)/1.8, cumList},
station = "Chicago";
country = CityData[station, "Country"];
population = CityData[station, "Population"];
location = CityData[station, "Coordinates"];
GDPPerCapita = CountryData[country, "GDPPerCapita"];
dateRange = {{2011, 1, 1}, {2011, 12, 31}, "Day"};
mean = WeatherData[station, "MeanTemperature", dateRange];
cdd = Join[Transpose[{mean[[All, 1]]}],
Transpose[{Max[# - reference, 0] & /@ mean[[All, 2]]}], 2];
hdd = Join[Transpose[{mean[[All, 1]]}],
Transpose[{Max[reference - #, 0] & /@ mean[[All, 2]]}], 2];
cumList = Transpose[{Join[
Transpose[{cdd[[All, 1]]}],
Transpose[{Drop[FoldList[Plus, 0, cdd[[All, 2]] + hdd[[All, 2]]],
1]}],
2]}];
Grid[station, country, location, population, GDPPerCapita,
Last[cumList]]]
In this particular example I used a set city name ie station = "Chicago". When I do this it returns the correct result for that specific city, in a grid in this case..
Grid["Chicago", "UnitedStates", {41.8376, -87.6818}, 2695598,
45230.2, {{{2011, 12, 31}, 3935.4}}]
I want the variables to be chosen from a list of cities....
cityLIST = CityData[#, "Name"] & /@ CityData[];
So basically I want to run this or something like it for every string in a list, and output the results to a table. I am new to mathematica, this is the first thing I have ever tried. If anyone has a minute to help me out with this I would really appreciate it.
Thanks