--------------------------------------------------
TRAJECTORY PLOTS - Stephen Randall, Robert DiFabio
--------------------------------------------------

1. OVERVIEW

    Trajectory plots are usually made once a year, and represent the planned Cassini trajectories
    for the upcoming year. When updating the trajectory plots, the Cassini/MIMI website will also
    be updated to show the newest plots.
    
    [Note that Master_Program refers to the folder ~/IDL/Master_Program/.]
    
2. GETTING THE EPHEMERIS FILES

    To plot the trajectory plots, you'll need to obtain two sets of ephemeris files. If you don't
    know how to do this, see section 2 of the Website Script Maintenance document.
    
    The two sets you need are:
        1 - EQU and KSM, daily [this is described in the website doc, but you need a time interval of
            86400 seconds instead of 3600 and use KSM instead of Geographic for the second]
        2 - EQU only, 10min [use 600 seconds for the time interval]
            
    [Note: While you're doing this, you may also want to update the script's ephemeris files as well.
    See the website document for details.]
    
    Put these ephemeris files on the desktop; you'll need easy access. 
    
3. UPDATING CASSINI_REV.TXT
    
    Open the file 091005_EventsTable_091207.xls in /Volumes/HD 2/cassini_data. The start and stop times
    of each time range [of each orbit] are in the yellow boxes in this file. Open a new file on your
    Desktop called 'cassini_orbits.txt', and put the time ranges that you've obtained into it. It
    should look like this:
    
        Time Range
        2004 240 0000-2004 326 0000
        2004 326 0000-2004 366 0000
        ... [for however many periods you have in that year]
        
    To get the tilt values, you need to open the IDL procedure createRev_File.pro [in Master_Program]
    and edit two values. Up near the top, there are two variables, fileEQU and fileKSM. They should
    be set to the paths of your new DAILY ephemeris files. [Note that you can use the 10min files here
    but it will cause this to take 144x longer than necessary.] Then open a Terminal window and compile
    ephem_analysis and createRev_File in Master_Program, and run createRev_File. This will print out
    the time ranges and tilt values. 
    
    Now that you have both the time range and tilt values, update Cassini_Rev with the correct info.
    [Cassini_Rev.txt lives in Master_Program]. Follow the pattern already in the file.
    
4. CREATING THE TRAJECTORY PLOTS
    
    Go to /Volumes/HD 2/cassini_data/trajectory_plots/ and create a new folder for the year for which
    you're doing the plots.
    
    Open a Terminal window and compile time_conv, plot_proc, cassini_analysis, ephem_analysis, and
    trangedata_analysis. Then run trangedata_analysis.
    
    Use cassini_orbits as the time range file, and set the ephemeris file to be the 10min EQU file
    you created earlier. Change the output directory to the folder you created a moment ago, and leave
    everything else the same. Then click Create Traj., and choose the 'separate axis' option. This
    creates all the trajectory plots you wanted in the folder that you created for your year. Before
    moving on, open a few of them to make sure that everything went okay.
    
    Finally, convert all the postscript plots in this folder to pdfs by opening a Terminal window and
    entering the command 'find /Volumes/HD\ 2/cassini_data/trajectory_plots/20XX -name \"*ps\" -exec
    pstopdf {} \\;' where 20XX represents the name of the new folder you created for these plots.
    for f in $(ls *.ps); do pstopdf ${f}; done
    
5. UPDATING THE WEBSITE

    First, clean up after yourself. Delete the three new ephemeris files you put on the Desktop, as
    well as the cassini_orbits.txt file. In addition, when the pstopdf command has finished, delete
    all the .ps plots from that folder.
    
    Second, you'll need to copy all of your new files up to the site. Connect to the Cassini server
    [Command-K in Finder] and navigate to the trajectories directory. Drop all pdf plots into the
    'plots' folder, and all the .txt files into the 'text' folder. Then open trajectories.html in
    TextWrangler.
    
    Note: Be very careful when editing this file.
    
    First, scroll to the end of the Javascript. You'll see this marker:
    
    <!-- ======================================================= -->
    <!-- END OF JAVASCRIPT. MODIFY WITH CAUTION ABOVE THIS LINE. -->
    <!-- ======================================================= -->
    
    Right below this, you should see a list of years. Add your year to the list. You addition should
    look like "<option value="2012">2012</option>" and it should be at the TOP of the list.
    
    Now scroll up to the function getDayOfYear(). Directly above this you should see "return num_orbits".
    Above this is an "else if" block. Add another "else if" block for your year. For example, if you
    see:
    
        else if (year === 2012)
        {
            list.options[0] = new Option("016 - 040  |  Orbit 160", "20120160000-20120400000", true, false);
            ...
            list.options[18] = new Option("364 - 012  |  Orbit 178", "20123640000-20130120000", false, false);
                                
            num_orbits = 19;
        }
        
    then you should add:    
        
        else if (year === 2013)
        {
            list.options[0] = new ...
            ...
            
            num_orbits = ...
        }
        
     directly beneath it.
     
     Use the pattern in previous years to set the correct values in the Options. Note that the first
     boolean value is only true for the first item in the list, and that num_orbits should be assigned
     a value that gives the number of orbits in that year. It's very important that the orbit numbers
     are correct, as well as the mostly numeric strings like "20120160000-20120400000". These are what
     let the site find the correct files on the server.
     
     Before calling it a day, check the site to make sure that the year's worth of data you just added
     is accessible. A new option should be available in the year drop-down menu [the year you just
     added] and when selected, it should allow you to select any orbit in that year. Try a couple of
     them to ensure that you typed in the information correctly.
    
6. ISSUES

    - Ensure that all names explicitly given in this document are used.
    - Ensure that all paths to files are correct.
    - Ensure that all site modifications are done exactly as described.
    - ENSURE THAT ALL INFORMATION ADDED TO THE SITE PAGE IS 100% CORRECT. Use the pattern of other
    year's entries to make sure you're doing it correctly.
    
---------------------
Stephen Randall, 2012
---------------------