Beispiel #1
0
    def OnCreateTestGeom(self, e):
        newWindow = MainWindow(None, -1, "Test Geometry!")
        newWindow.dsNameList = ("Synthetic test geometry")

        group1 = starsplatter.StarBunch()
        group1.set_nstars(4)
        group1.set_coords(0, (0.0, 0.0, 0.0))
        group1.set_coords(1, (5.0, 0.0, 0.0))
        group1.set_coords(2, (0.0, 5.0, 0.0))
        group1.set_coords(3, (0.0, 0.0, 5.0))
        group1.set_bunch_color((1.0, 1.0, 1.0, 1.0))

        group2 = starsplatter.StarBunch()
        group2.set_nstars(1)
        group2.set_coords(0, (-5.0, 0.0, 0.0))
        group2.set_bunch_color((1.0, 0.0, 0.0, 1.0))

        group3 = starsplatter.StarBunch()
        group3.set_nstars(1)
        group3.set_coords(0, (0.0, -5.0, 0.0))
        group3.set_bunch_color((0.0, 1.0, 0.0, 1.0))

        group4 = starsplatter.StarBunch()
        group4.set_nstars(1)
        group4.set_coords(0, (0.0, 0.0, -5.0))
        group4.set_bunch_color((0.0, 0.0, 1.0, 1.0))

        bunchList = [group1, group2, group3, group4]
        for sb in bunchList:
            sb.set_density(0.03)
            sb.set_scale_length(0.1)
        newWindow.setBunchList(bunchList, ["others", "minX", "minY", "minZ"])
        newWindow.SetStatusText("Test geometry constructed!")
        newWindow.SetTitle("Cam Control Test Points")
def bunch_clone(sb):
    result = starsplatter.StarBunch()
    result.set_nprops(sb.nprops())
    for i in range(sb.nprops()):
        result.allocate_next_free_prop_index(sb.propName(i))
    result.copy_stars(sb)
    return result
def mkBunch(dx, t):
    gp = starsplatter.StarBunch()
    vxId = gp.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_X_NAME)
    vyId = gp.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_Y_NAME)
    vzId = gp.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_Z_NAME)
    gp.set_time(t)
    gp.set_nstars(4)
    gp.set_coords(0, (0.0 + dx, 0.0, 0.0))
    gp.set_prop(0, vxId, 0.0)
    gp.set_prop(0, vyId, 0.0)
    gp.set_prop(0, vzId, 0.0)
    gp.set_id(0, 0)
    gp.set_coords(1, (5.0 + dx, 0.0, 0.0))
    gp.set_prop(1, vxId, 0.0)
    gp.set_prop(1, vyId, 0.0)
    gp.set_prop(1, vzId, 0.0)
    gp.set_id(1, 0)
    gp.set_coords(2, (0.0 + dx, 5.0, 0.0))
    gp.set_prop(2, vxId, 0.0)
    gp.set_prop(2, vyId, 0.0)
    gp.set_prop(2, vzId, 0.0)
    gp.set_id(2, 0)
    gp.set_coords(3, (0.0 + dx, 0.0, 5.0))
    gp.set_prop(3, vxId, 0.0)
    gp.set_prop(3, vyId, 0.0)
    gp.set_prop(3, vzId, 0.0)
    gp.set_id(3, 0)
    gp.set_bunch_color((0.1 * dx, 1.0 - 0.1 * dx, 1.0, 1.0))
    return gp
def mkBunch( dx ):
    gp= starsplatter.StarBunch()
    gp.set_nstars(4)
    gp.set_coords(0,(0.0+dx,0.0,0.0))
    gp.set_coords(1,(5.0+dx,0.0,0.0))
    gp.set_coords(2,(0.0+dx,5.0,0.0))
    gp.set_coords(3,(0.0+dx,0.0,5.0))
    gp.set_bunch_color((0.1*dx,1.0-0.1*dx,1.0,1.0))
    return gp
