Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.35 KB | None | 0 0
  1. FUNCTION ksp_915_winds_read_in, file, Header = hdr
  2.  
  3. compile_opt idl2
  4.  
  5. ;Error Catcher:
  6. CATCH, theError
  7. IF theError NE 0 THEN BEGIN
  8. CATCH, /cancel
  9. HELP, /LAST_MESSAGE, OUTPUT=errMsg
  10. FOR i=0, N_ELEMENTS(errMsg)-1 DO print, errMsg[i]
  11. RETURN, -1
  12. ENDIF
  13.  
  14. ;Define The File:
  15. ;file = '/nas/rhome/kpenning/owles/figures/k12_data_and_figures/915/data/u_wind.txt'
  16. ;file = '/nas/rhome/kpenning/owles/figures/k12_data_and_figures/915/data/v_wind.txt'
  17. file = '/nas/rhome/kpenning/owles/figures/k12_data_and_figures/915/data/w_wind.txt'
  18.  
  19. ;Check The Parameters:
  20. IF N_ELEMENTS(file) EQ 0 THEN file = DIALOG_PICKFILE(/MUST_EXIST, /READ)
  21.  
  22. ;Make Sure The File Exists:
  23. IF file EQ '' THEN MESSAGE, 'No file provided'
  24.  
  25. ;Open The File:
  26. OPENR, lun, file, /GET_LUN
  27.  
  28. ;Tells How Many Lines Are In The File:
  29. num_lines = FILE_LINES(file)
  30.  
  31. ;Define A Variable To Hold The File Information:
  32. data_arr = STRARR(num_lines)
  33.  
  34. ;Read In The File:
  35. READF, lun, data_arr
  36.  
  37. ;Close The File:
  38. FREE_LUN, lun
  39.  
  40. ;Skip The Unnecessary Lines In The Data File:
  41. skip_lines = 88
  42. skip_header = DINDGEN(num_lines/skip_lines)*skip_lines
  43. skip_moments_names = DINDGEN(num_lines/skip_lines)*skip_lines+1.
  44.  
  45. ;Defining The Number Of Elements Skipped In The File:
  46. skip_head = N_ELEMENTS(skip_header)
  47. skip_moment = N_ELEMENTS(skip_moments_names)
  48.  
  49. ;Condensing The Data To Get Rid Of The Skipped Lines:
  50. all_data = num_lines-(skip_head+skip_moment)
  51.  
  52. ;Putting The Remaining Data Into An Array:
  53. condensed_data = STRARR(all_data)
  54.  
  55. ;Defining The Array For The Time Of The 915 Scan:
  56. date_time = data_arr[skip_header]
  57.  
  58. ;Setting The Logical Operator To Be True or False For Skipping Lines:
  59. skipper = 0
  60.  
  61. ;Setting The Index For The New Array:
  62. k = 0
  63.  
  64. ;Moving The Data To The New Array:
  65. FOR i=0, num_lines-1 DO BEGIN
  66.  
  67. ;Skipping Over The Lines With Headers Or Extra Data:
  68. FOR j=0, skip_head-1 DO BEGIN
  69. IF i EQ skip_header[j] THEN skipper=1
  70. IF i EQ skip_moments_names[j] THEN skipper=1
  71. ;Make Sure To Change The Number Of Lines To Match The Number Of Lines In The File:
  72. ; IF i EQ 7128 THEN skipper=1
  73. ; IF i EQ 7392 THEN skipper=1
  74. IF i EQ 14960 THEN skipper=1
  75. ENDFOR
  76.  
  77. ;Putting The Condensed Data Into The New Array:
  78. IF skipper EQ 0 THEN condensed_data[k]=data_arr[i]
  79. IF skipper EQ 0 THEN k+=1
  80.  
  81. ;Resetting The True/False Logical Operator:
  82. skipper = 0
  83.  
  84. ENDFOR
  85.  
  86. ;Defining How Many Elements Are In The Condensed Data Array:
  87. condensed_data_elements = N_ELEMENTS(condensed_data)
  88.  
  89. ;Defining The String Arrays To Get The Data From The File:
  90. height_str = STRARR(condensed_data_elements)
  91. velocity_str = STRARR(condensed_data_elements)
  92. confidence_vel_str = STRARR(condensed_data_elements)
  93. spectrum_width_str = STRARR(condensed_data_elements)
  94. confidence_spec_wid_str = STRARR(condensed_data_elements)
  95. noise_str = STRARR(condensed_data_elements)
  96. snr_str = STRARR(condensed_data_elements)
  97.  
  98. ;Defining The Data Within The Strings In Order To Pull Out The Necessary Data:
  99. FOR i=0, condensed_data_elements-1 DO BEGIN
  100. height_str[i] = STRMID(condensed_data[i],0,5)
  101. velocity_str[i] = STRMID(condensed_data[i],6,9)
  102. confidence_vel_str[i] = STRMID(condensed_data[i],16,4)
  103. spectrum_width_str[i] = STRMID(condensed_data[i],24,6)
  104. confidence_spec_wid_str[i] = STRMID(condensed_data[i],32,4)
  105. noise_str[i] = STRMID(condensed_data[i],38,11)
  106. snr_str[i] = STRMID(condensed_data[i],49,9)
  107. ENDFOR
  108.  
  109. ;Defining How Many Elements Are In The Date And Time Array:
  110. date_time_elements = N_ELEMENTS(date_time)
  111.  
  112. ;Defining the String Arrays To Get The Date And Time Data:
  113. hour_str = STRARR(date_time_elements)
  114. minute_str = STRARR(date_time_elements)
  115. second_str = STRARR(date_time_elements)
  116.  
  117. ;Defining The Data Within The Time String In Order To Pull Out The Necessary Data For The Time Variables:
  118. FOR i=0, date_time_elements-1 DO BEGIN
  119. hour_str[i] = STRMID(date_time[i],0,2)
  120. minute_str[i] = STRMID(date_time[i],3,2)
  121. second_str[i] = STRMID(date_time[i],6,2)
  122. ENDFOR
  123.  
  124. ;Reading In The Data From The File:
  125. READS, height_str, height
  126. READS, velocity_str, velocity
  127. READS, confidence_vel_str, confidence_vel
  128. READS, spectrum_width_str, spectrum_width
  129. READS, confidence_spec_wid_str, confidence_spec_wid
  130. READS, noise_str, noise
  131. READS, snr_str, snr
  132. READS, hour_str, hour
  133. READS, minute_str, minute
  134. READS, second_str, second
  135.  
  136. ;Converting And Displaying The Time For The Plot:
  137. time_str = (hour_str)+((minute_str)/60.)+((second_str/3600.))
  138.  
  139. ;Defining The Month, Day And Hour To Be Used;
  140. month = 12
  141. day = 16
  142. year = 2013
  143.  
  144. ;Hour, Minute, and Second Arrays Have Already Been Created Above, But Are Fixed Here:
  145. hour = FIX(hour_str)
  146. minute = FIX(minute_str)
  147. second = FIX(second_str)
  148.  
  149. ;Combining The Time for JULDAY:
  150. time_test = JULDAY(month, day, year, hour, minute, second)
  151.  
  152. ;Setting Up In What Format The Data Will Be Displayed In The Plot Label:
  153. dummy = LABEL_DATE(DATE_FORMAT=['%H:%I'])
  154.  
  155. ;Setting Up The Data Array(s) That Will Store The Velocity Data For A Specific Time With A Silly Sorting Name(s):
  156. ;sorting_hat_u = FLTARR(86,81)
  157. ;sorting_hat_v = FLTARR(86,84)
  158. ;The Number Of W Values May Change Since There Are More Times Used:
  159. sorting_hat_w = FLTARR(86,170)
  160.  
  161. ;Setting Up The Data Array(s) That Will Store The Heights For A Specific Time:
  162. ;height_u = FLTARR(86,81)
  163. ;height_v = FLTARR(86,84)
  164. ;The Number Of W Values May Change Since There Are More Times Used:
  165. height_w = FLTARR(86,170)
  166.  
  167. ;Setting Up The Data Array(s) That Will Store The Data For A Specific Date And Time:
  168. ;time_str_u = FLTARR(86,81)
  169. ;time_str_v = FLTARR(86,84)
  170. ;The Number Of W Values May Change Since There Are More Times Used:
  171. time_str_w = FLTARR(86,170)
  172. ;time_test_lena = FLTARR(86,170)
  173.  
  174. ;Separating The Velocity For Each Specific Time:
  175. ;Setting The Count Variables Using Some Silly Names For People Who Helped Me Code This:
  176. vampire_corey = 0
  177. vampire_lena = 85
  178.  
  179. ;Splitting Up The Data Into Blocks Of Data To Be Plotted By Its Specific Time:
  180. ;There May Be Different Values For w Since There Are A Different Amount Of Times For w:
  181. ;FOR i=0, 80 DO BEGIN
  182. ;FOR i=0, 83 DO BEGIN
  183. FOR i=0, 169 DO BEGIN
  184. ; sorting_hat_u[*,i] = velocity_str[vampire_corey:vampire_lena]
  185. ; sorting_hat_v[*,i] = velocity_str[vampire_corey:vampire_lena]
  186. sorting_hat_w[*,i] = velocity_str[vampire_corey:vampire_lena]
  187. ; height_u[*,i] = height_str[vampire_corey:vampire_lena]
  188. ; height_v[*,i] = height_str[vampire_corey:vampire_lena]
  189. height_w[*,i] = height_str[vampire_corey:vampire_lena]
  190. ; time_str_u[*,i] = time_str[i]
  191. ; time_str_v[*,i] = time_str[i]
  192. time_str_w[*,i] = time_str[i]
  193. ; time_test_lena[*,i] = time_test[i]
  194. vampire_corey += 86
  195. vampire_lena += 86
  196. ENDFOR
  197.  
  198. ;Defining An Empty Array To Help Eliminate A Dimension For The Single Component Velocity Vector Plot Using A Silly Name:
  199. ;velocity_seong_u = FLTARR(86,81)
  200. ;velocity_seong_v = FLTARR(86,84)
  201. velocity_seong_w = FLTARR(86,170)
  202.  
  203. ;Plotting The Data:
  204. ;U-Direction:
  205. ;CGWINDOW, 'CGPLOT', time_str_u, height_u, XRANGE=[5.0,7.0], YRANGE=[0,5100], TITLE='U-Component of the Wind from the 915 MHz Wind Profiler', XTITLE='UTC Time', YTITLE='Height (m)', /NODATA
  206. ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_u, sorting_hat_u, time_str_u, height_u, VECCOLORS='red', FRACTION=0.2, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
  207.  
  208. ;V-Direction:
  209. ;CGWINDOW, 'CGPLOT', time_str_v, height_v, XRANGE=[5.0,7.0], YRANGE=[0,5100], TITLE='V-Component of the Wind from the 915 MHz Wind Profiler', XTITLE='UTC Time', YTITLE='Height (m)', /NODATA
  210. ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_v, sorting_hat_v, time_str_v, height_v, VECCOLORS='red', FRACTION=0.2, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
  211.  
  212. ;W-Direction:
  213. ;CGWINDOW, 'CGPLOT', time_str_w, height_w, XRANGE=[5.0,7.0], YRANGE=[0,5700], TITLE='W-Component of the Wind from the 915 MHz Wind Profiler', XTITLE='UTC Time', YTITLE='Height (m)', XTICKFORMAT='LABEL_DATE', XTICKUNITS='hours', /NODATA
  214. ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_w, sorting_hat_w, time_str_w, height_w, VECCOLORS='red', FRACTION=0.1, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
  215.  
  216. ;Test:
  217. ;CGWINDOW, 'CGPLOT', time_test_lena, height_w, XRANGE=[0,1], YRANGE=[0,5700], TITLE='W-Component of the Wind from the 915 MHz Wind Profiler', XTITLE='UTC Time', YTITLE='Height (m)', XTICKFORMAT='LABEL_DATE', XTICKUNITS='minutes', /NODATA
  218. ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_w, sorting_hat_w, time_test_lena, height_w, VECCOLORS='red', FRACTION=0.1, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
  219.  
  220. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement