Beispiel #1
0
    def setup(self):
        if self.usesmallfont:
            GG.prefs.font.setsmallfont()
            GG.padx=3
            GG.pady=3
        self.readUserPrefs()
        GG.icon = PhotoImage(data = spiderIcons.spider) #file = iconimage)
        # set up output streams for GUI
        self.msgfr = Frame(GG.topwindow,
                           relief=GG.frelief,
                           borderwidth=GG.brdr,
                           background=GG.bgd01)
        self.msgbox = Pmw.ScrolledText(self.msgfr, borderframe=4,
                                       vscrollmode='static',
                                       hscrollmode='dynamic',
                                       text_wrap='none')

        logfile = GG.sysprefs.logfile
        GB.outstream = GG.GUIOutput(self.msgbox, logfile)
        GB.errstream = GG.GUIOutput(self.msgbox, logfile)
        if GG.prefs.savelogfile:
            GB.outstream.uselogfile = 1
            GB.errstream.uselogfile = 1

        GG.balloon = Pmw.Balloon(GG.topwindow)
        GG.balloon.component('label').configure(font=GG.spid.font['small'])
Beispiel #2
0
 def putImage(self, imagefile):
     if not GG.setMainImage(imagefile):
         print "cannot find %s" % imagefile
         return
     imagefile = GG.mainImage
     self.img = PhotoImage(file=imagefile)  #, palette=256)   #/256/256)
     self.imglabel.configure(image=self.img)
Beispiel #3
0
 def systemdef(self):
     " reset to system defaults "
     GG.interface.user.font = GG.SysFonts()
     GG.prefs = GG.interface.user
     GG.spid = GG.interface.user.font
     self.current = GG.spid
     GG.spidui.setOptionDB(widget=GG.topwindow)
     self.redraw()
Beispiel #4
0
    def default(self):
        " reset GG.interface to system defaults "
        GG.interface = GG.SysInterface()  # new instance with defaults
        GG.prefs = GG.interface.user
        GG.sysprefs = GG.interface.system

        GG.spid = GG.prefs.font
        GG.colors = GG.prefs.colors
        GG.sysbgd = GG.colors.background
        GG.bgd01 = GG.colors.bgd01
        GG.bgd02 = GG.colors.bgd02
        GG.bgd03 = GG.colors.bgd03
        self.setValues()
Beispiel #5
0
    def __init__(self, **kwargs):
        """ set default values, decode keyword args """
        self.ID = ""
        self.title = ""
        self.name = ""  # short title
        self.projfile = "proj001"
        self.projdir = os.getcwd()
        self.dataext = "dat"
        self.host = gethostname()
        self.RunList = []  # a list of batchrun id's
        self.SpiderBatchDir = ""
        self.config = GG.sysprefs.configFile
        (date, time, x) = nowisthetime()
        self.startdate = "%s, %s" % (date, time)
        self.updated = ""
        self.parameters = {}
        self.pixelsize = ""
        self.kv = ""
        self.Cs = ""
        self.SpireVersion = GG.applicationversion

        keywords = [
            'ID', 'id', 'title', 'file', 'dir', 'projdir', 'config', 'dataext',
            'ext', 'host', 'SpiderBatchDir', 'name'
        ]
        for kw in kwargs:
            if kw not in keywords:
                GG.errstream("%s not a valid keyword" % kw)
                return
            if kw == 'id' or kw == 'ID': self.ID = kwargs[kw]
            elif kw == 'title': self.title = kwargs[kw]
            elif kw == 'name': self.name = kwargs[kw]
            elif kw == 'file': self.projfile = kwargs[kw]
            elif kw == 'dir' or kw == 'projdir': self.projdir = kwargs[kw]
            elif kw == 'ext' or kw == 'dataext': self.name = kwargs[kw]
            elif kw == 'host': self.host = kwargs[kw]
            elif kw == 'config': self.host = kwargs[kw]
            elif kw == 'SpiderBatchDir': self.SpiderBatchDir = kwargs[kw]
