def __init__(self, world_width, world_height): self.mWorldWidth = world_width self.mWorldHeight = world_height shipX = self.mWorldWidth / 2 shipY = self.mWorldHeight / 2 self.mShip = ship.Ship(shipX, shipY, self.mWorldWidth, self.mWorldHeight) self.mRocks = [] self.mObjects = [self.mShip] # rocks for x in range(10): rockX = random.randrange(0, self.mWorldWidth) rockY = random.randrange(0 , self.mWorldHeight) rock1 = rock.Rock(rockX, rockY, world_width, world_height) self.mRocks.append(rock1) self.mObjects.append(rock1) #stars self.mStars = [] for x in range(20): starX = random.randrange(0, self.mWorldWidth) starY = random.randrange(0, self.mWorldHeight) star1 = star.Star(starX, starY, self.mWorldWidth, self.mWorldHeight ) self.mStars.append(star1) self.mObjects.append(star1) self.mBullets = [] self.mGameLost = False self.mGameWon = False
def parse_stars3d(root_path): stars = [] path = root_path + "txt/" for file in os.listdir(path): constellation_name = get_constellation_name(root_path, file) with open(path + file) as text: for occurrence in re.findall( COORDINATES_RE, text.read(), re.MULTILINE): longitude = parse_angle( occurrence[1], occurrence[2], occurrence[3], 15) latitude = parse_angle( occurrence[4], occurrence[5], occurrence[6], 1) point3d = geometry.Vector3D.convert_from_spherical_coordinates( latitude, longitude) brightness = float(occurrence[9].replace(" ", "")) color = parse_color(occurrence[10]) tooltip = format_coordinates( occurrence[1], occurrence[2], occurrence[3], occurrence[4], occurrence[5], occurrence[6]) stars.append(star.Star( point3d, brightness, color, constellation_name, tooltip)) return stars
def __init__(self, width, height): self.mWorldWidth = width self.mWorldHeight = height shipx = random.randint(0, self.mWorldWidth) shipy = random.randint(0, self.mWorldHeight) self.mShip = ship.Ship(shipx, shipy, self.mWorldWidth, self.mWorldHeight) self.mBullet = [] NUM_ROCKS = random.randint(10, 20) self.mRocks = [] for i in range(NUM_ROCKS): rockx = random.randint(0, self.mWorldWidth) rocky = random.randint(0, self.mWorldHeight) rocks = rock.Rock(rockx, rocky, self.mWorldWidth, self.mWorldHeight) self.mRocks.append(rocks) NUM_STARS = 20 self.mStars = [] for i in range(NUM_STARS): starsx = random.randint(0, self.mWorldWidth) starsy = random.randint(0, self.mWorldHeight) stars = star.Star(starsx, starsy, self.mWorldWidth, self.mWorldHeight) self.mStars.append(stars) self.mObjects = self.mRocks[:] + [self.mShip] + self.mStars[:]
def __init__(self, world_width, world_height): self.mWorldWidth = world_width self.mWorldHeight = world_height self.mRocks = [] self.mStars = [] self.mBullets = [] self.mObjects = [] self.mShip = ship.Ship(world_width / 2, world_height / 2, self.mWorldWidth, self.mWorldHeight) for i in range(20): self.mStars.append( star.Star(random.randrange(0, 700), random.randrange(0, 700), self.mWorldWidth, self.mWorldHeight)) for s in self.mStars: self.mObjects.append(s) for i in range(10): self.mRocks.append( rock.Rock(random.randrange(0, 700), random.randrange(0, 700), self.mWorldWidth, self.mWorldHeight)) for r in self.mRocks: self.mObjects.append(r) self.mObjects.append(self.mShip) return
class Tracking: def __init__(self, sci_path=HAT_SCI_PATH, dark_path=HAT_DRK_PATH, band='v', name=HAT_NAME): self.planet_name = name self.sci_path = sci_path self.dark_frame = gsf.process_dark(dark_path) self.response_map = gsf.fits_open(RESPONSE_PATH + band.lower() + "_band_response_map.fts") self.stars = {} self.file_names = filter_names(gsf.generate_names(HAT_SCI_PATH)) self.aperture = -1 def file_grab(self, index): return gsf.fits_open(self.file_names[index]) def dark_subtract(self, science_frame): return science_frame - self.dark_frame def flatten(self, science_frame): return science_frame / self.response_map def make_adjustments(self, science_frame): return filter_image(median_subtract(self.flatten(self.dark_subtract(science_frame)))) def find_initial(self, identifier, science_frame, (initial_x, initial_y)): star_instance = star.Star(identifier) star_instance.add_frame(find_star(science_frame, (initial_x, initial_y))) self.stars[identifier] = star_instance
def get_stars(screen): mercury = star.Star(15, (85, 0, 170), screen) venus = star.Star(15, (170, 43, 43), screen) earth = star.Star(15, (0, 0, 255), screen) mars = star.Star(15, (223, 0, 32), screen) jupiter = star.Star(15, (249, 236, 228), screen) saturn = star.Star(15, (237, 189, 101), screen) uranus = star.Star(15, (87, 250, 255), screen) neptune = star.Star(15, (143, 188, 143), screen) return (mercury, venus, earth, mars, jupiter, saturn, uranus, neptune)
def import_stars(): #import coordinate positions of star data from csv star_data = pd.read_csv("hygdata_v3.csv", usecols=["Proper name", "x", "y"]) #drop all non-named stars star_data = star_data.dropna(subset=["Proper name"]) #create star instances from star data star_data["Obj"] = star_data.apply( lambda i: star.Star(i["Proper name"], (i["x"], i["y"])), axis=1) return star_data
def compute_alt(B, Balt): S = star.Star(B, Balt, mReps=mRepetitions()) print "Rooting Table" S.root_table(k=kRepetitions(), r=rDelta()) while S.need_r(confidence_level()): print "Extending r to", S.numbers_1xr.shape[1] + rDelta() S.extend_r(rDelta()) if S.numbers_1xr.shape[1] > 210000: return np.inf return S.r_star(confidence_level())
def print_ubvr_mags(): """ Prints U, B, V, and R magnitudes of a star against possible temperatures between 1000K and 10_000K. Star has radius equal to the sun and a distance of 10 parsecs from Earth. """ print("Temperature (K)\t| U \t| B \t| V \t| R") print("-"*16 + ("+" + "-"*7)*4) for temperature in range(1000, 11000, 1000): st = star.Star(constants.SOLAR_RADIUS, 10*constants.PARSEC, temperature) print("{0}\t\t\t| {1:.1f}\t| {2:.1f}\t| {3:.1f}\t| {4:.1f}".format(temperature, st.get_u_mag(), st.get_b_mag(), st.get_v_mag(), st.get_r_mag()))
def __init__(self, world_width, world_height): self.mWorldWidth = world_width self.mWorldHeight = world_height self.mShip = ship.Ship(300, 300, world_width, world_height) self.mRocks = [] self.mObjects = [] self.mBullets = [] self.mStars = [] for i in range(20): x = random.randint(0, self.mWorldWidth) y = random.randint(0, self.mWorldHeight) self.mStars.append(star.Star(x, y, world_width, world_height)) #add randrange for x and y for i in range(10): x = random.randint(0, self.mWorldWidth) y = random.randint(0, self.mWorldHeight) self.mRocks.append(rock.Rock(x, y, world_width, world_height)) self.mObjects = self.mRocks + self.mStars + [self.mShip] return
def __init__(self, name, width, heigth,framerate): game.Game.__init__(self,config.TITLE, config.SCREEN_X, config.SCREEN_Y) self.space = [] self.ship = ship.Ship() self.bullets = [] self.rocks = [] self.bfighter= [] self.b = 0 for bu in range(config.BULLET_COUNT): self.bullets.append (bullet.Bullet(Point(self.ship.shipX, self.ship.shipY),self.ship.rotation)) for numb in range(config.STAR_COUNT): self.star = star.Star() self.space.append(self.star) for num in range(config.ROCK_COUNT): self.bRock = rock.bigRock() self.rocks.append(self.bRock)
def evaluate(individual): WAVELENGTH = 0.75 # microns MCFOST_path = "../mcfost-workspace/" default_params = "default_parameters_star" VAMP_path = "" VAMP_data = "diffdata_RLeo_03_20170313_750-50_18holeNudged_0_0.idlvar" VAMP_data_info = "cubeinfoMar2017.idlvar" VAMP_data = VAMPIRES_data.VAMPIRES_data(VAMP_path + VAMP_data, VAMP_path + VAMP_data_info) # remove out bias from the observed data i.e. move the average to 1 VAMP_data.vhvv -= np.mean(VAMP_data.vhvv) - 1 VAMP_data.vhvvu -= np.mean(VAMP_data.vhvvu) - 1 dm = individual.genes["dust_mass"] Rin = individual.genes["inner_radius"] r = individual.genes["radius"] Rout = individual.genes["outer_radius"] free_params = {"dust_mass": dm, "Rin": Rin, "radius": r, "Rout": Rout} s = star.Star(free_params, default_params, WAVELENGTH, MCFOST_path, VAMP_data, load=False, verbose=False) s.calculate_reduced_chi2error() individual.data["data_Q"] = s.data_Q individual.data["data_U"] = s.data_U individual.data["reduced_chi2err_Q"] = s.reduced_chi2err_Q individual.data["reduced_chi2err_U"] = s.reduced_chi2err_U individual.data["reduced_chi2err"] = s.reduced_chi2err individual.fitness_score = s.reduced_chi2err
def project_visible_points(stars3d, view_area, obligatory_constellation=None): projected_stars2d = [] brightness_threshold = view_area.get_brightness_threshold() cos_view_angle = math.cos(view_area.view_angle) sin_view_angle = math.sin(view_area.view_angle) for star3d in stars3d: if star3d.brightness > brightness_threshold: continue point2d = view_area.project_point3d( star3d.point, cos_view_angle, sin_view_angle) if point2d is not None: projected_stars2d.append(star.Star( point2d, star3d.brightness, star3d.color, star3d.constellation, star3d.tooltip)) elif obligatory_constellation == star3d.constellation: return None return projected_stars2d
def __call__(self, temperature): """ Get magnitude of star in wave band if star is a specific temperature. :type temperature: int, float :param temperature: Temperature of star. :rtype: float :returns: Magnitude of star within specified wave band. :raises: ValueError """ st = star.Star(self.radius, self.distance, temperature) if self.wave_band == "u": return st.get_u_mag() elif self.wave_band == "b": return st.get_b_mag() elif self.wave_band == "v": return st.get_v_mag() elif self.wave_band == "r": return st.get_r_mag() else: raise ValueError("Could not identify wave band")
def setUp(self): initial_x = 11 initial_y = 22 initial_dx = 0 initial_dy = 0 self.expected_rotation = 0 self.expected_radius = 2 self.expected_world_width = 600 self.expected_world_height = 800 self.expected_max_brightness = 255 self.expected_min_brightness = 0 self.expected_color = (255, 255, 255) self.expected_dx = initial_dx self.expected_dy = initial_dy self.expected_x = initial_x self.expected_y = initial_y self.constructed_obj = star.Star(initial_x, initial_y, self.expected_world_width, self.expected_world_height) return
def makequads2(starlist, f=5.0, n=6, s=0, d=50.0, verbose=True): """ Similar, but fxf in subareas roughly f times smaller than the full frame. s allows to skip the brightest stars in each region :param f: smallness of the subareas :type f: float :param n: number of stars to consider in each subarea :type n: int :param d: minimal distance between stars :type d: float :param s: number of brightest stars to skip in each subarea :type s: int """ quadlist = [] sortedstars = star.sortstarlistbyflux(starlist) (xmin, xmax, ymin, ymax) = star.area(sortedstars) r = 2.0 * max(xmax - xmin, ymax - ymin) / f for xc in np.linspace(xmin, xmax, f + 2)[1:-1]: for yc in np.linspace(ymin, ymax, f + 2)[1:-1]: cstar = star.Star(x=xc, y=yc) das = cstar.distanceandsort(sortedstars) #closest = [s["star"] for s in das[0:4]] brightestwithinr = star.sortstarlistbyflux([ element["star"] for element in das if element["dist"] <= r ])[s:s + n] for fourstars in itertools.combinations(brightestwithinr, 4): if mindist(fourstars) > d: quadlist.append(Quad(fourstars)) if verbose: print "Made %4i quads from %4i stars (combi sub f=%.1f n=%i s=%i d=%.1f)" % ( len(quadlist), len(starlist), f, n, s, d) return quadlist
def __init__(self): # pyxel.init(imp.WINDOW_W, imp.WINDOW_H, caption="Pyxel Shooting", scale=3, fps=60) pyxel.init(imp.WINDOW_W, imp.WINDOW_H, caption="Pyxel Shooting", scale=3, fps=60, palette=[ 0x000000, 0xc8cbd2, 0x000000, 0xa7a5a2, 0xe057cd, 0x335793, 0x099c9e, 0xffffff, 0xef337b, 0x1f2856, 0x000000, 0xffff00, 0x000000, 0x000000, 0x000000, 0x000000 ]) pyxel.load("assets/my_resource.pyxres") pyxel.image(0).load(0, 0, "assets/img0.png") # メインScene タイトル セット self.SetSubScene(SceneTitle()) imp.StarScene = star.Star() pyxel.run(self.update, self.draw)
B_phi = B_phimin + rand() * (B_phimax - B_phimin) print "Star parameters" print "L: ", Lstar / star.L_star_CenA print "B: ", B1AU / star.sun_Bfield_1AU print "Angles: ", B_theta * 180.0 / pi, B_phi * 180.0 / pi # Create star object magmomvector = vector.Vector3D(0.0, 0.0, 1.0) magmomvector.rotateX(B_theta) magmomvector.rotateZ(B_phi) cenA = star.Star(star.M_star_CenA, star.R_star_CenA, Lstar, B1AU, star_position, star_velocity, magmom=magmomvector) print ship print cenA ship.fly(cenA, minimum_distance_from_star, afterburner_distance, timestep, return_mission=False) filename = 'flight_' + str(iship + 1) + '.telemetry' ship.write_telemetry_to_file(filename, cenA) # Extract data of interest from telemetry
def __init__(self, x, y, numstars): self.w = x self.h = y for i in range(numstars): self.objects.append(star.Star(x, y)) self.selected = self.objects[0]
# Now define star star_position = vector.Vector3D(0.0, 0.0, 0.0) star_velocity = vector.Vector3D(0.0, 0.0, 0.0) # Create star object for istar in range(nstars): magmomvector = vector.Vector3D(0.0, 0.0, 1.0) magmomvector.rotateX(rotation_angle[istar]) cenA = star.Star(star.M_star_CenA, star.R_star_CenA, star.L_star_CenA, star.sun_Bfield_1AU, star_position, star_velocity, magmom=magmomvector) stararray.append(cenA) afterburner_distance = 10e10 # [R_star] minimum_distance_from_star = 5 * star.R_star_CenA # closest distance to star. Only used to check, not to adjust sim! my_plot = make_figure_multiple_stars(ship, stararray, minimum_distance_from_star, afterburner_distance, timestep, return_mission=False, scale=20,
#"spots":[spot1]}#, spot2]} # ----- # CLEAR WORKSPACE # ----- helper.clear_directory(mcfost_path) # ----- # CREATE DENSITY FILE2 # ----- s = star.Star(free_params, default_params, WAVELENGTH, mcfost_path, VAMP_data, load=False, verbose=True) end = time.time() print("time") print(end - start) s.display_data(option=1) s.display_IQUV(scale="off") s.display_P(scale="off") plt.show()
def create_stars(self): if self.blue < 100: while len(self.stars) < self.settings.stars_allowed: star_i = star.Star(self) self.stars.add(star_i)
default_params = "default_parameters_star" WAVELENGTH = 0.75 # microns # location where the parameter file will be built and where the data folders will be created MCFOST_path = "../mcfost-workspace/" VAMP_path = mm_path VAMP_data = "diffdata_RLeo_03_20170313_750-50_18holeNudged_0_0.idlvar" VAMP_data_info = "cubeinfoMar2017.idlvar" # load in external data VAMP_data = VAMPIRES_data.VAMPIRES_data(VAMP_path + VAMP_data, VAMP_path + VAMP_data_info) # remove out bias from the observed data i.e. move the average to 1 VAMP_data.vhvv -= np.mean(VAMP_data.vhvv) - 1 VAMP_data.vhvvu -= np.mean(VAMP_data.vhvvu) - 1 # STAR 1 free_params = {'n_az': 3, 'n_rad': 20, 'nz': 70, 'n_rad_in': 10} s = star.Star(free_params, default_params, WAVELENGTH, MCFOST_path, VAMP_data, load=False) s.grid_data = s.load_data("data_disk/", "grid.fits.gz") s.dm_data = s.load_data("data_disk/", "dust_mass_density.fits.gz") print(s.grid_data.shape) print(s.dm_data.shape)
def sector(self, groupingMethod=GROUPING_METHOD): # Generate random sector name newsectorName = self.name_sector() # Create new sector object newSector = sector.Sector(newsectorName, sector.SECTOR_MAJOR_ROW, sector.SECTOR_MAJOR_COL, sector.SECTOR_ROWS, sector.SECTOR_COLS) # Generate number of stars numStars = random.dice_roll(1, 10, 20) # Create list of names used usedNames = list() # Generate first 20 star system positions ------------------------------ loopCount = 0 sCount = 0 while (sCount < 20): # Generate row and column # Subtract 1 to start numbers at 0 row = random.dice_roll(1, 10) - 1 col = random.dice_roll(1, 8) - 1 # Check for empy hex if (newSector.hex_empty(row, col)): # Hex is empty, create new star system nameLoopCount = 0 nameCheck = False while (not nameCheck): newSystemName = self.name_system() if (not (newSystemName in usedNames)): usedNames.append(newSystemName) nameCheck = True nameLoopCount += 1 if (nameLoopCount > 100): raise exception.MaxLoopIterationsExceed(MAX_LOOP_ITER) newSector.add_blank_system(newSystemName, row, col) sCount += 1 else: # Hex is occupied, do nothing pass # Catch runaway loop loopCount += 1 if (loopCount > 100): raise exception.MaxLoopIterationsExceed(MAX_LOOP_ITER) # Add remaining system positions based on grouping method -------------- # loopCount = 0 while (sCount < numStars): # Get row and column that fits grouping method # 0: Random loopCount = 0 if (groupingMethod == 0): while (True): newRow = random.dice_roll(1, 10) - 1 newCol = random.dice_roll(1, 8) - 1 if (newSector.hex_empty(newRow, newCol)): break loopCount += 1 if (loopCount > 100): raise exception.MaxLoopIterationsExceed(MAX_LOOP_ITER) # 1: Minimize the sum of distances between all systems elif (groupingMethod == 1): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() (newRow, newCol) = sumDistAllPos[sumDistAll.index(min(sumDistAll))] # 2: Maximize the sum of distances between all systems elif (groupingMethod == 2): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() (newRow, newCol) = sumDistAllPos[sumDistAll.index(max(sumDistAll))] # 3: 1/4 between min and max of the sum of distances between all # systems elif (groupingMethod == 3): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() sumDistJoined = zip(sumDistAll, sumDistAllPos) (newRow, newCol) = sorted(sumDistJoined)[len(sumDistJoined) / 4][1] # 4: 1/3 between min and max of the sum of distances between all # systems elif (groupingMethod == 4): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() sumDistJoined = zip(sumDistAll, sumDistAllPos) (newRow, newCol) = sorted(sumDistJoined)[len(sumDistJoined) / 3][1] # 5: 1/2 between min and max of the sum of distances between all # systems elif (groupingMethod == 5): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() sumDistJoined = zip(sumDistAll, sumDistAllPos) (newRow, newCol) = sorted(sumDistJoined)[len(sumDistJoined) / 2][1] # 6: Link groups of stars together by joining the groups with the # furthest nearest neighbors first elif (groupingMethod == 6): # Get groups of systems systemGroups = newSector.system_groups() # If only one large group, do something to add variety if (len(systemGroups) == 1): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() # Choose new position that maximizes sum of distances (newRow, newCol) = sumDistAllPos[sumDistAll.index(max(sumDistAll))] else: # Calculate distance between groups # Calculate systems in the groups whose distance define the # group distance (groupDistances, minDistGroupSystems) = newSector.system_group_distances() # Distance of each group to nearest group minDist = [0] * len(groupDistances) # Index of nearest group to each group minDistIndex = [0] * len(groupDistances) for gAIndex in xrange(len(groupDistances)): # Don't compare current group to itself during comparison minDist[gAIndex] = min( groupDistances[gAIndex][:gAIndex] + groupDistances[gAIndex][gAIndex + 1:]) minDistIndex[gAIndex] = groupDistances[gAIndex].index( minDist[gAIndex]) # Group that has furthest nearest neighboring group maxDistAIndex = minDist.index(max(minDist)) maxDistBIndex = minDistIndex[maxDistAIndex] # Stars that define the distance between the groups ((aRow, aCol), (bRow, bCol) ) = minDistGroupSystems[maxDistAIndex][maxDistBIndex] # Try places stars in the middle of a line between the groups line = hexutils.odd_q_line(aRow, aCol, bRow, bCol) (newRow, newCol) = line[len(line) / 2] # Check for lines that fall outside the grid if ((newRow == sector.SECTOR_ROWS) or (newRow < 0) or (newCol == sector.SECTOR_COLS) or (newCol < 0)): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() # Choose new position that maximizes sum of distances (newRow, newCol) = sumDistAllPos[sumDistAll.index( min(sumDistAll))] # 7: Link groups of stars together, starting with the smallest, # linking to their nearest elif (groupingMethod == 7): # Get groups of systems systemGroups = newSector.system_groups() # Shuffle groups to not favor any specific row or column systemGroupsShuffled = newSector.system_groups() np.random.shuffle(systemGroupsShuffled) # Sort systemGroups by number of stars in group sortedMinNumberGroups = sorted(systemGroupsShuffled, key=lambda g: len(g)) # First smallest group smallestGroup = sortedMinNumberGroups[0] # Smallest group index in unshuffled and unsorted list smallestGroupIndex = systemGroups.index(smallestGroup) # If only one large group, do something to add variety if (len(systemGroups) == 1): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() # Choose new position that maximizes sum of distances (newRow, newCol) = sumDistAllPos[sumDistAll.index(max(sumDistAll))] else: # Calculate distance between groups # Calculate systems in the groups whose distance define the # group distance # Note this order not based off of the shuffled, sorted # list above (groupDistances, minDistGroupSystems) = newSector.system_group_distances() # Distance of smallest group to nearest group minDist = min(groupDistances[smallestGroupIndex] [:smallestGroupIndex] + groupDistances[smallestGroupIndex] [smallestGroupIndex + 1:]) # Indices of min distance systems of nearest group to # smallest group minDistIndex = groupDistances[smallestGroupIndex].index( minDist) # Stars that define the distance between the groups ((aRow, aCol), (bRow, bCol) ) = minDistGroupSystems[smallestGroupIndex][minDistIndex] # Try places stars in the middle of a line between the groups line = hexutils.odd_q_line(aRow, aCol, bRow, bCol) (newRow, newCol) = line[len(line) / 2] # Check for lines that fall outside the grid if ((newRow == sector.SECTOR_ROWS) or (newRow < 0) or (newCol == sector.SECTOR_COLS) or (newCol < 0)): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() # Choose new position that maximizes sum of distances (newRow, newCol) = sumDistAllPos[sumDistAll.index( min(sumDistAll))] # 8: Link groups of stars together, starting with the largest, # linking to their nearest elif (groupingMethod == 8): # Get groups of systems systemGroups = newSector.system_groups() # Shuffle groups to not favor any specific row or column systemGroupsShuffled = newSector.system_groups() np.random.shuffle(systemGroupsShuffled) # Sort systemGroups by number of stars in group sortedMinNumberGroups = sorted(systemGroupsShuffled, key=lambda g: len(g)) # Last largest group largestGroup = sortedMinNumberGroups[len(sortedMinNumberGroups) - 1] # largest group index in unshuffled and unsorted list largestGroupIndex = systemGroups.index(largestGroup) # If only one large group, do something to add variety if (len(systemGroups) == 1): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() # Choose new position that maximizes sum of distances (newRow, newCol) = sumDistAllPos[sumDistAll.index(max(sumDistAll))] else: # Calculate distance between groups # Calculate systems in the groups whose distance define the # group distance # Note this order not based off of the shuffled, sorted # list above (groupDistances, minDistGroupSystems) = newSector.system_group_distances() # Distance of largest group to nearest group minDist = min( groupDistances[largestGroupIndex][:largestGroupIndex] + groupDistances[largestGroupIndex][largestGroupIndex + 1:]) # Indices of min distance systems of nearest group to # largest group minDistIndex = groupDistances[largestGroupIndex].index( minDist) # Stars that define the distance between the groups ((aRow, aCol), (bRow, bCol) ) = minDistGroupSystems[largestGroupIndex][minDistIndex] # Try places stars in the middle of a line between the groups line = hexutils.odd_q_line(aRow, aCol, bRow, bCol) (newRow, newCol) = line[len(line) / 2] # Check for lines that fall outside the grid if ((newRow == sector.SECTOR_ROWS) or (newRow < 0) or (newCol == sector.SECTOR_COLS) or (newCol < 0)): # Sum system distances for all new possible positions (sumDistAll, sumDistAllPos) = newSector.system_distances_test() # Choose new position that maximizes sum of distances (newRow, newCol) = sumDistAllPos[sumDistAll.index( min(sumDistAll))] else: (newRow, newCol) = sumDistAllPos[sumDistAll.index(min(sumDistAll))] # Create new system nameLoopCount = 0 nameCheck = False while (not nameCheck): newSystemName = self.name_system() if (not (newSystemName in usedNames)): usedNames.append(newSystemName) nameCheck = True nameLoopCount += 1 if (nameLoopCount > 100): raise exception.MaxLoopIterationsExceed(MAX_LOOP_ITER) newSector.add_blank_system(newSystemName, newRow, newCol) # Update count of created systems sCount += 1 # Catch runaway loop loopCount += 1 if (loopCount > 100): raise exception.MaxLoopIterationsExceed(MAX_LOOP_ITER) # Add worlds ----------------------------------------------------------- worldCount = 0 for systemKey in newSector.sorted_systems(): systemObj = newSector.hexes[systemKey].system # If world count has reached max, limit number of new worlds to one # per system if (worldCount < MAX_WORLDS): numWorlds = system.TABLE_WORLDS[random.dice_roll(1, 10)] worldCount += numWorlds else: numWorlds = 1 worldCount += numWorlds # Add worlds to system for nm in xrange(numWorlds): nameLoopCount = 0 nameCheck = False while (not nameCheck): newWorldName = self.name_world() if (not (newWorldName in usedNames)): usedNames.append(newWorldName) nameCheck = True nameLoopCount += 1 if (nameLoopCount > 100): raise exception.MaxLoopIterationsExceed(MAX_LOOP_ITER) # Roll tags atmosphere = world.TABLE_ATMOSPHERE[random.dice_roll(2, 6)] biosphere = world.TABLE_BIOSPHERE[random.dice_roll(2, 6)] pop2d6 = random.dice_roll(2, 6) population = world.TABLE_POPULATION[pop2d6] populationAlt = np.random.randint( world.TABLE_POPULATION_ALT[pop2d6][0], world.TABLE_POPULATION_ALT[pop2d6][1] + 1) t1d6 = random.dice_roll(1, 6) t1d10 = random.dice_roll(1, 10) t2d6 = random.dice_roll(1, 6) t2d10 = random.dice_roll(1, 10) # Don't allow duplicate tags, reroll until a new one is generated loopCount = 0 while ((t1d6 == t2d6) and (t1d10 == t2d10)): t2d6 = random.dice_roll(1, 6) t2d10 = random.dice_roll(1, 10) # Catch runaway loop loopCount += 1 if (loopCount > 100): raise exception.MaxLoopIterationsExceed(MAX_LOOP_ITER) tag1 = world.TABLE_TAGS[t1d6][t1d10] tag2 = world.TABLE_TAGS[t2d6][t2d10] techLevel = world.TABLE_TECH_LEVEL[random.dice_roll(2, 6)] temperatue = world.TABLE_TEMPERATURE[random.dice_roll(2, 6)] newWorld = world.World(name=newWorldName, atmosphere=atmosphere, biosphere=biosphere, population=population, populationAlt=populationAlt, tags=[tag1, tag2], temperature=temperatue, techLevel=techLevel) systemObj.worlds.append(newWorld) # Fill system data ----------------------------------------------------- # Use one roll star system (ORSS) rules for systemKey in newSector.sorted_systems(): # Get current system systemObj = newSector.hexes[systemKey].system # Rolls (ORSS) d4 = random.dice_roll(1, 4) d6 = random.dice_roll(1, 6) d8 = random.dice_roll(1, 8) d10_star = random.dice_roll(1, 10) d10_gas = random.dice_roll(1, 10) d12 = random.dice_roll(1, 12) d20 = random.dice_roll(1, 20) # Get main world from system (i.e. the first in the list with the highest TL) mainWorld = max( systemObj.worlds, key=lambda w: world.TABLE_TECH_LEVEL_REVERSE[w.techLevel]) # Get main world orbit temperature mod d12Mod = d12 + world.TABLE_MAIN_WORLD_ORBIT_TEMP_MOD[ mainWorld.temperature] # At this point, the modified d12 roll cannot be lower than 1 if (d12Mod < 1): d12Mod = 1 # Check d6 to determine usage of d4 and d12 rolls (ORSS) d4Mod = d4 # If d6 is 1, d4 becomes single red dwarf star system (ORSS) if (d6 == 1): d4Mod = 1 d12Mod = 0 # If d6 is 2 or 3 and d4 is 4 add 12 to d12 (ORSS) elif ((d6 == 2) or (d6 == 3)): if (d4 == 4): d12Mod += 12 # If d6 is 4, add 1 to d4 elif (d6 == 6): d4Mod += 1 # Main world orbit # d6 table is base orbit position mainOrbit = system.TABLE_MAIN_WORLD_ORBIT[d6] # d12 table modifies orbit position mainOrbit += system.TABLE_MAIN_WORLD_ORBIT_MOD[d12Mod] # First star color and spectral subclass color = star.TABLE_COLOR[star.TABLE_COLOR_ID[d12Mod]] colorText = star.TABLE_COLOR_TEXT[d12Mod] sequence = star.TABLE_COLOR_SEQUENCE[star.TABLE_COLOR_ID[d12Mod]] spectralSubclass = star.TABLE_SPECTRAL_SUBCLASS[d10_star] spectralSubclassMod = np.random.random() # Add first star systemObj.stars.append( star.Star(color, colorText, sequence, spectralSubclass, spectralSubclassMod)) # Use modified d4 to determine if there should be a second star (ORSS) numStars = system.TABLE_STARS[d4Mod] # Add 2nd star if necessary (ORSS) if (numStars > 1): # 2nd star has +4 to existing d12 roll(ORSS) d12Mod += 4 # 2nd star has alternate d10 roll (ORSS) d10_star2 = random.dice_roll(1, 10) # d12 table modifies orbit position (ORSS) mainOrbit += system.TABLE_MAIN_WORLD_ORBIT_MOD[d12Mod] # Second star color and spectral subclass (ORSS) color = star.TABLE_COLOR[star.TABLE_COLOR_ID[d12Mod]] colorText = star.TABLE_COLOR_TEXT[d12Mod] sequence = star.TABLE_COLOR_SEQUENCE[ star.TABLE_COLOR_ID[d12Mod]] spectralSubclass = star.TABLE_SPECTRAL_SUBCLASS[d10_star2] spectralSubclassMod = np.random.random() # Add star systemObj.stars.append( star.Star(color, colorText, sequence, spectralSubclass, spectralSubclassMod)) # Gas giants (ORSS) numSmallGas = system.TABLE_GAS_GIANT_SMALL[d10_gas] numLargeGas = system.TABLE_GAS_GIANT_LARGE[d10_gas] # Create list of gas giants gasList = [ orbitalobject.Planet( orbitalobject.TABLE_ORBITAL_OBJECT_TYPE['SMALL_GAS']) for sg in xrange(numSmallGas) ] gasList += [ orbitalobject.Planet( orbitalobject.TABLE_ORBITAL_OBJECT_TYPE['LARGE_GAS']) for lg in xrange(numLargeGas) ] # Shuffle gas giants into random order np.random.shuffle(gasList) # Add moons and rings to gas giants. Will replace with main world moons and rings if necessary. for gl in gasList: # Roll a d20 to determine the number of moons and rings for the giant gasD20 = random.dice_roll(1, 20) # Does the giant have rings gl.rings = self.rings(gasD20) # Add moons to the gas giant gl.moons = self.moons(gasD20) # Total number of objects (ORSS) numObjects = d4 + d8 - 1 # Place objects in orbits # Create an empty list of orbital objects orbitalList = list() for o in xrange(numObjects): orbitalList.append(None) # Check if orbitalList is long enough if (mainOrbit > len(orbitalList)): # Add extra blank spaces if list is not long enough for o in xrange(mainOrbit - len(orbitalList)): orbitalList.append(None) # Fill main world orbit moonList = self.moons(d20) # If airless or thin, determine which one if (mainWorld.atmosphere == world.TABLE_ATMOSPHERE[4]): # On a d2, 1 is airless, 2 is thin # Airless are going to be space stations or moon bases # Thin are going to be thin atmosphere rocky planets if (random.dice_roll(1, 2) == 1): # If airless, world is a moon or space station # If main world table rolls has moons, it is a moon, else it is a station if (len(moonList) > 0): isMoon = True isStation = False # If main world is a moon, is it a moon of a gas giant or rocky world # If the system has gas giants, it is a gas giant moon # Else it is a moon of a rocky planet (should be rare) if (numSmallGas + numLargeGas > 0): ofGas = True else: ofGas = False else: isMoon = False isStation = True # If the main world is a space station, is it a space station of a gas giant or rocky world # If the system has gas giants, it is a gas giant station # Else it is a station of a rocky planet (should be rare) if (numSmallGas + numLargeGas > 0): ofGas = True else: ofGas = False else: # Main world is just a thin atmosphere rocky planet isMoon = False isStation = False ofGas = False else: isMoon = False isStation = False ofGas = False # If we just chose a space station for TL2 or lower, turn it into a # planet instead. There is no way a TL2- civilization could survive # on a space station so we'll remove airless/thin and inert gas # atmospheres as options. If a hostile atmoshere still exists, then # They'll likely live in the rememants of an underground bunker or # maybe a biodome or something. if ((mainWorld.techLevel == world.TABLE_TECH_LEVEL[2]) or (mainWorld.techLevel == world.TABLE_TECH_LEVEL[3]) or (mainWorld.techLevel == world.TABLE_TECH_LEVEL[4])): # Planet flags isMoon = False isStation = False ofGas = False # New atmosphere roll roll2d5 = random.dice_roll(2, 5) mainWorld.atmosphere = world.TABLE_ALT_ATMOSPHERE[roll2d5] # Does it have rings hasRings = orbitalobject.TABLE_MINOR_RINGS[d20] # Insert main world # Moon of another body if (isMoon): # Attach main world to a moon moonList[random.dice_roll(1, len(moonList)) - 1].world = mainWorld # Moon of a gas giant if (ofGas): # Get gas giant to attach world as a moon to gasGiant = gasList.pop(0) # Replace gas giant moon list gasGiant.moons = moonList # Add rings to gas giant if necessary gasGiant.rings = hasRings # Put gas giant into orbit list orbitalList[mainOrbit - 1] = gasGiant # Moon of a rocky planet else: # Create rocky planet rockyPlanet = orbitalobject.Planet( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ROCKY'], moons=moonList, rings=hasRings) # Put rocky planet into orbit list orbitalList[mainOrbit - 1] = rockyPlanet # Space station around another body elif (isStation): # Create space station and attach world to it spaceStation = orbitalobject.SpaceStation(worldObj=mainWorld) mainWorld.name += ' Station' # Space station around a gas giant if (ofGas): # Get gas giant to attach world as a space station to gasGiant = gasList.pop(0) # Add world as space station to giant gasGiant.stations.append(spaceStation) # Add main world moons to gas giant moon list gasGiant.moons += moonList # Add rings to gas giant if necessary gasGiant.rings = hasRings # Put gas giant into orbit list orbitalList[mainOrbit - 1] = gasGiant # Space station around a rocky planet else: # Create rocky planet rockyPlanet = orbitalobject.Planet( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ROCKY'], moons=moonList, rings=hasRings) # Add world as space station to rocky planet rockyPlanet.stations.append(spaceStation) # Replace rocky planet moon list rockyPlanet.moons = moonList # Add rings to rocky planet if necessary rockyPlanet.rings = hasRings # Put gas giant into orbit list orbitalList[mainOrbit - 1] = rockyPlanet # Rocky world else: # Create rocky planet rockyPlanet = orbitalobject.Planet( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ROCKY'], moons=moonList, rings=hasRings, worldObj=mainWorld) orbitalList[mainOrbit - 1] = rockyPlanet # Asteroid belts (ORSS) innerBelts = list() for b in xrange(system.TABLE_HYDROCARBON_INNER_ASTEROID_BELTS[d8]): innerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['HYDROCARBON_ASTEROID_BELT']) ) for b in xrange(system.TABLE_ICY_INNER_ASTEROID_BELTS[d8]): innerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ICY_ASTEROID_BELT'])) for b in xrange(system.TABLE_METALLIC_INNER_ASTEROID_BELTS[d8]): innerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['METALLIC_ASTEROID_BELT'])) for b in xrange(system.TABLE_ROCKY_INNER_ASTEROID_BELTS[d8]): innerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ROCKY_ASTEROID_BELT'])) outerBelts = list() for b in xrange(system.TABLE_HYDROCARBON_OUTER_ASTEROID_BELTS[d8]): outerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['HYDROCARBON_ASTEROID_BELT']) ) for b in xrange(system.TABLE_ICY_OUTER_ASTEROID_BELTS[d8]): outerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ICY_ASTEROID_BELT'])) for b in xrange(system.TABLE_METALLIC_OUTER_ASTEROID_BELTS[d8]): outerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['METALLIC_ASTEROID_BELT'])) for b in xrange(system.TABLE_ROCKY_OUTER_ASTEROID_BELTS[d8]): outerBelts.append( orbitalobject.AsteroidBelt( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ROCKY_ASTEROID_BELT'])) # Insert inner asteroid belts (ORSS) for ib in innerBelts: # Create inner and outer orbits indices innerMin = 0 innerMax = mainOrbit outerMin = mainOrbit + 1 outerMax = len(orbitalList) # Try to place in the middle of the inner orbits. placed = False # If that is full go closer to the main world orbit. # If that is full try the beginning of the inner orbits. # If that is full place in the first open spot in the outer orbits. searchOrder = range(innerMax / 2, innerMax) + range( innerMin, innerMax / 2) + range(outerMin, outerMax) for orbitIndex in searchOrder: # Look for a None slot in the orbitalList to fill if (orbitalList[orbitIndex] == None): # Replace None slot with inner belt orbitalList[orbitIndex] = ib placed = True # Stop searching break # If there were no slots open, append belt to end of system if (not placed): orbitalList.append(ib) # Insert outer asteroid belts (ORSS) for ob in outerBelts: # Create outer orbits indices outerMin = mainOrbit + 1 outerMax = len(orbitalList) # Try to place in the middle of the outer orbits. placed = False # If that is full go towards the outer orbits # If that is full try the beginning of the outer orbits searchOrder = range(outerMax / 2, outerMax) + range( outerMin, outerMax / 2) for orbitIndex in searchOrder: # Look for a None slot in the orbitalList to fill if (orbitalList[orbitIndex] == None): # Replace None slot with inner belt orbitalList[orbitIndex] = ob placed = True # Stop searching break # If there were no slots open, append belt to end of system if (not placed): orbitalList.append(ob) # Create list of worlds still to be placed otherAirless = list() otherWorlds = list() for w in systemObj.worlds: # We have already placed the main world if (w is not mainWorld): # Save airless worlds for later if (w.atmosphere == world.TABLE_ATMOSPHERE[4]): # If TL2-, put in other worlds, else put in airless if ((w.techLevel == world.TABLE_TECH_LEVEL[2]) or (w.techLevel == world.TABLE_TECH_LEVEL[3]) or (w.techLevel == world.TABLE_TECH_LEVEL[4])): otherWorlds.append(w) else: # Space stations are cool otherAirless.append(w) else: # Add world to list otherWorlds.append(w) ## Place remaining worlds that don't have airless/thin atomspheres for ow in otherWorlds: # d20 roll for planet stats d20 = random.dice_roll(1, 20) # Create moons moonList = self.moons(d20) # Create rings hasRings = self.rings(d20) # Create rocky planet rockyPlanet = orbitalobject.Planet( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ROCKY'], moons=moonList, rings=hasRings, worldObj=ow) # Planet has not been placed yet placed = False # If burning start from 1/6 from the innermost orbit if (ow.temperature == world.TABLE_TEMPERATURE[12]): searchIndex = len(orbitalList) / 6 # If warm start 1/4 from the innermost orbit elif (ow.temperature == world.TABLE_TEMPERATURE[10]): searchIndex = len(orbitalList) / 4 # If temperate-to-warm start 1/3 from the innermost orbit elif (ow.temperature == world.TABLE_TEMPERATURE[11]): searchIndex = len(orbitalList) / 3 # If temperate try to put near the middle orbit elif (ow.temperature == world.TABLE_TEMPERATURE[7]): searchIndex = len(orbitalList) / 2 # If cold to temperate start 2/3 from the innermost orbit elif (ow.temperature == world.TABLE_TEMPERATURE[3]): searchIndex = 2 * len(orbitalList) / 3 # If cold start from 3/4 from the innermost orbit elif (ow.temperature == world.TABLE_TEMPERATURE[4]): searchIndex = 3 * len(orbitalList) / 4 # If frozen start from 5/6 from the innermost orbit elif (ow.temperature == world.TABLE_TEMPERATURE[2]): searchIndex = 5 * len(orbitalList) / 6 # Go outward both directions from starting index innerSplit = range(0, searchIndex)[::-1] outerSplit = range(searchIndex, len(orbitalList)) # Create search list from the split lists searchList = list() for index in xrange(max(len(innerSplit), len(outerSplit))): if (index < len(innerSplit)): searchList.append(innerSplit[index]) if (index < len(outerSplit)): searchList.append(outerSplit[index]) # Search orbitalList for orbitIndex in searchList: # Look for a None slot in the orbital to fill if (orbitalList[orbitIndex] == None): # Place rocky planet orbitalList[orbitIndex] = rockyPlanet placed = True # Stop searching break # If no open orbit slots, append to end if (not placed): orbitalList.append(rockyPlanet) # Insert gas giants evenly into inner and outer orbits (ORSS) for gl in gasList: placed = False # Get list of indicies of orbits orbitIndices = range(len(orbitalList)) # Shuffle list of indices np.random.shuffle(orbitIndices) # Search shuffled index list for orbitIndex in orbitIndices: # Look for a None slot in the orbital to fill if (orbitalList[orbitIndex] == None): # Place rocky planet orbitalList[orbitIndex] = gl placed = True # Stop searching break # If no open orbit slots, append to end if (not placed): orbitalList.append(gl) # Insert hot rock, cold stone, and ice planets to fill rest of orbits (ORSS) innerOrbits = range(0, mainOrbit) for ioIndex in innerOrbits: if (orbitalList[ioIndex] == None): # d20 roll for planet stats d20 = random.dice_roll(1, 20) # Create moons moonList = self.moons(d20) # Create rings hasRings = self.rings(d20) # Create hot planet rockyPlanet = orbitalobject.Planet( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['HOT_ROCK'], moons=moonList, rings=hasRings) # Place planet orbitalList[ioIndex] = rockyPlanet outerOrbits = range(mainOrbit, len(orbitalList)) for ooIndex in outerOrbits: if (orbitalList[ooIndex] == None): # d20 roll for planet stats d20 = random.dice_roll(1, 20) # Create moons moonList = self.moons(d20) # Create rings hasRings = self.rings(d20) # Create cold planet # On a d2, 1 is a cold stone planet and 2 is an ice planet if (random.dice_roll(1, 2) == 1): objectType = orbitalobject.TABLE_ORBITAL_OBJECT_TYPE[ 'COLD_STONE'] else: objectType = orbitalobject.TABLE_ORBITAL_OBJECT_TYPE[ 'ICE'] rockyPlanet = orbitalobject.Planet(objectType=objectType, moons=moonList, rings=hasRings) # Place planet orbitalList[ooIndex] = rockyPlanet # Place remaining worlds that have airless/thin atmospheres for oa in otherAirless: # Planet index to try to place station/base world at randomOrbitIndices = range(0, len(orbitalList)) np.random.shuffle(randomOrbitIndices) for roi in randomOrbitIndices: # Avoid asteroid belts if (not isinstance(orbitalList[roi], orbitalobject.AsteroidBelt)): # We'll treat all airless/thin as airless at this point to # offset how we changed the TL2- worlds to something with a # thicker atmosphere # If 1 it can be a space station # If 2 it can be a moon base if the chosen planet has any moons # otherwise we'll revert to it being a space station isMoon = False isStation = True if (random.dice_roll(1, 2) == 2): if (len(orbitalList[roi].moons) > 0): # If the randomly chosen moon has a world already, just # make this a station instead moonRoll = random.dice_roll( 1, len(orbitalList[roi].moons)) if (orbitalList[roi].moons[moonRoll - 1].world == None): isMoon = True isStation = False moonIndex = moonRoll # Create moon world if (isMoon): orbitalList[roi].moons[moonIndex - 1].world = oa break # Create space station and attach world to it if (isStation): spaceStation = orbitalobject.SpaceStation( worldObj=oa) oa.name += ' Station' # Add world as space station to rocky planet orbitalList[roi].stations.append(spaceStation) break # If for some reason a world didn't get put into an orbit, randomly # insert it into the orbit list somewhere # Get list of worlds in this orbit list orbitWorldList = list() for ol in orbitalList: orbitWorldList += ol.world_list() # Compare orbit list worlds system worlds for owl in orbitWorldList: if (owl not in systemObj.worlds): # d20 roll for planet stats d20 = random.dice_roll(1, 20) # Create moons moonList = self.moons(d20) # Create rings hasRings = self.rings(d20) # Create rocky planet rockyPlanet = orbitalobject.Planet( objectType=orbitalobject. TABLE_ORBITAL_OBJECT_TYPE['ROCKY'], moons=moonList, rings=hasRings, worldObj=owl) # Randomly place world orbitInsert = random.dice_roll(1, len(orbitalList)) - 1 orbitalList.insert(orbitInsert, rockyPlanet) # Put orbital list into system objects list systemObj.objects = orbitalList # Add corporations ----------------------------------------------------- for i in xrange(MAX_CORPORATIONS): newSector.corporations.append(self.corporation()) # Add religions -------------------------------------------------------- for i in xrange(MAX_RELIGIONS): newSector.religions.append(self.religion()) # Return new sector ---------------------------------------------------- return (newSector)
import numpy as np import matplotlib.pyplot as plt import star starposition = vector.Vector3D(0.0, 0.0, 0.0) starvelocity = vector.Vector3D(0.0, 0.0, 0.0) magmoment = vector.Vector3D(0.0, 0.0, 1.0) # unit vector describing the stellar dipole #magmoment.rotateX(0.5*np.pi) # Create star (Alpha Cen A Parameters) s = star.Star(star.M_star_CenA, star.R_star_CenA, star.L_star_CenA, star.sun_Bfield_1AU, starposition, starvelocity, magmom=magmoment) npoints = 100 AU = star.AU # Define grid for plotting field px = np.linspace(-10.0 * AU, 10.0 * AU, num=npoints) py = np.linspace(-2.0 * AU, 2.0 * AU, num=npoints) pz = np.linspace(-10.0 * AU, 10.0 * AU, num=npoints) Bx = np.zeros((npoints, npoints))
#!/usr/bin/env python3 import star s = star.Star("CSID7") import fire f = fire.Fire("XIO-P1", "XIO-P3") import animate animator = animate.Animator() animator.post_updater(f) animator.post_updater(s) import time while True: time.sleep(100)
def __init__(self): self.la = language.Language() self.pr = program.Program() self.gu = guitar.Guitar() self.st = star.Star()
def create_star(self): self.star_list.add(star.Star(SCREEN_WIDTH, SCREEN_HEIGHT))