示例#1
0
def pid_stage_temp_with_pump(logfile, set_temp=0.65):

    #array is min temp, max temp, uc pump heating voltage, uc pump maintenance voltage, ic pump heating voltage, ic pump maintenance voltage
    ucpump_settings = np.array([
        [0.5, 0.55, 3, 2, 0, 0],
        [0.55, 0.65, 3, 2.2, 0, 0, 0],
        [0.65, 0.7, 4.0, 2.5, 0,
         0],  #uc pump temp is ~ 27.7 K for this to work
        [0.7, 0.75, 4.0, 2.7, 0.5, 0.5]
    ])

    ginds = np.intersect1d(
        np.where(ucpump_settings[:, 0] <= set_temp)[0],
        np.where(ucpump_settings[:, 1] > set_temp)[0])[0]
    sc.He3UCp.set_voltage(ucpump_settings[gind, 2])
    print('He3 UC pump to heating voltage: ' + str(ucpump_settings[gind, 2]) +
          'V')
    time.sleep(120)
    while float(gt.gettemp(logfile, 'UC Stage')) < (set_temp - 0.01):
        time.sleep(60)
        print(gt.gettemp(logfile, 'UC Stage'))
    sc.ChaseLS.set_PID_temp(1, set_temp)
    sc.ChaseLS.set_heater_range(2)
    print(
        'Turning on PID on Heater, reducing pump temp to maintenance voltage, waiting 5 min for stability'
    )
    sc.He3UCp.set_voltage(ucpump_settings[gind, 3])
    print(time.datetime())
    time.sleep(60 * 5)
    iter = True
    while iter:
        if float(sc.ChaseLS.get_HTR_output()) > 95:
            print('adjusting pump up to help heater')
            sc.He3UCP.set_voltage(float(sc.He3UCp.read_voltage()) + .1)
        elif float(sc.ChaseLS.get_HTR_output()) < 5:
            print('adjusting pump down to prevent runaway')
            sc.He3UCP.set_voltage(float(sc.He3UCp.read_voltage()) - 0.1)
        else:
            iter = False
        time.sleep(60 * 5)
    return
def main():    

    if userkbflag is True:
        loadknow(userkb)

    filename = datetime('%y%m%d%H%M%S') + '.log'
    try:
        log = open(filename,'w')

        angerlvl = aggro.query()
        angerlvlprev = angerlvl
        
      ### main while loop ###
        while True: #=D =) =| =( D=
            
            try:
                input = None
                if angerlvl in range(0,2):
                    input = raw_input("What have you to say?: ")
                elif angerlvl in range(2,4):
                    input = raw_input("What do you want?: ")
                elif angerlvl in range(4,6):
                    input = raw_input("YOU ARE NOT A HAMSTER!!!: ")
                else:
                    print "THE UNIVERSE HAS BROKEN!!!!!!!!!"
            except EOFError:
                aggro.stop()
                print '\n\t'+filename, 'created.'
                break

         # after getting input
            log.write('\n> ' + input)

            infoset = inputs(input)
            #print infoset
            aggro.shift(infoset)
            angerlvlprev = angerlvl
            angerlvl = aggro.query()
            if angerflag is True:
                print "Current anger level is: " + angerlvl.__str__()
        
            sent = getKnowledge(input)

            outsent = None

            senttype = infoset[2]

            if senttype is 'reflex':
                outsent = chooseOut(infoset, angerlvl, angerlvlprev, sent)
            elif senttype is 'know':
                if sent is not None:
                    outsent = Sentence('know', angerlvl, sent).__str__() + "  "
                else:
                    outsent = "I don't know anything about "+input+"."
            else:
                if senttype == 'empty':
                    outsent = "...?"
                else:
                    outsent = Sentence(senttype, angerlvl).__str__()
                

            # after printing output
            log.write('\n(anger level: ' + repr(angerlvl) + ') ' + outsent)
            
            print outsent
    except IOError:
        print filename + ': could not open file to write'
    log.close()
    return
示例#3
0
 def __init__(self):
     self.id = None
     self.login_time = t.datetime()
     self.mac = None
     self.user_id = None
     self.key = None
