Commit e6407619 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

changed sta file handling

parent b89b403b
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -226,8 +226,8 @@ input:
### e.g. frame error insertion or transport simulation for JBM testing
### can be given globally or in individual conditions of type ivas or evs
# tx:
    ### REQUIRED: Type of bitstream processing; possible types: "jbm" or "fer"
    #type: "jbm"
    ### REQUIRED: Type of bitstream processing; possible types: "JBM" or "FER"
    #type: "JBM"
    
    ### JBM
    ### REQUIRED: either error_pattern or error_profile
+2 −2
Original line number Diff line number Diff line
@@ -96,8 +96,8 @@ input:
### e.g. frame error insertion or transport simulation for JBM testing
### can be given globally here or in individual conditions of type ivas or evs
# tx:
    ### REQUIRED: Type of bitstream processing; possible types: "jbm" or "fer"
    #type: "jbm"
    ### REQUIRED: Type of bitstream processing; possible types: "JBM" or "FER"
    #type: "JBM"
    
    ### JBM
    ### REQUIRED: either error_pattern or error_profile
+20 −11
Original line number Diff line number Diff line
@@ -108,7 +108,6 @@ def create_error_pattern(
) -> None:
    """
    Creates error pattern with desired frame error rate for bitstream processing
    For 3, 5, 6 and 10 percent FER the results are deterministic

    Parameters
    ----------
@@ -124,16 +123,26 @@ def create_error_pattern(

    with TemporaryDirectory() as tmp_dir:
        tmp_dir = Path(tmp_dir)
        if frame_error_rate in LIST_FER:
            # copy sta file
            sta_file = ERROR_PATTERNS_DIR.joinpath(f"sta_{int(frame_error_rate)}")
            tmp_sta_file = tmp_dir.joinpath("sta")
            shutil.copyfile(sta_file, tmp_sta_file)

        else:
            warnings.warn(
                f"Frame error rate {frame_error_rate}% is not a default rate. Error pattern is random and not deterministic."
            )
        sta_file = ERROR_PATTERNS_DIR.joinpath(f"sta_template")
        tmp_sta_file = tmp_dir.joinpath("sta")
        # TODO: compute seed
        seed = 0
        # open file and modify
        lines = []
        with open(sta_file, "r") as sta_file_txt:
            lines.append(sta_file_txt.readline())  # not changed
            lines.append(f"{sta_file_txt.readline()[:-2]}{frame_error_rate/100}\n")
            lines.append(sta_file_txt.readline())  # not changed
            lines.append(f"{sta_file_txt.readline()[:-2]}{seed}\n")
            lines.append(sta_file_txt.readline())  # not changed
            lines.append(f"{sta_file_txt.readline()[:-2]}{1-(frame_error_rate/100*2)}\n")
            lines.append(sta_file_txt.readline())  # not changed
            lines.append(f"{sta_file_txt.readline()[:-2]}{1-(frame_error_rate/100*2)}\n")
            lines.append(sta_file_txt.readline())  # not changed

        with open(tmp_sta_file, "w") as tmp_sta_file_txt:
            tmp_sta_file_txt.write("".join(lines))

        gen_patt(
            len_sig=len_sig,
+0 −9
Original line number Diff line number Diff line
EID
BER           = 0.100000
GAMMA         = 0.000000
RAN-seed      = 0x356007f8
Current State = B
GOOD->GOOD    = 0.800000
GOOD->BAD     = 1.000000
BAD ->GOOD    = 0.800000
BAD ->BAD     = 1.000000
+0 −9
Original line number Diff line number Diff line
EID
BER           = 0.050000
GAMMA         = 0.000000
RAN-seed      = 0x6d30b654
Current State = G
GOOD->GOOD    = 0.900000
GOOD->BAD     = 1.000000
BAD ->GOOD    = 0.900000
BAD ->BAD     = 1.000000
Loading