linex7.pro

InfoInfo
Search:    

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

PRO SETUP,IDATUNIT,lab

;IDATFILNM =

;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

; bin=format
; seq=sequential
; pst=postscript
; ihour=startHour
; imin=startMinute

;idatfil= findfile('/Volumes/physics_data/Ftp/MACCS_DATA/AugASCII/CD/2007ir/*.*')

; idatfilnm=dialog_pickfile (path='/Volumes/physics_data/Ftp/MACCS_DATA/AugASCII/CD/2007ir/')

esc = 1

IF sequential eq 0 then begin

WHILE esc ge 1 DO BEGIN

;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

; intvlhr=0
; intervalMinute=0
; intvlsec=0

; ihour=startHour
; imin=startMinute

ENDWHILE

endif else begin

;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)

; endhour=endHour
; endminute=endMinute

; tick = tick

endelse

endsetup:

PRO DATREAD,IDATUNIT,PREV,lab

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

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'

unit=idatunit

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]

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

;print, 'ftime, fx, fy, fz = ', ftime, fx, fy, fz

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

; MENU = [,]

; COMPOSE TITLE FOR PLOT

length=lenh

syrday = STRING(FORMAT="(I05)", YRDAY)
yrday = strmid(IYR,7,1)

;fnamelp= '~/'+site+syrday+'lp'+'.ps'

; 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

set_plot, 'win'

!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

; 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

t1 = t1 + increment
endfor
endelse

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', $

MONTH =

A365: MONTH = CHARM(MON)

A366: IF((IDAY-LEAPYR(MON)) LE 0) THEN MON = MON - 1

function xticks, axis, index, value
on_error,1

if keyword_set(help) then begin

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

endif
if sec eq 0 then begin ;Seconds are not shown on time scale if they are zero.

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

This is a Wiki Spot wiki. Wiki Spot is a non-profit organization that helps communities collaborate via wikis.