示例#4
0
def smartList(starlist, time, seeing, slowdown,outdir = None):
    """ Determine the best target to observe from the provided scriptobs-compatible starlist.
        Here the best target is defined as an unobserved target (ie not in observed targets )
        that is visible above 30 degrees elevation. Higher elevation targets are prefered,
        but those that rise above 85 degrees will be regected to avoid slewing through the zenith. """
    # Convert the unix timestamp into a python datetime


    if type(time) == float:
        dt = datetime.utcfromtimestamp(int(time))
    elif type(time) == datetime:
        dt = time
    elif type(time) == ephem.Date:
        dt = time.datetime()
    else:
        #punt
        dt = datetime.utcfromtimestamp(int(time.time()))
        
    if not outdir:
        outdir = os.getcwd()
    observed, _ = ObservedLog.getObserved(os.path.join(outdir,"observed_targets"))

    # Generate a pyephem observer for the APF
    apf_obs = ephem.Observer()
    apf_obs.lat  = '37:20:33.1'
    apf_obs.long = '-121:38:17.7'
    apf_obs.elevation = 1274
    # Minimum observation to observe things at
    apf_obs.horizon = str(TARGET_ELEVATION_MIN)
    apf_obs.date = dt
    # APF latitude in radians
    apf_lat = apf_obs.lat

    # Calculate the moon's location
    moon = ephem.Moon()
    moon.compute(apf_obs)

    # Parse the starlist
    try:
        sn, star_table, lines, stars = parseStarlist(starlist)
    except ValueError:
        # This will be raised when the starlist could not be parsed successfully.
        apflog( "No target could be selected because starlist could not be parsed.", level="warn",echo=True)
        return None
    targNum = len(sn)

    # Minimum Brightness based on conditions
    VMAX = 14

    # Distance to stay away from the moon [Between 15 and 25 degrees]

    moonDist = np.degrees(np.sqrt((moon.ra - star_table[:,DS_RA])**2 + (moon.dec - star_table[:,DS_DEC])**2))
    md = TARGET_MOON_DIST_MAX - TARGET_MOON_DIST_MIN
    minMoonDist = ((moon.phase / 100.) * md) + TARGET_MOON_DIST_MIN  

    available = np.ones(targNum, dtype=bool)
    moon_check = np.where(moonDist > minMoonDist, True, False)
    available = available & moon_check

    # If seeing is bad, only observe bright targets ( Large VMAG is dim star )       
    brightenough = np.where(star_table[:, DS_VMAG] < VMAX,True,False)
    available = available & brightenough

    obs_length = star_table[:,DS_EXPT] * star_table[:,DS_NSHOTS] + 45 * (star_table[:,DS_NSHOTS]-1)
    vis, star_elevations, fin_els = Visible.is_visible(apf_obs,stars,obs_length)
    available = available & vis
        
    done = [ True if n in observed else False for n in sn ]
    availableandnotdone = available & np.logical_not(done)
    
    if not any(availableandnotdone):
        apflog( "All visible targets have been observed",level="warn",echo=True)
        (good,) = np.where(available)
    else:
        (good,) = np.where(availableandnotdone)

    delta = fin_els[good] - star_elevations[good]
    neg   = np.where(delta < 0)
    pos   = np.where(delta >= 0)
    inv_els = fin_els[good]
    inv_els[neg]  = fin_els[good[neg]] - 90
    inv_els[pos] = 90 - fin_els[good[pos]]
    sort_fin_els_idx = np.argsort(inv_els)
    idx = good[sort_fin_els_idx[0]]
                  
    res = dict()

    res['RA']     = stars[idx].a_ra
    res['DEC']    = stars[idx].a_dec
    res['PM_RA']  = star_table[idx, DS_PMRA]
    res['PM_DEC'] = star_table[idx, DS_PMDEC]
    res['VMAG']   = star_table[idx, DS_VMAG]
    res['BV'] = 0.6
    res['PRI'] = 10.
    res['SCORE'] = 1.0
    res['COUNTS'] = star_table[idx, DS_COUNTS]
    res['EXP_TIME'] = star_table[idx, DS_EXPT]
    res['NEXP'] = star_table[idx, DS_NSHOTS]
    res['NAME']   = sn[idx]
    res['SCRIPTOBS'] = lines[idx]
    return res