Beispiel #6
0
 def __init__(self, **kwargs):
     """ set default values, decode keyword args """
     self.ID = ""
     self.title = ""
     self.name = ""  # short title
     self.projfile = "proj001"
     self.projdir = os.getcwd()
     self.dataext = "dat"
     self.host = gethostname()
     self.RunList = []   # a list of batchrun id's
     self.SpiderBatchDir = ""
     self.config = GG.sysprefs.configFile
     (date, time, x) = nowisthetime()
     self.startdate = "%s, %s" % (date, time)
     self.updated = ""
     self.parameters = {}
     self.pixelsize = ""
     self.kv = ""
     self.Cs = ""
     self.SpireVersion = GG.applicationversion
     
     keywords = ['ID', 'id', 'title','file','dir','projdir','config',
                 'dataext','ext','host','SpiderBatchDir', 'name']
     for kw in kwargs:
         if kw not in keywords:
             GG.errstream("%s not a valid keyword" % kw)
             return
         if kw == 'id' or kw == 'ID': self.ID = kwargs[kw]
         elif kw == 'title': self.title = kwargs[kw]
         elif kw == 'name': self.name = kwargs[kw]
         elif kw == 'file': self.projfile = kwargs[kw]
         elif kw == 'dir' or kw == 'projdir': self.projdir = kwargs[kw]
         elif kw == 'ext' or kw == 'dataext': self.name = kwargs[kw]
         elif kw == 'host': self.host = kwargs[kw]
         elif kw == 'config': self.host = kwargs[kw]
         elif kw == 'SpiderBatchDir': self.SpiderBatchDir = kwargs[kw]
Beispiel #7
0
def readUserPrefs(verbose=1):
    " writes out user prefs if the file isn't there "
    filename = GG.interface.file
    if not os.path.exists(filename):
        writeUserPrefs(0)
    else:
        B = fileReadLines(filename)
        if B == None:
            showerror('File Open Error')
            return

        D = {}
        for line in B:
            if line.find(':') < 0:
                continue
            s = line.split(':',1)
            key, value = s[0], s[1].strip()
            D[key] = value

        #if 'useLocalPrefsFile' in D:
        #   GG.prefs.useLocalPrefsFile = int(D['useLocalPrefsFile'])

        keys = D.keys()
        for key in keys:
            value = D[key]

            # see if value is a dictionary
            if len(value) > 0 and value[0] == '{' and value[-1] == '}':
                value = eval(value)
                #print "%s is a dictionary: %s" % (key, str(value.keys()))

                if key == 'colors':
                    GG.prefs.colors.setAttributes(value)
                elif key == 'font':
                    GG.prefs.font.font = value
                elif key == 'AppDict':
                    GG.sysprefs.AppDict = value
                    
            elif type(value) == type("string"):
                # see if it's an integer
                try:
                    value = int(value)
                except:
                    pass

                # some values should have the project extension
                if hasProject() and key in ['filenumFile', 'paramFile']:
                    base, ext = os.path.splitext(value)
                    if ext == '':
                        value = value + '.' + GB.P.dataext
                    elif ext == '.':
                        value = value + GB.P.dataext
                    elif ext != GB.P.dataext:
                        value = base + '.' + GB.P.dataext

                # set values in GG.prefs and GG.sysprefs
                if hasattr(GG.prefs, key):
                    try:
                        value = int(value)
                        exec("GG.prefs.%s = %d" % (key, value))
                    except:
                        exec("GG.prefs.%s = '%s'" % (key, value))
                elif hasattr(GG.sysprefs, key):
                    try:
                        value = int(value)
                        exec("GG.sysprefs.%s = %d" % (key, value))
                    except:
                        exec("GG.sysprefs.%s = '%s'" % (key, value))

                if key == 'editor' and value not in GG.editorlist:
                    GG.editorlist.append(value)

        # set shortcuts
        GG.interface = GG.SysInterface()   # create a new instance
        GG.interface.user = GG.prefs
        GG.interface.system = GG.sysprefs
        if GG.prefs.useLocalPrefsFile == 0 or not hasProject():
            GG.interface.file = os.path.join(os.environ['HOME'],".spire")
        else:
            GG.interface.file = os.path.join(GB.P.projdir, '.spire')
        GG.spid = GG.prefs.font
        GG.colors = GG.prefs.colors
        GG.sysbgd = GG.colors.background
        GG.bgd01 = GG.colors.bgd01
        GG.bgd02 = GG.colors.bgd02
        GG.bgd03 = GG.colors.bgd03
