示例#1
0
def test_read_write_measurement():
    with TempDirectory() as directory:
        filename = 'test.nc'
        io = nc.NCFile(os.path.join(directory.path, filename))
        original = utilities.CornerCases()
        name = 'measurement'
        io.write(original, name)
        assert original == io.read(name)
示例#2
0
def test_read_write_sweepstreamarray():
    with TempDirectory() as directory:
        filename = 'test.nc'
        io = nc.NCFile(os.path.join(directory.path, filename))
        original = utilities.fake_sweep_stream_array()
        name = 'sweep_stream_array'
        io.write(original, name)
        assert original == io.read(name)
示例#3
0
def test_cached_stream_array():
    with TempDirectory() as directory:
        filename = 'test.nc'
        io = nc.NCFile(os.path.join(directory.path, filename),
                       cache_s21_raw=True)
        original = utilities.fake_stream_array()
        name = 'measurement'
        io.write(original, name)
        assert np.all(original.s21_raw == io.read(name).s21_raw)
示例#4
0
def new_nc_file(suffix='', directory=settings.BASE_DATA_DIR, metadata=None):
    if suffix and not suffix.startswith('_'):
        suffix = '_' + suffix
    if metadata is None:
        metadata = all_metadata()
    root_path = os.path.join(
        directory,
        time.strftime('%Y-%m-%d_%H%M%S') + suffix + nc.NCFile.EXTENSION)
    logger.debug("Creating new NCFile with path %s" % root_path)
    return nc.NCFile(root_path, metadata=metadata)