示例#5
0
def getNext(time,
            seeing,
            slowdown,
            star_dates,
            bstar=False,
            standardstar=False,
            verbose=False,
            sheetn="FakeGoogledex",
            owner='Vogt',
            googledex_file="./newgoogledex.csv",
            method="inquad",
            observed_file="observed_targets"):
    """ Determine the best target for UCSC team to observe for the given input.
        Takes the time, seeing, and slowdown factor.
        Returns a dict with target RA, DEC, Total Exposure time, and scritobs line
    """
    # Convert the unix timestamp into a python datetime
    if type(time) == float:
        dt = datetime.utcfromtimestamp(int(time))
    elif type(time) == datetime:
        dt = time
    elif type(time) == ephem.Date:
        dt = time.datetime()
    else:
        dt = datetime.utcnow()
        # punt

    confg = dict()
    confg['I2'] = 'Y'
    confg['decker'] = 'W'

    if verbose:
        apflog("getNext(): Finding target for time %s" % (dt), echo=True)

    if slowdown > SLOWDOWN_MAX:
        apflog(
            "getNext(): Slowndown value of %f exceeds maximum of %f at time %s"
            % (slowdown, SLOWDOWN_MAX, dt),
            echo=True)
        return None

    try:
        apfguide = ktl.Service('apfguide')
        stamp = apfguide['midptfin'].read(binary=True)
        ptime = datetime.fromtimestamp(stamp)
    except:
        if type(dt) == datetime:
            ptime = dt
        else:
            ptime = datetime.utcnow()

    # List of targets already observed
    observed, obstimes = update_local_googledex(ptime,
                                                googledex_file=googledex_file,
                                                observed_file=observed_file)

    global last_objs_attempted
    try:
        lastline = ktl.read("apftask", "SCRIPTOBS_LINE")
        if not bstar:  # otherwise from previous night
            lastobj = lastline.split()[0]

        if verbose:
            apflog("getNext(): Last object attempted %s" % (lastobj),
                   echo=True)
    except:
        lastobj = None

    if lastobj:
        if lastobj not in observed and lastobj not in last_objs_attempted:
            last_objs_attempted.append(lastobj)
            if verbose:
                apflog("getNext(): Last objects attempted %s" %
                       (last_objs_attempted),
                       echo=True)

            if len(last_objs_attempted) > 5:
                apflog("getNext(): 5 failed acquisition attempts", echo=True)
                last_objs_attempted = []
                return None

    ###
    # Need to update the googledex with the lastObserved date for observed targets
    # Scriptobs line uth utm can be used for this
    # Need to convert a uth and utm to a JD quickly.
    # timedelta = now - uth,utm : minus current JD?
    ###

    # Generate a pyephem observer for the APF
    apf_obs = ephem.Observer()
    apf_obs.lat = '37:20:33.1'
    apf_obs.long = '-121:38:17.7'
    apf_obs.elevation = 1274
    # Minimum observation to observe things at
    apf_obs.horizon = str(TARGET_ELEVATION_MIN)
    apf_obs.date = dt
    # APF latitude in radians
    apf_lat = (37 + 20 / 60. + 33.1 / 3600.) * np.pi / 180.

    # Calculate the moon's location
    moon = ephem.Moon()
    moon.compute(apf_obs)

    # Parse the Googledex
    # Note -- RA and Dec are returned in Radians
    if verbose:
        apflog("getNext(): Parsing the Googledex...", echo=True)
    sn, star_table, do_flag, stars = parseGoogledex(sheetn=sheetn,
                                                    outfn=googledex_file)
    star_table['apfpri'], star_table['phases'] = getpriority.getpriority(
        star_table['starname'],
        star_table,
        ephem.julian_date(dt),
        star_dates,
        apf_obs.sidereal_time(),
        method=method,
        standard=standardstar)

    targNum = len(sn)
    if verbose:
        apflog("getNext(): Parsed the Googledex...", echo=True)

    # Note which of these are B-Stars for later.
    bstars = star_table['comments'] == 'B star'
    if verbose:
        apflog("getNext(): Finding B stars", echo=True)

    available = np.ones(targNum, dtype=bool)
    totexptimes = np.zeros(targNum, dtype=float)
    cur_elevations = np.zeros(targNum, dtype=float)
    i2cnts = np.zeros(targNum, dtype=float)
    star_table['counts'] = np.zeros(targNum, dtype=float)
    star_table['expt'] = np.zeros(targNum, dtype=float)
    star_table['nshots'] = np.zeros(targNum, dtype=int)

    # Is the target behind the moon?
    # Distance to stay away from the moon
    md = TARGET_MOON_DIST_MAX - TARGET_MOON_DIST_MIN
    minMoonDist = ((moon.phase / 100.) * md) + TARGET_MOON_DIST_MIN
    moonDist = np.degrees(
        np.sqrt((moon.ra - star_table['ra'])**2 +
                (moon.dec - star_table['dec'])**2))
    if verbose:
        apflog("getNext(): Culling stars behind the moon", echo=True)
    moon_check = np.where(moonDist > minMoonDist, True, False)
    available = available & moon_check

    # We just need a B star, so restrict our math to those
    if bstar:
        if verbose:
            apflog("getNext(): Selecting B stars", echo=True)
        available = available & bstars

        f = available
        if verbose:
            apflog("getNext(): Computing star elevations", echo=True)
        fstars = [s for s, _ in zip(stars, f) if _]
        vis, star_elevations, fin_star_elevations = is_visible(
            fstars, apf_obs, [400] * len(bstars[f]), TARGET_ELEVATION_MIN,
            TARGET_ELEVATION_PREF_MIN, TARGET_ELEVATION_MAX)

        available[f] = available[f] & vis
        cur_elevations[np.where(f)] += star_elevations[np.where(vis)]

        star_table['counts'][available] = 1e9
        star_table['expt'][available] = 900
        star_table['nshots'][available] = 2
        totexptimes[available] = 400

    # Just need a normal star for observing
    else:
        # Available and not a BStar
        if verbose:
            apflog("getNext(): Culling B stars", echo=True)
        available = np.logical_and(available, np.logical_not(bstars))

        if len(last_objs_attempted) > 0:
            for n in last_objs_attempted:
                attempted = (sn == n)
                available = available & np.logical_not(
                    attempted)  # Available and not observed

        # Calculate the exposure time for the target
        # Want to pass the entire list of targets to this function
        f = available
        if verbose:
            apflog("getNext(): Computing star elevations", echo=True)
        fstars = [s for s, _ in zip(stars, f) if _]
        #        star_elevations=calc_elevations(fstars,apf_obs)
        vis, star_elevations, fin_star_elevations = is_visible(
            fstars, apf_obs, [0] * len(fstars), TARGET_ELEVATION_MIN,
            TARGET_ELEVATION_PREF_MIN, TARGET_ELEVATION_MAX)
        available[f] = available[f] & vis
        f = available
        fstars = [s for s, _ in zip(stars, f) if _]
        if verbose:
            apflog("getNext(): Computing exposure times", echo=True)
        exp_times, exp_counts, i2counts = calculate_ucsc_exposure_time(
            star_table['vmag'][f], star_table['precision'][f],
            star_elevations[np.array(vis)], seeing, star_table['b-v'][f])

        exp_times = exp_times * slowdown
        maxtimes = computeMaxTimes(sn[f], exp_times)
        totexptimes[f] += exp_times
        i2cnts[f] += i2counts
        if verbose:
            apflog("getNext(): Formating exposure times", echo=True)
        star_table['expt'][f], star_table['nshots'][f] = format_time(
            exp_times, i2counts)
        #        exp_counts /= star_table[f, DS_NSHOTS]
        if verbose:
            apflog("getNext(): Formating exposure meter", echo=True)
        star_table['counts'][f], star_table['nshots'][f] = format_expmeter(
            exp_counts, star_table['nshots'][f])

        # Is the exposure time too long?
        if verbose:
            apflog("getNext(): Removing really long exposures", echo=True)
        time_check = np.where(exp_times < maxtimes, True, False)

        available[f] = available[f] & time_check
        f = available

        # Is the star currently visible?
        if verbose:
            apflog("getNext(): Computing stars visibility", echo=True)
        fstars = [s for s, _ in zip(stars, f) if _]
        vis, star_elevations, fin_star_elevations = is_visible(
            fstars, apf_obs, exp_times, TARGET_ELEVATION_MIN,
            TARGET_ELEVATION_PREF_MIN, TARGET_ELEVATION_MAX)
        if vis != []:
            available[f] = available[f] & vis
        cur_elevations[np.where(f)] += star_elevations[np.where(vis)]

    # Now just sort by priority, then cadence. Return top target
    if len(sn[available]) < 1:
        apflog("getNext(): Couldn't find any suitable targets!",
               level="error",
               echo=True)
        return None

    cadence_check = (ephem.julian_date(dt) -
                     star_table['lastobs']) / star_table['cadence']
    good_cadence = np.where(cadence_check > 1.0, True, False)
    good_cadence_available = available & good_cadence

    if any(good_cadence_available):
        try:
            pri = max(star_table['apfpri'][good_cadence_available])
            sort_i = np.where(
                star_table['apfpri'][good_cadence_available] == pri, True,
                False)
            available = good_cadence_available
        except:
            pri = max(star_table['apfpri'][available])
            sort_i = np.where(star_table['apfpri'][available] == pri, True,
                              False)
    elif any(available):
        apflog(
            "getNext(): No new stars available, going back to the previously observed list.",
            level="warn",
            echo=True)
        pri = max(star_table['apfpri'][available])
        sort_i = np.where(star_table['apfpri'][available] == pri, True, False)
    else:
        apflog("getNext(): Couldn't find any suitable targets!",
               level="error",
               echo=True)
        return None

    starstr = "getNext(): star table available: %s" % (sn[available][sort_i])
    apflog(starstr, echo=True)

    sort_j = cur_elevations[available][sort_i].argsort()[::-1]

    t_n = sn[available][sort_i][sort_j][0]

    elstr = "getNext(): star elevations %s" % (
        cur_elevations[available][sort_i][sort_j])
    apflog(elstr, echo=True)

    t_n = sn[available][sort_i][sort_j][0]

    apflog("getNext(): selected target %s" % (t_n))

    idx, = np.where(sn == t_n)
    idx = idx[0]

    stars[idx].compute(apf_obs)

    res = dict()

    res['RA'] = stars[idx].a_ra
    res['DEC'] = stars[idx].a_dec
    res['PM_RA'] = 0.0
    res['PM_DEC'] = 0.0
    res['VMAG'] = star_table['vmag'][idx]
    res['BV'] = star_table['b-v'][idx]
    res['COUNTS'] = star_table['counts'][idx]
    res['EXP_TIME'] = star_table['expt'][idx]
    res['NEXP'] = star_table['nshots'][idx]
    res['TOTEXP_TIME'] = totexptimes[idx]
    res['I2CNTS'] = i2cnts[idx]
    res['NAME'] = sn[idx]
    res['SCORE'] = star_table['apfpri'][idx]
    res['PRI'] = star_table['apfpri'][idx]
    res['SCRIPTOBS'] = makeScriptobsLine(res,
                                         do_flag[idx],
                                         dt,
                                         decker=confg['decker'],
                                         I2=confg['I2'],
                                         owner=owner)
    return res