# We'll clip the data to this bounding box, in order to show handling
# of cilpped-out points.  You'll probably want to adjust this based
# on the bounds of the data you are rendering.
sliceBBox = starsplatter.gBoundBox(0.0, 0.0, 10000.0, 33750.0, 33750.0,
                                   11000.0)

# Load the data.
# We can avoid loading any particular particle type by passing None for
# that bunch.
halo = None
disk = None
bulge = None
stars = None
bndry = None
gas1 = starsplatter.StarBunch()
gas2 = starsplatter.StarBunch()

# These are the mean masses for the various particle types,
# useful in getting a good balance of optical densities
meanMassByType = {"gas": 0.000371245}
for gas, fname, bunchname in [(gas1, fname1, "gas1"), (gas2, fname2, "gas2")]:
    infile = open(fname, "r")
    outList = starsplatter.load_gadget(infile,
                                       [gas, halo, disk, bulge, stars, bndry])
    infile.close()

# Create versions restricted to particles within the bounding box
gas1_cropped = bunch_clone(gas1)
cropBunchTo(gas1_cropped, "gas1_cropped", sliceBBox)
gas2_cropped = bunch_clone(gas2)
     drawLine(axes, 1000, 100,
              (bbox.xmin(),bbox.ymax(),bbox.zmax()),
              (bbox.xmax(),bbox.ymax(),bbox.zmax())
              )
     drawLine(axes, 1100, 100,
              (bbox.xmax(),bbox.ymin(),bbox.zmax()),
              (bbox.xmax(),bbox.ymax(),bbox.zmax())
              )

bunchList= []

ctr= worldBB.center()

mycam= createBBoxCamera(worldBB,15.0)

axes= starsplatter.StarBunch(1200)
axes.set_time(0.0);
axes.set_bunch_color((1.0,0.0,0.0,1.0))
createBBoxFrame(axes,worldBB)

bunchList.append(axes)

group1= starsplatter.StarBunch(1)
group1.set_time(0.0)
group1.set_coords(0,(worldBB.xmin()+0.4,worldBB.ymin()+0.7,ctr[2]))
group1.set_id(0,0);
g1vx= group1.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_X_NAME)
g1vy= group1.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_Y_NAME)
g1vz= group1.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_Z_NAME)
gp1Mass= group1.allocate_next_free_prop_index("mass")
group1.set_prop(0,g1vx,0.0);
Beispiel #7
0
#! /usr/bin/env python
import sys
import os
import starsplatter

gas= starsplatter.StarBunch()
gas.set_bunch_color((0.3,0.4,0.5,0.1))
gas.set_nstars(16)
gas.dump(sys.stderr)

gas.set_density(2,0.15)
gas.set_exp_constant(3,1.2)
gas.dump(sys.stderr)

baseNProps= gas.nprops()
gas.set_nprops(baseNProps+3)

gas.set_attr(starsplatter.StarBunch.COLOR_ALG,
             starsplatter.StarBunch.CM_COLORMAP_2D)
gas.set_prop(7,baseNProps+1,123.4)
gas.set_prop(3,baseNProps+2,45.6)
gas.set_prop(5,baseNProps+0,7.8)
gas.set_propName(0+baseNProps,"somePropName")
print("Just set property %d+0 name to <%s>"%\
      (baseNProps,gas.propName(baseNProps+0)))
print("Property %d+1 has no name: <%s>"%\
      (baseNProps,gas.propName(baseNProps+1)))
print("Property %d+3 does not even exist: <%s>"%\
      (baseNProps,gas.propName(baseNProps+3)))
gas.dump(sys.stderr)
    diagSqr += d*d
    diag= math.sqrt(diagSqr)
    fromPt= (atPt[0]+0.5*sepfac*diag,
             atPt[1]+0.5*sepfac*diag,
             atPt[2]+3*sepfac*diag)
    thiscam= starsplatter.Camera(fromPt,atPt,(0.0,1.0,0.0),
                                 fov, -1*sepfac*diag, -5*sepfac*diag)
    return thiscam

