Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTION ksp_915_winds_read_in, file, Header = hdr
- compile_opt idl2
- ;Error Catcher:
- CATCH, theError
- IF theError NE 0 THEN BEGIN
- CATCH, /cancel
- HELP, /LAST_MESSAGE, OUTPUT=errMsg
- FOR i=0, N_ELEMENTS(errMsg)-1 DO print, errMsg[i]
- RETURN, -1
- ENDIF
- ;Define The File:
- ;file = '/nas/rhome/kpenning/owles/figures/k12_data_and_figures/915/data/u_wind.txt'
- ;file = '/nas/rhome/kpenning/owles/figures/k12_data_and_figures/915/data/v_wind.txt'
- file = '/nas/rhome/kpenning/owles/figures/k12_data_and_figures/915/data/w_wind.txt'
- ;Check The Parameters:
- IF N_ELEMENTS(file) EQ 0 THEN file = DIALOG_PICKFILE(/MUST_EXIST, /READ)
- ;Make Sure The File Exists:
- IF file EQ '' THEN MESSAGE, 'No file provided'
- ;Open The File:
- OPENR, lun, file, /GET_LUN
- ;Tells How Many Lines Are In The File:
- num_lines = FILE_LINES(file)
- ;Define A Variable To Hold The File Information:
- data_arr = STRARR(num_lines)
- ;Read In The File:
- READF, lun, data_arr
- ;Close The File:
- FREE_LUN, lun
- ;Skip The Unnecessary Lines In The Data File:
- skip_lines = 88
- skip_header = DINDGEN(num_lines/skip_lines)*skip_lines
- skip_moments_names = DINDGEN(num_lines/skip_lines)*skip_lines+1.
- ;Defining The Number Of Elements Skipped In The File:
- skip_head = N_ELEMENTS(skip_header)
- skip_moment = N_ELEMENTS(skip_moments_names)
- ;Condensing The Data To Get Rid Of The Skipped Lines:
- all_data = num_lines-(skip_head+skip_moment)
- ;Putting The Remaining Data Into An Array:
- condensed_data = STRARR(all_data)
- ;Defining The Array For The Time Of The 915 Scan:
- date_time = data_arr[skip_header]
- ;Setting The Logical Operator To Be True or False For Skipping Lines:
- skipper = 0
- ;Setting The Index For The New Array:
- k = 0
- ;Moving The Data To The New Array:
- FOR i=0, num_lines-1 DO BEGIN
- ;Skipping Over The Lines With Headers Or Extra Data:
- FOR j=0, skip_head-1 DO BEGIN
- IF i EQ skip_header[j] THEN skipper=1
- IF i EQ skip_moments_names[j] THEN skipper=1
- ;Make Sure To Change The Number Of Lines To Match The Number Of Lines In The File:
- ; IF i EQ 7128 THEN skipper=1
- ; IF i EQ 7392 THEN skipper=1
- IF i EQ 14960 THEN skipper=1
- ENDFOR
- ;Putting The Condensed Data Into The New Array:
- IF skipper EQ 0 THEN condensed_data[k]=data_arr[i]
- IF skipper EQ 0 THEN k+=1
- ;Resetting The True/False Logical Operator:
- skipper = 0
- ENDFOR
- ;Defining How Many Elements Are In The Condensed Data Array:
- condensed_data_elements = N_ELEMENTS(condensed_data)
- ;Defining The String Arrays To Get The Data From The File:
- height_str = STRARR(condensed_data_elements)
- velocity_str = STRARR(condensed_data_elements)
- confidence_vel_str = STRARR(condensed_data_elements)
- spectrum_width_str = STRARR(condensed_data_elements)
- confidence_spec_wid_str = STRARR(condensed_data_elements)
- noise_str = STRARR(condensed_data_elements)
- snr_str = STRARR(condensed_data_elements)
- ;Defining The Data Within The Strings In Order To Pull Out The Necessary Data:
- FOR i=0, condensed_data_elements-1 DO BEGIN
- height_str[i] = STRMID(condensed_data[i],0,5)
- velocity_str[i] = STRMID(condensed_data[i],6,9)
- confidence_vel_str[i] = STRMID(condensed_data[i],16,4)
- spectrum_width_str[i] = STRMID(condensed_data[i],24,6)
- confidence_spec_wid_str[i] = STRMID(condensed_data[i],32,4)
- noise_str[i] = STRMID(condensed_data[i],38,11)
- snr_str[i] = STRMID(condensed_data[i],49,9)
- ENDFOR
- ;Defining How Many Elements Are In The Date And Time Array:
- date_time_elements = N_ELEMENTS(date_time)
- ;Defining the String Arrays To Get The Date And Time Data:
- hour_str = STRARR(date_time_elements)
- minute_str = STRARR(date_time_elements)
- second_str = STRARR(date_time_elements)
- ;Defining The Data Within The Time String In Order To Pull Out The Necessary Data For The Time Variables:
- FOR i=0, date_time_elements-1 DO BEGIN
- hour_str[i] = STRMID(date_time[i],0,2)
- minute_str[i] = STRMID(date_time[i],3,2)
- second_str[i] = STRMID(date_time[i],6,2)
- ENDFOR
- ;Reading In The Data From The File:
- READS, height_str, height
- READS, velocity_str, velocity
- READS, confidence_vel_str, confidence_vel
- READS, spectrum_width_str, spectrum_width
- READS, confidence_spec_wid_str, confidence_spec_wid
- READS, noise_str, noise
- READS, snr_str, snr
- READS, hour_str, hour
- READS, minute_str, minute
- READS, second_str, second
- ;Converting And Displaying The Time For The Plot:
- time_str = (hour_str)+((minute_str)/60.)+((second_str/3600.))
- ;Defining The Month, Day And Hour To Be Used;
- month = 12
- day = 16
- year = 2013
- ;Hour, Minute, and Second Arrays Have Already Been Created Above, But Are Fixed Here:
- hour = FIX(hour_str)
- minute = FIX(minute_str)
- second = FIX(second_str)
- ;Combining The Time for JULDAY:
- time_test = JULDAY(month, day, year, hour, minute, second)
- ;Setting Up In What Format The Data Will Be Displayed In The Plot Label:
- dummy = LABEL_DATE(DATE_FORMAT=['%H:%I'])
- ;Setting Up The Data Array(s) That Will Store The Velocity Data For A Specific Time With A Silly Sorting Name(s):
- ;sorting_hat_u = FLTARR(86,81)
- ;sorting_hat_v = FLTARR(86,84)
- ;The Number Of W Values May Change Since There Are More Times Used:
- sorting_hat_w = FLTARR(86,170)
- ;Setting Up The Data Array(s) That Will Store The Heights For A Specific Time:
- ;height_u = FLTARR(86,81)
- ;height_v = FLTARR(86,84)
- ;The Number Of W Values May Change Since There Are More Times Used:
- height_w = FLTARR(86,170)
- ;Setting Up The Data Array(s) That Will Store The Data For A Specific Date And Time:
- ;time_str_u = FLTARR(86,81)
- ;time_str_v = FLTARR(86,84)
- ;The Number Of W Values May Change Since There Are More Times Used:
- time_str_w = FLTARR(86,170)
- ;time_test_lena = FLTARR(86,170)
- ;Separating The Velocity For Each Specific Time:
- ;Setting The Count Variables Using Some Silly Names For People Who Helped Me Code This:
- vampire_corey = 0
- vampire_lena = 85
- ;Splitting Up The Data Into Blocks Of Data To Be Plotted By Its Specific Time:
- ;There May Be Different Values For w Since There Are A Different Amount Of Times For w:
- ;FOR i=0, 80 DO BEGIN
- ;FOR i=0, 83 DO BEGIN
- FOR i=0, 169 DO BEGIN
- ; sorting_hat_u[*,i] = velocity_str[vampire_corey:vampire_lena]
- ; sorting_hat_v[*,i] = velocity_str[vampire_corey:vampire_lena]
- sorting_hat_w[*,i] = velocity_str[vampire_corey:vampire_lena]
- ; height_u[*,i] = height_str[vampire_corey:vampire_lena]
- ; height_v[*,i] = height_str[vampire_corey:vampire_lena]
- height_w[*,i] = height_str[vampire_corey:vampire_lena]
- ; time_str_u[*,i] = time_str[i]
- ; time_str_v[*,i] = time_str[i]
- time_str_w[*,i] = time_str[i]
- ; time_test_lena[*,i] = time_test[i]
- vampire_corey += 86
- vampire_lena += 86
- ENDFOR
- ;Defining An Empty Array To Help Eliminate A Dimension For The Single Component Velocity Vector Plot Using A Silly Name:
- ;velocity_seong_u = FLTARR(86,81)
- ;velocity_seong_v = FLTARR(86,84)
- velocity_seong_w = FLTARR(86,170)
- ;Plotting The Data:
- ;U-Direction:
- ;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
- ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_u, sorting_hat_u, time_str_u, height_u, VECCOLORS='red', FRACTION=0.2, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
- ;V-Direction:
- ;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
- ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_v, sorting_hat_v, time_str_v, height_v, VECCOLORS='red', FRACTION=0.2, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
- ;W-Direction:
- ;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
- ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_w, sorting_hat_w, time_str_w, height_w, VECCOLORS='red', FRACTION=0.1, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
- ;Test:
- ;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
- ;CGWINDOW, 'CGDRAWVECTORS', velocity_seong_w, sorting_hat_w, time_test_lena, height_w, VECCOLORS='red', FRACTION=0.1, /ORDERED, LENGTH=0.03, /OVERPLOT, /ADDCMD
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement