Pro hlz_to_utim, doy, year, lowlat=lowlat, oval=oval, debug=debug, $ entrycmd=entrycmd, exitcmd=exitcmd ; ;NAME: ; hlz_to_utim ;PURPOSE: ; To compute magnetic latitude of the orbit and detremine the times ; of high latitude and passage through the ovals and create a utim file ; to set/clear flags upon entry and exit of the zone. ; ;SAMPLE CALLING SEQUENCE: ; hlz_to_utim, DOY, year, lowlat=45, oval=[50,70] ;INPUTS: ; DOY - day of year (string) ; year - year (string) ; lowlat - lower limit for high latitude region (default = 40 degrees mag) ; oval - array of low and upper magnetic latitude limits for oval ; boundaries (default = [50,70]) ; entrycmd - optional string for command to execute when entering the oval ; exitcmd - optional string for command to execute when entering the oval ; Assumes North magnetic pole at latitude = 78.5 and longitude = -70 ;OUTPUTS ; Creates utim file in the format HLZ_yydoy.utim into the directory /tsw/obs/utim ;HISTORY: ; Written 29-Jun-98 by JFC ; Derived from high_mag_lat.pro by TDT ; 06-May-99 TDT Converted to 00:00 - 24:00 days, added entrycmd, exitcmd ;# version='hlz_to_utim Vers. 1.1' if not keyword_set(entrycmd) then entrycmd = 'ICSQREG (REG=$HLZ, VAL=1)' if not keyword_set(exitcmd) then exitcmd = 'ICSQREG (REG=$HLZ, VAL=0)' clear_utplot thetam=(90-78.5)/!radeg phim=-70./!radeg if (not keyword_set(lowlat)) then lowlat=40. if (not keyword_set(oval)) then oval=[50.,70.] if (not keyword_set(debug)) then debug=0 t1=doytim2ints(string(doy)+' 00:00') t2=doytim2ints(string(doy)+' 23:59:59') times=timegrid(t1,t2,minutes=1,/string) saa=gtt_orbit(times,'is_saa') wsaa=where(saa gt 0) lat=gtt_orbit(times, 'lat') lon=gtt_orbit(times, 'lon') phi=lon/!radeg theta=(90-lat)/!radeg if (debug) then begin utplot,times,lat & wait,2 utplot,times,theta & wait,2 endif dot=cos(theta)*cos(thetam)+sin(theta)*sin(thetam)*(cos(phi)*cos(phim)+sin(phi)*sin(phim)) latm=90.-acos(dot)*!radeg if (debug) then begin utplot,times,latm outplot,times,lat,line=1 & wait,2 endif w=where(abs(latm) gt lowlat) highm=0*lat & highm(w)=1 w=where((abs(latm) gt oval(0)) and (abs(latm) lt oval(1))) ovalm=0*lat & ovalm(w)=1 filename=string('HLZ_'+strcompress(string(year),/remove_all)+strcompress(string(doy),/remove_all)+'.utim') dir='/tsw/obs/utim/' ;dir='/disk02/people/covingto/idl/' ovalentrylat=fltarr(100) ovalentrytime=strarr(100) ovalleavelat=fltarr(100) ovalleavetime=strarr(100) timestime=strarr(n_elements(times)) timestime=strmid(times,11,8) openw,1,dir+filename printf,1,'# HLZ avoidance for: ',strcompress(string(doy),/remove_all),strcompress(string(year)) printf,1,'#' printf,1,'# Generated by hlz_to_utim.pro' printf,1,'#' ;plot,ovalm,yrange=[0,1.5] j=0 k=0 for i = 0, n_elements(ovalm)-2 do begin if(ovalm(i) eq 0) then begin if(ovalm(i+1) eq 1) then begin ovalentrylat(k)=latm(i+1) ovalentrytime(k)=timestime(i+1) ; print,'k: ',k,'entry: ',ovalentrylat(k),' ',ovalentrytime(k) k=k+1 end end if(ovalm(i) eq 1) then begin if((ovalm(i+1) eq 0) and (k ne 0)) then begin j=j+1 ovalleavelat(j-1)=latm(i) ovalleavetime(j-1)=timestime(i) ; print,'j: ',j-1,'leave: ',ovalleavelat(j-1),' ',ovalleavetime(j-1) end end endfor for z = 0, j-1 do begin print,'entry: ',ovalentrylat(z),' ',ovalentrytime(z) printf,1,'ABS ',ovalentrytime(z),' CMD ',entrycmd print,'leave: ',ovalleavelat(z),' ',ovalleavetime(z) printf,1,'ABS ',ovalleavetime(z),' CMD ',exitcmd printf,1,'#' endfor print,"Created utim file: ",dir+filename close,1 return end