PRO linex7,inFil,startHou,startMinut,startSecon,endHou,endMinut,endSecon,sit,forma,sequentia,postscrip,bxmi,bxma,bymi,byma,bzmi,bzma,tic,intervalHou,intervalMinut,intervalSecon
;This program is run by ftpsri.sh at :00, :15, :30, and :45 past every hour of every day.
;It inputs Augsburg format ASCII files and creates line plots of the raw MACCS Iridium data.
;This program modified by Jake Kern and Ryan Cobian 6/2/99
; MODIFIED BY Mark Engebretson July 14, 2004 for Y2K and huge data files.
; MODIFIED BY Michael Murphy August 1, 2007 to include Nain and Cape Dorset accomidations
; MODIFIED BY Jesse Docken August 16, 2007 to make it command-line friendly
; MODIFIED BY Erik Johnson August 17, 2007 to fix some minor bugs
; MODIFIED BY Erik Johnson August 31, 2007 to output .png line plot files
common aa, idoc,lenh,issec,dtime,x,y,z
common bb,MINVALx,MINVALy,MINVALz,MAXVALx,MAXVALy,MAXVALz
common cc,esca
common dd,inFile,startHour,startMinute,startSecond,endHour,endMinute,endSecond,site,format,sequential,postscript,bxmin,bxmax,bymin,bymax,bzmin,bzmax,tick,intervalHour,intervalMinute,intervalSecond
inFile = inFil
startHour = startHou
startMinute = startMinut
startSecond = startSecon
endHour = endHou
endMinute = endMinut
endSecond = endSecon
site = sit
format = forma
sequential = sequentia
postscript = postscrip
bxmin = bxmi
bxmax = bxma
bymin = bymi
bymax = byma
bzmin = bzmi
bzmax = bzma
tick = tic
intervalHour = intervalHou
intervalMinute = intervalMinut
intervalSecond = intervalSecon
IDOC = LONARR(24)
SETUP,IDATUNIT,lab
END
PRO SETUP,IDATUNIT,lab
common aa;, idoc,lenh,issec,dtime,x,y,z
common bb;,MINVALx,MINVALy,MINVALz,MAXVALx,MAXVALy,MAXVALz,tick
common cc;,esca
common dd;,inFile,startHour,startMinute,startSecond,endHour,endMinute,endSecond,site,format,sequential,postscript,bxmin,bxmax,bymin,bymax,bzmin,bzmax,tick,intervalHour,intervalMinute,intervalSecond
;IDATFILNM =
;This first widget allows user to specify time range of plot
;and it contains an option for sequential plotting and an option
;an option for postcripts.
PRINT,' Lineplot Input Routine'
PRINT,' '
;desc = [ $
; '0, Label, Lineplot Routine, center', $
; '1, Base,, Row', $
; '0, integer,0, Label_left = Start Hour:, width=3, tag=hour', $
; '2, integer,0, Label_left = Start Minute:, width=3, tag=iminute', $
; '1, Base,, Row', $
; '0, integer,24, Label_left = End Hour:, width=3, tag=endhour', $
; '2, integer,0, Label_left = End Minute:, width=3,column, tag=endminute', $
; '1, Base,, Row', $
; '0, bUTTON, Asci|Raw Binary|Clean Binary, Frame, Label_Top=File Type,exclusive,set_value=0, tag=bin', $
; '2, button, Single File|Multiple Files, Label_Top=Files, exclusive, set_value=0, frame, tag=filnum',$
; '1, Base,, Row', $
; '0, button, No|Yes,Frame,Label_Top=Sequential Plots, exclusive, set_value=0,tag=seq',$
; '1, Base,,Row',$
; '0, button, No|Yes,Frame,Label_Top=Postscripts, exclusive, set_value=1, tag=pst',$
; '1, Base,, Row', $
; '0, Button, OK, Quit , tag = ok', $
; '2, Button, Cancel, quit, tag=endsetup']
;atitle='Lineplot INPUT'
; a=cw_form(desc, /column,title= atitle)
; if (a.endsetup eq 1) then begin
; goto, endsetup
; endif
esca=1
; bin=format
; seq=sequential
; pst=postscript
; ihour=startHour
; imin=startMinute
issec= 0.0
ISSEC = ((startHour*3600) + (startMinute*60))
endhour=endHour
endminute=endMinute
lenh=0.0
lenh=(endhour +(endminute/60.)) - (issec/3600.)
tick = 12 ;First plot always contains 12 ticks
minvalx =
minvaly = ;x,y,and z min and max values are null to start(they are autoscaled).
minvalz =
maxvalx =
maxvaly =
maxvalz =
;idatfil= findfile('/Volumes/physics_data/Ftp/MACCS_DATA/AugASCII/CD/2007ir/*.*')
endi=size(idatfil)
if 1 eq 1 then begin
; idatfilnm=dialog_pickfile (path='/Volumes/physics_data/Ftp/MACCS_DATA/AugASCII/CD/2007ir/')
OPENR,IDATUNIT,inFile,/GET_LUN
DATREAD,IDATUNIT,PREV,lab
free_lun,IDATUNIT
esc = 1
IF sequential eq 0 then begin
WHILE esc ge 1 DO BEGIN
DPLOT,PWR,TIMER,LAB
free_lun,IDATUNIT
;This widget appears if user does not select sequential
;plotting. x,y,and z min and max values as well as the
;time range and number of ticks can be set manually.
;desc = [ $
; '0, Label, Lineplot Routine, center', $
; '1, Base,, Row', $
; '0, float,0, Label_left = Start Hour:, width=3, tag=hour', $
; '2, integer,0, Label_left = Start Minute:, width=3, tag=iminute', $
; '1, Base,, Row', $
; '0, float,24, Label_left = End Hour:, width=3, tag=endhour', $
; '2, integer,10, Label_left = End Minute:, width=3,column, tag=endminute', $
; '1, Base,, Row', $
; '0, text,, Label_left = BXmin:, width=4,tag=bxmin',$
; '2, text,, Label_left = BXmax:, width=4, tag=bxmax',$
; '1, Base,,Row',$
; '0, text,,Label_left = BYmin:, width=4, tag=bymin',$
; '2, text,, Label_left = BYmax:, width=4, tag=bymax',$
; '1, Base,,Row',$
; '0, text,,Label_left = BZmin:, width=4, tag=bzmin',$
; '2, text,, Label_left = BZmax:, width=4, tag=bzmax',$
; '1, Base,,Row',$
; '0, integer,5, Label_left = Xticks:, width=4, tag=tick',$
; '1, Base,,Row',$
; '0, Button, OK, Quit , tag = ok', $
; '2, Button, Quit, quit, tag=endsetup']
;atitle='Lineplot INPUT'
; a=cw_form(desc, /column,title= atitle)
; if (a.endsetup eq 1) then begin
; goto, endsetup
; endif
esca=1
; intvlhr=0
; intervalMinute=0
; intvlsec=0
esc=1
; ihour=startHour
; imin=startMinute
issec= 0.0
ISSEC = ((startHour*3600) + (startMinute*60))
endhour=endHour
endminute=endMinute
lenh=0.0
lenh=(endhour +(endminute/60.)) - (issec/3600.)
MINVALx = bxmin
MAXVALx = bxmax
MINVALy = bymin ;Here x,y,z min and max values can be set manually in widget.
MAXVALy = bymax
MINVALz = bzmin
MAXVALz = bzmax
tick = tick
ENDWHILE
endif else begin
;This widget appears if the user chooses sequential
;plotting. A start and end time is chosen and an interval
;is selected(interval can be as small as one second).
free_lun,IDATUNIT
;desc = [ $
; '0, Label, Lineplot Routine, center', $
; '1, Base,, Row', $
; '0, float,0, Label_left = Start Hour:, width=3, tag=hour', $
; '2, integer,0, Label_left = Start Minute:, width=3, tag=iminute', $
; '4, integer,0, Label_left = Start Second:, width=3, tag=isecond', $
; '1, Base,, Row', $
; '0, float,24, Label_left = End Hour:, width=3, tag=endhour', $
; '2, integer,0, Label_left = End Minute:, width=3, tag=endminute', $
; '4, integer,0, Label_left = End Second:, width=3, tag=endsecond', $
; '1, Base,, Row', $
; '0, text,, Label_left = BXmin:, width=4,tag=bxmin',$
; '2, text,, Label_left = BXmax:, width=4, tag=bxmax',$
; '1, Base,,Row',$
; '0, text,,Label_left = BYmin:, width=4, tag=bymin',$
; '2, text,, Label_left = BYmax:, width=4, tag=bymax',$
; '1, Base,,Row',$
; '0, text,,Label_left = BZmin:, width=4, tag=bzmin',$
; '2, text,, Label_left = BZmax:, width=4, tag=bzmax',$
; '1, Base,,Row',$
; '0, integer,8, Label_left = Xticks:, width=3, tag=tick',$
; '1, Base,,Row',$
; '0, integer,0, Label_left = Interval(mins), width=3, tag=intvlmin', $
; '2, integer,0, Label_left = Interval(secs), width=3,tag=intvlsec',$
; '4, integer,0, Label_left = Interval(hours), width=3, tag=intvlhr',$
; '1, Base,, Row', $
; '0, Button, OK|Quit, Frame, Label_Top=Graph,exclusive,set_value=1, tag=esca', $
; '1, Base,,Row',$
; '0, Button, OK, Quit , tag = ok']
;atitle='Lineplot INPUT'
; a=cw_form(desc, /column,title= atitle)
;esca=0
;intvlhr=0
;intvlmin=0
;intvlsec=0
;esca=a.esca
;intvlhr=a.intvlhr
;intvlmin=a.intvlmin
;intvlsec=a.intvlsec
;isecond=a.isecond
;endsecond=a.endsecond
;ihour=startHour
;imin=startMinute
issec= 0.0
ISSEC = ((startHour*3600) + (startMinute*60))+startSecond
; endhour=endHour
; endminute=endMinute
lenh=0.0
lenh=(endhour +(endminute/60.)+(endSecond/3600.)) - (issec/3600.)
MINVALx = BXmin
MAXVALx = BXmax
MINVALy = BYmin ;Here x,y,z min and max values can be set manually in widget.
MAXVALy = BYmax
MINVALz = BZmin
MAXVALz = BZmax
; tick = tick
DPLOT,PWR,TIMER,LAB
endelse
endif else begin
for i=2, endi(3)-1 do begin
inFile=idatfil(i)
OPENR,IDATUNIT,inFile,/GET_LUN
DATREAD,IDATUNIT,PREV,lab
free_lun,IDATUNIT
DPLOT,PWR,TIMER,LAB
free_lun,IDATUNIT
endfor
endelse
endsetup:
END
PRO DATREAD,IDATUNIT,PREV,lab
common aa;, idoc,lenh,issec,dtime,x,y,z
common bb;,MINVALx,MINVALy,MINVALz,MAXVALx,MAXVALy,MAXVALz,tick
common cc;,esca
common dd;,inFile,startHour,startMinute,startSecond,endHour,endMinute,endSecond,site,format,sequential,postscript,bxmin,bxmax,bymin,bymax,bzmin,bzmax,tick,intervalHour,intervalMinute,intervalSecond
if format ne 0 then begin
; set the keyword raw to 1 for raw maccs and to 2 for raw gsc
; x and y are the byte dimensions of the file. The order for the different
; types is raw maccs, raw gsc, cleaned maccs, cleaned gsc, 5 sec, and 1 min
; (the raw files do not have fixed length)
x = [35, 21, 28, 15, 15, 14]
y = [00, 00, 86400L, 86400L, 17280L, 1440L]
sizes = [00, 00, 2419200L, 1296000L, 259200L, 20160L]
if format eq 1 then raw=1 else raw = 0
; Open file and get file size
;This section determines file name and year/day from the binary file's name
dottest= ' '
dotcount=0
While dottest ne "." do begin
dottest= strmid(inFile, dotcount,1)
dotcount=dotcount+1
endwhile
if raw eq 1 then begin
print,"It's raw, I'm going in..."
;statcode= strmid(inFile, dotcount-5, 2)
statcode = strmid(strlowcase(inFile), 0, 2)
print,format="(%'I\'ve found a statcode, it appears to be... %s.')", statcode
;year= strmid(inFile, dotcount-3, 2)
year = strmid(inFile, 2, 2)
print,format="(%'Got a year here, looks like %s.')",year
;day= strmid(inFile, dotcount, 3)
day = strmid(inFile, 4, 3)
print,format="(%'Found a day, it\'s %s.')",day
idoc(4)= 0L
iyr=0L
idy=0L
;print, statcode, 'STAT', year, 'year', day, 'day'
iyr=float(year)
idy=float(day)
idoc(4)= (iyr*1000+idy)
endif else begin
statcode=strmid(inFile, dotcount-8, 2)
idoc(4)=float(strmid(inFile, dotcount-6, 5))
endelse
;print, idoc(4), 'idoc4'
CASE statcode of
'na': idoc(3)=[122]
'pg': idoc(3)=[111]
'cy': idoc(3)=[112]
'iq': idoc(3)=[117]
'cd': idoc(3)=[104]
'ig': idoc(3)=[109]
'ch': idoc(3)=[103]
'rb': idoc(3)=[118]
'pb': idoc(3)=[116]
'gh': idoc(3)=[110]
're': idoc(3)=[119]
'cb': idoc(3)=[120]
'bl': idoc(3)=[121]
'ca': idoc(3)=[301]
ELSE : begin ;unknown station
print,'Unacceptable Station Code'
ENDELSE
endcase
unit=idatunit
file_info = fstat(unit)
file_size = file_info.size
print,file_size
if keyword_set(raw) then begin
type = raw - 1
if raw eq 1 then y(0) = file_size / x(0)
if raw eq 2 then y(1) = file_size / x(1)
endif else begin
type = where(file_size eq sizes, count)
;print,type
if count eq 0 then begin
;print,'Error in file size.'
stop
endif else type = type(0)
endelse
print,'Now processing ';,filename
data_array = bytarr(x(type),y(type))
readu,unit,data_array
offset = [3, 2, 1, 0, 0, 0]
hh = data_array(offset(type) + 0,*)
mm = data_array(offset(type) + 1,*)
offset(5) = -1
bx1 = long(data_array(offset(type) + 3:offset(type) + 6,*),0,1,y(type))/1000.
by1 = long(data_array(offset(type) + 7:offset(type) + 10,*),0,1,y(type))/1000.
bz1 = long(data_array(offset(type) + 11:offset(type) + 14,*),0,1,y(type))/1000.
case type of
5: ss = 0
4: ss = data_array(2,*) ; 5 sec
3: ss = data_array(2,*) ; gsc clean
2: begin ; maccs clean
tf1 = data_array(0,*)
ss = data_array(3,*)
bx1 = long(data_array(04:07,*),0,1,y(type))/1000.
bx2 = long(data_array(08:11,*),0,1,y(type))/1000.
by1 = long(data_array(12:15,*),0,1,y(type))/1000.
by2 = long(data_array(16:19,*),0,1,y(type))/1000.
bz1 = long(data_array(20:23,*),0,1,y(type))/1000.
bz2 = long(data_array(24:27,*),0,1,y(type))/1000.
end
1: begin ; gsc raw
dd = fix (data_array( 0: 1,*),0,1,y(type))
ss = data_array(4,*)
end
0: begin ; maccs raw
header= data_array( 0,*)
dd = fix (data_array( 1: 2,*),0,1,y(type))
ss = data_array(5,*)
bx2 = long(data_array(18:21,*),0,1,y(type))/1000.
by2 = long(data_array(22:25,*),0,1,y(type))/1000.
bz2 = long(data_array(26:29,*),0,1,y(type))/1000.
tf1 = data_array(30,*)
tf2 = data_array(31,*)
block = data_array(32,*)
status= data_array(33,*)
house = data_array(34,*)
end
endcase
bx1=extrac(bx1,0,1,1,86400)
bx2=extrac(bx2,0,1,1,86400)
by1=extrac(by1,0,1,1,86400)
by2=extrac(by2,0,1,1,86400)
bz1=extrac(bz1,0,1,1,86400)
bz2=extrac(bz2,0,1,1,86400)
n=findgen(file_size/x(type))
nstep=n
n=n*2
x=fltarr(172800L)
y=x
z=x
x[n]=Bx1[nstep+50]
x[n+1]= bx2[nstep+50]
y[n]=By1[nstep+50]
y[n+1]=By2[nstep+50]
z[n]=Bz1[nstep+50]
z[n+1]=Bz2[nstep+50]
timeX = hh*3600. + mm*60. + ss
timex=extrac(timex,0,1,1,86400)
Dtime=dblarr(172800)
Dtime[n]=timex[nstep+50]- 0.75
Dtime[n+1]= timex[nstep+50]- 0.250
endif
if format eq 0 then begin
BAD = 32767
TIME = FINDGEN(50)
LABEL =
READF,idatunit, format = '(12(i8),/,12(i8))', IDOC
READF,IDATUNIT,format = '(a)', LABEL
PRINT, 'LABEL = ', LABEL
lab=label
DTIME = fltARR(900000)
dtime2=dtime
X = FLTARR(900000)
Y = X
Z = X
I=0L
WHILE (NOT EOF (IDATUNIT)) DO BEGIN
;readf,IDATUNIT,format='(f15, 3(f12))' ,FTIME,FX,FY,FZ ;formats A80 Fluxgate
;readf,IDATUNIT,format='(g15, 3(g12))' ,FTIME,FX,FY,FZ ;formats Sondy search coil
readf,IDATUNIT ,FTIME,FX,FY,FZ
DTIME(I)= FTIME
X(I)= FX
Y(I) = FY
Z(I) = FZ
;print, 'ftime, fx, fy, fz = ', ftime, fx, fy, fz
I=I+1
ENDWHILE
;DTIME=FLTARR(I)
;X=DTIME
;Y=DTIME
;Z=DTIME
;DTIME=EXTRAC(DDTIME,0,I)
;X=EXTRAC(XX,0,I)
;Y=EXTRAC(YY,0,I)
;Z=EXTRAC(ZZ,0,I)
endif
end
PRO DPLOT,PWR,TIMER,LAB
common aa;, idoc,lenh,issec,dtime,x,y,z
common bb;,MINVALx,MINVALy,MINVALz,MAXVALx,MAXVALy,MAXVALz,tick
common cc;,esca
common dd;,inFile,startHour,startMinute,startSecond,endHour,endMinute,endSecond,site,format,sequential,postscript,bxmin,bxmax,bymin,bymax,bzmin,bzmax,tick,intervalHour,intervalMinute,intervalSecond
; MENU = [,]
TLAB =
CASE idoc(3) OF
0: sitename='IRM Data'
101: sitename='PANGNIRTUNG'
112: sitename='CLYDE RIVER'
117: sitename='IQALUIT'
104: sitename='CAPE DORSET'
109: sitename='IGLOOLIK'
103: sitename='CORAL HARBOUR'
118: sitename='REPULSE BAY'
116: sitename='PELLY BAY'
110: sitename='GJOA HAVEN'
119: sitename='RESOLUTE BAY'
120: sitename='CAMBRIDGE BAY'
121: sitename='BAKER LAKE'
122: sitename='NAIN'
201: sitename='AGO P1'
202: sitename='AGO P2'
203: sitename='AGO P3'
204: sitename='AGO P4'
205: sitename='AGO P5'
206: sitename='AGO P6'
15: sitename='Sondrestromfjord'
16: sitename='South Pole'
277: sitename='AGO A77'
276: sitename='Halley'
280: sitename='AGO A80'
281: sitename='AGO A81'
284: sitename='AGO A84'
301: sitename='Cambridge'
1: sitename='Air Force Academy'
3: sitename='Jicamarca'
4: sitename='Los Alamos '
5: sitename='San Gabriel '
300: sitename='Korea'
700: sitename='Kotelnyy'
701: sitename='Tixie'
702: sitename='Chokurdakh'
703: sitename='Zyryanka'
704: sitename='Chichijima'
705: sitename='Ewa Beach'
706: sitename='St. Patatunka'
707: sitename='Lunping'
708: sitename='Muntinlupa'
709: sitename='Onagawa'
710: sitename='Popov Island'
711: sitename='Moshiri'
600: sitename='Fort Churchill'
601: sitename='Contwoyto Lake'
602: sitename='Dawson'
603: sitename='Eskimo Point'
604: sitename='Gillam'
605: sitename='Island Lake'
606: sitename='Fort McMurray'
607: sitename='Pinawa'
608: sitename='Rabbit Lake'
609: sitename='Rankin Inlet'
610: sitename='Fort Simpson'
611: sitename='Fort Smith'
612: sitename='Taloyoak'
ELSE : begin ;unknown station
PRINT,'Unknown Station. Enter the name of the station.'
mentemp=' '
READ, mentemp
sitename= mentemp
ENDELSE
endcase
YRDAY = IDOC(4)
; COMPOSE TITLE FOR PLOT
print,YRDAY
MMDD, YRDAY, MON, DAY, IYR
YRDIVTH = YRDAY/1000
IF YRDIVTH LE 80 THEN BEGIN
IHEAD = STRING(FORMAT="(5X,'YEARDAY = ',I5,13X,A3,' ',I2,', 200',I1,' ')", $
YRDAY,MON,DAY,IYR)
ENDIF ELSE BEGIN
IHEAD = STRING(FORMAT="(5X,'YEARDAY = ',I5,13X,A3,' ',I2,', 19',I2,' ')", $
YRDAY,MON,DAY,IYR)
ENDELSE
IHEAD = sitename + IHEAD
length=lenh
T1 = issec / 3600.
T2 = T1 + LENH
syrday = STRING(FORMAT="(I05)", YRDAY)
yrday = strmid(IYR,7,1)
fnamelp= '/Volumes/physics_data/Ftp/MACCS_DATA/LinePlots/PostScript/'+strupcase(site)+'/200'+yrday+'ir/'+site+syrday+'.ps'
;fnamelp= '~/'+site+syrday+'lp'+'.ps'
set_plot, 'x'
; window,0,xpos=0,ypos=0,xsize=800,ysize=500
!p.multi=[0,1,3]
!x.style=1
!x.margin=[10,10]
!x.style=1
!y.margin=[2,2]
IF esca ne 0 then Begin
;plot,Dtime(where ((fix(x) ne 32767) and (x ne 0.0)))/3600,x(where((fix(x) ne 32767)and (x ne 0.0))),$
;xticks=tick,xrange = [t1,t2], yrange=[MINVALx,MAXVALx],title = ihead,charsize=2.0,ytitle='Mag H',$
;xtickformat='xticks', ystyle=18
;!Y.TITLE = STRMID(LAB,63,4)
;plot,Dtime(where ((fix(y) ne 32767) and (y ne 0.0)))/3600,y(where((fix(y) ne 32767)and (y ne 0.0))),$
;xticks=tick,xrange = [t1,t2], charsize=2.0,yrange=[minvaly, maxvaly],ytitle='Mag H',$
;xtickformat='xticks', ystyle=18
;!Y.TITLE = STRMID(LAB,67,4)
;plot,Dtime(where ((fix(z) ne 32767) and (z ne 0.0)))/3600,z(where((fix(z) ne 32767)and (z ne 0.0))),$
;xticks=tick, xrange = [t1,t2], charsize=2.0,yrange=[minvalz, maxvalz],ytitle='Mag H',$
;xtickformat='xticks', ystyle=18
endif else begin ;This is the beginning of the sequential plotting loop.
increment = intervalHour + (intervalMinute/60.) + (intervalSecond/3600.)
testend = (t2-t1)/increment
auto=0
if minvalx eq then auto=1
for test=0,testend-1 do begin
t2= t1 + increment
set_plot, 'win'
window,0,xpos=0,ypos=0,xsize=800,ysize=500
!p.multi=[0,1,3]
!x.style=1
!x.margin=[10,10]
!x.style=1
!y.margin=[2,2]
timestep=dtime(1)-dtime(0)
te1=t1*3600/timestep
te2=t2*3600/timestep
if auto eq 1 then begin
minvalx=min(x(te1:te2)) ;This aids in autoscaling.
maxvalx=max(x(te1:te2))
minvaly=min(y(te1:te2))
maxvaly=max(y(te1:te2))
minvalz=min(z(te1:te2))
maxvalz=max(z(te1:te2))
endif
plot,Dtime(where ((fix(x) ne 32767) and (x ne 0.0)))/3600,x(where((fix(x) ne 32767)and (x ne 0.0))),$
xticks=tick,xrange = [t1,t2], yrange=[MINVALx,MAXVALx],title = ihead,charsize=2.0,ytitle='Bx',$
xtickformat='xticks', ystyle=18
plot,Dtime(where ((fix(y) ne 32767) and (y ne 0.0)))/3600,y(where((fix(y) ne 32767)and (y ne 0.0))),$
xticks=tick,xrange = [t1,t2], charsize=2.0,yrange=[minvaly, maxvaly],ytitle='By',$
xtickformat='xticks', ystyle=18
plot,Dtime(where ((fix(z) ne 32767) and (z ne 0.0)))/3600,z(where((fix(z) ne 32767)and (z ne 0.0))),$
xticks=tick, xrange = [t1,t2], charsize=2.0,yrange=[minvalz, maxvalz],ytitle='Bz',$
xtickformat='xticks', ystyle=18
;desc = [ $
; '0, Label, Lineplot Routine, center', $
; '1, Base,, Row', $
; '0, Button, NEXT, Quit , tag = ok', $
; '2, Button, QUIT, quit, tag=endprog']
;atitle='Lineplot INPUT'
; a=cw_form(desc, /column,title= atitle)
; if (a.endprog eq 1) then begin
; goto, endloop
; endif
if (postscript eq 1) then begin
seqnum= STRING(FORMAT="(I03)", test+1)
fnameseq='/Volumes/physics_data/Ftp/MACCS_DATA/LinePlots/PostScript/'+site+'/200'+IYR+'ir/'+site+syrday + strcompress(seqnum,/remove_all) +'.ps'
; set_plot, 'ps'
; device, filename=fnameseq,/landscape
; !p.multi=[0,1,3]
; !x.style=1
; !x.margin=[10,10]
; !x.style=1
; !y.margin=[2,2]
;plot,Dtime(where ((fix(x) ne 32767) and (x ne 0.0)))/3600,x(where((fix(x) ne 32767)and (x ne 0.0))),$
;xticks=tick,xrange = [t1,t2], yrange=[MINVALx,MAXVALx],title = ihead,charsize=2.0,ytitle='Mag H',$
;xtickformat='xticks', ystyle=18
;;!Y.TITLE = STRMID(LAB,63,4)
;plot,Dtime(where ((fix(y) ne 32767) and (y ne 0.0)))/3600,y(where((fix(y) ne 32767)and (y ne 0.0))),$
;xticks=tick,xrange = [t1,t2], charsize=2.0,yrange=[minvaly, maxvaly],ytitle='Mag z',$
;xtickformat='xticks', ystyle=18
;;!Y.TITLE = STRMID(LAB,67,4)
;plot,Dtime(where ((fix(z) ne 32767) and (z ne 0.0)))/3600,z(where((fix(z) ne 32767)and (z ne 0.0))),$
;xticks=tick, xrange = [t1,t2], charsize=2.0,yrange=[minvalz, maxvalz],ytitle='Mag H',$
;xtickformat='xticks', ystyle=18
; device, /close_file
endif
t1 = t1 + increment
endfor
endelse
if (postscript eq 0) then begin
goto, endprogram
endif
set_plot, 'ps'
device, filename=fnamelp,/landscape
!p.multi=[0,1,3]
!x.style=1
!x.margin=[10,10]
!x.style=1
!y.margin=[2,2]
;************U***This is the spot that controls titles for the postscript plots***********************
plot,Dtime(where ((fix(x) ne 32767) and (x ne 0.0)))/3600,x(where((fix(x) ne 32767)and (x ne 0.0))),$
xticks=tick,xrange = [t1,t2], yrange=[MINVALx,MAXVALx],title = ihead,charsize=2.0,ytitle='Bx',$
xtickformat='xticks', xminor=5,ystyle=18
;!Y.TITLE = STRMID(LAB,63,4)
plot,Dtime(where ((fix(y) ne 32767) and (y ne 0.0)))/3600,y(where((fix(y) ne 32767)and (y ne 0.0))),$
xticks=tick,xrange = [t1,t2], charsize=2.0,yrange=[minvaly, maxvaly],ytitle='By',$
xtickformat='xticks',xminor=5, ystyle=18
;!Y.TITLE = STRMID(LAB,67,4)
plot,Dtime(where ((fix(z) ne 32767) and (z ne 0.0)))/3600,z(where((fix(z) ne 32767)and (z ne 0.0))),$
xticks=tick, xrange = [t1,t2], charsize=2.0,yrange=[minvalz, maxvalz],ytitle='Bz',$
xtickformat='xticks',xminor=5, ystyle=18
device, /close_file
;Use Z-buffer to make .png plot
set_plot, 'Z'
;device, filename=fnamelp2
!p.background=255
!p.color=0
!p.multi=[0,1,3]
!x.style=1
!x.margin=[14,5]
!x.style=1
!y.margin=[2,2]
;************U***This is the spot that controls titles for the postscript plots***********************
plot,Dtime(where ((fix(x) ne 32767) and (x ne 0.0)))/3600,x(where((fix(x) ne 32767)and (x ne 0.0))),$
xticks=6,xrange = [t1,t2], yrange=[MINVALx,MAXVALx],title = ihead,charsize=2.0,ytitle='Bx',$
xtickformat='xticks', xminor=5,ystyle=18
;!Y.TITLE = STRMID(LAB,63,4)
plot,Dtime(where ((fix(y) ne 32767) and (y ne 0.0)))/3600,y(where((fix(y) ne 32767)and (y ne 0.0))),$
xticks=6,xrange = [t1,t2], charsize=2.0,yrange=[minvaly, maxvaly],ytitle='By',$
xtickformat='xticks',xminor=5, ystyle=18
;!Y.TITLE = STRMID(LAB,67,4)
plot,Dtime(where ((fix(z) ne 32767) and (z ne 0.0)))/3600,z(where((fix(z) ne 32767)and (z ne 0.0))),$
xticks=6, xrange = [t1,t2], charsize=2.0,yrange=[minvalz, maxvalz],ytitle='Bz',$
xtickformat='xticks',xminor=5, ystyle=18
image = tvrd()
write_png, '/Volumes/physics_data/Ftp/MACCS_DATA/LinePlots/PNG/'+strupcase(site)+'/200'+yrday+'ir/'+site+syrday+'.png', image
endloop:
endprogram:
END
PRO MMDD,YRDAY,MONTH,MNTHDA,IYR
; 11 NOV 85 S FAVIN
; GIVEN YRDAY LIKE 85199
; RETURNS WITH CHARACTER MONTH AND DAY NUMBER IN MONTH
LEAPYR = [0,0,31,60,91,121,152,182,213,244,274,305,335,366]
NOLEAP = [0,0,31,59,90,120,151,181,212,243,273,304,334,365]
CHARM = [,'JAN','FEB','MAR','APR','MAY','JUN', $
'JUL','AUG','SEP','OCT','NOV','DEC']
MONTH =
IYEAR = FIX(YRDAY/1000)
IDAY = FIX(YRDAY - IYEAR*1000)
MON= FIX(IDAY/30+1)
IF((IYEAR MOD 100) EQ 0) THEN GOTO, A366
IF((IYEAR MOD 4) EQ 0) THEN GOTO, A366
IF((IDAY-NOLEAP(MON)) LE 0) THEN MON = MON -1
MNTHDA=IDAY-NOLEAP(MON)
A365: MONTH = CHARM(MON)
IYR=IYEAR
RETURN
A366: IF((IDAY-LEAPYR(MON)) LE 0) THEN MON = MON - 1
MNTHDA=IDAY-LEAPYR(MON)
GOTO, A365
END
function xticks, axis, index, value
on_error,1
if keyword_set(help) then begin
helpdir = 'c:\rsi\idl40\help\user'
helpfile = helpdir + '\xticks.txt'
xdisplayfile, helpfile
return, 0
endif
;hour = fix(value+.5)
hour = fix(value)
if hour gt 23 then hour = hour -24
min = fix(value*60. mod 60.)
sec = fix(value*3600. mod 60. + .5)
if sec eq 60 then begin
sec = 0
min = min + 1
if min eq 60 then begin
min = 0
hour = hour+1
endif
endif
if sec eq 0 then begin ;Seconds are not shown on time scale if they are zero.
return, string(format = '(i2.2,":",i2.2)',hour,min)
endif
;min = fix(value*60. mod 60. + .5)
;if min eq 60 then begin
; min = 0
; hour = hour+1
;endif
;sec = fix(value*3600. mod 60. + .5)
;if sec eq 60 then sec = 0
return, string(format = '(i2.2,":",i2.2,":",i2.2)', hour, min, sec)
end