Beispiel #8
0
def GG_evolution(dslist = [], data = None, dm_data = None, outname = 'GG_rstrip.dat'):


    ds0 = yt.load(dslist[0])
    M = ds0.parameters['DiskGravityStellarDiskMass'] * cgs.Msun
    a = ds0.parameters['DiskGravityStellarDiskScaleHeightR'] * cgs.Mpc
    b = ds0.parameters['DiskGravityStellarDiskScaleHeightz'] * cgs.Mpc

    star_profile = lambda x : profiles.stellar_surface_density(x, b = b, M =M, a =a)

    Pram = np.logspace(-16,-11, 50) # ram pressure in cgs

    Rstrip = np.zeros( (np.size(dslist), np.size(Pram)) )
    Rstrip_dm = np.zeros( (np.size(dslist), np.size(Pram)) )
    t      = np.zeros(np.size(dslist))

    f = open(outname, 'w')
    # header
    f.write("# t")
    for P in Pram:
        f.write(" %3.3f"%(np.log10(P)))
    f.write("\n")

    i = 0
    for d in dslist:
        ds = yt.load(d)

        tnow  = ds.current_time.convert_to_units('Myr').value
        t[i]  = round(tnow)
        index = np.argmin( np.abs(data['t'] - tnow))

        x     = (data['r'][1:] + data['r'][:-1])*0.5
        gas   = data['surface_density'][index]

        x_dm  = (dm_data['r'][1:] + dm_data['r'][:-1])*0.5
        dm    = dm_data['surface_density'][index]

        gas_profile = profiles.gas_profile_function(x * cgs.kpc, gas, unit = 'cgs')
        dm_profile  = profiles.gas_profile_function(x_dm * cgs.kpc, dm, unit = 'cgs')

        j = 0
        f.write("%i"%(round(tnow)))
        for P in Pram:
            Rstrip[i][j] = GG.stripping_radius(star_profile, gas_profile, Pram = P,
                                      lu = cgs.kpc)

            Rstrip_dm[i][j] = GG.stripping_radius(star_profile, gas_profile, Pram = P,
                                                  dm = dm_profile, lu = cgs.kpc)

            f.write(" %3.3E"%(Rstrip[i][j]))
            j = j + 1

        f.write("\n");

        i = i + 1

    f.close()

    data = {}

    data['t']    = t
    data['Pram'] = Pram

    data['Rstrip'] = Rstrip
    data['stats']  = {}

    data['stats']['avg'] = np.average(Rstrip, 0)
    data['stats']['min'] = np.min(Rstrip, 0)
    data['stats']['max'] = np.max(Rstrip, 0)
    data['stats']['std'] = np.std(Rstrip, 0)

    data['Rstrip_dm'] = Rstrip_dm
    data['dm_stats']  = {}

    data['dm_stats']['avg'] = np.average(Rstrip_dm, 0)
    data['dm_stats']['min'] = np.min(Rstrip_dm, 0)
    data['dm_stats']['max'] = np.max(Rstrip_dm, 0)
    data['dm_stats']['std'] = np.std(Rstrip_dm, 0)

    dd.io.save('GG_evolution.h5', data)

    return