Пример #1
0
def get_chip_region(fname):
    """Get the chip region of a data set

    Parameters
    ----------
    fname: str
        Path to an experimental data file. The file format is
        determined from the file extenssion (tdms or rtdc).

    Returns
    -------
    chip_region: str
        The chip region ("channel" or "reservoir")
    """
    fname = pathlib.Path(fname).resolve()
    ext = fname.suffix

    if ext == ".rtdc":
        with h5py.File(path_to_str(fname), mode="r") as h5:
            chip_region = h5.attrs["setup:chip region"]
    elif ext == ".tdms":
        name = fname.name
        path = fname.parent
        mx = name.split("_")[0]
        para = path / (mx + "_para.ini")
        if para.exists():
            camcfg = rt_config.load_from_file(path_to_str(para))
            chip_region = camcfg["General"]["Region"].lower()

    return chip_region
Пример #2
0
def get_chip_region(fname):
    """Get the chip region of a data set

    Parameters
    ----------
    fname: str
        Path to an experimental data file. The file format is
        determined from the file extenssion (tdms or rtdc).

    Returns
    -------
    chip_region: str
        The chip region ("channel" or "reservoir")
    """
    fname = pathlib.Path(fname).resolve()
    ext = fname.suffix

    if ext == ".rtdc":
        with h5py.File(str(fname), mode="r") as h5:
            chip_region = h5.attrs["setup:chip region"]
    elif ext == ".tdms":
        name = fname.name
        path = fname.parent
        mx = name.split("_")[0]
        para = path / (mx + "_para.ini")
        if para.exists():
            camcfg = rt_config.load_from_file(str(para))
            chip_region = camcfg["General"]["Region"].lower()

    return chip_region
Пример #3
0
def get_chip_region(path):
    fname = pathlib.Path(path).resolve()
    ext = fname.suffix
    if ext == ".rtdc":
        with h5py.File(fname, mode="r") as h5:
            chip_region = h5.attrs["setup:chip region"]
    elif ext == ".tdms":
        name = fname.name
        path = fname.parent
        mx = name.split("_")[0]
        para = path / (mx + "_para.ini")
        if para.exists():
            camcfg = rt_config.load_from_file(para)
            chip_region = camcfg["general"]["region"].lower()
        else:
            config = get_rtdc_config(path)
            chip_region = config["setup"]["chip region"]
    return chip_region
Пример #4
0
def get_flow_rate(fname):
    """Get the flow rate of a data set

    Parameters
    ----------
    fname: str
        Path to an experimental data file. The file format is
        determined from the file extenssion (tdms or rtdc).

    Returns
    -------
    flow_rate: float
        The flow rate [µL/s] of the data set
    """
    fname = pathlib.Path(fname).resolve()
    ext = fname.suffix

    if ext == ".rtdc":
        with h5py.File(str(fname), mode="r") as h5:
            flow_rate = h5.attrs["setup:flow rate"]
    elif ext == ".tdms":
        name = fname.name
        path = fname.parent
        mx = name.split("_")[0]
        para = path / (mx + "_para.ini")
        if para.exists():
            camcfg = rt_config.load_from_file(str(para))
            flow_rate = camcfg["general"]["flow rate [ul/s]"]
        else:
            # analyze the filename
            warnings.warn(
                "{}: trying to manually find flow rate.".format(fname))
            flow_rate = float(fname.split("ul_s")[0].split("_")[-1])
    else:
        raise ValueError("`fname` must be an .rtdc or .tdms file!")

    return flow_rate
Пример #5
0
def get_flow_rate(fname):
    """Get the flow rate of a data set

    Parameters
    ----------
    fname: str
        Path to an experimental data file. The file format is
        determined from the file extenssion (tdms or rtdc).

    Returns
    -------
    flow_rate: float
        The flow rate [µL/s] of the data set
    """
    fname = pathlib.Path(fname).resolve()
    ext = fname.suffix

    if ext == ".rtdc":
        with h5py.File(path_to_str(fname), mode="r") as h5:
            flow_rate = h5.attrs["setup:flow rate"]
    elif ext == ".tdms":
        name = fname.name
        path = fname.parent
        mx = name.split("_")[0]
        para = path / (mx + "_para.ini")
        if para.exists():
            camcfg = rt_config.load_from_file(path_to_str(para))
            flow_rate = camcfg["general"]["flow rate [ul/s]"]
        else:
            # analyze the filename
            warnings.warn("{}: trying to manually find flow rate.".
                          format(fname))
            flow_rate = float(fname.split("ul_s")[0].split("_")[-1])
    else:
        raise ValueError("`fname` must be an .rtdc or .tdms file!")

    return flow_rate
Пример #6
0
def GetDefaultConfiguration(key=None):
    cfg = rt_config.load_from_file(cfg_file)
    if key is not None:
        return cfg[key]
    else:
        return cfg
Пример #7
0
    def compare(x, y):
        """
        Compare keys for sorting.
        """
        if isinstance(x, (list, tuple)):
            x = x[0]
        if isinstance(y, (list, tuple)):
            y = y[0]
        
        if x in orderlist:
            rx = orderlist.index(x)
        else:
            rx = len(orderlist) + 1
        if y in orderlist:
            ry = orderlist.index(y)
        else:
            ry = len(orderlist) + 1
        if rx == ry:
            if x<y:
                ry += 1
            else:
                rx += 1
        return rx-ry

    return sorted(cfgkeys, cmp=compare)

cfg_dir = pkg_resources.resource_filename("shapeout", "cfg")
cfg_file = os.path.join(cfg_dir, "default.cfg")
cfg = rt_config.load_from_file(cfg_file)
cfg_ordered_list = GetConfigurationKeys(cfg_file)
Пример #8
0
def GetDefaultConfiguration(key=None):
    cfg = rt_config.load_from_file(cfg_file)
    if key is not None:
        return cfg[key]
    else:
        return cfg
Пример #9
0
        """
        Compare keys for sorting.
        """
        if isinstance(x, (list, tuple)):
            x = x[0]
        if isinstance(y, (list, tuple)):
            y = y[0]

        if x in orderlist:
            rx = orderlist.index(x)
        else:
            rx = len(orderlist) + 1
        if y in orderlist:
            ry = orderlist.index(y)
        else:
            ry = len(orderlist) + 1
        if rx == ry:
            if x < y:
                ry += 1
            else:
                rx += 1
        return rx - ry

    return sorted(cfgkeys, cmp=compare)


cfg_dir = pkg_resources.resource_filename("shapeout", "cfg")
cfg_file = os.path.join(cfg_dir, "default.cfg")
cfg = rt_config.load_from_file(cfg_file)
cfg_ordered_list = GetConfigurationKeys(cfg_file)
Пример #10
0
def get_default_config():
    cfg_dir = pkg_resources.resource_filename("shapeout", "cfg")
    cfg_file = pathlib.Path(cfg_dir) / "default.cfg"
    cfg = dclab_config.load_from_file(cfg_file)
    return cfg
Пример #11
0
def get_default_config():
    cfg_dir = pkg_resources.resource_filename("shapeout", "cfg")
    cfg_file = pathlib.Path(cfg_dir) / "default.cfg"
    cfg = dclab_config.load_from_file(cfg_file)
    return cfg