<!doctype debiandoc system>
<debiandoc>
  <book>
    <titlepag>
      <title>The Smeg Manual</title>

      <author>
	<name>Tom Rothamel</name>
	<email>tom-smeg@onegeek.org</email>
      </author>
      
      <version>Interim Release 1</version>

      <copyright>
	<copyrightsummary>Copyright &copy; 1999 Tom Rothamel</copyrightsummary>
        <p>
This manual is free software; you may redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
        </p>
        <p>
This is distributed in the hope that it will be useful, but
<em>without any warranty</em>; without even the implied warranty of
merchantability or fitness for a particular purpose.  See the GNU
General Public License for more details.
        </p>
        <p>
A copy of the GNU General Public License is available 
on the World Wide Web at <url id="http://www.gnu.org/copyleft/gpl.html"
name="&urlname">. You can also obtain it by writing to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA.
        </p>
      </copyright>
    </titlepag>
    
    <toc detail="sect1">
    
    <chapt>
      Using Smeg for visual satellite observation.
      <p>
This chapter is a tutorial explaining how to use Smeg as a tool for 
visual satellite observation. If you're into radio predictions, please
read this chapter for its discussion of Smeg basics, then read the next
for detail about radio predictions. If you only want to know about visual
predictions, you can read this chapter and skip the next. If 
you'd like to use Smeg for both purposes (or you just thirst for
knowledge), you should read both chapters.
      <p>
