Free planetarium

 
User avatar
Quarior
Explorer
Explorer
Topic Author
Posts: 236
Joined: 11 Oct 2016
Location: Local Universe/Laniakea/Virgo SC/Local Group/Via Lactea/Orion–Cygnus Arm/Sol System/Gaia
Contact:

Tools and Utilities

18 Dec 2016 09:13

This thread is the continuation of Tools and Utilities by JackDole in the old forum.





AsterBeltCreator by JackDole :
I put this work by JackDole because I add a French translation, otherwise, the default language is English and the German translation is also include. I add Credit if you put C or c.
Version Python, no GUI (save to AsterBeltCreator.py) :
# -*- coding: utf-8 -*- 

import locale, platform, sys, random, math
from datetime import datetime

# AsterBeltCreator v0.3.2
# by JackDole
# 2016.04.10 19:43:27
# converted to Python and enhanced by FaceDeer
# more enhanced by JD

# Some English strings corrected by LookAtDaDakka
# Object type 'DwarfMoon' added at the suggestion of LookAtDatDakka
# Default number of items reduced to 50
# Order of the parameter query changed. Now parent object is asked first.
# Numbering offset added for dwarf moons. So that with an offset of 1000, the numbering starts at 'ParentBody.D1001' instead at 'ParentBody.D1'.
# Binaries and moons for dwarf moons disabled.
# Shall moons and binary partners be classified as 'DwarfMoon'

# this version works with Python  2.7, 3.4, 3.5 and 3.6

#-------------------------------------------------------------------------------

Locale = locale.getdefaultlocale()
VersionPython = 'Python ' + (platform.python_version())
Version = '0.3.2'
print (VersionPython + '\n' + 'AsterBeltCreator ' + Version + '\n')

# english default strings
Credit = "AsterBeltMaker " + Version + " : \nOriginal by JackDole\nConverted to Python and enhanced by FaceDeer\nMore enhanced by JackDole\nTranslation :\nEnglish : JackDole and LookAtDatDakka\nGerman : JackDole\nFrench : Quarior"
LngStr01 = "Preset \n 1 = Vulcanoiden \n 2 = Oort cloud \n 0 = No preset \n C = Credit \n x = Exit : "
LngStr02 = "Type of object \n 1 = Asteroid \n 2 = Comet \n 3 = DwarfMoon \n Default = 1 : "
LngStr03 = "Number of objects \n Default = 50 : "
LngStr04 = "Name for group of objects \n Default = "
LngStr05 = "Parent object \n Default = Sol : "
LngStr06 = "Is the Parent object a barycenter?\n 1 = yes \n 0 = no \n Default = 0 : "
LngStr07 = "Total mass of the main objects in solar mass."
LngStr08 = "If your object have Earth Mass, put a '-' sign for the number"
LngStr09 = "Example = Earth + Moon = 1 + 0.012302 = -1.012302"
LngStr10 = "Must be specified; an approximate value is sufficient. : "
LngStr11 = "Minimum radius in AU or KM"
LngStr12 = "If you have KM, put a '-' sign for the number"
LngStr14 = " Default = 5.0 AU : "
LngStr15 = "Maximum radius in AU or KM"
LngStr16 = "If you have KM, put a '-' sign for the number"
LngStr17 = " Default = 6.0 AU : "
LngStr18 = "Minimum radius of objects in km \n Default = 0.1 : "
LngStr19 = "Maximum radius of objects in km \n Default = 50.0 : "
LngStr20 = "Maximum eccentricity of orbit\n Default = 0.1 : "
LngStr21 = "Minimum eccentricity of orbit\n Default = 0.0 : "
LngStr22 = "Maximum variation of inclination in degrees \n Default = 10.0 : "
LngStr23 = "RefPlane (Ecliptic, Equator, Extrasolar) \n Default = Ecliptic : "
LngStr24 = "Epoch \n Default = 2457395.5 : "
LngStr25 = "Output file name \n Default = "
LngStr26 = "Inclination to the reference plane in degree \n Default = 0 : "
LngStr27 = "AscendingNode in degrees \n Random value if 0 \n Default = 0 : "
LngStr28 = "Numbering Offset\n Default = 0 : "
LngStr29 = "Shall moons and binary partners be classified as 'DwarfMoon'? \n 1 = Yes \n 0 = No \n Default = 0 (No)"
#LngStr30 = "Minimum distance between binary objects in km \n Default = 0 (Value is generated randomly) : "

