BACKGROUND
Per the Coastal Information Data Program (CDIP), they are generating a spectral heat/intensity map for wave swell at http://cdip.ucsd.edu
Chip, I know, not using Ruby, but assuming that Belisarius's point calculation is fine, I'd use Mathematica's ListContourPlot instead, as it is much simpler to understand and it gives a cleaner picture.
(* Read in data, the web address can be specified *)
a = Import[<url of cpid data>, "Table"];
Import
leaves in a pre
tag in the first sublist and as a single element sublist at the end, this removes it
dat = a[[ ;; -2]][[All, -72;; ]];
by first taking all but the last element, and then taking the last 72 elements of each remaining sublists.
ListContourPlot
expects a list of points of the form {{x, y, f}, ...}
, so we need to transform dat
into that form, as explained elsewhere:
pts =Flatten[
Table[ {
(rr =Log[.025 + (.58 - .25)/64 r]) Cos@(tt = t 5 Degree), (* x-coord *)
rr Sin@tt, (* y-coord *)
dat[[r,t]] (* function value *)
},
{r, 7, 64}, {t, 1, 72}
],
1 ]
and then plot them
ListContourPlot[pts,
ColorFunctionScaling -> False,
ColorFunction -> (ColorData["CMYKColors"][(# - .000007)/(.0003 - 0.000007)]&)
]
This gives:
which can be touched up by fixing the clipping and the ColorFunction
scaling. Also, with some work radial contours could be added.
I am really in a rush, so can't finish right now, but as nobody answered yet, here is a first approach:
Code in Mathematica (sorry, as I said no time right now):
a = Import["http://cdip.ucsd.edu/data_access/MEM_2dspectra.cdip?100",
"Table"];
Graphics@Flatten[Table[
(*colors, dont mind*)
{ColorData["CMYKColors"][(a[[r, t]] - .000007)/(.0003 - 0.000007)],
(*point size, dont mind*)
PointSize[1/Sqrt[r]/10],
(*Coordinates for your points "a" is your data matrix *)
Point[
{(rr =Log[.025 + (.58 - .25)/64 r]) Cos@(tt = t 5 Degree),
rr Sin@tt}]
}
(*values for the iteration*)
, {r, 7, 64}, {t, 1, 72}], 1]
(*Rotation, dont mind*)
/. gg : Graphics[___] :> Rotate[gg, Pi/2]
I still can't get the right color scale: