PRO DRAW, z, a ; Create indices into the colortable clr = WoColorConvert(INDGEN(256)) ; Grab device coordinates of cursor position CURSOR, x, y, /Device z = [x,y] ; Execute following until mouse button released WHILE !Mouse.button GT 0 DO BEGIN ; Get updated cursor position CURSOR, x, y, /Device, /Change ; Plot line based on initial cursor position ; and last curor position z = [[z],[x,y]] PLOTS, z, /Device, Color=clr(2) ENDWHILE ; Find unique cases of z z = UNIQN(TRANSPOSE(z)) ; Get data coordinates of line plotted; convert from device to data coordinates IF PARAM_PRESENT(a) THEN BEGIN a = (TRANSPOSE(CONVERT_COORD(TRANSPOSE(z),/Device,/To_data)) )(*,0:1) ENDIF END PRO smooth5, Filename=filename ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Read in data file ; Any variable that is not a float variable, we need to ; declare the data type. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; date1 = {!DT} aruid = INTARR(1) locx = LONARR(1) & locy = LONARR(1) IF KEYWORD_SET(filename) THEN filename=filename ELSE $ filename = 'monk54_16jan.txt' ; Change Dt_Template to [5, -1] because the date is now ordered with the year first ; Add filter keyword so we filter out the '|' character between each column status = DC_READ_FREE('c:\1martin\ARTSdata\current_smoothing\data.txt', batch, date1, date1, animlid, aruid,$ locx, locy, bearing, maxsignal, /Column, Resize=INDGEN(8)+1, $ Dt_template=[5,-1], Nskip=2, Filter=["|"]) READ,'Enter year:',year READ,'Enter month, valid values are 1-12:',month READ,'Enter start and end day, valid values are 1-31 (e.g. 16,17):',sday, eday READ,'Enter start hour and end hour, valid values are 0-23 (e.g. 0, 22):',shour, ehour ; Compute julian start and end date sdate = var_to_dt(year,month,sday,shour) edate = var_to_dt(year,month,eday,ehour) ; Find indices based on date/time range the user specified ; and find unique days based on indices returned ind = WHERE(date1(*).julian GE sdate.julian AND date1(*).julian LE edate.julian) date_uniq = UNIQUE(date1(ind).day) ; Find unique tower locations items = UNIQUE(aruid) items = STRING(STRTRIM(items,2)) ; Set up a color table and create color indices TEK_COLOR clr = WoColorConvert(INDGEN(256)) flag = 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Cycle through each tower-day combinations for the given file ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FOR c=0l, n_elements(date_uniq)-1 DO BEGIN FOR i=0l, n_elements(items)-1 DO BEGIN ; Find indices for given day/tower combo uniq_ind = WHERE(aruid EQ items(i) AND date1.day EQ date_uniq(c), count) IF count EQ 0 THEN GOTO, done ; Subset bearing and date data for given tower/day combo brng_plot = bearing(uniq_ind) date_plot = date1(uniq_ind) ; Find x loc, y loc and animal id for given day/tower combo locx_n = STRING(STRTRIM(locx(uniq_ind(0)),2)) locy_n = STRING(STRTRIM(locy(uniq_ind(0)),2)) animlid_n = STRING(STRTRIM(animlid(uniq_ind(0)),2), Format='(A3)') ; Use hardware fonts for a nicer look !P.font = 0 ; Compute range of X data so can create ; gridlines at 30 degree increments maxy = MAX(brng_plot, Min=miny) xrang = (maxy-miny)/30.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Create PLOT ; Plot annotation and axes using specified date range ; Disable plotting data and use exact scaling for X and Y axes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; WINDOW,0, Xs=1024, Ys=756, Title='Tower '+items(i)+' title = 'blac=95, gre=105, blu=110, pur=115, pin=120, red=125, yel>125' PLOT, date_plot, brng_plot, Psym=1, $ Color=clr(0), Background=clr(1), $ Title=title, XStyle=1, $ Ptl_color=clr(0), Pxt_color=clr(0), $ Ticklen=.5, Yticks=xrang, Ystyle=1, $ /Nodata ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Overplot data based on maxsignal values ; Maxsignal color: ; -9000 to -9500 black ; -9501 to -10000 dark gray ; -10001 to -10500 green ; -10501 to -11000 blue ; -11001 to -11500 purple ; -11501 to -12000 pink ; -12001 to -12500 red ; -12501 to -15000 yellow ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; lower_limit = [-9500.0, -10000, -10500, -11000, -11500, -12000,- 12500, -15000] up_limit = [-9000.0, -9501, -10001, -10501, -11001, -11501, -12001, -12501] colors = WoColorConvert([0, 14, 3, 4, 12, 13, 2, 7]) FOR max_cnt=0l, 7 DO BEGIN maxsig_ind = WHERE(maxsignal GE lower_limit(max_cnt) AND maxsignal LE up_limit(max_cnt), Count) IF (count GT 0) THEN $ OPLOT, date_plot(maxsig_ind), brng_plot(maxsig_ind), Psym=2, $ Color=colors(max_cnt) ENDFOR ; Set font back to default !P.font = -1 ; Initalize arrays to something big so we can fill ; them with data values returns from the DRAW procedure dates_n = STRARR(1000) minutes_n = STRARR(1000) pts_n = STRARR(1000) indx = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Execute DRAW procedure until user enters "q" from keyboard or ; enter "c" to continue to next day/tower combo or ; enter "n" to draw another line ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; REPEAT BEGIN ; Have the user select their data line DRAW, z, pts ; Add the Julian offset for the plot JulianA = pts(*,0) + !Pdt.Dt_Offset(0) ; Convert to a new date/time var dta = JUL_TO_DT(JulianA) ; Convert date/time and bearing data to strings DT_TO_STR, dta, dates, minutes, Date_fmt=1, Time_fmt=-1 minutes = STRING(minutes, Format='(A8)') pts = STRCOMPRESS(STRING(pts(*,1),Format='(D5.1)'),/Remove_all) PRINT, 'Select "n" to draw another line\012Select "c" to continue to next tower/day combination\012Select "q" to quit the program' a = GET_KBRD(1) IF STRLOWCASE(a) EQ 'n' THEN PRINT,'Create next data line' IF STRLOWCASE(a) EQ 'q' THEN BEGIN WDELETE, 0 RETURN ENDIF ; Check size of data returned len = N_ELEMENTS(dates) ; Assign values dates_n(indx) = dates minutes_n(indx) = minutes pts_n(indx) = pts ;Free memory of the date and data arrays dates=0b times=0b minutes=0b indx = indx + len ; Increase size of array if needed IF indx GT 600 THEN BEGIN dates_n = [dates_n, STRARR(1000)] minutes_n = [minutes_n, STRARR(1000)] pts_n = [pts_n, STRARR(1000)] ENDIF ENDREP UNTIL STRLOWCASE(a) EQ 'c' WDELETE,0 dates_n = dates_n(0:indx-1) minutes_n = minutes_n(0:indx-1) pts_n = pts_n(0:indx-1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Write out the date for each tower to a file ; If first time through loop then we need to write out variable names ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF flag EQ 1 THEN BEGIN ; Convert date/time var format DT_TO_STR, date_plot(0), d, t, Date_fmt = 2 d = STRSUBST(d, '/', '_', /Global) filename = 'c:\1martin\ARTSdata\current_smoothing\output_'+d+'.dat'+'' OPENW, unit, 'c:\1martin\ARTSdata\current_smoothing\output_'+d+'.dat'+'', /Get_lun, /Append PRINTF, unit, 'date', 'time', 'aruid', 'animalid', 'locx', 'locy', $ 'bearing', Format='(7(A10, ","))' flag = 0 FOR cnt=0l, n_elements(dates_n)-1 DO $ PRINTF, unit, dates_n(cnt), minutes_n(cnt), items(i), animlid_n, $ locx_n, locy_n, pts_n(cnt), Format='(7(A10, ","))' FREE_LUN, unit ENDIF ELSE IF flag EQ 0 THEN BEGIN OPENU, unit, 'c:\1martin\ARTSdata\current_smoothing\output_'+d+'.dat'+'', /Get_lun, /Append FOR cnt=0l, n_elements(dates_n)-1 DO $ PRINTF, unit, dates_n(cnt), minutes_n(cnt), items(i), animlid_n, $ locx_n, locy_n, pts_n(cnt), Format='(7(A10, ","))' FREE_LUN, unit ENDIF done: ENDFOR ENDFOR END