if Locale[0] == 'de_DE':
    # german strings
    Credit = "AsterBeltMaker " + Version + " : \nOriginal durch JackDole\nKonvertiert zu to Python und verbessert durch FaceDeer\nMehr verbessert durch JackDole\nTranslation :\nEnglisch : JackDole durch LookAtDatDakka\nDeutsche : JackDole\nFranzösisch : Quarior"
    LngStr01 = "Voreinstellungen \n 1 = Vulkanoiden \n 2 = Oortsche Wolke \n 0 = Keine Voreinstellungen \n C = Kredit \n x = Ende : "
    LngStr02 = "Typ der Objekte \n 1 = Asteroiden \n 2 = Kometen \n 3 = Zwergmond \n Standard = 1 : "
    LngStr03 = "Anzahl der Objekte \n Standard = 50 : "
    LngStr04 = "Name der Objekte \n Eine laufende Nummer wird angefuegt. \n Standard = "
    LngStr05 = "Zentralobjekt \n Standard = Sol : "
    LngStr06 = "Ist das Zentralobjekt ein Barycenter ?\n 1 = Ja \n 0 = Nein \n Standard = 0 : "
    LngStr07 = "Totale Masse der Hauptobjekte des Systems in Sonnenmassen."
    LngStr08 = "Wenn du die Angaben in Erdmassen hast, setze ein '-' Zeichen vor der Zahl"
    LngStr09 = "Beispiel = Erde + Mond = 1 + 0.012302 = -1.012302"
    LngStr10 = "Muss angegeben werden. \n Ein angenaeherter Wert ist ausreichend. : "
    LngStr11 = "Innerer Radius in AU oder KM"
    LngStr12 = "Bei KM, setze ein '-' Zeichen vor der Zahl"
    LngStr14 = " Standard = 5.0 AU : "
    LngStr15 = "Aeusserer Radius in AU oder KM"
    LngStr16 = "Bei KM, setze ein '-' Zeichen vor der Zahl"
    LngStr17 = " Standard = 6.0 AU : "
    LngStr18 = "Minimaler Radius der Objekte in km \n Standard = 0.1 : "
    LngStr19 = "Maximaler Radius der Objekte in km \n Standard = 50.0 : "
    LngStr20 = "Maximale Exzentrizitaet der Umlaufbahn \n Standard = 0.1 : "
    LngStr21 = "Minimale Exzentrizitaet der Umlaufbahn \n Standard = 0.0 : "
    LngStr22 = "Maximale Variation der Inklination der Umlaufbahn in Grad \n Standard = 10.0 : "
    LngStr23 = "Referenze Ebene (Ecliptic, Equator, Extrasolar) \n Standard = Ecliptic : "
    LngStr24 = "Epoche \n Standard = 2457395.5 : "
    LngStr25 = "Name der Ausgabedatei \n Standard = "
    LngStr26 = "Neigung zur Referenzeebene in Grad \n Standard = 0 : "
    LngStr27 = "AscendingNode in Grad \n Wenn 0 wird ein zufaelliger Wert erzeugt \n Standard = 0 : "
    LngStr28 = "Nummerierung Offset\n Standard = 0 : "
    LngStr29 = "Sollen Monde und binaere Partner als 'DwarfMoon' eingestuft werden?"
    #LngStr30 = "Minimaler Abstand zwischen Binaeren Objekten in km \n Standard = 0 (Wert wird zufaellig erzeugt) : "