if (len(sys.argv)<2):
    sys.exit("You must supply a filename as an argument.");

# Load the data.
# We can avoid loading any particular particle type by passing None for
# that bunch.
gas= starsplatter.StarBunch()
halo= None
disk= starsplatter.StarBunch()
bulge= starsplatter.StarBunch()
stars= starsplatter.StarBunch()
bndry= None
infile= open(sys.argv[1],"r")
outList= starsplatter.load_gadget(infile,[gas,halo,disk,bulge,stars,bndry])
infile.close()

# Find the bounding box which holds all the particles, printing their
# properties as we go
bbox= None
for (name,bunch) in [("gas",gas), ("disk",disk),
                     ("bulge",bulge), ("stars",stars)]:
    print("%%%% %s: %d particles"%(name,bunch.nstars()))
Beispiel #9
0
#! /usr/bin/env python
import sys
import os
import starsplatter

mycam = starsplatter.Camera((10.0, 10.0, 30.0), (0.0, 0.0, 0.0),
                            (0.0, 1.0, 0.0), 35.0, -20.0, -40.0, 0)

group1 = starsplatter.StarBunch()
group1.set_nstars(4)
group1.set_coords(0, (0.0, 0.0, 0.0))
group1.set_coords(1, (5.0, 0.0, 0.0))
group1.set_coords(2, (0.0, 5.0, 0.0))
group1.set_coords(3, (0.0, 0.0, 5.0))
group1.set_bunch_color((0.0, 1.0, 1.0, 1.0))

group2 = starsplatter.StarBunch()
group2.set_nstars(3)
group2.set_coords(0, (-5.0, 0.0, 0.0))
group2.set_coords(1, (0.0, -5.0, 0.0))
group2.set_coords(2, (0.0, 0.0, -5.0))
group2.set_bunch_color((1.0, 0.0, 1.0, 1.0))

circlegroup = starsplatter.StarBunch()
circlegroup.set_nstars(3)
circlegroup.set_coords(0, (-5.0, 0.0, 0.0))
circlegroup.set_coords(1, (0.0, -5.0, 0.0))
circlegroup.set_coords(2, (0.0, 0.0, -5.0))
circlegroup.set_bunch_color((1.0, 0.0, 0.0, 1.0))

myren1 = starsplatter.StarSplatter()
Beispiel #10
0
#! /usr/bin/env python
import sys
import os
import starsplatter

mycam= starsplatter.Camera((0.0,0.0,3.0),
                           (0.0,0.0,0.0),
                           (0.0,1.0,0.0),
                           30.0,-1.0,-5.0)
gas= starsplatter.StarBunch()
stars= starsplatter.StarBunch()
dark= starsplatter.StarBunch()

myren= starsplatter.StarSplatter()
infile= open("../data/test.tipsy","r")
starsplatter.load_tipsy_box_ascii(infile,gas,stars,dark)
infile.close()

gas.set_bunch_color((1.0,0.0,0.0,1.0))
gas.set_density(1.0)
gas.set_scale_length(0.1)
stars.set_bunch_color((0.0,1.0,0.0,1.0))
stars.set_density(1.0)
stars.set_scale_length(0.1)
dark.set_bunch_color((0.0,0.0,1.0,1.0))
dark.set_density(0.1)
dark.set_scale_length(0.1)
gas.dump(sys.stderr)
myren.set_image_dims(640,480)
myren.set_camera(mycam)
myren.set_debug(True)
#! /usr/bin/env python
import sys
import os
import starsplatter

mycam= starsplatter.Camera((0.0,0.0,30.0),
                           (0.0,0.0,0.0),
                           (0.0,1.0,0.0),
                           35.0,-20.0,-40.0)

