------------------ Windows Steps ---------------------
a. 	Download -> Ashtech (Thales Navigation) - dload32.exe from
	ftp://ftp.thalesnavigation.com/software/Ashtech%20Solutions/Download%20ver.%202.60/
	or (ask SOPAC for a copy....if it is no longer available from Thales)
	to a Windows NT, 2000 or XP host.
b.	Unzip and install (e.g copy or relocate unzipped components) to directory of your choice.
c.	Relocate ALL concerned Ashtech Micro-Z "U*" raw files to local host (single directory).
        BEFORE doing so, make a permanent backup of these files!!!!!!!!
d.	Start Ashtech "dload" by double-clicking icon.
e.	From left side of interface navigate to location directory where "U*" raw files live.
f. 	Choose Edit->Select All
g.	In right side of interface navigate to the location where you want the "B,E,S"
	files to be created.
h. 	Click and drag the "selected set" from the left side to the right side.  Note,
	this process can take A VERY LONG TIME (1 hour or more).
i.	Move converted "B,E,S" files back to a Unix host.
j.      Follow "Unix Steps" below.




------------------ Unix Steps ---------------
# Ask SOPAC for a copy of the following utilities....or replace
# the functionality with your own logic/utils:
#             gweek
#             jday
#
# Acquire teqc from Unavco if you don't already have it:
#  http://www.unavco.org/facility/software/teqc/teqc.html
#


# a. Convert multi-day raw files to multi-day rinex files
#    and multi-session, single-day raw files to multi-session,
#    single-day rinex files.
#
foreach file (B*.???)
  set site = `echo $file | cut -c2-5`
  set jday = `echo $file | cut -f2 -d"."`
  set yy = `echo $file | cut -c7-8`
  set session = `echo $file | cut -c6`
  set gweek = `/shared/scripts/bin/archive/gweek $jday $yy | cut -f1 -d" "`
  echo $file $jday $yy $gweek

  teqc +obs ${site}${jday}${session}.${yy}o +nav ${site}${jday}${session}.${yy}n -ash d -week $gweek $file
end



# b. Convert multi-day rinex files to single-day rinex files.
#
#
#    NOTE: YOU MUST MODIFY each of the following loops, including
#          most of the parameters inside, for EACH and EVERY
#          multi-day rinex file.  Use teqc +qc FIRST to verify
#          what the beginning and ending days are.  Use those
#          dates to set the loop interval.
#    NOTE: Below examples assume data doesn't cross a year boundary.
#          If it does, you have to deal with that too.  With two
#          loops instead of one.
# bsat024a.04o 
set outdir = 'single-day'
set day = 024
while ($day < 045)
 set mm = `/shared/scripts/bin/archive/jday $day 2004 | cut -c1-2`
 set dd = `/shared/scripts/bin/archive/jday $day 2004 | cut -c3-4`
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 -O.st 2004 $mm $dd 0 0 0 bsat024a.04o  > ${outdir}/bsat${day}0.04o
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 bsat024a.04n  > ${outdir}/bsat${day}0.04n
 @ day ++
 if ($day < 10) set day = "00"${day}
 if ($day < 100 && $day > 9) set day = "0"$day
end
# Do overlap with next bsat file (part a)
 teqc -week 1254 -st 20040214000000 -e 20040214235959 -O.st 2004 02 14 0 0 0 bsat024a.04o  > ${outdir}/bsat0451.04o
 teqc -week 1254 -st 20040214000000 -e 20040214235959 bsat024a.04n  > ${outdir}/bsat0451.04n
# Do overlap with previous bsat file (part b)
 teqc -week 1257 -st 20040214000000 -e 20040214235959 -O.st 2004 02 14 0 0 0 bsat045a.04o  > ${outdir}/bsat0452.04o
 teqc -week 1257 -st 20040214000000 -e 20040214235959 bsat045a.04n  > ${outdir}/bsat0452.04n

# bsat045a.04o
set day = 046
while ($day < 154)
 set mm = `/shared/scripts/bin/archive/jday $day 2004 | cut -c1-2`
 set dd = `/shared/scripts/bin/archive/jday $day 2004 | cut -c3-4`
 teqc -week 1257 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 -O.st 2004 $mm $dd 0 0 0 bsat045a.04o  > ${outdir}/bsat${day}0.04o
 teqc -week 1257 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 bsat045a.04n  > ${outdir}/bsat${day}0.04n
 @ day ++
 if ($day < 10) set day = "00"${day}
 if ($day < 100 && $day > 9) set day = "0"$day
end

