Page 1 of 2

Readable .dat files?

Posted: 04.11.2008, 01:19
by Hungry4info
For fun, I'm making a fictional catalogue of stars using a java program, whose output is to a dat file. When I run the program, it generates the .dat file which I slip into the /extras/ folder.

Celestia doesn't read it =(.

How can I get Celestia to show .dat files that I make?

Re: Readable .dat files?

Posted: 04.11.2008, 01:31
by Reiko
You'll probably have to replace the Celestia star.dat file with yours to make them show or turn that .dat file into an .stc file.

I'm just guess of course.

Re: Readable .dat files?

Posted: 04.11.2008, 12:47
by selden
Celestia only uses a single stars.dat
If your file is in the correct binary format, you can replace the file that comes with Celestia.

Otherwise, create a textual STC file containing your star definitions.

Re: Readable .dat files?

Posted: 16.11.2008, 00:28
by Hungry4info
Hmm. How in the world do I make a file in binary format?

Re: Readable .dat files?

Posted: 16.11.2008, 03:41
by selden
To create a binary file, you run a program which reads a textual input file and writes a binary file.
There is no specific format for binary files in general, each is different depending on the intent of the program's author.

Celestia's stars.dat is created using such a special program. It translates stars.txt into stars.dat
Unfortunately, SourceForge's svn archive is returning a "Bad Gateway" error to me right now,
so I can't point you to the program that's used.

Re: Readable .dat files?

Posted: 16.11.2008, 12:31
by ajtribick
Selden's information is slightly out of date, that was how things worked before I got my hands on the star database and updated it to the new Hipparcos revision. :)

The program used is a Perl script: src/tools/stardb/buildstardb.pl. It builds stars.dat and stars.txt directly from the Hipparcos catalogue (mostly the new revision of the Hipparcos catalog CDS I/311, but the spectral types are from CDS I/298 since this information is not present in the new Hipparcos catalogue.)

I have described the format of stars.dat on the Celestia Wikibook here.

Re: Readable .dat files?

Posted: 19.11.2008, 21:26
by Hungry4info
Is it possible to modify a perl script to take information from me? instead of from the Hipparcos database? Basically, I want to make a few million fictional stars, and I have come to the conclusion that .dat files load faster than .stc files.

While we're on the subject, is there any way to have .ssc files in .dat format?

Re: Readable .dat files?

Posted: 20.11.2008, 03:10
by Reiko
Yes that would be nice to convert those huge STC files used to populate other galaxies into DAT files. They take forever to load.

Re: Readable .dat files?

Posted: 20.11.2008, 13:51
by Fenerit
Hungry4info wrote:Hmm. How in the world do I make a file in binary format?

You need an HEX editor (there are lot for free on the net). Open the ASCII dat then save it as binary.

For some free HEX editors:

http://www.snapfiles.com/downloadfind.php?action=s&search.x=22&search.y=11&st=hex+editor

Re: Readable .dat files?

Posted: 29.11.2008, 00:14
by Hungry4info
Okay. I've downloaded AptEdit Pro ... and am uncertain just how to save my ASCII dat file as a bin file.

Image

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

Also, is it possible to have .ssc files like this?

Re: Readable .dat files?

Posted: 30.11.2008, 04:01
by Reiko
If you figure out how to convert a txt to .DAT let me know please. :)
Also, how does one combine two .DAT files? For example if I were to convert a large .DAT would I be able to merge it with the one used by celestia?

Re: Readable .dat files?

Posted: 30.11.2008, 11:29
by jogad
Hello

Searching in the forum I found the answer here.

http://www.shatters.net/forum/viewtopic.php?f=2&t=11625&p=94997&hilit=makestardb#p94997

I am very surprised that you forgot it, Reiko.

Then merging the two text files is easy with a command like:
copy /B stars1.txt + stars2.text stars.txt
Or the equivalent with your OS.
That gives you a merged text file that you can convert into a .dat file using the makestardb.exe utility.

Regards

Re: Readable .dat files?

Posted: 30.11.2008, 17:51
by Reiko
jogad wrote:Hello

Searching in the forum I found the answer here.

http://www.shatters.net/forum/viewtopic.php?f=2&t=11625&p=94997&hilit=makestardb#p94997

I am very surprised that you forgot it, Reiko.

Then merging the two text files is easy with a command like:
copy /B stars1.txt + stars2.text stars.txt
Or the equivalent with your OS.
That gives you a merged text file that you can convert into a .dat file using the makestardb.exe utility.

