PRO bscan, datafile, start_at, end_at = end_at, average = average, $ max_scale = max_scale, min_scale = min_scale, $ range = range, altitude = altitude ;========================================================================= ; Reads fixed-record-length binary data files with 30 word headers. ; This program runs on a DOS-PC or Unix-workstation, under PV-WAVE ; or IDL, and makes color images of any airborne or ground-based ; lidar field in a time-versus-range or time-versus-altitude style. ; Please report bugs and suggestions for improvement to Shane Mayor, ; University of Wisconsin-Madison, shane@lidar.ssec.wisc.edu, ; office: 608-263-6847 ;========================================================================= ;========================================================================= ; First, determine what os running and where to get BSCAN ; supporting files (i.e. color tables, etc.) if Unix. ;========================================================================= print,'BSCAN Version 1.060 (18 November 97)' bscan_files = '' if ((!Version.os eq 'sunos') OR (!Version.os eq 'solaris') OR $ (!version.os eq 'AIX')) then begin bscan_files = getenv('BSCAN_FILES') if (bscan_files eq '') then begin print,'Sorry, BSCAN cannot find BSCAN_FILES in your environment.' print,'Please exit PV-WAVE or IDL and set the BSCAN_FILES '+$ ' environment variable:' print,'At NCAR-ATD: BSCAN_FILES=/local/lib/bscan/' print,'At NOAA-ETL: BSCAN_FILES=/opt/local/shane/' print,'At Wisconsin: BSCAN_FILES=/usr6/shane/bscan/code/' return endif else begin bscan_files = bscan_files + '/' print,'BSCAN_FILES = ',bscan_files endelse endif else if (!Version.os eq 'Win32') then begin ; PC version of PV-WAVE path = !Path ; Search through the !Path variable and locate the subdir with the word ; bscan in it. Then set bscan_files to that subdir. result = strpos(strupcase(path),'BSCAN') if (result gt -1) then begin path_chars = strarr(strlen(path)) for i = 0,n_elements(path_chars)-1 do begin path_chars(i) = strmid(path,i,1) endfor semi_locs = where(path_chars eq ';') lt_result = where(semi_locs lt result) gt_result = where(semi_locs gt result) if (lt_result(0) ne -1) then begin start_pos = semi_locs(max(lt_result))+1 endif else begin start_pos = 0 endelse if (gt_result(0) ne -1) then begin end_pos = semi_locs(min(gt_result)) endif else begin end_pos = n_elements(path_chars) endelse chars = end_pos - start_pos print,start_pos, end_pos, chars bscan_files = strmid(path,start_pos,chars) ; Append backslash if necessary (for DOS systems) if (strmid(bscan_files,strlen(bscan_files)-1,1) ne '\') then begin bscan_files = bscan_files + '\' endif print,'BSCAN_FILES = ',bscan_files endif else begin print,'Sorry, reference to BSCAN was not found in your !Path.' print,'Please set your !Path to include location of BSCAN files.' print,'The subdirectory name must contain the word BSCAN.' return endelse endif else begin print,'Running on non-Unix and non-win32 platform.' print,'Not sure how to proceed. Program ending.' return endelse ;====================================================================== ; Check to make sure we can find the data file. ;====================================================================== err = findfile(datafile,count=count) if (count eq 0) then begin print,'Data file: '+datafile+' cannot be found.' return endif ;====================================================================== ; Check to make sure we can find the color tables ; This essentially checks to make sure BSCAN_FILES is correct. ;====================================================================== err = findfile(bscan_files+'browell_.27',count=count) if (count eq 0) then begin print,'Color table: '+bscan_files+'browell_.27 cannot be found.' return endif err = findfile(bscan_files+'velocity.32',count=count) if (count eq 0) then begin print,'Color table: '+bscan_files+'velocity.32 cannot be found.' return endif ;====================================================================== ; Set some initial conditions here ;====================================================================== loop = 1 set_file = 'BSCAN.SET' eps_option = 0 ps_image = 1 ps_color_option = 2 ; 1 for no-color, 2 for color ps_fn = '' ps_path = '' pretitle= '' platform= '' instrument='' field='' project = '' supplement1 = '' supplement2 = '' lr_flag = 1 flag = -999.0 screen_type = !d.name dual_time = 0b upper_row_time_label = '' lower_row_time_label = '' upper_row_hour_adj = 0 lower_row_hour_adj = 0 landscape = 0b transects = 0 range_shift = 0. alt_shift = 0. paper_size = 0. custom_xsize = 0. custom_ysize = 0. custom_xoffset = 0. custom_yoffset = 0. x_dim = 500. y_dim = 300. first_loop = 0. range_extend_flag=0 ; 1 = user wants to display beyond range of data altitude_extend_flag=0 ; 1 = user wants to display beyond altitude of data. ;====================================================================== ; Check out the first header in the data file. ; Determine file size and if byteswapping is required. ;====================================================================== openr,lun,datafile,/get_lun stats = fstat(lun) record = assoc(lun,fltarr(30)) first_header = record(0) close,lun free_lun,lun byteswap=0b if ((first_header(11) ne flag) and (first_header(11) lt 1)) then begin byteswap = 1b print,'Byteswapping required.' stop endif if (byteswap) then byteorder,first_header,/Lswap prof_len = first_header(28) if (prof_len le 0) then begin print,'Sorry. First header of '+datafile print,'says that profile length is less than or equal to 0.' print,'This header element must be positive number.' print,'BSCAN stopping.' stop endif rec_len = prof_len + 30 data_id = first_header(16) platform_id = first_header(22) recs_in_file = long(stats.size/(rec_len*4)) mb_in_file = long(stats.size)/(1024.*1024) ; Check out the last header in the data file. openr,lun,datafile,/get_lun record = assoc(lun,fltarr(rec_len)) last_record = record(recs_in_file-1) last_header = last_record(0:29) close,lun free_lun,lun if (byteswap) then byteorder,last_header,/Lswap lookups,data_id,platform_id,$ instrument,field,platform,$ cfile,mns,mxs hours = strtrim(string(fix(first_header(0))),2) minutes = strtrim(string(fix(first_header(1))),2) if (strlen(minutes) eq 1) then minutes='0'+minutes seconds = strtrim(string(fix(first_header(2))),2) if (strlen(seconds) eq 1) then seconds='0'+seconds first_file_time = hours+':'+minutes+':'+seconds hours = strtrim(string(fix(last_header(0))),2) maj_tim_tic = (hours/6)+1 minutes = strtrim(string(fix(last_header(1))),2) if (strlen(minutes) eq 1) then minutes='0'+minutes seconds = strtrim(string(fix(last_header(2))),2) if (strlen(seconds) eq 1) then seconds='0'+seconds last_file_time = hours+':'+minutes+':'+seconds print,'File name = '+datafile+', Date: '+$ strtrim(string(fix(first_header(11))),2)+'-'+$ strtrim(string(fix(first_header(12))),2)+'-'+$ strtrim(string(fix(first_header(13))),2) print,strtrim(recs_in_file,2),' records, ',strtrim(mb_in_file,2),' MB, ',$ first_file_time,' to ',last_file_time,', data ID = ',$ strtrim(fix(first_header(16)),2) start_at_size = size(start_at) openr,lun,datafile,/get_lun if (start_at_size(1) eq 7) then begin ; string detected if (strpos(strupcase(start_at),'T') ne -1) then begin ; transect number detected findtran,fix(start_at),lun,rec_len,recs_in_file,first_rec,tran2 endif else if (strpos(start_at,':') ne -1) then begin ; time detected findtime,start_at,lun,rec_len,recs_in_file,first_rec endif else begin print,'Use of string for start position requires : '+$ '(for time) or T (for transect).' return endelse endif else begin ; record number detected first_rec = long(start_at) endelse if (not keyword_set(average)) then average = 1 if (keyword_set(end_at)) then begin end_at_size = size(end_at) if (end_at_size(1) eq 7) then begin ; string detected if (strpos(strupcase(end_at),'T') ne -1) then begin ; transect number detected findtran,fix(end_at),lun,rec_len,recs_in_file,tran3,last_rec endif else if (strpos(end_at,':') ne -1) then begin ; time detected findtime,end_at,lun,rec_len,recs_in_file,last_rec endif else begin print,'Use of string for end_at requires : '+$ '(for time) or T (for transect).' return endelse endif else begin ; record number detected last_rec = long(end_at) endelse endif else begin if (strpos(strupcase(start_at),'T') ne -1) then begin last_rec = tran2 endif else begin last_rec = first_rec + (512*average) - 1 endelse endelse close,lun free_lun,lun if (first_rec ge recs_in_file-1) then begin print,'Sorry, there are only ',strtrim(recs_in_file,2),' records in ',datafile print,'and you asked to start reading at record ',strtrim(first_rec,2),'.' return endif the_most_recs = (512*average) if (((last_rec-first_rec) GT the_most_recs) and (average GT 1)) then begin last_rec = first_rec + the_most_recs - 1 if (last_rec lt recs_in_file-1) then begin print,'Due to the average keyword and the limit of 512 averaged profiles,' print,'the last record that will be read is '+ $ strtrim(last_rec,2) endif endif if ((last_rec gt recs_in_file-1) or (last_rec lt 0)) then $ last_rec = recs_in_file-1 if (first_rec lt 0) then first_rec = 0 num_recs = last_rec - first_rec + 1 read_data_entry: if (average gt 1) then begin print,'Reading records '+strtrim(first_rec,2)+' to '+$ strtrim(last_rec,2)+' ('+strtrim(num_recs,2)+' records, averaging every '+$ strtrim(average,2)+' together.)' endif else begin print,'Reading records '+strtrim(first_rec,2)+' to '+$ strtrim(last_rec,2)+' ('+strtrim(num_recs,2)+' records, with no averaging.)' endelse data_recs = num_recs/average print,'The resulting data array will contain '+strtrim(data_recs,2)+' profiles.' data = fltarr(prof_len,data_recs) header = fltarr(30,data_recs) openr,lun,datafile,/get_lun record=assoc(lun,fltarr(rec_len)) if (last_rec gt (recs_in_file-1)) then begin last_rec = recs_in_file - average endif if (byteswap) then begin ; Read with byteswapping if (average gt 1) then begin ; accumulate and average while reading data_rec = 0 sum=fltarr(rec_len) for i=first_rec,last_rec-average+1,average do begin for j=1,average do begin k = i + j - 1 ; print,'data_rec,j,k = ',data_rec,j,k z=record(k) byteorder,z,/Lswap sum=sum+z(30:rec_len-1) endfor header(*,data_rec) = z(0:29) data(*,data_rec) = sum(*)/average sum(*)=0. data_rec = data_rec + 1 endfor endif else begin ; straight read of every record with no averaging for i=first_rec,last_rec do begin z=record(i) byteorder,z,/Lswap header(*,i-first_rec) = z(0:29) data(*,i-first_rec) = z(30:rec_len-1) endfor endelse endif else begin ; Read with no byteswapping if (average gt 1) then begin ; accumulate and average while reading data_rec = 0 sum=fltarr(rec_len) for i=first_rec,last_rec-average+1,average do begin for j=1,average do begin k = i + j - 1 ; print,'data_rec,j,k = ',data_rec,j,k z=record(k) sum=sum+z(30:rec_len-1) endfor header(*,data_rec) = z(0:29) data(*,data_rec) = sum(*)/average sum(*)=0. data_rec = data_rec + 1 endfor endif else begin ; straight read of every record with no averaging for i=first_rec,last_rec do begin z=record(i) header(*,i-first_rec) = z(0:29) data(*,i-first_rec) = z(30:rec_len-1) endfor endelse endelse this_transect = z(29) close,lun free_lun,lun ;============================================================== ; Check to make sure some variables in the header are constant ;============================================================== const_test = header(21,*) - shift(header(21,*),1) delta_locs = where(const_test ne 0) if (delta_locs(0) ne -1) then begin print print,'Warning: Header element number 21 (range-resolution of data)' print,'is not constant through this segment of data.' print,'Program cannot continue.' print,'Please check reduced data file.' stop return endif const_test = header(23,*) - shift(header(23,*),1) delta_locs = where(const_test ne 0) if (delta_locs(0) ne -1) then begin print print,'Warning: Header element number 23 (number of header words per record)' print,'is not constant through this segment of data. Program cannot continue.' print,'Please check reduced data file.' stop return endif const_test = header(28,*) - shift(header(28,*),1) delta_locs = where(const_test ne 0) if (delta_locs(0) ne -1) then begin print print,'Warning: Header element number 28 (number of profile words per record)' print,'is not constant through this segment of data. Program cannot continue.' print,'Please check reduced data file.' stop return endif const_test = 0b delta_locs = 0b ;============================================================= ; Check to see how many transects this segment spans ;============================================================= transects = max(header(29))-min(header(29))+1 ;============================================================= ; Check to see how many hours of data the scene spans ;============================================================= delta_scene_hours = max(header(0)) - min(header(0)) data_size = size(data) ;print,data_size ; Now check some things that only need to be done the ; first time through. if (loop eq 1) then begin ; Flag sample style screen_sample_style=flag PS_sample_style=flag ; First, check to see if data is ground-based or airborne airborne = -1 if (fix(first_header(22)) eq 9) then airborne = 0 if (fix(first_header(22)) eq 8) then airborne = 1 if (airborne lt 0) then begin ask1: print,'' print,'Is this airborne or ground-based data?' print,'1) airborne' print,'2) ground-based' answer = 0 read,answer if ((answer lt 1) or (answer gt 2)) then begin print,'You must reply with either 1 or 2.' goto,ask1 endif if (answer eq 1) then begin airborne = 1 print,'Airborne selected.' endif if (answer eq 2) then begin airborne = 0 print,'Ground-based selected.' endif endif ; Make sure header element 21 has a non-zero value in it. if (header(21,0) le 0.) then begin print,'Warning: header element 21 is: '+strtrim(header(21,0),2) print,'This value is not allowed for range resolution of data.' ask9: print,'Enter new value (meters per word).' metpwd = 0. read,metpwd if (metpwd le 0.) then begin print,strtrim(metpwd,2)+' is not valid.' print,'Please enter a positive number.' goto,ask9 endif ask10: print,'Would you like to update the data file?' print,'1) yes' print,'2) no' answer=-1 read,answer if ((answer lt 1) or (answer gt 2)) then begin print,'You may only answer 1 or 2.' goto, ask10 endif if (answer eq 1) then begin fixhdr,datafile,21,metpwd endif endif ;=================================================================== ; Images can be made with the platform at the bottom with range ; increasing up **OR** platform at the top with range increasing down. ; The default is platform at the bottom with range increasing up. ;=================================================================== updn = 1 ;==================================================================== ; If the data are airborne, find out if nadir or zenith image. ; If it is not obvious (i.e. not + or - 90.) then ask the user. ;==================================================================== if (airborne eq 1) then begin if (header(7,0) eq 90.) then updn = 1 if (header(7,0) eq -90.) then updn = -1 if ((header(7,0) ne 90.) and (header(7,0) ne -90.)) then begin ask_updn: print,'Beam elevation is not + or - 90.' print,'Do want the image to appear as:' print,'1) nadir (platform at the top, lidar looking down)' print,'2) zenith (platform at the bottom, lidar looking up)' updn=0. read,updn if ((updn ne 1) and (updn ne 2)) then begin print,'You may choose 1 or 2 only.' print,'(Even if the data are not zenith or nadir.)' goto,ask_updn endif if (updn eq 1) then begin updn=-1 print,'Nadir selected' endif if (updn eq 2) then begin updn=1 print,'Zenith selected' endif endif else begin if (updn eq 1) then begin print,'This appears to be zenith data.' endif if (updn eq -1) then begin print,'This appears to be nadir data.' endif endelse endif ;================================================================== ; Set the min and max scale for the color bar here ;================================================================== if (not keyword_set(max_scale)) then max_scale = mxs if (not keyword_set(min_scale)) then min_scale = mns load_ct,bscan_files + cfile,bins,RGB_array if (max_scale eq flag) then begin find_mag,max(data),mag max_scale = .50 * 10^(mag) endif if (min_scale eq flag) then begin min_scale = 0. endif max_scale = float(max_scale) min_scale = float(min_scale) ;========================================================================= ; Decide on whether the image will be altitude aligned or not. ; If altitude-aligned, then altitude (m ASL) will be the vertical coordinate ; If not altitude-aligned, then range (m from platform) will ; be the vertical coordinate. ;========================================================================= range_flag = 1b altitude_flag = 0b if (airborne) then begin range_flag = 0b altitude_flag = 1b endif if (keyword_set(range)) then begin print,'Time versus RANGE plot requested.' range_flag = 1b altitude_flag = 0b endif else begin range = 1 endelse if (keyword_set(altitude)) then begin print,'Time versus ALTITUDE plot requested.' range_flag = 0b altitude_flag = 1b endif else begin altitude = 1 endelse ;====================================================== ; Find out if user wants a new window for each image. ;====================================================== ask05: print,'' window_prompt=-1 print,'Would you like to:' print,'1) Keep all images on the screen (do not prompt again)' print,'2) Delete recent image before creating new one (do not prompt again)' print,'3) Be prompted with a choice each time an image is created.' print,'4) Quit BSCAN now and return to WAVE prompt.' read,window_prompt if ((window_prompt lt 1) or (window_prompt gt 4)) then begin print,'You may only answer 1, 2, 3, or 4. Please try again.' goto,ask05 endif if (window_prompt eq 1) then new_window = 1 if (window_prompt ge 2) then new_window = -1 if (window_prompt eq 4) then return endif min_alt = min(header(3,*)) max_alt = max(header(3,*)) alt_range = max_alt - min_alt if (updn eq 1) then start_alt = min_alt if (updn eq -1) then start_alt = max_alt sampling_inquiry: if ((!d.name ne 'PS') and (screen_sample_style eq flag)) then begin ; X or WIN32 device print,'' print,'Subsampling required for this device: '+strtrim(!d.name) print,'Which do you want? (This will set the default for this run.)' ask_screen_sample_style: print,'1) bilinear interpolation' print,'2) nearest neighbor' print,'3) bilinear interpolation(skip flagged values)' read,screen_sample_style if (screen_sample_style lt 1) or (screen_sample_style gt 3) then begin print,'Please choose 1, 2, or 3 only.' goto,ask_screen_sample_style endif else begin print,'' if (screen_sample_style eq 1) then $ print,'Bilinear interpolation subsampling selected for screen display.' if (screen_sample_style eq 2) then $ print,'Nearest neighbor subsampling selected for screen display.' if (screen_sample_style eq 3) then begin print,'Bilinear interpolation subsampling selected for screen display (skip flagged values).' if(flag eq 0.0)then begin print,'What value do you want to represent bad data?' read,flag endif endif endelse endif else if ((!d.name eq 'PS') and (PS_sample_style eq flag)) then begin ; PS device print,'Options for PS display.' print,'Which do you want? (This will set the default for this run.)' ask_PS_sample_style: print,'1) subsampling using bilinear interpolation' print,'2) subsampling using nearest neighbor method' print,'3) subsampling using bilinear interpolation(skip flagged values)' ; print,'3) no subsampling (plot all data as read)' read,PS_sample_style if (PS_sample_style lt 1) or (PS_sample_style gt 3) then begin print,'Please choose 1, 2, or 3 only.' goto,ask_PS_sample_style endif else begin print,'' if (PS_sample_style eq 1) then $ print,'Bilinear interpolation subsampling selected for PS output.' if (PS_sample_style eq 2) then $ print,'Nearest neighbor subsampling selected for PS output.' if (PS_sample_style eq 3) then begin print,'Bilinear interpolation subsampling selected for PS output (skip flagged values).' if(flag eq 0.0)then begin print,'What value do you want to represent bad data?' read,flag endif endif ; ;check for bad user values for the image size ; if (x_dim le 0) then x_dim = 500 if (y_dim le 0) then y_dim = 300 endelse goto, sample_entry endif vertical_alignment_entry: if (altitude_flag) then begin print,'Altitude range of platform during this segment: ',$ strtrim(min_alt,2)+' - '+strtrim(max_alt,2)+' m' print,'Platform altitude changes '+strtrim(alt_range,2)+$ ' m during this segment' if (alt_range ne 0.) then begin print,'Altitude alignment required.' expanded_range = fix((alt_range / header(21,0)) + header(28,0)) ; print,'Expanded vertical range '+strtrim(expanded_range,2)+' words' data1 = fltarr(expanded_range,data_recs) data1(*) = flag ref_alt = max_alt ; print,'Reference altitude = '+strtrim(ref_alt,2) for i = 0,(data_recs-1) do begin start_word = fix((ref_alt-header(3,i))/header(21,i)) stop_word = fix(start_word + header(28,i) - 1) ; print,header(3,i),' 0-'+strtrim((expanded_range-1),2)+' ',$ ; strtrim(start_word,2)+'-'+strtrim(stop_word,2),stop_word-start_word+1 ; stop data1(start_word:stop_word,i) = data(*,i) endfor endif else begin data1 = data endelse data1_size=size(data1) vertical1 = (findgen(data1_size(1))*header(21,0)*float(updn)) + $ start_alt + (first_header(20)*float(updn)) + alt_shift endif else begin data1 = data data1_size=size(data1) vertical1 = (findgen(data1_size(1))*header(21,0)) + $ first_header(20) + range_shift endelse ;print,data1_size vertical_extend_entry: ; This section is under developement by S Mayor as of 11/18/97 ; If the user specifies a range or altitude above/below the max/min ; altitude or range of the data, then we have to make an oversized ; array and place the existing data into it at the right spot. ; This is essentially padding with flags. if (altitude_flag) then begin ; altitude display requested if ((min(altitude) lt min(vertical1)) or $ (max(altitude) gt max(vertical1))) then altitude_extend_flag=1 if ((min(altitude) gt min(vertical1)) and $ (max(altitude) lt max(vertical1))) then altitude_extend_flag=0 print,'altitude_extend_flag=',altitude_extend_flag if (altitude_extend_flag eq 1) then begin extend_alt_up = max(altitude)-max(vertical1) extend_alt_dn = min(vertical1)-min(altitude) if (extend_alt_up lt 0) then extend_alt_up=0. if (extend_alt_dn lt 0) then extend_alt_dn=0. extend_dim = (extend_alt_up/header(21,0)) + $ (extend_alt_dn/header(21,0)) + data1_size(1) print,'extend_alt_up=',extend_alt_up,' m' print,'extend_alt_dn=',extend_alt_dn,' m' print,'data1_size=',data1_size print,'extend_dim=',extend_dim,' words' exp_data = fltarr(fix(extend_dim+1),data1_size(2)) print,'size(exp_data)=',size(exp_data) endif endif else begin ; range display requested if ((min(range) lt min(vertical1)) or $ (max(range) gt max(vertical1))) then range_extend_flag=1 if ((min(range) gt min(vertical1)) and $ (max(range) lt max(vertical1))) then range_extend_flag=0 if (range_extend_flag eq 1) then begin extend_range_up = max(altitude)-max(vertical1) extend_range_dn = min(vertical1)-min(altitude) if (extend_range_up lt 0) then extend_range_up=0. if (extend_range_dn lt 0) then extend_range_dn=0. extend_dim = (extend_range_up/header(21,0)) + $ (extend_range_dn/header(21,0)) + data1_size(1) print,'extend_range_up=',extend_range_up,' m' print,'extend_range_dn=',extend_range_dn,' m' print,'data1_size=',data1_size print,'extend_dim=',extend_dim,' words' exp_data = fltarr(fix(extend_dim+1),data1_size(2)) print,'size(exp_data)=',size(exp_data) endif endelse vertical_extract_entry: ; Extract a swath across the data array for display ; This will restrict the vertical dimension of the data being displayed. ;print,'altitude_flag=',altitude_flag if (altitude_flag) then begin if (n_elements(altitude) eq 1) then begin ; no altitudes specified by user. Take all. levels = where(vertical1 gt (-500.)) endif else begin ; altitudes specified by user. levels = where((vertical1 ge min(altitude)) and (vertical1 le max(altitude))) endelse endif else begin if (n_elements(range) eq 1) then begin ; no ranges specified by user. Take all. levels = indgen(n_elements(vertical1)) endif else begin ; ranges specified by user. levels = where((vertical1 ge min(range)) and (vertical1 le max(range))) endelse endelse data2 = data1(levels,*) data2_size = size(data2) ;print,data2_size vertical2 = vertical1(levels) if(first_loop eq 0) then goto, first_loop_jump_point sample_entry: ;if ((!d.name eq 'PS') and (screen_sample_style eq ps_sample_style)) then goto,color_entry if (!d.name eq screen_type) then begin ; This image going to the screen if (screen_sample_style eq 1) then begin ; print,'Bilinear congridding...' data3 = congrid(data2,y_dim,x_dim,/Interp) endif else if (screen_sample_style eq 2) then begin ; print,'Nearest-neighbor congridding...' data3 = congrid(data2,y_dim,x_dim) endif else if (screen_sample_style eq 3) then begin s = size(data2) dx = double((s(1)-1)/(y_dim-1)) dy = double((s(2)-1)/(x_dim-1)) my_x = fltarr(y_dim) my_y = fltarr(x_dim) j = 0 for i=0.0, s(1)-1, dx DO BEGIN my_x(j) = i j = j + 1 endfor my_x(y_dim-1)=s(1)-1 j = 0 for i=0.0, s(2)-1, dy DO BEGIN my_y(j) = i j = j + 1 endfor my_y(x_dim-1)=s(2)-1 print,'Working...' data3 = newbilinear(data2,my_x,my_y,flag) endif else begin print,'Screen sample style ',screen_sample_style,' not supported.' print,'BSCAN stopping.' stop endelse endif else begin ; This image going to a Postscript file if (PS_sample_style eq 0) then begin data3 = data2 endif else if (PS_sample_style eq 1) then begin ; print,'Bilinear congridding...' data3 = congrid(data2,y_dim,x_dim,/Interp) endif else if (PS_sample_style eq 2) then begin ; print,'Nearest-neighbor congridding...' data3 = congrid(data2,y_dim,x_dim) endif else if (screen_sample_style eq 3) then begin s = size(data2) dx = double((s(1)-1)/(y_dim-1)) dy = double((s(2)-1)/(x_dim-1)) my_x = fltarr(y_dim) my_y = fltarr(x_dim) j = 0 for i=0.0, s(1)-1, dx DO BEGIN my_x(j) = i j = j + 1 endfor my_x(y_dim-1)=s(1)-1 j = 0 for i=0.0, s(2)-1, dy DO BEGIN my_y(j) = i j = j + 1 endfor my_y(x_dim-1)=s(2)-1 print,'Working...' data3 = newbilinear(data2,my_x,my_y,flag) endif else begin print,'PS sample style ',PS_sample_style,' not supported.' print,'BSCAN stopping.' stop endelse endelse vertical3 = interpol(vertical2,y_dim) data3_size = size(data3) color_entry: scale_range = max_scale - min_scale if (scale_range eq 0.) then begin print,'Warning: SCALE_RANGE = 0.' print,'BSCAN cannot continue.' stop endif bin_width = scale_range/float(bins-2) ;print,'bin_width = ',bin_width elements = where(data3 eq max_scale) if (elements(0) ge 0) then data3(elements)=data3(elements)-0.00001 data4 = fix((data3 - min_scale)/bin_width) + 1 elements = where(data4 lt 0.) if (elements(0) ge 0) then data4(elements)=0. elements = where(data4 gt (bins-2)) if (elements(0) ge 0) then data4(elements)=float(bins-1) disp_arr=byte(data4) if (!d.name eq 'PS') and (ps_color_option eq 1) then begin disp_arr=(byte(data4)*255)/bins !p.color = 0 endif sx=x_dim + 200 sy=y_dim + 212 disp_size=size(disp_arr) dx=float(disp_size(2))/sx dy=float(disp_size(1))/sy x0=(1.-dx)/2. y0=(1.-dy)/3.5 data_id = header(16,0) m = header(11,0) if (m ne flag) then begin ascii_mo,m,month endif else begin month = ' ' endelse day = header(12,0) year = header(13,0) date_string=strtrim(string(fix(day)),2)+' '+month+' '+$ strtrim(string(fix(year)),2) hours = strtrim(string(fix(header(0,0))),2) minutes = strtrim(string(fix(header(1,0))),2) if (strlen(minutes) eq 1) then minutes='0'+minutes seconds = strtrim(string(fix(header(2,0))),2) if (strlen(seconds) eq 1) then seconds='0'+seconds first_rec_time = hours+':'+minutes+':'+seconds hours = strtrim(string(fix(header(0,data_recs-1))),2) minutes = strtrim(string(fix(header(1,data_recs-1))),2) if (strlen(minutes) eq 1) then minutes='0'+minutes seconds = strtrim(string(fix(header(2,data_recs-1))),2) if (strlen(seconds) eq 1) then seconds='0'+seconds last_rec_time = hours+':'+minutes+':'+seconds window_title = instrument+' '+date_string+', '+first_rec_time+' to '+$ last_rec_time+' (records '+strtrim(string(long(first_rec)),2)+'-'+$ strtrim(string(long(last_rec )),2)+')' start_graphics: if ((!d.name ne 'PS') and (window_prompt eq 3)) then begin ask06: print,'' new_window = -1 print,'Open a new window?' print,'1) Yes (keep existing window and open a new one)' print,'2) No (delete existing window (if present) and open a new one) ' read,new_window if ((new_window lt 1) or (new_window gt 2)) then begin print,'You may only answer 1 or 2. Please try again.' goto, ask06 endif if (new_window eq 2) then new_window = -1 endif if (!d.name ne 'PS') then begin ; print,'new_window = ',new_window if (new_window eq 1) then begin ; Open a new window with the /free keyword window,xsize=sx,ysize=sy,title=window_title,colors=256,retain=2,/free endif else begin ; Just kill the latest window then open a new one window,xsize=sx,ysize=sy,title=window_title,colors=256,retain=2 endelse endif ; WHITE white !p.background=bins erase if ((updn eq -1) and (lr_flag gt 0)) then begin disp_rotate=3 vertical4=rotate(vertical3,2) endif if ((updn eq 1) and (lr_flag gt 0)) then begin disp_rotate=4 vertical4=vertical3 endif if ((updn eq -1) and (lr_flag lt 0)) then begin disp_rotate=6 vertical4=rotate(vertical3,2) endif if ((updn eq 1) and (lr_flag lt 0)) then begin disp_rotate=1 vertical4=vertical3 endif tv,rotate(disp_arr,disp_rotate),x0,y0,xsize=dx,ysize=dy,/normal ; Remember, screen_type is only set at the initialization. ; It does not tell you whether you are in PS mode or not. ; It only tells you whether you are X or win32. ; You must use !d.name to know whether you are writing to PS. ; BLACK black if (ps_color_option eq 2) then begin !p.color = bins+1 endif else begin !p.color = 0 endelse if (!d.name eq 'PS') then begin if (landscape) then begin ; Use larger characters for Landscape !p.charsize = 1.0 !p.thick=3 endif else begin ; Use smaller characters for Portrait !p.charsize = 0.75 !p.thick=2 endelse endif else begin ; screen output !p.charsize = 1.0 !p.thick=2 endelse !p.font=0 y1=y0-.02 y2=y0-.04 y3=y0-.068 y4=y0-.093 y5=(y0+dy)+.02 y6=(y0+dy)+.04 y7=(y0+dy)+.048 y8=(y0+dy)+.076 y9=y0-.03 y10=(y0+dy)+.03 x1=x0-.015 x2=x0-.025 x3=x0-.040 x4=x0-.045 x5=(x0+dx)+.015 x6=(x0+dx)+.025 x7=(x0+dx)+.040 x8=(x0+dx)+.045 x9=x0-.072 plots,[x0,x0+dx],[y1,y1],/normal plots,[x0,x0+dx],[y5,y5],/normal plots,[x1,x1],[y0,y0+dy],/normal plots,[x5,x5],[y0,y0+dy],/normal ;============================================================================== ;******** VERTICAL axes section starts here ********************************* ;============================================================================== vertical_extent = max(vertical4) - min(vertical4) if (vertical_extent gt 3000.) then begin maj_range_tic = 1000. min_range_tic = 250. frac = 0 endif else if (vertical_extent gt 1000.) then begin maj_range_tic = 500. min_range_tic = 100. frac = 1 endif else begin maj_range_tic = 250. min_range_tic = 50. frac = 2 endelse remainder_thres = vertical_extent/y_dim for i = 0,(n_elements(vertical4)-1) do begin if (vertical4(i) ge 0.) then begin maj_remainder = (vertical4(i) mod maj_range_tic) min_remainder = (vertical4(i) mod min_range_tic) ; print,i,vertical4(i),maj_remainder,min_remainder if (maj_remainder le remainder_thres) then begin y = y0 + (float(i)/sy) plots,[x1,x3],[y,y],/normal plots,[x5,x7],[y,y],/normal if (frac eq 0) then begin ; DO NOT display fraction of km in the vertical axes tic labels vert_axes_string = strtrim(string(fix(vertical4(i)/1000.)),2) endif else if (frac eq 1) then begin ; Display tenths of km (1 decimal place) in the vertical axes tic labels vert_axes_string = strtrim(string((vertical4(i)/1000.),format='(f7.1)'),2) endif else begin ; Display .25 km (2 decimal place) in the vertical axes tic labels vert_axes_string = strtrim(string((vertical4(i)/1000.),format='(f7.2)'),2) endelse xyouts,x4,y-0.01,vert_axes_string,alignment=1,/normal xyouts,x8,y-0.01,vert_axes_string,alignment=0,/normal endif if (min_remainder le remainder_thres) then begin y = y0 + (float(i)/sy) plots,[x1,x2],[y,y],/normal plots,[x5,x6],[y,y],/normal endif endif endfor if ((!d.name eq 'X') or (!d.name eq 'PS')) then begin if (frac eq 0) then x = x0 - 0.072 if (frac eq 1) then x = x0 - 0.083 if (frac eq 2) then x = x0 - 0.096 if (altitude_flag) then begin xyouts,x,y0+(dy/2),'Altitude (km ASL)',$ orientation=90,alignment=.5,/normal endif else begin xyouts,x,y0+(dy/2),'Range (km)',$ orientation=90,alignment=.5,/normal endelse endif if (airborne) then begin xyouts,(1.-x9),y7,'N LAT',/normal,alignment=.75 xyouts,(1.-x9),y8,'E LON',/normal,alignment=.75 endif else begin xyouts,(1.-x9),y7,'AZ',/normal,alignment=.75 xyouts,(1.-x9),y8,'EL',/normal,alignment=.75 endelse xyouts,(x6+x7)/2.,y3,upper_row_time_label,/normal,alignment=0. if (dual_time) then xyouts,(x6+x7)/2.,y4,lower_row_time_label,/normal,alignment=0. ;========================================================================== ;******************** Horizontal axes section ***************************** ;========================================================================== ; ;Added this if statement in case someone entered a bad tick mark value ; if (maj_tim_tic le 0) then maj_tim_tic = 1. header_size = size(header) if (lr_flag gt 0) then begin ; time increasing to the right start_horizontal_scan = 0 end_horizontal_scan=header_size(2)-1 step=1 endif else begin ; time increasing to the left start_horizontal_scan=header_size(2)-1 end_horizontal_scan=0 step=-1 endelse h_tick_count = 0 old_min = header(1,start_horizontal_scan) ; The following variables are 2-word arrays each. ; They define the starting and ending coordinates of horizontal axes tic label strings. ; pre refers to the most recent label. ; now refers to the one currently being considered. pre_top_upper = [lr_flag*(-1.),lr_flag*(-1.)] pre_bot_upper = [lr_flag*(-1.),lr_flag*(-1.)] pre_top_lower = [lr_flag*(-1.),lr_flag*(-1.)] pre_bot_lower = [lr_flag*(-1.),lr_flag*(-1.)] now_top_upper = [lr_flag*(-1.),lr_flag*(-1.)] now_bot_upper = [lr_flag*(-1.),lr_flag*(-1.)] now_top_lower = [lr_flag*(-1.),lr_flag*(-1.)] now_bot_lower = [lr_flag*(-1.),lr_flag*(-1.)] for i=start_horizontal_scan,end_horizontal_scan,step do begin x=x0+((float(i)/float(header_size(2)))*dx) if ((header(1,i) mod maj_tim_tic) eq 0.) and (header(1,i) ne old_min) then begin upper_hr = (header(0,i)+upper_row_hour_adj) if (upper_hr lt 0) then upper_hr = 24 + upper_hr if (upper_hr gt 23) then upper_hr = upper_hr - 24 lower_hr = (header(0,i)+lower_row_hour_adj) if (lower_hr lt 0) then lower_hr = 24 + lower_hr if (lower_hr gt 23) then lower_hr = lower_hr - 24 upper_hours = strtrim(string(fix(upper_hr)),2) lower_hours = strtrim(string(fix(lower_hr)),2) minutes = strtrim(string(fix(header(1,i))),2) if (strlen(minutes) eq 1) then minutes = '0'+minutes if (strlen(upper_hours) eq 1) then upper_hours = '0'+upper_hours if (strlen(lower_hours) eq 1) then lower_hours = '0'+lower_hours upper_time_string = upper_hours+':'+minutes lower_time_string = lower_hours+':'+minutes ; This part checks to see if the upper axis elements are flags and ; if they are not, puts them into the string variables. if (header(18,i) ne header(24,i)) then begin lat_string = strtrim(string(header(18,i),format='(f7.2)'),2) endif else begin lat_string = ' ' endelse if (header(19,i) ne header(24,i)) then begin lon_string = strtrim(string(header(19,i),format='(f7.2)'),2) endif else begin lon_string = ' ' endelse if (header(6,i) ne header(24,i)) then begin beam_az_string = strtrim(string(header(6,i),format='(f7.2)'),2) endif else begin beam_az_string = ' ' endelse if (header(7,i) ne header(24,i)) then begin beam_el_string = strtrim(string(header(7,i),format='(f7.2)'),2) endif else begin beam_el_string = ' ' endelse now_top_lower(0)=x-((((strlen(upper_time_string)+2.)*!d.x_ch_size)/2.)/!d.x_size) now_top_lower(1)=x+((((strlen(upper_time_string)+2.)*!d.x_ch_size)/2.)/!d.x_size) now_bot_lower(0)=x-((((strlen(lower_time_string)+2.)*!d.x_ch_size)/2.)/!d.x_size) now_bot_lower(1)=x+((((strlen(lower_time_string)+2.)*!d.x_ch_size)/2.)/!d.x_size) if (airborne) then begin now_top_upper(0)=x-(((strlen(lat_string)*!d.x_ch_size)/2.)/!d.x_size) now_top_upper(1)=x+(((strlen(lat_string)*!d.x_ch_size)/2.)/!d.x_size) now_bot_upper(0)=x-(((strlen(lon_string)*!d.x_ch_size)/2.)/!d.x_size) now_bot_upper(1)=x+(((strlen(lon_string)*!d.x_ch_size)/2.)/!d.x_size) endif else begin now_top_upper(0)=x-(((strlen(beam_az_string)*!d.x_ch_size)/2.)/!d.x_size) now_top_upper(1)=x+(((strlen(beam_az_string)*!d.x_ch_size)/2.)/!d.x_size) now_bot_upper(0)=x-(((strlen(beam_el_string)*!d.x_ch_size)/2.)/!d.x_size) now_bot_upper(1)=x+(((strlen(beam_el_string)*!d.x_ch_size)/2.)/!d.x_size) endelse if (lr_flag gt 0) then begin ; Time increasing to the right if ((now_top_lower(0) gt pre_top_lower(1)) and $ (now_bot_lower(0) gt pre_bot_lower(1))) then begin ; Full-tick marks and labels plots,[x,x],[y1,y2],/normal plots,[x,x],[y5,y6],/normal xyouts,x,y3,upper_time_string,/normal,alignment=.5 h_tick_count = h_tick_count + 1 if (dual_time) then xyouts,x,y4,lower_time_string,/normal,alignment=.5 if (airborne) then begin ; If airborne then print lat and lon across the top xyouts,x,y7,lat_string,/normal,alignment=.5 xyouts,x,y8,lon_string,/normal,alignment=.5 endif else begin ; If ground-based then print beam angles across the top xyouts,x,y7,beam_az_string,/normal,alignment=.5 xyouts,x,y8,beam_el_string,/normal,alignment=.5 endelse pre_top_upper = now_top_upper pre_bot_upper = now_bot_upper pre_top_lower = now_top_lower pre_bot_lower = now_bot_lower endif else begin ; half tick marks with no labels if (delta_scene_hours lt 2.) then begin plots,[x,x],[y1,y9],/normal plots,[x,x],[y5,y10],/normal endif endelse endif else begin ; Time decreasing to the right if ((now_top_lower(1) lt pre_top_lower(0)) and $ (now_bot_lower(1) lt pre_bot_lower(0))) then begin plots,[x,x],[y1,y2],/normal plots,[x,x],[y5,y6],/normal xyouts,x,y3,upper_time_string,/normal,alignment=.5 h_tick_count = h_tick_count + 1 if (dual_time) then xyouts,x,y4,lower_time_string,/normal,alignment=.5 if (airborne) then begin ; If airborne then print lat and lon across the top xyouts,x,y7,lat_string,/normal,alignment=.5 xyouts,x,y8,lon_string,/normal,alignment=.5 endif else begin ; If ground-based then print beam angles across the top xyouts,x,y7,beam_az_string,/normal,alignment=.5 xyouts,x,y8,beam_el_string,/normal,alignment=.5 endelse pre_top_upper = now_top_upper pre_bot_upper = now_bot_upper pre_top_lower = now_top_lower pre_bot_lower = now_bot_lower endif else begin ; half tick marks with no labels if (delta_scene_hours lt 2.) then begin plots,[x,x],[y1,y9],/normal plots,[x,x],[y5,y10],/normal endif endelse endelse endif old_min = header(1,i) endfor ; If no time/lat/lon/az/el tick marks were drawn, mark the first and last time. if (h_tick_count eq 0) then begin ; Compute the x-center of the first profile x = x0 + (dx/data_recs)/2. plots,[x,x],[y1,y2],/normal plots,[x,x],[y5,y6],/normal ; Compute the x-center of the last profile x = (x0 + dx) - (dx/data_recs)/2. plots,[x,x],[y1,y2],/normal plots,[x,x],[y5,y6],/normal endif ;========================================================================== ;******************** Color bar and annotation **************************** ;========================================================================== color_ba,bins,min_scale,max_scale,ps_color_option xyouts,.5,.94,field,alignment=.5,/normal xyouts,.05,.94,instrument,/normal xyouts,.95,.94,date_string,alignment=1.,/normal ;========================================================================== ; If other optional annotations are available, write them on the image ;========================================================================== if (strlen(pretitle) gt 0) then xyouts,.50,.97,pretitle,alignment=.5,/normal if (strlen(project) gt 0) then xyouts,.05,.97,project,/normal if (strlen(platform) gt 0) then xyouts,.95,.97,platform,alignment=1.,/normal if (strlen(supplement1) gt 0) then begin case (strupcase(supplement1)) of 'TRANSECT': out_supp1 = supplement1 + ' ' + strtrim(fix(this_transect),2) 'DURATION': begin header_size = size(header) first_dt = var_to_dt(header(13,0),header(11,0),header(12,0),$ header(0,0),header(1,0),header(2,0)) last_dt = var_to_dt(header(13,header_size(2)-1),header(11,header_size(2)-1),$ header(12,header_size(2)-1),header(0,header_size(2)-1),$ header(1,header_size(2)-1),header(2,header_size(2)-1)) dur = dt_duration(last_dt,first_dt)*24.*60. if (airborne) then begin append_String = ' MINUTES' endif else begin append_String = ' MIN STARE' endelse out_supp1 = strtrim(string((dur),format='(f6.2)'),2) + append_String end else: out_supp1 = supplement1 endcase xyouts,.05,.91,out_supp1,/normal endif if (strlen(supplement2) gt 0) then begin case (strupcase(supplement2)) of 'TRANSECT': out_supp2 = supplement2 + ' ' + strtrim(fix(this_transect),2) 'DURATION': begin header_size = size(header) first_dt = var_to_dt(header(13,0),header(11,0),header(12,0),$ header(0,0),header(1,0),header(2,0)) last_dt = var_to_dt(header(13,header_size(2)-1),header(11,header_size(2)-1),$ header(12,header_size(2)-1),header(0,header_size(2)-1),$ header(1,header_size(2)-1),header(2,header_size(2)-1)) dur = dt_duration(last_dt,first_dt)*24.*60. if (airborne) then begin append_string = ' MINUTES' endif else begin append_string = ' MIN STARE' endelse out_supp2 = strtrim(string((dur),format='(f6.2)'),2) + append_String end else: out_supp2 = supplement2 endcase xyouts,.95,.91,out_supp2,alignment=1.,/normal endif ;print,'=====MAKING IMAGE=======================' ;print,'num_recs = ',num_recs ;print,'average = ',average ;print,'data_recs = ',data_recs ;print,'device name = ',!d.name ;print,'screen_sample_style = ',screen_sample_style ;print,'PS_sample_style = ',ps_sample_style ;print,'max_scale = ',max_scale ;print,'min_scale = ',min_scale ;print,'scale_range = ',scale_range ;print,'bins = ',bins ;print,'bin_width = ',bin_width ;print,'airborne = ',airborne ;print,'beam elevation = ',header(7,0) ;print,'========================================' first_loop_jump_point: first_loop = 1. end_at_transect = 0b if (keyword_set(end_at)) then begin if (strpos(strupcase(end_at),'T') ne -1) then end_at_transect = 1b endif if ((strpos(strupcase(start_at),'T') ne -1) OR (end_at_transect)) then begin final_transect=last_header(29) if (this_transect ne final_transect) then begin next_transect = this_transect + transects endif else begin next_transect = first_header(29) endelse option1 = 'a) Next transect (#'+strtrim(fix(next_transect),2)+', ' openr,lun,datafile,/get_lun record=assoc(lun,fltarr(rec_len)) findtran,next_transect,lun,rec_len,recs_in_file,next_first_rec,next_last_rec close,lun free_lun,lun endif else begin option1 = 'a) Next image (#'+strtrim(fix(loop+1),2)+', ' next_first_rec = last_rec + 1 if (next_first_rec gt recs_in_file-1) then begin next_first_rec=0 num_recs = 512*average endif next_last_rec = next_first_rec + num_recs - 1 if (next_last_rec gt recs_in_file-1) then next_last_rec = recs_in_file-1 next_num_recs = next_last_rec - next_first_rec + 1 endelse next_num_recs = next_last_rec - next_first_rec + 1 if (average gt 1) then begin next_string = strtrim(next_first_rec,2)+' to '+$ strtrim(next_last_rec,2)+', '+$ strtrim(next_num_recs,2)+' records, averaging every '+$ strtrim(average,2)+')' endif else begin next_string = strtrim(next_first_rec,2)+' to '+$ strtrim(next_last_rec,2)+', '+$ strtrim(next_num_recs,2)+' records, with no averaging.)' endelse if (!d.name eq 'PS') then begin print,'Closing PS file.' device,/close set_plot,screen_type ps_image = ps_image + 1 endif main_menu: print,' ' if (alt_shift ne 0.) then begin print,'WARNING: Altitude-axes shifting turned on! (',alt_shift,' m)' endif if (range_shift ne 0.) then begin print,'WARNING: Range-axes shifting turned on! (',range_shift,' m)' endif print,'BSCAN Main Menu Options:' print,option1+' '+next_string print,'x) Create image in X-window' print,'b) Make PS file' print,'c) Change color-bar scale limits' print,'d) Left-right image reversal' print,'e) Change sampling method' if (range_flag) then begin print,'f) Change the range swath of data being displayed' print,'g) Altitude align the data' print,'h) Move range axis up/down with respect to image' endif else begin print,'f) Change the altitude swath of data being displayed' print,'g) Remove altitude alignment' print,'h) Move altitude axis up/down with respect to image' endelse print,'i) Optional annotation' print,'j) Time axis options' print,'k) Delete most recent window from screen' print,'l) Stop and make data available' print,'m) Pointer print,'n) Save/restore settings print,'o) Compute/display mean profile' print,'p) redraw current scene' print,'q) use different color table' print,'r) create a TIFF file' print,'s) change image size' print,'z) Quit BSCAN' answer = ' ' print,'Please select a choice. Enter a letter.' read,answer if (strupcase(answer) eq 'A') then begin loop = loop + 1 first_rec = next_first_rec last_rec = next_last_rec num_recs = next_num_recs print,'' goto,read_data_entry endif if (strupcase(answer) eq 'B') then begin ask12: ps_color_option=2 print,'Enter: print,'1) for no-color print,'2) for color read,ps_color_option if (ps_color_option lt 1) or (ps_color_option gt 2) then begin print,'You may only enter 1 or 2.' print,'Please try again.' goto,ask12 endif ask15: eps_option=0 print,'Enter: print,'1) for regular postscript print,'2) Encapsulated postscript read,eps_option if (eps_option lt 1) or (eps_option gt 2) then begin print,'You may only enter 1 or 2.' print,'Please try again.' goto,ask15 endif ask20: ps_option = 0 print,' ' print,'Postscript options:' print,'1) Portrait, top-half of page' print,'2) Portrait, bottom-half of page' print,'3) Landscape, full page' print,'4) Portrait, custom location & size' print,'5) Landscape, custom location & size' read,ps_option if (ps_option lt 1) or (ps_option gt 5) then begin print,'You may only enter 1 to 5.' print,'Please try again.' goto,ask20 endif if (ps_image eq 0) then begin ask21: answer = 0 print,' ' if (strlen(ps_path) eq 0) then begin print,'Currently, the PS file will be created in' print,'the directory you are running this from.' endif else begin print,'Current path: ',ps_path endelse print,'Keep this path?' print,'1) yes, keep the current path' print,'2) no, set a new path' read,answer if ((answer lt 1) or (answer gt 2)) then begin print,'You may only answer 1 or 2.' print,'Please try again.' goto,ask21 endif if (answer eq 2) then begin print,'Enter a new path (location to create PS file).' read,ps_path if ((!Version.os eq 'sunos') OR (!Version.os eq 'solaris')) then begin ; Append forward slash if necessary if (strmid(ps_path,strlen(ps_path)-1,1) ne '/') then begin ps_path = ps_path + '/' endif endif else begin ; Append backward slash if necessary if (strmid(ps_path,strlen(ps_path)-1,1) ne '\') then begin ps_path = ps_path + '\' endif endelse endif endif print,' ' if (strlen(ps_fn) gt 0) then begin print,'The last PS file you made was '+ps_fn endif else begin print,'This will be your first PS file this run of BSCAN.' endelse if (eps_option eq 2) then begin ps_file_exten = '.eps' endif else begin ps_file_exten = '.ps' endelse print,'This will be image number '+strtrim(ps_image,2)+' from this run.' if (strlen(strtrim(ps_image,2)) eq 1) then $ default_ps_fn = 'bscan00' + string(strtrim(ps_image,2))+ps_file_exten if (strlen(strtrim(ps_image,2)) eq 2) then $ default_ps_fn = 'bscan0' + string(strtrim(ps_image,2))+ps_file_exten if (strlen(strtrim(ps_image,2)) eq 3) then $ default_ps_fn = 'bscan' + string(strtrim(ps_image,2))+ps_file_exten ps_fn = default_ps_fn print,'Enter PS file name. (Default is '+default_ps_fn+')' read,ps_fn if (strlen(ps_fn) le 0) then begin ps_fn = ps_path + default_ps_fn endif else begin ps_fn = ps_path + ps_fn endelse enter_paper_size: if ((paper_size lt 1) or (paper_size gt 2)) then begin print,' ' print,'Select paper size.' print,'1) Letter' print,'2) Legal' read,paper_size if ((paper_size lt 1) or (paper_size gt 2)) then begin print,'Sorry, you may choose only 1 or 2.' goto,enter_paper_size endif endif if (ps_color_option eq 2) then begin print,'Color PS' print,' ' set_plot,'PS' device,filename=ps_fn if (eps_option eq 2) then begin print,'Set to Encapsulated postscript.' device,/color,/encapsulated,bits_per_pixel=8 endif else begin device,/color,bits_per_pixel=8 endelse endif else begin print,'non-Color PS' print,' ' set_plot,'PS' device,filename=ps_fn if (eps_option eq 2) then begin print,'Set to Encapsulated postscript.' device,/encapsulated,bits_per_pixel=8 endif else begin ; device,bits_per_pixel=8 endelse endelse print,'Creating PS file: ',ps_fn if ((ps_option eq 1) or (ps_option eq 2)) then begin device,/portrait landscape = 0b if (ps_option eq 1) then begin ; PORTRAIT-TOP print,'Portrait, top-half.' if (paper_size eq 1) then begin ; letter size print,'For letter-size paper.' device,yoffset=5.47,ysize=4.35,/inches endif else begin ; legal size print,'For legal-size paper.' device,yoffset=6.97,ysize=4.35,/inches endelse device,xoffset=0.75,xsize=7.00,/inches endif else begin ; PORTRAIT-BOTTOM print,'Portrait, bottom-half.' if (paper_size eq 1) then begin ; letter size print,'For letter-size paper.' device,yoffset=1.15,ysize=4.35,/inches endif else begin ; legal size print,'For legal-size paper.' device,yoffset=2.65,ysize=4.35,/inches endelse device,xoffset=0.75,xsize=7.00,/inches endelse endif else if (ps_option eq 3) then begin print,'Landscape, full-page.' device,/landscape landscape = 1b if (paper_size eq 1) then begin print,'For letter-size paper.' ; device,yoffset=10.425,/inches 3/7/96 device,yoffset=10.005,xsize=8.5625,/inches endif else begin print,'For legal-size paper.' device,yoffset=11.625,/inches endelse endif else if (ps_option eq 4) then begin print,'Portrait, custom location & sizing' device,/portrait landscape = 0b print,'Enter xsize in inches' read,custom_xsize print,'Enter ysize in inches ' read,custom_ysize print,'Enter xoffset in inches' read,custom_xoffset print,'Enter yoffset in inches ' read,custom_yoffset device,ysize=custom_ysize,xsize=custom_xsize,/inches device,yoffset=custom_yoffset,xoffset=custom_xoffset,/inches endif else if (ps_option eq 5) then begin print,'Landscape, custom location & sizing' device,/landscape landscape = 1b print,'Enter xsize in inches' read,custom_xsize print,'Enter ysize in inches ' read,custom_ysize print,'Enter xoffset in inches' read,custom_xoffset print,'Enter yoffset in inches ' read,custom_yoffset device,ysize=custom_ysize,xsize=custom_xsize,/inches device,yoffset=custom_yoffset,xoffset=custom_xoffset,/inches endif print,' ' goto,sampling_inquiry endif if (strupcase(answer) eq 'C') then begin print,'Enter new min scale value.' read,min_scale print,'Enter new max scale value.' read,max_scale ; wdelete goto,main_menu endif if (strupcase(answer) eq 'D') then begin lr_flag = lr_flag * (-1) header = rotate(header,7) ; wdelete goto,sample_entry endif if (strupcase(answer) eq 'E') then begin ; Flag sample style screen_sample_style=flag PS_sample_style=flag goto,sampling_inquiry endif if (strupcase(answer) eq 'F') then begin if (altitude_flag) then begin print,'Enter new min altitude value (in meters ASL).' read,min_altitude print,'Enter new max altitude value (in meters ASL).' read,max_altitude altitude = [min_altitude,max_altitude] if (min_altitude gt max_altitude) then altitude = shift(altitude,1) endif if (range_flag) then begin print,'Enter new min range value (in meters from platform).' read,min_range print,'Enter new max range value (in meters from platform).' read,max_range range = [min_range,max_range] if (min_range gt max_range) then range = shift(range,1) endif ; wdelete goto,vertical_extract_entry endif if (strupcase(answer) eq 'G') then begin if (altitude_flag) then begin altitude_flag = 0b range_flag = 1b endif else begin altitude_flag = 1b range_flag = 0b endelse if (altitude_flag) then begin print,'Enter new min altitude value.' read,min_altitude print,'Enter new max altitude value.' read,max_altitude altitude = [min_altitude,max_altitude] endif if (range_flag) then begin print,'Enter new min range value.' read,min_range print,'Enter new max range value.' read,max_range range = [min_range,max_range] endif ; wdelete goto,vertical_alignment_entry endif if (strupcase(answer) eq 'H') then begin if (altitude_flag) then begin print,' ' print,'This option shifts altitude axes up or down with respect to' print,'the data. Used when data file altitudes are in systematic error.' print,'Positive value moves axes down. Negative value moves axes up.' print,'Current altitude axes shift = ',alt_shift,' m' print,'Enter number of meters to shift altitude axes.' read,alt_shift endif if (range_flag) then begin print,' ' print,'This option shifts range axes toward or away from the platform ' print,'and data. Used when data file altitudes are in systematic error.' print,'Positive value increases distance to platform. Negative value ' print,'moves data closer to platform.' print,'Current range axes shift = ',alt_shift,' m' print,'Enter number of meters to shift range axes.' read,range_shift endif goto,vertical_alignment_entry endif if (strupcase(answer) eq 'I') then begin supp_text_menu: print,' ' print,' CURRENT SETTING' print,' ===============' print,'1) Pre-title (top-center) '+pretitle print,'2) Project name (top-left) '+project print,'3) Platform name (top-right) '+platform print,'4) Supplement 1 (below lidar name on left) '+supplement1 print,'5) Supplement 2 (below date on right) '+supplement2 print,'6) Field (color bar title) '+field print,'7) Instrument name '+instrument print,'8) Return to BSCAN main menu print,'Please select 1 - 8.' read,answer if ((answer lt 1) or (answer gt 8)) then begin print,'You may answer only 1 - 8.' print,'Please try again' goto,supp_text_menu endif if (answer eq 1) then begin print,'Enter the pre-title (top-center)' read,pretitle endif if (answer eq 2) then begin print,'Enter the project name (top-left)' read,project endif if (answer eq 3) then begin print,'Enter the platform name (top-right)' read,platform endif if (answer eq 4) then begin print,'Enter supplement 1 (bottom-left)' read,supplement1 endif if (answer eq 5) then begin print,'Enter supplement 2 (bottom-right)' read,supplement2 endif if (answer eq 6) then begin print,'Enter field name and units for color-bar ' read,field endif if (answer eq 7) then begin print,'Enter instrument name ' read,instrument endif if (answer eq 8) then goto,main_menu goto,start_graphics endif if (strupcase(answer) eq 'J') then begin time_questions: answer=0 print,' ' print,'The time axis is always below the image.' print,'and can have two rows of labels below it.' if (dual_time) then begin print,'1) Dual-time on lower axis: on' endif else begin print,'1) Dual-time on lower axis: off' endelse print,'2) Upper-row time-tic axis label (right-side) : ',upper_row_time_label print,'3) Lower-row time-tic axis label (right-side) : ',lower_row_time_label print,'4) Upper-row time-tic hour-adjustment: ',upper_row_hour_adj print,'5) Lower-row time-tic hour-adjustment: ',lower_row_hour_adj print,'6) Number of seconds between tick marks: ',maj_tim_tic*60 print,'Please enter 1-6.' read,answer if ((answer ge 1) or (answer le 5)) then begin if (answer eq 1) then begin if (dual_time) then begin dual_time = 0b endif else begin dual_time = 1b endelse endif if (answer eq 2) then begin print,'Enter upper-row time-tic axis label (i.e. UTC, CDT, MST).' read,upper_row_time_label endif if (answer eq 3) then begin print,'Enter lower-row time-tic axis label (i.e. UTC, CDT, MST).' read,lower_row_time_label endif if (answer eq 4) then begin print,'Enter upper-row time-tic hour adjustment (a + or - whole number).' read,upper_row_hour_adj endif if (answer eq 5) then begin print,'Enter lower-row time-tic hour adjustment (a + or - whole number).' read,lower_row_hour_adj endif if (answer eq 6) then begin print, "How many seconds would you like between tick marks?" read, maj_tim_tic maj_tim_tic = maj_tim_tic/60 endif ; wdelete goto, start_graphics endif goto, main_menu endif if (strupcase(answer) eq 'K') then begin ; Remove most recent window from screen wdelete goto,main_menu endif if (strupcase(answer) eq 'L') then begin ; Stop and make data available print,'' print,'You may now work with BSCAN variables interactively.' print,'' print,'In IDL type help,header' print,' help,data' print,'' print,'In PV-WAVE type info,header' print,' info,data' print,'' print,'In either IDL or PV-WAVE type .con to continue BSCAN.' print,'' !p.thick=1 stop !p.thick=2 goto,main_menu endif if (strupcase(answer) eq 'M') then begin ; pointer print,'' print,'Sorry, this option installed yet.' goto,main_menu endif if (strupcase(answer) eq 'N') then begin ; save/restore settings ask13: print print,'1) Save current settings' print,'2) Restore other settings' print,'3) Return to main menu' print,'4) Tell me about save/restore settings' print,'Please choose 1, 2, 3 or 4' read,answer if ((answer lt 1) or (answer gt 4)) then begin print,'You may choose only 1, 2, 3 or 4.' print,'Please try again.' goto,ask13 endif if (answer eq 1) then begin ; SAVE SETTINGS altitude = [min(vertical2),max(vertical2)] range = [min(vertical2),max(vertical2)] print print,'Please choose' print,'1) to write to BSCAN.SET' print,'2) to specify your own set file name' print,'3) return to main menu without saving settings' answer = '0' read,answer if (answer eq 1) then set_file='BSCAN.SET' if (answer eq 2) then begin print print,'Please enter set file name:' read,set_file endif if ((answer lt 1) or (answer gt 2)) then goto,main_menu print print,'Writing: ',set_file openw,lun,set_file,/get_lun printf,lun,pretitle printf,lun,ps_path printf,lun,platform printf,lun,project printf,lun,supplement1 printf,lun,supplement2 printf,lun,dual_time printf,lun,upper_row_time_label printf,lun,lower_row_time_label printf,lun,upper_row_hour_adj printf,lun,lower_row_hour_adj printf,lun,min_scale printf,lun,max_scale printf,lun,altitude_flag printf,lun,altitude printf,lun,range_flag printf,lun,range printf,lun,screen_sample_style printf,lun,PS_sample_style printf,lun,range_shift printf,lun,alt_shift printf,lun,color_table_filename close,lun free_lun,lun goto,main_menu endif if (answer eq 2) then begin ; RESTORE SETTINGS print print,'Please choose ' print,'1) to read from BSCAN.SET' print,'2) to read from a set file you specify' print,'3) to return to the main menu' answer = 'x' read,answer if (answer eq 1) then set_file='BSCAN.SET' if (answer eq 2) then begin print print,'Please enter a set file name' read,set_file endif if ((answer lt 1) or (answer gt 2)) then goto,main_menu err = findfile(set_file,count=count) if (count eq 0) then begin print,'Set file: '+set_file+' cannot be found.' goto,main_menu endif altitude = [min(vertical2),max(vertical2)] range = [min(vertical2),max(vertical2)] color_table_filename=' ' print,'Reading '+set_file openr,lun,set_file,/get_lun readf,lun,pretitle readf,lun,ps_path readf,lun,platform readf,lun,project readf,lun,supplement1 readf,lun,supplement2 readf,lun,dual_time readf,lun,upper_row_time_label readf,lun,lower_row_time_label readf,lun,upper_row_hour_adj readf,lun,lower_row_hour_adj readf,lun,min_scale readf,lun,max_scale readf,lun,altitude_flag readf,lun,altitude readf,lun,range_flag readf,lun,range readf,lun,screen_sample_style readf,lun,PS_sample_style readf,lun,range_shift readf,lun,alt_shift readf,lun,color_table_filename close,lun free_lun,lun goto,vertical_alignment_entry endif if (answer eq 4) then begin print,'' print,'Currently, BSCAN saves 13 scene settings into an ASCII' print,'file named '+set_file+' in your current directory.' print,'The settings include: PS path; pre-title; platform; project;' print,'supplement1; supplement2; dual time flag (on or off); upper' print,'and lower row time label and hour adjustment; max and min print,'color bar scale.' print,'' print,'Press return to continue...' answer = '' read,answer goto,main_menu endif endif if (strupcase(answer) eq 'O') then begin ; meanprof,header,data print,'Sorry, this option not installed yet.' goto,main_menu endif if (strupcase(answer) eq 'P') then begin goto,start_graphics endif if (strupcase(answer) eq 'Q') then begin color_table_filename = ' ' print,'Enter color table file name. print,'(Include path if file is not in current directory.)' read,color_table_filename err = findfile(color_table_filename,count=count) if (count eq 0) then begin print,'Color table file: '+color_table_filename+' cannot be found.' goto,main_menu endif load_ct,color_table_filename,bins,RGB_array goto,main_menu endif if (strupcase(answer) eq 'R') then begin byte_array = TVRD(0,0,sx,sy) RGB_array=RGB_array*256L ;=================================================== ; red_bytes = byte_array ; grn_bytes = byte_array ; blu_bytes = byte_array ; for i = 0,(n_elements(byte_array)-1) do begin ; red_bytes(i)=RGB_array(0,byte_array(i)) ; grn_bytes(i)=RGB_array(1,byte_array(i)) ; blu_bytes(i)=RGB_array(2,byte_array(i)) ; endfor ; RGB_bytes = bytarr(sx,sy,3) ; RGB_bytes(*,*,0)=red_bytes ; RGB_bytes(*,*,1)=grn_bytes ; RGB_bytes(*,*,2)=blu_bytes ; tiff_status = DC_WRITE_TIFF('test.tif',RGB_bytes,$ ; Class='RGB Full Color') ;================================================= tiff_status = DC_WRITE_TIFF('test.tif',byte_array,$ Palette=RGB_array,Class='Palette Color',Compress='None') if (tiff_status ne 0) then begin print,'tiff write status = ',tiff_status endif else begin print,'Successful TIFF write.' endelse goto,main_menu endif if (strupcase(answer) eq 'S') then begin print,'What do you what the X dimension of the resulting image to be?' read,x_dim print,'What do you what the Y dimension of the resulting image to be?' read,y_dim goto,main_menu endif if (strupcase(answer) eq 'X') then goto,sample_entry if (strupcase(answer) ne 'Z') then begin print,'Sorry, that is not a main menu option.' print,' ' goto,main_menu endif retall end