Message Boards Message Boards

0
|
9709 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Difficulty with StarData

The following script produces a nice table showing some properties of the naked eye stars, arranged in order of decreasing brightness.

Unfortunately, this script runs very slowly, and can take over half an hour to complete. It is also not completely repeatable, sometimes omitting a few stars from the list, so that there is fewer than the full complement of 8910 entries.

I would greatly appreciate suggestions that might improve the performance of this script.

StarData[EntityClass["Star", "NakedEyeStar"]];
StarData[%, {"Name", "ApparentMagnitude", "Declination", 
   "RightAscension"}];
% //. {a___, _Missing, b___} :> {a, b};
% /. {n_String, m_, dec_, ra_} :> {m, {n, m, dec, ra}} // Sort;
% /. {_Real, a_List} :> a;
% /. {n_String, m_, dec_, ra_} :> {n, m, UnitConvert[dec], 
    UnitConvert[ra], dec, ra};
% /. Quantity[a_, "Radians"] :> a;
% /. {n_String, m_, decrad_, rarad_, dec_, ra_} :> {n, 
    m, {dec, ra}, {\[Pi]/2 - decrad, rarad}};
Transpose@Prepend[Transpose@%, Range@Length@%];
startable = 
  Prepend[%, {"Index", "Name", "Magnitude", 
    ToString@{"Declination", "Right Ascension"}, 
    ToString@{\[Theta], \[Phi]}}];
POSTED BY: David Vasholz
2 Replies

Thank you for your response. Your suggestions have improved the performance of the script, so that it runs roughly twice as fast. Sometimes there are wild variations in speed, and I have attached a pdf file that shows the results for 10 trials.

Attachments:
POSTED BY: David Vasholz

Change the online data pull to a single query

onlineData = StarData[EntityClass["Star", "NakedEyeStar"],
   {"Name", "ApparentMagnitude", "Declination", "RightAscension"}];

The sorting can be streamlined

data = SortBy[onlineData, #[[2]] &];

data2 = data /. {n_String, m_, dec_, ra_} :> {n, m, UnitConvert[dec], 
     UnitConvert[ra], dec, ra};

data3 = data2 /. Quantity[a_, "Radians"] :> a;
data3 = data3 /. {n_String, m_, decrad_, rarad_, dec_, ra_} :> {n, 
     m, {dec, ra}, {\[Pi]/2 - decrad, rarad}};

data3 = Transpose@Prepend[Transpose@data3, Range@Length@data3];

starTable = 
  Prepend[data3, {"Index", "Name", "Magnitude", 
    "{Declination, Right Ascension}", ToString@{\[Theta], \[Phi]}}];
POSTED BY: Robert Hanlon
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