if Locale[0]== 'fr_FR':
    # french strings
    Credit = "AsterBeltMaker " + Version + " : \nOriginal par JackDole\nConverti en Python et amélioré par FaceDeer\nPlus amélioré par JackDole\nTraduction :\nAnglais : JackDole et LookAtDatDakka\nAllemand : JackDole\nFrançais : Quarior"
    LngStr01 = "Préréglage \n 1 = Vulcanoiden \n 2 = Nuage d'Oort \n 0 = Pas de préréglage \n C = Crédit \n x = Quitter : "
    LngStr02 = "Type d'objet \n 1 = Astéroïde \n 2 = Comète \n 3 = Satellite naine \n Défaut = 1 : "
    LngStr03 = "Nombre d'objets \n Défaut = 50 : "
    LngStr04 = "Nom du groupe d'objets \n Défaut = "
    LngStr05 = "Parent de l'objet \n Défaut = Sol : "
    LngStr06 = "Le parent est-il un barycentre ?\n 1 = Oui \n 0 = Non \n Défaut = 0 : "
    LngStr07 = "Masse totale de l'objet principal en masse solaire."
    LngStr08 = "Si vous choississez en masse terrestre, mettre un signe '-' pour le nombre"
    LngStr09 = "Exemple = Terre + Lune = 1 + 0.012302 = -1.012302"
    LngStr10 = "Doit être spécifié; une valeur approximative est suffisante. : "
    LngStr11 = "Rayon minimum en UA ou km"
    LngStr12 = "Si vous mettez en km, mettre un signe '-' pour le nombre"
    LngStr14 = " Défaut = 5.0 AU : "
    LngStr15 = "Rayon maximum en UA ou km"
    LngStr16 = "Si vous mettez en km, mettre un signe '-' pour le nombre"
    LngStr17 = " Défaut = 6.0 AU : "
    LngStr18 = "Rayon minimum de l'objet en km \n Défaut = 0.1 : "
    LngStr19 = "Rayon maximum de l'objet en km \n Défaut = 50.0 : "
    LngStr20 = "Eccentricité maximum de l'orbite\n Défaut = 0.1 : "
    LngStr21 = "Eccentricité minimum de l'orbite\n Défaut = 0.0 : "
    LngStr22 = "Variation maximum de l'inclinaison en degré \n Défaut = 10.0 : "
    LngStr23 = "RefPlane (Plan de référence) (Ecliptic (Ecliptique), Equator (Equateur), Extrasolar (Extrasolaire)) \n Défaut = Ecliptic : "
    LngStr24 = "Epoch (Epoque) \n Défaut = 2457395.5 : "
    LngStr25 = "Nom du fichier en sortie \n Default = "
    LngStr26 = "Inclinaison au plan de référence en degré \n Défaut = 0 : "
    LngStr27 = "AscendingNode en degré \n Valeur aléatoire si 0 \n Défaut = 0 : "
    LngStr28 = "Décallage pour la numérotation\n Défaut = 0 : "
    LngStr29 = "Les lunes et les partenaires binaires sont-ils classés comme des 'DwarfMoon' (lunes naines) ? \n 1 = Oui \n 0 = Non \n Défaut = 0 (Non)"
    #LngStr30 = "Distance minimum entre les objets binaires en km \n Défaut = 0 (Valeur est généré aléatoirement) : "

#-------------------------------------------------------------------------------

daysYear = 365.24218985
AU = 149597870.691
SolMassOfEarth = 3.00316726157558694887e-6
EarthMass = 5.9736e24

#uncomment this line if you want repeatable results
#random.seed(100)

#-------------------------------------------------------------------------------

def GetInput(s):
    if sys.version_info >= (3,0):
        return input(s)
    else:
        return raw_input(s)


# Select preset