# msai018a.04o
set day = 018
while ($day < 140)
 set mm = `/shared/scripts/bin/archive/jday $day 2004 | cut -c1-2`
 set dd = `/shared/scripts/bin/archive/jday $day 2004 | cut -c3-4`
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 -O.st 2004 $mm $dd 0 0 0 msai018a.04o > ${outdir}/msai${day}0.04o
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 msai018a.04n > ${outdir}/msai${day}0.04n
 @ day ++
 if ($day < 10) set day = "00"${day}
 if ($day < 100 && $day > 9) set day = "0"$day
end

# pbai0200.04o
set day = 020
while ($day < 148)
 set mm = `/shared/scripts/bin/archive/jday $day 2004 | cut -c1-2`
 set dd = `/shared/scripts/bin/archive/jday $day 2004 | cut -c3-4`
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 -O.st 2004 $mm $dd 0 0 0 pbai0200.04o > ${outdir}/pbai${day}a.04o
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 pbai0200.04n > ${outdir}/pbai${day}a.04n
 @ day ++
 if ($day < 10) set day = "00"${day}
 if ($day < 100 && $day > 9) set day = "0"$day
end

# pski028a.04o
set day = 028
while ($day < 151)
 set mm = `/shared/scripts/bin/archive/jday $day 2004 | cut -c1-2`
 set dd = `/shared/scripts/bin/archive/jday $day 2004 | cut -c3-4`
 teqc -week 1255 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 -O.st 2004 $mm $dd 0 0 0 pski028a.04o > ${outdir}/pski${day}0.04o
 teqc -week 1255 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 pski028a.04n > ${outdir}/pski${day}0.04n
 @ day ++
 if ($day < 10) set day = "00"${day}
 if ($day < 100 && $day > 9) set day = "0"$day
end

# ptlo022c.04o
set day = 022
while ($day < 144)
 set mm = `/shared/scripts/bin/archive/jday $day 2004 | cut -c1-2`
 set dd = `/shared/scripts/bin/archive/jday $day 2004 | cut -c3-4`
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 -O.st 2004 $mm $dd 0 0 0 ptlo022c.04o > ${outdir}/ptlo${day}0.04o
 teqc -week 1254 -st 2004${mm}${dd}000000 -e 2004${mm}${dd}235959 ptlo022c.04n > ${outdir}/ptlo${day}0.04n
 @ day ++
 if ($day < 10) set day = "00"${day}
 if ($day < 100 && $day > 9) set day = "0"$day
end




# c. Convert multi-session, single-day rinex files to
#    single-session, single-day rinex files.
#
#    NOTE: Similar to step B.  You must make a loop,
#          or set of loops, for each station having
#          multiple sessions per day.
#
set year = 2004
set yy = 04
foreach site (psmk)
  foreach day (`ls ${site}*o | cut -c5-7|sort|uniq`)
   set mm = `/shared/scripts/bin/archive/jday $day $year | cut -c1-2`
   set dd = `/shared/scripts/bin/archive/jday $day $year | cut -c3-4`
   set gweek = `/shared/scripts/bin/archive/gweek $day $year | cut -f1 -d" "`
   set obsfiles = `ls ${site}${day}*o`
   set navfiles = `ls ${site}${day}*n`
   teqc -week $gweek -st ${year}${mm}${dd}000000 -e ${year}${mm}${dd}235959 -O.st $year $mm $dd 0 0 0 $obsfiles > ${site}${day}0.${yy}o
   teqc -week $gweek -st ${year}${mm}${dd}000000 -e ${year}${mm}${dd}235959 $navfiles > ${site}${day}0.${yy}n
   @ day ++
   if ($day < 10) set day = "00"${day}
   if ($day < 100 && $day > 9) set day = "0"$day
  end
end



# d. Send everything to SOPAC on CDs.
#
#





# e. At SOPAC - "CLEAN" completed, single-day
#    rinex files with respect to metadata in database,
#    apply/modify compression scheme and archive.
#
foreach year (2004)
  set yy = `echo $year | cut -c3-4`
  foreach file (*${yy}o)
    set site = `echo $file | cut -c1-4`
    set day = `echo $file | cut -c5-7`
    /shared/scripts/bin/archive/dbCleanRinexFile.pl -d $day -y $year -s ${site}0000 -n '        SuGar - Sumatran GPS Array' -f $file
    compress $file
  end
end
compress ???????0.??n

foreach day (`ls *04o.Z | cut -c5-7 | sort |uniq`)
 mkdir $day
end

foreach file (*04o.Z *04n.Z)
 set day = `echo $file | cut -c5-7`
 mv $file $day/
end