These tutorials assume you've started smeg already (you can do so by
running the <prgn>smeg</prgn> command. They also assume that you'll be
giving all the commands as part of the same session. (A safe assumption,
as Smeg currently can't save state between sessions.)
Commands you're to give will be prefixed by the <tt>smeg></tt> prompt, and
output will be shown unprefixed.
      <sect>
	  Step 1: Defining the observer's location.
	<p>
The first step in predicting satellite passes is to define the observer's
position. This is done using three commands:
<tt>set lat <var>latitude</var></tt>,
<tt>set lon <var>longitude</var></tt>, and
<tt>set alt <var>altitude</var></tt>.
The latitude and longitude are given as signed decimal degrees. For 
latitude, positive is north, and for longitude, positive is east. (Please
note that this means observers in the Americas will have to enter a
negative number for longitude. Altitude is given as a decimal number
representing kilometers above mean sea level. To check the current settings,
one can run the command <tt>show location</tt>, which will print out the
current location.
	<p>
The following example will change the location for predictions to that of
a beach near Tom's house. (It then displays the location for confirmation
purposes.)
	<example>
smeg> lat 40.9266
smeg> set lon -73.3123
smeg> set alt 0
smeg> show location
The current location is:
        Latitude:  40.9266 N
        Longitude: 73.3123 W
        Altitude: 0.0000
</example>
	<p>
      <sect>
	Step 2: Loading and filtering orbital elements.
	<p>
A satellite's orbit can be characterized by a set of orbital elements. These
elements are usually produced by NORAD, but occasionally are created by
amateur observers (as is occasionally the case for classified satellites.).
Before Smeg can be useful, a set of these elements must be loaded. This
is accomplished by the <tt>tle <var>filename</var></tt> command. (Tle stands
for two-line elements, the format NORAD uses for element files.)
	<p>
For prediction of visual passes, using two line elements with embedded
magnitude information is highly recommended. (This is currently the
only way one can load magnitude information into Smeg.) The tle file
of choice is the McCants file. It's available from <url id="http://www.fc.net:80/~mikem/tle.html" 
name="&urlname"> as mccants.tle. Included in the Smeg distribution is a
perl script, <prgn>gettle</prgn> that will fetch the file automatically.
To use it, simply run (from the shell) the command 
<tt>gettle mccants.tle</tt>. Then, in Smeg, to use the tle file:
	<example>
smeg> tle mccants.tle 
Loaded 1462 elements.
</example>
	<p>
The McCants file is only updated about once a week. You may need to
download other files in order to have accurate predictions of manuvering
satellites and spacecraft. (Such as the space shuttle, soyuz capsules, and
progress freighters.)
	<p>
This loads the elements from a file, and builds a satlist structure in
memory. Depending on your circumstances, this may be enough. However, in
some cases, it may be desirable to filter out entries from the satlist.
This is done using the command <tt>filter satlist <var>expression</var></tt>.
The expression used varies depending on exactly what filtering is
desired on.
	<p>
One useful filter command is <tt>filter satlist minmag &lt; 4</tt>, which
will remove from the list satellites that have a theoretical maximum 
brightness in perfect conditions of greater than 4th magnitude. (Remember,
a lower magnitude means a brighter star or satellite.) Another useful
command is <tt>filter satlist norad = 16609</tt>, which selects Mir, which
has the NORAD catalog number of 16609. Of course, the number can be changed
to that of any other satellite. Conditions can be connected by the boolean
operators <tt>and</tt> and <tt>or</tt>. <!-- Please see the section on
expressions for more details. -->
	<p>
Filtering can only remove satellites from the list, not add them. You can
add all filtered-out satellites back to the list by running the command
<tt>unfilter satlist</tt>. You can also see the current contents of the
satlist by running the command <tt>show satlist</tt>.
      <sect>
	Step 3: Predicting passes.
	<p>
The next step is to predict when the satellites in the satlist will be
in your line of sight. This is modified by a minimum elevation, which
is set using the command <tt>set minelev <var>elevation</var></tt>. I find 
that <tt>set minelev 10</tt> works well for visual observations from my
site, your mileage may vary.
	<p>
Once the minimum elevation is set, you can run the <tt>predict passes</tt>
command. This will generate a list of passes for the next 24 hours. (This
can be modified using timespecs, as discussed later in this manual.) Smeg
will print out a progress report, and will eventually tell you the number
of passes that it found.
<example>
smeg> set minelev 10
smeg> predict passes
Prediction complete. 6427 passes found.
</example>
	<p>
      <sect>
	Step 4: Filtering passes.
	<p>
Before we get down to the actual commands needed to filter passes, it's
good to find out in exactly what conditions a satellite is visible. The
basic rule is that a satellite is potentially visible if the observer is
in darkness while the satellite is in sunlight. As a practical matter, for
darkness to reign the sun's elevation has to be less than -6 degrees beneath
the horizon. 
	<p>
Two expressors have been added to smeg to represent these two conditions.
The first, <tt>sunel</tt> is a float representing the elevation of the sun, 
in degrees.  The second, <tt>lit</tt>, is a boolean that is true when the
satellite is lit at either the beginning or the end of the pass.
	<p>
Using this pair, and the <tt>filter passes</tt> command, we can easily select
only potentially visible passes. The passes that are not filtered out after
the following command will always be potentially visible (although perhaps
they may be very dim.).
<example>
smeg> filter passess sunel &lt; -6 and lit
2143 passes passed filter.
</example>
	<p>
      <sect>
	Step 5: Stepping through passes.
	<p>
After passing the filter, all the satellites seen are potentially 
visible. Most, however, are very dim. To determine which can be easily
seen visually, we can step through the list of passes, calculating the
magnitude at various points along each one, printing out a line when a 
condition is met. This is done using the command
<tt>step passes <var>expression</var></tt>, as in:
<example>
smeg> step passes mag < 4
25407 Cosmos 2360 r (11.055 days old)
        19990717 22:30:21   62.1 NE  44.5 +3.9
        19990717 22:30:51   77.0 E   43.2 +3.8
        19990717 22:31:21   90.1 E   40.1 +3.8
        19990717 22:31:51  100.6 E   36.1 +3.9
        19990717 22:32:21  108.7 E   31.8 +4.0
19120 Cosmos 1943 r (11.173 days old)
        19990717 22:29:21   11.2 N   59.9 +3.8
        19990717 22:29:51   35.1 NE  68.6 +3.4
        19990717 22:30:21   77.2 E   70.9 +3.2
        19990717 22:30:51  110.4 E   64.3 +3.1
[etc...]
</example>
	<p>
Note that this usually produces copious amounts of output. You can redirect
this output by prefixing the command with <tt>less</tt> or <tt>print</tt>.
<tt>less</tt> pipes the output to the pager (usually <prgn>less</prgn>,
appropriately enough.), while <tt>pager</tt> sends the output to 
a printer, or at least the <prgn>lpr</prgn> program.
	<p>
For each pass, one header line is printed, and one or more data lines are
printed. The header line consists of, from left to right: the satellite's 
norad number, the satellite's common name, and the age of the elements 
used to make this prediction. The data lines contain the following:
The date (in YYYYMMDD format), the local time, the satellite's azimuth,
a compass heading roughly indicating that azimuth, the satellite's
elevation, and the satellite's visual magnitude, if available.
	<p>
Probably the most useful thing to use in these expressions is the <tt>mag</tt>
expressor, which allows you to compare against the satellite's current
computed magnitude. (Remember, the lower the magnitude, the brighter the
satellite is.) If the element files omit magnitude, this will lead to an
empty least. In that case, leave the expression blank. (A blank expression
is always true.) You'll be stuck having to use other means to find the
magnitude of the object, but at least you'll get output that's correct
in other respects.
      <sect>
	Step 6: In the field.
	<p>
The previous step should be enough for someone with an accurately set
watch to observe satellites in the field. However, for someone with a
laptop, Smeg has even more benefits. These are the <tt>live</tt> displays.
	<p>
The first is useful if your laptop is fast enough to do the predictions
itself. In that case, one simply runs the <tt>live passes</tt> command, 
which will display predicted passes. Please note that this is only 
filtered by the <tt>filter passes</tt> command, but not the results
of <tt>step passes</tt>. Pass selection is accomplished using the
up and down arrow keys, 'q' exits the mode.
	<p>
The second, and more complicated, procedure is useful if the laptop is not
fast enough to run predictions. (This is especially the case if it doesn't
have a FPU.) First, complete steps 1-5 on a fast machine. Then, complete
steps 1 and 2 on the slow laptop. Enter the command <tt>noradfilter</tt>.
Enter the norad numbers produced by the <tt>step passes</tt>, one per line.
End with a blank line. Then, finally, run <tt>live satlist</tt>. While this
discards pass times, it does provide a way to run the live display on a 
slower laptop.
	<p>
The live displays are based on system time. It's highly reccomended that
you use a protocol such as NTP to synchronize your system's clock with
a reference time source.
	<p>
It's been found that these live displays work best when used in conjunction
with two person teams. One watches the laptop (destroying night vision), and
calls out the bearing to the object. The other scans the sky. When he finds
it, he'll then point it out to the first observer, who won't need to look
at the laptop to find it.
	<p>
Of course, the best laid plans can be destroyed by clouds or light 
pollution. That's just life. Still, we wish you luck in your observing
efforts!


    <chapt>
      Using Smeg for radio predictions.
      <p>
[This section not written yet.]


    <chapt>
      Making Smeg more usable.
      <p>
It may seem from the above chapters that using Smeg requires lots of
typing. While this is somewhat true, it can also be somewhat mitigated by
using definable procedures and the .smeg1rc file.
      <sect>
	Definable Procedures.
	<p>
Before discussing procedures, it's somewhat important to point out one
of the properties of the way Smeg parses files. It is smart enough to
find mutiple commands on the same line, and parse them appropriately.
Definable procedures use this property.
	<p>
Defining a procedure associates a command string with a name. It's done
using the <tt>def <var>name</var> <var>string</var></tt> command. The
string of commands is usually quoted using double quotes. A procedure
can be called using the command <tt>call <var>name</var></tt>. Calling
a procedure parses the associated command string as if it was typed at
the command line. For example:
<example>
smeg> def beach "set lat 40.9266 set lon -73.3123"
smeg> call beach
</example>
      <sect>
	The .smeg1rc file.
	<p>
On startup, Smeg looks for a file named .smeg1rc in the directory specified
by the HOME environment variable. It runs any commands found in this file
as if the commands had been typed at the prompt. You can also include 
comments in this file by beginning a line with the '#' character. The
maximum length of lines in the .smeg1rc file is 512 characters.
	<p>
The .smeg1rc file is useful for setting site specific defaults, as well as 
for defining procedures that can be referenced later.


<!--

    <chapt>
      Reference manual.
      <sect>
	Commands.
	<p>
A command is something one can type at the smeg> prompt, causing Smeg to take
an action. It's possible to type more than one command per prompt, but at 
least one command should be present per line.

	<sect1>
	  <tt>echo <var>string</var></tt> - displays a string.
	  <p>
Echo will print its argument, a string, on the output channel. It's 
most useful in the rcfile, as a method of conveying information to the 
user.

	<sect1>
	  <tt>less <var>command</var></tt> - diverts output to pager.
	  <p>
The less command will execute its argument, another command, with the
output channel piped to a pager. The exact pager can be changed using the
<tt>set pager</tt> command. Mixing the <tt>less</tt> and <tt>print</tt>
commands can lead to problems.

	<sect1>
	  <tt>print <var>command</var></tt> - diverts output to a printer.
	  <p>
The print command will execute its argument, another command, with the
output channel piped to a print spooler. The exact pager can be 
changed using the <tt>set printcmd</tt> command. Mixing the <tt>less</tt> 
and <tt>print</tt> commands can lead to problems.

	<sect1>
	  <tt>set <var>string</var> <var>string</var></tt> - sets options.
	  <p>
This command sets a settable, identified by the first string, to a value
specified by the second string. See the section on settables below
for details on what can be set.

	<sect1>
	  <tt>def <var>string</var> <var>string</var></tt> - defines a procedure.
	  <p>
The def command creates a new procedure. The name of that procedure is set
to the first string, while the second string is used to define the 
procedure's body. The second string is usually a quoted string. Please
note that the body is not parsed before being defined. Instead, it's 
parsed when the procedure is called. This command can also be used to
redefine a procedure.

	<sect1>
	  <tt>call <var>string</var></tt> - calls a procedure.
	  <p>
Call can be used to call a defined procedure. The procedure is parsed at
call time, so an error message based on the procedure definition can be
printed out.

	<sect1>
	  <tt>tle <var>string</var></tt> - loads two line elements from a file.
	  <p>
This command reads a set of two line elements from a file, specified by the
argument. It uses them to initialize the satlist. 

	<sect1>
	  <tt>filter satlist <var>expression</var></tt> - filters the satellite list.
	  <p>
This command applies the expression to the current satlist. Satellites that
satisfy the expression are left on the list, while those that fail it are 
removed. See the section on expressions for more information on filters that
can be applied to the satlist. Filtering will never create a larger list.

	<sect1>
	  <tt>noradfilter</tt> - interactively filter satellites based on norad number.
	  <p>
The noradfilter command filters the satlist based only on norad numbers.
Once run, it will prompt the user for a list of norad numbers. Enter the
numbers, one per line. Terminate entry with a blank line. Smeg will use
these numbers to filter the current satlist. (Note that this can only
remove entries from the list, not add them.)

	<sect1>
          <tt>unfilter satlist</tt> - resets satlist to last element load.
	  <p>
Unfilter satlist will restore the satellite list to its state after the
last tle command. It undoes all filtering done to the satlist in the
intervening time.

	<sect1>
	  <tt>predict passes [ [ <var>timespec</var> ] <var>timespec</var> ]</tt> - predicts passes.
	  <p>
Predict passes will create a list of passes. (A pass is defined as a timespan
in which the satellite is above a minimum elevation, set by <tt>set minelev</tt>,
defaulting to 0 degrees.) It can take zero, one, or two timespecs. If
called without any arguments, it will predict passes for a period of
one day starting at its invocation. If called with a single argument, it 
considers the argument to be the end of the prediction window (with the
start being the current time.) Two arguments are used to specify a window
in the order start, end.

	<sect1>
	  <tt>filter passes <var>expression</var></tt> - applies a filter to the passlist.
	  <p>
Filter passes uses an expression to filter the list of passes. If the 
expression evaluates to true for the expression

-->


  </book>
</debiandoc>