while 1 == 1:
    ObjectType = 'Asteroid'
    nameOfAster = "Asteroid"
    defObjName = 'S'
    defFileName = "AsterBelt"
    RefPlane = 'Ecliptic'
    epoch = 2457395.5
    TotalMass = 0.0
    AscNode = 0.0
    numberingOffset = 0
    binAsDwarf = 0
    MainInclination = 0.0
    asterSuffix = ''
    asterColor = ''

    print ('------------------------------------------------------------------------------')

    ts = LngStr01
    Preset = GetInput(ts)

    if Preset == "x" or Preset == "q":
        exit()
    elif Preset == "C" or Preset == "c":
        print(Credit + "\n")
    elif Preset == "":
        Preset = "0"
    print (Preset)
    print ("")

    # Preset Vulcanoids
    if Preset == "1":
        NumberOfAster = 200
        AsterName = 'VS'
        CenterObject = 'Sol'
        InnerRadius = 0.15
        OuterRadius = 0.18
        MaxRadiusOfAster = 3
        MinRadiusOfAster = 0.1
        MaxEccentricity = 0.001
        MinEccentricity = 0.0
        MaxInclination = 10
        FileName = 'Vulcanoids'
        
    # Preset Oort cloud
    elif Preset == "2":
        ObjectType = 'Comet'
        NumberOfAster = 2000
        AsterName = 'OC'
        CenterObject = 'Sol'
        InnerRadius = 5000
        OuterRadius = 50000
        MaxRadiusOfAster = 500
        MinRadiusOfAster = 0.1
        MaxEccentricity = 0.3
        MinEccentricity = 0.0
        MaxInclination = 180
        FileName = 'OortCloud'
        #FileName = 'OortCloudComets'

    # No preset
    elif Preset == "0":
        # Center object
        CenterObject = GetInput(LngStr05)
        if CenterObject == '':
            CenterObject = 'Sol'
        print (CenterObject + '\n')
        
        # BaryCenter object
        isBaryCenter = GetInput(LngStr06)
        if isBaryCenter == '1' or isBaryCenter == 'y' or isBaryCenter == 'j':
            isBaryCenter = 1
        else:
            isBaryCenter = 0
        print (isBaryCenter)
        print ("")

        if isBaryCenter == 1:
            TotalMass = ''
            while TotalMass == '' or TotalMass >= 'A':
                print(LngStr07)
                print(LngStr08)
                print(LngStr09)
                TotalMass = GetInput(LngStr10)
            TotalMass = float(TotalMass)
            if TotalMass < 0:
                TotalMass = abs(TotalMass * SolMassOfEarth)
            print (TotalMass)
            print ("")

        # ObjectType = Asteroid , Comet or DwarfMoon
        AskObjectType = GetInput(LngStr02)
        if AskObjectType == '2' or AskObjectType == 'C':
            ObjectType = 'Comet'
            defObjName = 'C'
            defFileName = CenterObject + 'CometCloud'
        elif AskObjectType == '3' or AskObjectType == 'D':
            ObjectType = 'DwarfMoon'
            defObjName = CenterObject + '.D'
            defFileName = CenterObject + 'DwarfMoons'
        else:
            ObjectType =  'Asteroid'
            defObjName = 'S'
            defFileName = CenterObject + 'AsterBelt'
        print (ObjectType + "\n")
        
        # Numbering offset
        numberingOffset = GetInput(LngStr28)
        if numberingOffset == '':
            numberingOffset = 0
        numberingOffset = int(numberingOffset)
        print (numberingOffset)
        print("")
            
        # DwarMoon or not DwarMoon, thats the question
        if ObjectType != 'DwarfMoon':
            binAsDwarf = GetInput(LngStr29 + "\n")
            if binAsDwarf == '1' or binAsDwarf == 'Y' or binAsDwarf == 'j':
                binAsDwarf = 1
            else:
                binAsDwarf = 0
            print (binAsDwarf)
            print("")
            
        # Minmus distance binarys
        #minDistBin = GetInput(LngStr28)
        #if minDistBin == '':
        #    minDistBin = 0
        #minDistBin = float(minDistBin)
        #print (minDistBin)
        #print ("")

        # Amount of asteroids
        NumberOfAster = GetInput(LngStr03)
        if NumberOfAster == '':
            NumberOfAster = 50
        NumberOfAster = int(NumberOfAster)
        print (NumberOfAster)
        print ("")

        # Name of the asteroids - a serial number is appended
        AsterName = GetInput(LngStr04 + defObjName + ' : ')
        if AsterName == '':
            AsterName = defObjName
        print (AsterName + '\n')
        
        # Orbital radii in AU
        print (LngStr11)
        print (LngStr12)
        InnerRadius = GetInput(LngStr14)
        if InnerRadius == '':
            InnerRadius = 5.0
        InnerRadius = float(InnerRadius)
        if InnerRadius < 0:
            InnerRadius = abs(InnerRadius / AU)
        print (InnerRadius)
        print ("")

        print (LngStr15)
        print (LngStr16)
        
        OuterRadius = GetInput(LngStr17)
        if OuterRadius == '':
            OuterRadius = 6.0
        OuterRadius = float(OuterRadius)
        if OuterRadius < 0:
            OuterRadius = abs(OuterRadius / AU)
        print (OuterRadius)
        print ("")

        MinRadiusOfAster = GetInput(LngStr18)
        if MinRadiusOfAster == '':
            MinRadiusOfAster = 0.1
        MinRadiusOfAster = float(MinRadiusOfAster)
        print (MinRadiusOfAster)
        print ("")

        # Radius of asteroids in KM
        MaxRadiusOfAster = GetInput(LngStr19)
        if MaxRadiusOfAster == '':
            MaxRadiusOfAster = 50.0
        MaxRadiusOfAster = float(MaxRadiusOfAster)
        print (MaxRadiusOfAster)
        print ("")

        #orbital eccentricity
        MaxEccentricity = GetInput(LngStr20)
        if MaxEccentricity == '':
            MaxEccentricity = 0.1
        MaxEccentricity = float(MaxEccentricity)
        print (MaxEccentricity)
        print ("")

        MinEccentricity = GetInput(LngStr21)
        if MinEccentricity == '':
            MinEccentricity = 0.0
        MinEccentricity = float(MinEccentricity)
        print (MinEccentricity)
        print ("")

        # Orbital inclination  in degrees
        MainInclination = GetInput(LngStr26)
        if MainInclination == '':
            MainInclination = 0.0
        MainInclination = float(MainInclination)
        print (MainInclination)
        print ("")

        # Variation of inclination +- in degrees
        MaxInclination = GetInput(LngStr22)
        if MaxInclination == '':
            MaxInclination = 10.0
        MaxInclination = float(MaxInclination)
        print (MaxInclination)
        print ("")

        #  AscendingNode
        AscNode = GetInput(LngStr27)
        if AscNode == '':
            AscNode = 0.0
        AscNode = float(AscNode)
        print (AscNode)
        print ("")

        # Refplane
        RefPlane = GetInput(LngStr23)
        if RefPlane == '':
            RefPlane = 'Ecliptic'
        print (RefPlane + '\n')
        
        # Epoch
        epoch = GetInput(LngStr24)
        if epoch == '':
            epoch = 2457395.5
        epoch = float(epoch)
        print (epoch)
        print ("")

        #FileName
        FileName = GetInput(LngStr25 + defFileName + ' : ')
        if FileName == '':
            FileName = defFileName


    FileName =  '{0}_{1}.sc'.format(FileName, NumberOfAster)
    print ('\nCreating: ' + FileName + "\n\n")

    #---------------------------------------------------------------------------

    #rotation periods in hours. See https://www.boulder.swri.edu/~bottke/rubble/node3.html
    MaxRotationPeriod = 12
    MinRotationPeriod = 0.1

    ChanceOfMoon = 0.9
    ChanceOfBinary = 0.1

    if ObjectType == 'Comet':
        ChanceOfMoon = 1.0
        ChanceOfBinary = 0.2

    # If you want dwarf moons with moons change these values:
    # ChanceOfMoon < 1.0
    # ChangeOfBinary > 0.0
    if ObjectType == 'DwarfMoon':
        ChanceOfMoon = 1.0
        ChanceOfBinary = 0.0

    class Orbit:
        def PrintIt(self):
            result = ['\tOrbit\n\t{']
            if hasattr(self, 'epoch'):
                result.append('\t\tEpoch\t\t\t{0}'.format(self.epoch))
            else:
                result.append('\t\tEpoch\t\t\t2457395.5')
            if hasattr(self, 'semi'):
                result.append('\t\tSemiMajorAxis\t{0}'.format(self.semi))
            if hasattr(self, 'period'):
                result.append('\t\tPeriod\t\t\t{0}'.format(self.period))
            if hasattr(self, 'eccen'):
                result.append('\t\tEccentricity\t{0}'.format(self.eccen))
            if hasattr(self, 'incl'):
                result.append('\t\tInclination\t\t{0}'.format(self.incl))
            if hasattr(self, 'ascen'):
                result.append('\t\tAscendingNode\t{0}'.format(self.ascen))
            if hasattr(self, 'argof'):
                result.append('\t\tArgOfPericen\t{0}'.format(self.argof))
            if hasattr(self, 'refplane'):
                result.append('\t\tRefPlane\t\t"{0}"'.format(self.refplane))
            else:
                result.append('\t\tRefPlane\t\t"Ecliptic"')
            #result.append('\t\tMeanAnomaly\t\t0.0')
            result.append('\t\tMeanAnomaly\t\t{0}'.format(self.mean))
            result.append('\t}')
            return '\n'.join(result)

    class Asteroid:
        def PrintIt(self):
            result = [ObjectType + ' "{0}"\n{{\n\tParentBody\t"{1}"\n\tClass\t\t"Asteroid"'.format(self.name, self.parent)]
            if hasattr(self, 'mass'):
                result.append('\tMass\t\t{0}'.format(self.mass))
            if hasattr(self, 'radius'):
                result.append('\tRadius\t\t{0}\n'.format(self.radius))
            if hasattr(self, 'rotation'):
                result.append('\tRotationPeriod\t{0}'.format(self.rotation))
            if hasattr(self, 'obliquity'):
                result.append('\n\tObliquity\t\t{0}\n'.format(self.obliquity))
            result.append(self.orbit.PrintIt())
            result.append('}')
            return '\n'.join(result)

        def getSafeMoonRadius(self):
            return self.radius/AU * 1.2

    class DwarfMoon:
        def PrintIt(self):
            result = ['DwarfMoon "{0}"\n{{\n\tParentBody\t"{1}"\n\tClass\t\t"Asteroid"'.format(self.name, self.parent)]
            if hasattr(self, 'mass'):
                result.append('\tMass\t\t{0}'.format(self.mass))
            if hasattr(self, 'radius'):
                result.append('\tRadius\t\t{0}\n'.format(self.radius))
            if hasattr(self, 'rotation'):
                result.append('\tRotationPeriod\t{0}'.format(self.rotation))
            if hasattr(self, 'obliquity'):
                result.append('\n\tObliquity\t\t{0}\n'.format(self.obliquity))
            result.append(self.orbit.PrintIt())
            result.append('}')
            return '\n'.join(result)

    class BinaryAsteroid:
        def PrintIt(self):
            result = ['Barycenter "{0}"\n{{\n\tParentBody\t"{1}"'.format(self.name, self.parent)]
            result.append(orbit.PrintIt())
            result.append('}\n')

            density = randomGenerator(2,4) * 1e12 / EarthMass

            #asteroid = Asteroid()
            if binAsDwarf == 1:
                asteroid = DwarfMoon()
            else:
                asteroid = Asteroid()
            
            asteroid.name = self.name + " A"
            asteroid.parent = self.name
            asteroid.radius = self.radius1
            asteroid.mass = 4/3 * math.pi * math.pow(asteroid.radius,3) * density
            asteroid.orbit = self.componentorbit
            result.append(asteroid.PrintIt())

            asteroid.name = self.name + " B"
            asteroid.radius = self.radius2
            asteroid.mass = 4/3 * math.pi * math.pow(asteroid.radius,3) * density
            asteroid.orbit.argof = (asteroid.orbit.argof + 180) % 360
            result.append(asteroid.PrintIt())
            return '\n'.join(result)

    #three different random number generators that give a floating point number between
    #the two parameters but with different distributions

    def uniform(a, b):
        return random.uniform(a, b)

    # A normal distribution placing a and b at three standard deviations out from the mean
    # clamping the result so that there are no outliers beyond the desired range
    def gaussian(a, b):
        result = random.gauss((a+b)/2.0, (b-a)/6.0)
        return max(min(result, b), a)

    randomGenerator = gaussian

    def makeMoon(parentAsteroid, moonCount):
        innerLimit = parentAsteroid.radius/AU * 1.1
        outerLimit = innerLimit * 20

        if binAsDwarf == 1:
            moon = DwarfMoon()
        else:
            moon = Asteroid()
        
        moon.radius = random.uniform(parentAsteroid.radius/20, parentAsteroid.radius/4)
        moon.mass = 4/3 * math.pi * math.pow(moon.radius,3) * parentAsteroid.density
        moon.name = parentAsteroid.name + '.{0}'.format(moonCount)
        moon.parent = parentAsteroid.name

        orbit = Orbit()
        orbit.parent = parentAsteroid.name
        orbit.refplane = 'Equator'
        orbit.semi = random.uniform(innerLimit, outerLimit)
        orbit.incl = randomGenerator(-90, 90)
        orbit.eccen = randomGenerator(0, 0.01)       # 0.1
        orbit.argof = random.uniform(0,360)
        orbit.ascen = random.uniform(0,360)
        orbit.mean = random.uniform(0,180)

        moon.orbit = orbit

        return moon.PrintIt()


    def makeAsteroid(count, orbit):
        asteroid = Asteroid()
        asteroid.name = AsterName + '{0}'.format(count)
        asteroid.parent = CenterObject
        asteroid.radius = randomGenerator(MinRadiusOfAster, MaxRadiusOfAster)
        asteroid.density = randomGenerator(2,4) * 1e12 / EarthMass
        asteroid.mass = 4/3 * math.pi * math.pow(asteroid.radius,3) * asteroid.density
        asteroid.rotation = randomGenerator(MinRotationPeriod,MaxRotationPeriod)
        asteroid.obliquity = random.uniform(0,360)
        asteroid.orbit = orbit

        output = [asteroid.PrintIt()]
        
        moonCount = 0
        while random.random() > ChanceOfMoon and moonCount < 10:
            moonCount = moonCount + 1
            output.append(makeMoon(asteroid, moonCount))
        
        return '\n'.join(output)

    def makeBinaryAsteroid(count, orbit):
        binary = BinaryAsteroid()
        binary.name = AsterName + '{0}'.format(count)
        binary.parent = CenterObject
        binary.radius1 = randomGenerator(MinRadiusOfAster, MaxRadiusOfAster)
        binary.radius2 = binary.radius1 * random.uniform(0.25,1)
        binary.orbit = orbit

        componentOrbit = Orbit()
        componentOrbit.period = random.uniform(0.1, 3) / daysYear
        componentOrbit.incl = random.uniform(0,360)
        componentOrbit.eccen = randomGenerator(0, 0.01)      # 0.1
        componentOrbit.argof = random.uniform(0,360)
        componentOrbit.ascen = random.uniform(0,360)
        componentOrbit.mean = random.uniform(0,180)
        componentOrbit.refplane = 'Equator'

        binary.componentorbit = componentOrbit

        return binary.PrintIt()


    with open(FileName, 'w') as outputfile:
        outputfile.write('// ' + ObjectType + 's made with AsterBeltCreator\n// ' + Version + '\n// {0}'.format(datetime.today()))
        
        outputfile.write('\n\n')
        outputfile.write('// ParentObject    = ' + CenterObject + '\n')
        outputfile.write('// Objecttype      = ' + ObjectType + '\n')
        outputfile.write('// NumberOffset    = ' + str(numberingOffset) + '\n')
        outputfile.write('// NumberOfAster   = ' + str(NumberOfAster) + '\n')
        outputfile.write('// AsterName       = ' + AsterName + '\n')
        outputfile.write('// InnerRadius     = ' + str(InnerRadius) + '\n')
        outputfile.write('// OuterRadius     = ' + str(OuterRadius) + '\n')
        outputfile.write('// MinRadiusOfAster = ' + str(MinRadiusOfAster) + '\n')
        outputfile.write('// MaxRadiusOfAster = ' + str(MaxRadiusOfAster) + '\n')
        outputfile.write('// MaxEccentricity = ' + str(MaxEccentricity) + '\n')
        outputfile.write('// MinEccentricity = ' + str(MinEccentricity) + '\n')
        outputfile.write('// MainInclination = ' + str(MainInclination) + '\n')
        outputfile.write('// MaxInclination  = ' + str(MaxInclination) + '\n')
        outputfile.write('// RefPlane        = ' + RefPlane + '\n')

        if AscNode >= 0:
            outputfile.write('// AscNode         = ' + str(AscNode) + '\n')
        outputfile.write('// FileName        = ' + FileName)

        for count in range(NumberOfAster):
            orbit = Orbit()
            orbit.semi = randomGenerator(InnerRadius, OuterRadius)
            if TotalMass > 0.0:
                orbit.period = math.sqrt(math.pow(orbit.semi, 3) / TotalMass)
            orbit.incl =  randomGenerator(-MaxInclination, MaxInclination) + MainInclination
            orbit.eccen = randomGenerator(MinEccentricity, MaxEccentricity)
            orbit.argof = random.uniform(0,360)
            if AscNode == 0.0:
                orbit.ascen = random.uniform(0,360)
            else:
                orbit.ascen = AscNode
            orbit.mean = random.uniform(0,180)
            orbit.epoch = epoch
            orbit.refplane = RefPlane

            outputfile.write('\n\n')

            if random.random() > ChanceOfBinary:
                outputfile.write(makeAsteroid(numberingOffset+count+1, orbit))
            else:
                outputfile.write(makeBinaryAsteroid(numberingOffset+count+1, orbit))

GUI version here.

Who is online

Users browsing this forum: Google [Bot] and 5 guests