Message Boards Message Boards

0
|
12444 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Need help importing data from a file.

Posted 9 years ago

I need help figuring out how to have a Mathematica script open a file. Each line of the script is in the format: C Name ti tf x y z xdot ydot zdot xsig ysig zsig xdotsig ydotsig zdotsig I have attached the file. I need my script to open the file, and for each satellite it needs to take the first row, take Name, X, Y, Z... so the second column, 5th column, 6th column, and 7th column, for the first row of the file for each satellite. (there are several satellites numbered GPS15, GPS24, GPS25, etc.... It then needs to map x, y, z for all of the satellites and label them on the map with their Name. I know it involves lists. I've tried, I can't figure out how to do this. Thank you so much!

Attachments:
POSTED BY: Nathan Lundholm
6 Replies

Sorry about the delay. I usually can't reply on weekdays, thanks to workload.

The attached file is pretty much what you need for this job. It is not complete, since I do not understand ECEF and the format is not directly supported by Mathematica. You will have to write a conversion function. I have, however, done pretty much all of the rest of the job. You will also have to alter SetDirectory[] to the name of the folder in which your data resides.

It is late here for me, and I haven't cleaned up the file as well as I should. It should execute without errors as it stands, if you can get the value in SetDirectory[] right. Post again here if it does not execute, please.

Understanding what I'm sending will take you some time. If you want to use Mathematica, take the time. It has the steep learning curve typical of computer languages (or maybe a bit steeper), but it's worth the trouble. When you have questions, post again here. I'll be notified by e-mail. I will get to them on weekends and occasionally during the week. Good luck.

Attachments:
POSTED BY: Bill Lewis

I really do need help badly. I am clueless. I'm about ready to just give up.

POSTED BY: Nathan Lundholm

{ C, Name, ti, tf, x, y, z, xdot, ydot, zdot, xsig, ysig, zsig, xdotsig, ydotsig, zdotsig } For each satellite there's many lines, each is a different time of day, I think 15 minutes apart? Right now we're only worried about the first line for each satellite. We need Name, x, y, z. We then need to put a peg on a map for X, Y, and Z for each satellite, and label each peg with Name. Here's the issue, the file is in ECEF... not latitude/longtiude.

POSTED BY: Nathan Lundholm

Ok, please put the names in Mathematica format: { name1, name2, name3, etc}, and I'll give it another try.

POSTED BY: Bill Lewis

If you look again I provided the names for all 16 columns... you missed C and Name apparently.

POSTED BY: Nathan Lundholm

Suggestions:

First, you are better off with Dataset[] and Association[] than List[], especially if you have V10.2 or even V10.1. Dataset[] had a steep learning curve but much better tractability and very much better response time.

Second: this will some effort -- maybe a few days or a week's worth considering that you have not done this before.

Your input file is apparently intended for Excel. I'd suggest that you import it into Excel and take another look at it. Your listed column names are: ti tf x y z xdot ydot zdot xsig ysig zsig xdotsig ydotsig zdotsig. There are 14 names, but '2-8=-1=-1_pos.txt' has 16 columns. Suggest using Excel to get the same number to delete some columns, or else add more names to your list. Once you get the columns right, I'd suggest exporting the file as .csv, which is more tractable than a .txt file, just as good practice.

If you lack Excel, try posting again.

Once that is done, you can import the file using SemanticImport[]. I'd suggest some variant on: SetDirectory[<wherever the file is>.] symbolName=SemanticImport[<filename>, <| col1name->"Text", col2Name->"Text",col3Name->"Integer", col4Name->"Real", and the rest of the columns Real.|>]; ResetDirectory[];

That should give you a Dataset[] with named columns. If you want to change symbolName, see Dataset[]. If you want units on the values, see Quantity[].

Once you're that far, try re-posting. If you want to continue on your own, look at guide/MapsAndCartography. Mapping isn't that hard to do once you get your data organized.

Good luck!

POSTED BY: Bill Lewis
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract