Exemple #1
0
 def _cache_key(self):
     field_keys = ""
     if self.field_args is not None:
         field_keys = "-".join(
             ["%s:%s" % (name, field.units.__class__.__name__) for name, field in self.field_args.items()])
     key = self.name + self.ptype._cache_key + field_keys + ('TIME:%f' % ostime())
     return md5(key.encode('utf-8')).hexdigest()
Exemple #2
0
 def __init__(self, interval, process=None):
     self.interval = interval
     self.start = ostime()
     self._mem_start = psutil.Process(getpid()).memory_info().rss
     self._mem_measurement = []
     if self._mem_start > 0:
         self._mem_measurement.append(0)
     self.event = Event()
     self.thread = Thread(target=self._target)
     self.thread.start()
Exemple #3
0
def conv_arr_img(data):
    return (255.0 / data.max() * (data - data.min())).astype(np.uint8)


x, y = np.meshgrid(np.linspace(-1, 1, 5), np.linspace(-1, 1, 5))
d = np.sqrt(x * x + y * y)
sigma, mu = 1.0, 0.0
g = np.exp(-((d - mu)**2 / (2.0 * sigma**2))).astype(dtype=np.float32)

if __name__ == '__main__':
    timer_overall = BackgroundMeasureMemory(0.01)

    # ==== ADD SIMPLE IN-MEMORY EXAMPLE HERE BEFORE GOING TO FILES ==== #
    timed_mem_collection_1 = BackgroundMeasureMemory(0.01)
    sleep(0.1)
    time_s_genStommel_np = ostime()
    a = 10000 * 1e3
    b = 10000 * 1e3
    scalefac = 0.05
    lon = np.linspace(0, a, 200, dtype=np.float32)
    lat = np.linspace(0, b, 200, dtype=np.float32)
    U = np.zeros((lon.size, lat.size), dtype=np.float32)
    V = np.zeros((lon.size, lat.size), dtype=np.float32)
    beta = 2e-11
    r = 1 / (11.6 * 86400)
    es = r / (beta * a)
    for i in range(lon.size):
        for j in range(lat.size):
            xi = lon[i] / a
            yi = lat[j] / b
            U[i, j] = -(1 - math.exp(-xi / es) - xi) * math.pi**2 * np.cos(