Regards
Oh yeah!! Thanks :)

Re: Readable .dat files?

Posted: 02.12.2008, 00:47
by Reiko
Is there something out there to do this with that isn't a command line utility? Most of the time I can never get them to work properly.

Re: Readable .dat files?

Posted: 02.12.2008, 00:49
by Hungry4info
Yeah I'm having trouble getting makestarsdb to work properly. It says I need to specify the number of stars, but I'm unsure how it wants me to do it.

Re: Readable .dat files?

Posted: 03.12.2008, 11:30
by jogad
Hello

Yes Hungry4info. To build a stars datafile you must specify yourself the number of stars in it.
The first line of your text file is the number of stars.

Then each line describes a particular star.
There are two possible formats for that.

The first one is more precise but data are a bit more difficult to interpret by us, poor humans beings, and more difficult to find. Each line contains the following data:
- # catalog HIP
- X Y and Z coordinates in light years
- ABSOLUTE magnitude of the star
- Spectral type

An easiest other way is to provide data as follows:
- # catalog HIP
- Right Ascension in decimal degrees
- Declination in decimal degrees
- Distance in light years
- RELATIVE magnitude of the star
- Spectral type

Data in a line are separated by spaces or tabulations.

In the first case you build your data file with

Code: Select all

makestardb textfile datafile

In the second case with

Code: Select all

makestardb –s textfile datafile

And for your Reiko I suppose that if you have trouble with command line it is because you operate under Windows.
It is possible to use command line without open a command window and get lost here.
Just put all files that you need in the same directory. Then make a text file witch contains the command line(s) and save it with a name witch ends by .bat. Don’t forget to end the last line of your command file by a carriage return. Double clicking on it will execute the command lines without quitting the GUI.
The command to make a text file from a stars data file is

Code: Select all

startextfump stardatafile textfile

A+

Re: Readable .dat files?

Posted: 03.12.2008, 11:50
by ajtribick
It's probably better to work with stars.dat itself -- regard stars.txt as a human-readable view into stars.dat, however given the coordinates conversion (from rectangular to polar) and the conversion to decimal, generating stars.dat from stars.txt will probably result in slightly different positions.

I'm personally not convinced we need to keep stars.txt around in v1.6.0 -- it's a holdover from the old generation process; the new star database generation process does not need it at all, and it is a very large file that only serves to duplicate another large file.

Re: Readable .dat files?

Posted: 03.12.2008, 13:15
by jogad
Hi

You are perfectly right!

The method is possible but anyhow it is not correct to merge a text file with X, Y and Z coordinates with one containing AR, Dec and Distance.

Only the First format is acceptable. If we have' only AR, Dec, Distance and relative magnitudes, the conversion must be done in X, Y, Z and absolute magnitues before trying to build the data file.
With this method, there is no conversion and thus no precision loss. In fact I noticed a (very) little one, not in the coordinates, but curiously on the magnitude! (on the third decimal place).

But for an add-on it seems that the best method is always to make a stc file witch is human readable and preserves the original stars.

Re: Readable .dat files?

Posted: 03.12.2008, 17:00
by chris
ajtribick wrote:It's probably better to work with stars.dat itself -- regard stars.txt as a human-readable view into stars.dat, however given the coordinates conversion (from rectangular to polar) and the conversion to decimal, generating stars.dat from stars.txt will probably result in slightly different positions.

I'm personally not convinced we need to keep stars.txt around in v1.6.0 -- it's a holdover from the old generation process; the new star database generation process does not need it at all, and it is a very large file that only serves to duplicate another large file.

I agree with you. With the new process for generating stars.dat and the improvements to stc files, stars.txt is unnecessary now.

--Chris

Re: Readable .dat files?

Posted: 03.12.2008, 18:31
by Guckytos
Just a few short questions/suggestions on making a stars.dat for an addon.

I have also a huge load of data that I am currently converting to .STCs (~1200 entries [without a load of binaries])

Do I really need to assign them a HIP number?
I have the data in an X Y Z coordinate system, but I am not sure, if it is the same as used in Celestia. I tried to look that one up, but didn't find its center and orientation (yet).
Can I also define barycenters?

So, from these questions I'd like to edrive the following feature requests for future Celestia versions:
  • Possibility to add user .dat files (binary or text) with addons
  • define barycenters
  • Possibility to use modify commands for already existing stars within these .dat files

My 2 cents.

Regards,

Guckytos