Exemplo n.º 1
0
def convert(x, name):
    """Try to convert string to a Python object.
    if not possible return a string
    name: if "date time", force conversion from string to seconds"""
    if name == "date time": return timestamp(x)
    try:
        return float(x)
    except:
        pass
    try:
        return timestamp(x)
    except:
        pass
    return x
def update_data():
    from time_string import timestamp
    status = "Merging..."
    t = nom_delay = act_delay = zeros(0)
    for logfile in logfiles.values():
        t = concatenate((t,[timestamp(d,"") for d in logfile.date_time]))
        nom_delay = concatenate((nom_delay,map(filename_delay,logfile["filename"])))
        act_delay = concatenate((act_delay,logfile.act_delay))
    data.t,data.act_delay,data.nom_delay = t,act_delay,nom_delay
Exemplo n.º 3
0
 def start_time(self):
     from time_string import timestamp
     from time import time
     lines = self.lines((0, 80))
     try:
         t = timestamp(lines[0][0])
     except:
         t = time()
     return t
Exemplo n.º 4
0
 def next_timestamp(text, offset):
     from time_string import timestamp
     from numpy import nan
     i = text.find("\n", offset) + 1
     if i < 0: t = nan
     else:
         j = text.find("\t", i)
         if j < 0: t = nan
         else: t = timestamp(text[i:j])
     return t
    "//Femto/C/All Projects/APS/Experiments/2016.11/Logfiles/Sample-Temperature-1.log"
timezone = "-06"  # CST

# Parameters
c = 15.0  # sample heat capacity [J/K]
Rin = 1.0  # thermal resistance heater-sample [K/W]
Rout = 10.0  # thermal resistance sample-ambient [K/W]
sigma1 = 0  #1e-8 # radiative coupling heater-sample [W/K^4]
sigma2 = 0  #1e-9 # radiative coupling sample-ambient [W/K^4]
Tout = 273 + 29  # ambient temperature

info("Loading data")
Tin_log = table(Tin_logfile, separator="\t")[53180:]
T_log = table(T_logfile, separator="\t")[:-120]

t_Tin = array([timestamp(t + timezone) for t in Tin_log.date_time])
T_Tin = Tin_log.value + 273
Tin = interp1d(t_Tin, T_Tin, kind='linear', bounds_error=False)
t = array([timestamp(t + timezone) for t in T_log.date_time])
T = T_log.value + 273


def dT_dt(T, t):
    """Derivative of temperature T at time t."""
    Pin = 1. / Rin * (Tin(t) - T) + sigma1 * (Tin(t)**4 - T**4
                                              )  # heat float into sample
    Pout = 1. / Rout * (T - Tout) + sigma2 * (T**4 - Tout**4
                                              )  # head flow out of sample
    dT_dt = 1. / c * (Pin - Pout)  # rate of temperature change
    return dT_dt