示例#6
0
def smartList(starlist, time, seeing, slowdown):
    """ Determine the best target to observe from the provided scriptobs-compatible starlist.
        Here the best target is defined as an unobserved target (ie not in observed targets )
        that is visible above 30 degrees elevation. Higher elevation targets are prefered,
        but those that rise above 85 degrees will be regected to avoid slewing through the zenith. """
    # Convert the unix timestamp into a python datetime

    # punt
    dt = datetime.utcnow()

    if type(time) == float:
        dt = datetime.utcfromtimestamp(int(time))
    elif type(time) == datetime:
        dt = time
    elif type(time) == ephem.Date:
        dt = time.datetime()

    observed, _ = getObserved(os.path.join(os.getcwd(), "observed_targets"))

    # Generate a pyephem observer for the APF
    apf_obs = ephem.Observer()
    apf_obs.lat = '37:20:33.1'
    apf_obs.long = '-121:38:17.7'
    apf_obs.elevation = 1274
    # Minimum observation to observe things at
    apf_obs.horizon = str(TARGET_ELEVATION_MIN)
    apf_obs.date = dt
    # APF latitude in radians
    apf_lat = (37 + 20 / 60. + 33.1 / 3600.) * np.pi / 180.

    # Calculate the moon's location
    moon = ephem.Moon()
    moon.compute(apf_obs)

    # Parse the starlist
    try:
        sn, star_table, lines, stars = parseStarlist(starlist)
    except ValueError:
        # This will be raised when the starlist could not be parsed successfully.
        apflog(
            "No target could be selected because starlist could not be parsed.",
            level="warn",
            echo=True)
        return None
    targNum = len(sn)

    # Minimum Brightness based on conditions
    VMAX = 14

    # Distance to stay away from the moon [Between 15 and 25 degrees]

    moonDist = np.degrees(
        np.sqrt((moon.ra - star_table[:, DS_RA])**2 +
                (moon.dec - star_table[:, DS_DEC])**2))
    md = TARGET_MOON_DIST_MAX - TARGET_MOON_DIST_MIN
    minMoonDist = ((moon.phase / 100.) * md) + TARGET_MOON_DIST_MIN

    available = np.ones(targNum, dtype=bool)
    moon_check = np.where(moonDist > minMoonDist, True, False)
    available = available & moon_check

    # If seeing is bad, only observe bright targets ( Large VMAG is dim star )
    brightenough = np.where(star_table[:, DS_VMAG] < VMAX, True, False)
    available = available & brightenough

    obs_length = star_table[:, DS_EXPT] * star_table[:, DS_NSHOTS] + 45 * (
        star_table[:, DS_NSHOTS] - 1)
    vis, star_elevations, fin_els = is_visible(stars, apf_obs, obs_length,
                                               TARGET_ELEVATION_MIN,
                                               TARGET_ELEVATION_PREF_MIN,
                                               TARGET_ELEVATION_MAX)
    available = available & vis

    done = [True if n in observed else False for n in sn]
    availableandnotdone = available & np.logical_not(done)

    if not any(availableandnotdone):
        apflog("All visible targets have been observed",
               level="warn",
               echo=True)
        (good, ) = np.where(available)
    else:
        (good, ) = np.where(availableandnotdone)

    delta = fin_els[good] - star_elevations[good]
    neg = np.where(delta < 0)
    pos = np.where(delta >= 0)
    inv_els = fin_els[good]
    inv_els[neg] = fin_els[good[neg]] - 90
    inv_els[pos] = 90 - fin_els[good[pos]]
    sort_fin_els_idx = np.argsort(inv_els)
    idx = good[sort_fin_els_idx[0]]

    res = dict()

    res['RA'] = stars[idx].a_ra
    res['DEC'] = stars[idx].a_dec
    res['PM_RA'] = star_table[idx, DS_PMRA]
    res['PM_DEC'] = star_table[idx, DS_PMDEC]
    res['VMAG'] = star_table[idx, DS_VMAG]
    res['BV'] = 0.6
    res['PRI'] = 10.
    res['SCORE'] = 1.0
    res['COUNTS'] = star_table[idx, DS_COUNTS]
    res['EXP_TIME'] = star_table[idx, DS_EXPT]
    res['NEXP'] = star_table[idx, DS_NSHOTS]
    res['NAME'] = sn[idx]
    res['SCRIPTOBS'] = lines[idx]
    return res
