Creating Spectral Heat maps or Intensity maps from CDIP data using Ruby

前端 未结 2 1272
自闭症患者
自闭症患者 2021-01-03 11:50

BACKGROUND

Per the Coastal Information Data Program (CDIP), they are generating a spectral heat/intensity map for wave swell at http://cdip.ucsd.edu

2条回答
  •  梦谈多话
    2021-01-03 12:41

    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[, "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:

    ListContourPlot of cpid data supplied by OP

    which can be touched up by fixing the clipping and the ColorFunction scaling. Also, with some work radial contours could be added.

提交回复
热议问题