4

I have an entry in a CSV file like this (piece of data):

"","x","y","sim1","sim2","sim3","sim4","sim5","sim6","sim7","sim8","sim9","sim10","sim11","sim12"
"1",181180,333740,5.56588745117188,6.29487752914429,7.4835410118103,5.75873327255249,6.62183284759521,5.81478500366211,4.85671949386597,5.90418815612793,6.32611751556396,6.99649047851562,6.52076387405396,5.68944215774536
"2",181140,333700,6.36264753341675,6.5217604637146,6.16843748092651,5.55328798294067,7.00429201126099,6.43625402450562,6.17744159698486,6.72836923599243,6.38574266433716,6.81451606750488,6.68060827255249,6.14339065551758
"3",181180,333700,6.16541910171509,6.44704437255859,7.51744651794434,5.46270132064819,6.8890323638916,6.46842670440674,6.07698059082031,6.2140531539917,6.43774271011353,6.21923875808716,6.43355655670166,5.90692138671875

The x and y represents the longitude and latitude for each point in a simulation. I have to store this in an array. I thought to find the min and max for each x and y and them create a matrix with this dimension and after this do some scale to discover what value should be at the (0,0) (0,1) (0,2) and so on in my matrix.

In D3, there is a function that do all of this:

scaleX = d3.scale.linear().domain([d3.min(simulationDataset, function(d) {return d.x;}), d3.max(simulationDataset, function(d) { return d.x; })]);
scaleY = d3.scale.linear().domain([d3.min(simulationDataset, function(d) {return d.y;}), d3.max(simulationDataset, function(d) { return d.y; })]);

There is something similar in Python or I should all of this from zero?

Thanks in advance.

pceccon
  • 9,379
  • 26
  • 82
  • 158
  • 2
    Just as a side note -- instead of using both `d3.min` and `d3.max`, you can simply use `d3.extent`. – Lars Kotthoff Oct 03 '13 at 20:10
  • 1
    Oh and [this question](http://stackoverflow.com/questions/1969240/mapping-a-range-of-values-to-another) should be helpful. – Lars Kotthoff Oct 03 '13 at 20:11
  • Hi, @LarsKotthoff. Thanks for the tip in d3. This question that you mentioned is how I'm doing until now. I was wondering if there where a short way, i.e, a short command, to do this, like in d3. (: – pceccon Oct 05 '13 at 01:19

2 Answers2

1

The Spectra library seems to do what you are looking for. Specifically, the spectra.scale.

Matt
  • 4,029
  • 3
  • 20
  • 37
-3

You probably want to use numpy for this sort of thing in Python.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • 3
    Yes, @DanielRoseman, I know that the solution probably involves Numpy, but I don't have any idea about how I could achieve what I want. – pceccon Oct 03 '13 at 19:50