group1= starsplatter.StarBunch()
group1.set_time(0.0);
group1.set_nstars(1)
group1.set_coords(0,(-5.0,0.0,0.0))
group1.set_id(0,0);
g1vx= group1.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_X_NAME)
g1vy= group1.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_Y_NAME)
g1vz= group1.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_Z_NAME)
gp1Mass= group1.allocate_next_free_prop_index("mass")
group1.set_prop(0,g1vx,0.0);
group1.set_prop(0,g1vy,10.0);
group1.set_prop(0,g1vx,0.0);
group1.set_prop(0,gp1Mass,1.7)
group1.set_bunch_color((1.0,1.0,1.0,1.0))

group2= starsplatter.StarBunch()
group2.set_time(1.0);
group2.set_nstars(1)
group2.set_coords(0,(5.0,0.0,0.0))
group2.set_id(0,0);
g2vx= group2.allocate_next_free_prop_index(starsplatter.StarBunch.VEL_X_NAME)
Beispiel #12
0
    def readBunchesFromFile(self, t, typeString="tipsy"):
        fileIsReadable = 1
        try:
            if not (os.access(t, os.F_OK)):
                self.describeError("No such file %s!" % t)
            else:
                self.dsNameList.append(t)
        except Exception as e:
            fileIsReadable = 0
            mainWindow.describeError("Cannot open file: %s" % e)

        if not fileIsReadable: return  # filename failed reality check
        if typeString == "dubinski":
            disk1 = starsplatter.StarBunch()
            disk2 = starsplatter.StarBunch()
            bulge1 = starsplatter.StarBunch()
            bulge2 = starsplatter.StarBunch()
            infile = open(t, "r")
            bunchList = [disk1, disk2, bulge1, bulge2]
            bunchNameList = ["disk1", "disk2", "bulge1", "bulge2"]
            outList = starsplatter.load_dubinski(infile, bunchList)
            infile.close()
        elif typeString == "gadget":
            gas = starsplatter.StarBunch()
            halo = starsplatter.StarBunch()
            disk = starsplatter.StarBunch()
            bulge = starsplatter.StarBunch()
            stars = starsplatter.StarBunch()
            bndry = starsplatter.StarBunch()
            infile = open(t, "r")
            bunchList = [gas, halo, disk, bulge, stars, bndry]
            bunchNameList = ["gas", "halo", "disk", "bulge", "stars", "bndry"]
            outList = starsplatter.load_gadget(infile, bunchList)

            # Drop the boundary points
            bunchList = bunchList[0:-2]
            bunchNameList = bunchNameList[0:-2]

            infile.close()
        elif typeString == "tipsy":
            gas = starsplatter.StarBunch()
            halo = starsplatter.StarBunch()
            stars = starsplatter.StarBunch()
            infile = open(t, "r")
            bunchList = [gas, halo, stars]
            bunchNameList = ["gas", "halo", "stars"]
            outList = starsplatter.load_tipsy_box_ascii(
                infile, gas, stars, halo)
        else:
            sys.exit("Unrecognized file type %s!" % typeString)

        return (bunchList, bunchNameList)
Beispiel #13
0
#! /usr/bin/env python
import sys
import os
import starsplatter

filename = sys.argv[1]

mycam = starsplatter.Camera((-5.0, -9.0, 3.0), (0.0, 0.0, 0.0),
                            (0.0, 0.0, 1.0), 35.0, -1.0, -50.0)
# I think disk1 and bulge1 are Milky Way, disk2 and bulge2 are Andromeda
disk1 = starsplatter.StarBunch()
disk2 = starsplatter.StarBunch()
bulge1 = starsplatter.StarBunch()
bulge2 = starsplatter.StarBunch()

infile = open(filename, "r")
outList = starsplatter.load_dubinski(infile, [disk1, disk2, bulge1, bulge2])
infile.close()

myren = starsplatter.StarSplatter()
myren.set_image_dims(640, 480)
myren.set_camera(mycam)
myren.set_exposure_type(starsplatter.StarSplatter.ET_LOG_AUTO)
myren.set_exposure_scale(0.5)
myren.set_debug(1)

disk1.set_bunch_color((0.8, 0.5, 1.0, 1.0))
disk1.set_density(0.00002)
disk1.set_exp_constant(1000.0)
disk1.dump(sys.stderr)