adding extra stars to constellations

pull/661/head
Pablo Gonzalez 2021-02-03 15:30:13 +01:00
parent e233f51dd9
commit 6fa61caaa6
8 changed files with 18262 additions and 12 deletions

View File

@ -2721,6 +2721,7 @@
{"name":"planetarium.app.js","url":"planetarium.app.js"},
{"name":"planetarium.data.csv","url":"planetarium.data.csv"},
{"name":"planetarium.const.csv","url":"planetarium.const.csv"},
{"name":"planetarium.extra.csv","url":"planetarium.extra.csv"},
{"name":"planetarium.settings.js","url":"settings.js"},
{"name":"planetarium.img","url":"planetarium-icon.js","evaluate":true}
],

View File

@ -24,4 +24,6 @@ Maybe you want to add some more constellations to the planetarium. As you can se
- Find the two stars that you want to join in your constellation (a constellation line). For identifying a star you have to have a look at the name, usually something like `AL UMA` (alpha star of constellation ursa major). Lets say that you want to join stars 155 and 8 (this is constellation canis menor, that only has a line joining two stars).
- Go to file `planetarium.const.csv` and add two lines for your new constellation. The first one will be the name of the constellation, the second one the pair of stars that you want to join, separated by coma (see the file for examples).
- Do not forget to add a break line after the last constellation.
- Upload the new `planetarium.const.csv` to your bangle (or emualator) and test it out.
- Upload the new `planetarium.const.csv` to your bangle (or emulator) and test it out.
What is a constellation star is not in the 500 star list in `planetarium.data.csv`? If you need another star to draw the constellation you can find that star in the full star list (`starinfo/planetarium.stars.csv`) and put it in `planetarium.extra.csv`. That stars will be loaded only when constellations are shown. In order to refer to these extra stars in the `planetarium.const.csv` you have to use the code `e_linenumber`, in order to differenciate them from the stars in the normal file. For instance, to refer to the first star in the file `planetarium.extra.csv`, you will refer it as `e_1`. Do not forget to add an extra line at the end as in the other files.

View File

@ -39,7 +39,10 @@ function siderealTime(julianDay)
* Draws a single star in the sky.
* starPositions is a dictionary that gets modified and it is used later for ploting the constelations
*/
function drawStar(zeta,theta,z,julianDay,latitude,longitude,starDE,starRA,starMag,starNumber,starPositions){
function drawStar(zeta,theta,z,julianDay,latitude,longitude,starInfo,starNumber,starPositions){
let starRA = parseFloat(starInfo[0]);
let starDE = parseFloat(starInfo[1]);
let starMag = parseFloat(starInfo[2]);
var dec = Math.asin(Math.sin(theta) * Math.cos(starDE) * Math.cos(starRA + zeta) + Math.cos(theta) * Math.sin(starDE));
var ascen = Math.atan2(Math.cos(starDE) * Math.sin(starRA + zeta), Math.cos(theta) * Math.cos(starDE) * Math.cos(starRA + zeta) - Math.sin(theta) * Math.sin(starDE)) + z;
var H = siderealTime(julianDay) - longitude - ascen;
@ -107,17 +110,28 @@ function plotSky(lat,lon,date){
starNumber++;
//Process the star
starInfo = line.split(',');
//console.log(starInfo[0]);
starRA = parseFloat(starInfo[0]);
starDE = parseFloat(starInfo[1]);
starMag = parseFloat(starInfo[2]);
drawStar(zeta,theta,z,julianDay,latitude,longitude,starDE,starRA,starMag,starNumber,starPositions);
drawStar(zeta,theta,z,julianDay,latitude,longitude,starInfo,starNumber,starPositions);
linestart = lineend+1;
lineend = f.indexOf("\n",linestart);
}
if (settings.constellations){
//First plot the extra stars for the constellations
fe=storage.read("planetarium.extra.csv","r");
linenum=linestart = 0;
lineend = fe.indexOf("\n");
let starNumber = 0;
while (lineend>=0) {
line = fe.substring(linestart,lineend);
starNumber++;
starInfo = line.split(',');
drawStar(zeta,theta,z,julianDay,latitude,longitude,starInfo,"e_"+starNumber,starPositions);
linestart = lineend+1;
lineend = fe.indexOf("\n",linestart);
}
//End of ploting extra stars
linenum=linestart = 0;
fc=storage.read("planetarium.const.csv","r");
lineend = fc.indexOf("\n");
@ -131,14 +145,13 @@ function plotSky(lat,lon,date){
linestart = lineend+1;
lineend = fc.indexOf("\n",linestart);
g.setColor(0,255,0);
if (linenum>11)
break;
constelationShowing=false;
for (j=0;j<lines.length;j++){
positions = lines[j].split(' ');
positionStar1=starPositions[parseInt(positions[0])];
positionStar2=starPositions[parseInt(positions[1])];
positionStar1=starPositions[positions[0]];
positionStar2=starPositions[positions[1]];
//Both stars need to be visible
if (positionStar1 && positionStar2)
{
@ -149,6 +162,7 @@ function plotSky(lat,lon,date){
constelationShowing=false;
g.flip();
}
//Write the name
if (constelationShowing && settings.consnames)
g.drawString(name,positionStar2[0]+10,positionStar2[1]);

View File

@ -22,3 +22,5 @@ Can Maior
1 47,1 37,37 22,22 178,37 89
Bootes
3 118,118 279,279 286,286 180,180 316,316 3
Lupus
140 210,322 140,322 410,410 98,98 234,234 210,98 302,302 362,234 e_1,234 e_2

1 Orion
22 1 47,1 37,37 22,22 178,37 89
23 Bootes
24 3 118,118 279,279 286,286 180,180 316,316 3
25 Lupus
26 140 210,322 140,322 410,410 98,98 234,234 210,98 302,302 362,234 e_1,234 e_2

View File

@ -0,0 +1,2 @@
1.394,-0.230,4.3,LA LEP
1.367,-0.226,4.4,KA LEP
1 1.394 -0.230 4.3 LA LEP
2 1.367 -0.226 4.4 KA LEP

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
'''
* This information is from the Yale Bright Star Catalog. First number is the RA (Right ascension) in radians. Careful because in all
* the catalogs this is in Hour angle. We have to convert it to degrees and then to radians.
* The second number is the DE (declination) in radians. In this case in the catalogs is in degrees, just convert to radians.
* Third number is the aparent magnitude
'''
import csv
import math
with open('starsoriginal.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
data_read = [row for row in csv_reader]
stars=[]
for row in data_read:
hours = float(row[0])
min = float(row[1])
seg = float(row[2])
rahours = hours+(min+seg/60)/60
radegress = rahours*360/24
radradians = math.radians(radegress)
deg = float(row[3])
dem = float(row[4])
des = float(row[5])
if (deg<0):
desex = deg-(dem+des/60)/60
else:
desex = deg+(dem+des/60)/60
derad = math.radians(desex)
stars.append(['{:.3f}'.format(radradians),'{:.3f}'.format(derad),'{:.1f}'.format(float(row[6])),row[7].strip()])
with open("planetarium.stars.csv", "wt") as fp:
writer = csv.writer(fp, delimiter=",")
# writer.writerow(["your", "header", "foo"]) # write header
writer.writerows(stars)

File diff suppressed because it is too large Load Diff