View Single Post
Old 01-11-12, 08:35 AM   #167
don1reed
Ace of the Deep
 
Join Date: Dec 2004
Location: Valhalla: Silent Generation
Posts: 1,149
Downloads: 910
Uploads: 0
Default

Using the Python/Stellarium method for Celestial Navigation with SH3 & SH4.

The Script is in your [here is example of what mine looks like]

My Documents/SH3/data/cfg/Careers/(skippers name)/1/(skippers name).map

Every time you save a game, SH3/SH4 updates this file to your PRECISE location on the F5 Chart.

Here is what my Python script file looks like, note what I've highlighted in RED below. I happen to play multi-games and this is the game I play on fridays:

+++++++++++++++++++++++++++++++++++++++++++++++

# By Michael Jones, 01/01/2008. mjones004@ameritech.net
# Revised 11/29/2009 to work with Stellarium 0.10.2
# This program reads the latitude and longitude data for a
# sub in Silent Hunter III, IV and creates a startup script for
# Stellarium. This sets the Date, Time and Location of the
# sub in Stellarium, allowing players to use celestial navigation in the game.

import string, os, sys

####### Edit Locations here ############

# Change the directory on the next line to point to SaveData.map in your saved game directory.
savedgame = "C:\\Users\\Gamer\\My Documents\\JAG\\data\\cfg\\Careers\\z\\0\\Fri.map"
# Set the Stellarium directory
stellocation = "C:\\Stellarium"

####### End Editable locations #########

# read savegame.
f=open(savedgame,'r')
content= f.read()
f.close()
# find lat & Lon in the file
start = content.find("Waypoint")
longst = content.find("Pt0=",start)
longnd = content.find(",",longst)
latnd = content.find(",",longnd+1)
# convert to dec deg
longitude = float(content[longst+4:longnd])/120000
latitude = float(content[longnd+1:latnd])/120000

# get date&time (input)
date = raw_input('GMT yyyy/mm/dd :')
time = raw_input('GMT hh:mm :')

# set the ocean label
if (-90 < longitude <= 30):
ocean = "Atlantic Ocean"
elif (30 < longitude <= 105):
ocean = "Indian Ocean"
elif (longitude <= -90 or longitude > 105):
ocean = "Pacific Ocean"

# Write startup script.
date = date.replace('/', ':')
longitude = str(longitude)
latitude = str(latitude)

stella=open(stellocation + "\\scripts\\JAG.ssc",'w')
stella.write("core.setDate(\""+date+"T"+time+":00\ ")\n")
stella.write("core.setObserverLocation("+longitude +", "+latitude+", 2, 0, \"SH3 Navigation Point, "+ ocean +"\", \"earth\")");
stella.close()

# now open stellarium and take your star sights
prog = "start /d \""+ stellocation +"\" stellarium.exe --startup-script sh3.ssc"
os.system(prog)
sys.exit()
++++++++++++++++++++++++++++++++++++++++++++++++

Inside this scrip file is the formula the game uses for determining your geo coord when it updates your *.map file.

Real Navigators plot their positions five times per day (There's something religious about that. ;-) )

Body: Sun and sometimes Sun and/or Moon, used for Running Fixes.
Daylight sights:
1. Ante Meridian (A.M.)
2. Meridian (Noon)
3. Post Meridan (P.M.)

Body: Stars, Moon, & Planets, used for Fixes.
4. Evening Twilight sights. (Round of three bodies)
5. Morning Twilight sights. (Round of three bodies)

Inside my *.map file: (Located at the bottom of the file)

[Waypoint]
Pt8=44333.77,6863332.00,0.00

If I divide 44333.77 by 120000, I get = 0.369448, changing into degrees and minutes = 0° 22.2 E. Why East, you ask, well because it's a positive number (N and E are positive numbers)continuing
6863332.00/120000 = 57.194433 = 57° 11.6N.

The Python script file, when working properly, allows the player to input Game date and Time (GMT). It sends this data to Stellarium and allows the player to select the celestial bodies necessary to obtain a fix.

Stellarium provides the player with body's Azimuth and Altitude of the sight to the precise second of time. If a round of stars is to be obtained, one must allow seconds to ellapse between each sight to reenact what the real navigator does. Real life doesn't have a pause button.

Getting Python and Stellarium to work hand in hand is a tedious business, admittedly, and for those interested in TC other than TCx1, Celestial Navigation in SH3 is not recommended.
Then there is the issue with newer versions of Python don't get me started on that. (I once had grey hair, now I have none.)

edit:

Both Python and Stellarium are stand-alone programs and as such, it requires the player to save his game, then open python, input the date/time, which then opens Stellarium, then player must obtain the data for his virtual sights, go to Almanac for war years, then reduce the sights via either
Nories,
HO-211,
HO-229,
HO-249,
Concise Sight Reduction Tables,
or
pure math:
sin Hc = sin Lat sin dec + cos Lat cos dec cos LHA
cos Z = sin dec - sin Lat sin Hc / cos Lat cos Hc

You'll soon find you have no time left to enjoy playing the game; but, if you're determined...
Remember...Real Celestial Navigation is like doing your own Taxes five times per day. LoL

Cheers
__________________
[SIGPIC][/SIGPIC]
During times of universal deceit, telling the truth becomes a revolutionary act.

~ George Orwell

Last edited by don1reed; 01-11-12 at 09:40 AM.
don1reed is offline   Reply With Quote