def timestampFormat(time: str):
    time.datetime()
示例#8
0
def main():

    if userkbflag is True:
        loadknow(userkb)

    filename = datetime('%y%m%d%H%M%S') + '.log'
    try:
        log = open(filename, 'w')

        angerlvl = aggro.query()
        angerlvlprev = angerlvl

        ### main while loop ###
        while True:  #=D =) =| =( D=

            try:
                input = None
                if angerlvl in range(0, 2):
                    input = raw_input("What have you to say?: ")
                elif angerlvl in range(2, 4):
                    input = raw_input("What do you want?: ")
                elif angerlvl in range(4, 6):
                    input = raw_input("YOU ARE NOT A HAMSTER!!!: ")
                else:
                    print "THE UNIVERSE HAS BROKEN!!!!!!!!!"
            except EOFError:
                aggro.stop()
                print '\n\t' + filename, 'created.'
                break

        # after getting input
            log.write('\n> ' + input)

            infoset = inputs(input)
            #print infoset
            aggro.shift(infoset)
            angerlvlprev = angerlvl
            angerlvl = aggro.query()
            if angerflag is True:
                print "Current anger level is: " + angerlvl.__str__()

            sent = getKnowledge(input)

            outsent = None

            senttype = infoset[2]

            if senttype is 'reflex':
                outsent = chooseOut(infoset, angerlvl, angerlvlprev, sent)
            elif senttype is 'know':
                if sent is not None:
                    outsent = Sentence('know', angerlvl, sent).__str__() + "  "
                else:
                    outsent = "I don't know anything about " + input + "."
            else:
                if senttype == 'empty':
                    outsent = "...?"
                else:
                    outsent = Sentence(senttype, angerlvl).__str__()

            # after printing output
            log.write('\n(anger level: ' + repr(angerlvl) + ') ' + outsent)

            print outsent
    except IOError:
        print filename + ': could not open file to write'
    log.close()
    return