Posted By

brn-cntrl on 05/30/15


Tagged

data visualization scientific


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jbyerson


ionosphere map


 / Published in: Processing
 

This is a preliminary visualization done in Processing to test the process of parsing and visualizing data from .ionex files available through NASA's Reverb | Echo portal.

  1. //Ionosphere Visualization Comparisons
  2. //Brian Cantrell
  3. //Project completed as part of Data Visualization course at
  4. //USC School of Cinematic Arts with Evan Hughes
  5.  
  6. float w;
  7. float lat;
  8. String [] latStrings;
  9. String [] valStrings;
  10. int [] theVals;
  11. PImage map;
  12. PImage heatmap;
  13. color c;
  14. int count;
  15. int curVals;
  16.  
  17. // -- Setup --//
  18.  
  19. void setup() {
  20.  
  21. latStrings = loadStrings("ionLats.txt");
  22. valStrings = loadStrings("ionValsFull2.txt");
  23. map = loadImage("images/map.png");
  24. heatmap = loadImage("images/heatmapColors.png");
  25. size(1080, 544, P3D);
  26. smooth();
  27. curVals = 0;
  28. }
  29.  
  30. // -- Main Loop -- //
  31.  
  32. void draw() {
  33.  
  34. noStroke();
  35. //only animate until end of file
  36. //Loop through the lattitude values
  37. if (count == 5) {
  38. count = 0;
  39. }
  40. if (count == 0) {
  41. background(255);
  42. if (curVals >= valStrings.length) {
  43. curVals = 0;
  44. }
  45. for (int i = 0; i < latStrings.length; i++) {
  46.  
  47. lat = map(float(latStrings[i]), 90., -90., 0., float(height));
  48. theVals = parseVals(valStrings[i+curVals]);
  49. //For every lattitude value grab its array of sensor readings
  50. for (int j = 0; j < theVals.length; j++) {
  51. //map the color of each "pixel" to the value of the sensor reading
  52. c = heatmap.get(int(map(theVals[j], 0, 1000, 0, 428)), 0);
  53. fill(c);
  54. w = width/theVals.length;
  55. //fill a row of "pixels"
  56. rect(j*w, lat-5, theVals.length, 10);
  57. }
  58. }
  59. curVals+=71;
  60. image(map, 0, 0);
  61. tint(255, 50);
  62. //uncomment to save images for animation
  63. //saveFrame("map-####.jpg");
  64. }
  65. count++;
  66. }
  67.  
  68. // -- Function for returning integer array for TEC values --//
  69.  
  70. int [] parseVals(String s) {
  71. //Grab string from file
  72. String theString = s;
  73. // strip string of brackets, quotations, and spaces
  74. String stripped = theString.replace("[", "").replace("]", "").replace("\"", "").replace("“", "").replace(" ", "");
  75. // split string on commas and cast as int
  76. int [] parsed = int(stripped.split(","));
  77. return parsed;
  78. }

Report this snippet  

You need to login to post a comment.