Ejemplo n.º 1
0
def main():
    io = Io()
    io.eval_args()
    ret = {'ok': True}

    cmc = False

    base_doc = io.get_base_doc("se3")
    for id in io.ids:
        doc = io.get_doc_db(id)
        if io.update:
            doc = io.update_cal_doc(doc, base_doc)

        cal = Cal(doc)
        ana = Analysis(doc, analysis_type="direct")

        cus_dev = init_customer_device(doc)

        cus_dev.range_trans(ana)
        cal.temperature_comp(ana)
        cal.temperature_gas_direct(ana)
        cal.pressure_gn_corr(ana)
        cal.pressure_gn_mean(ana)

        temperature_dict = ana.pick_dict('Temperature', 'compare')
        gas = cal.Aux.get_gas()
        ind_dict = cal.Pres.get_dict('Type', 'ind')
        offset_dict = cal.Pres.get_dict('Type', 'ind_offset')
        range_dict = cal.Range.get_dict('Type', 'ind')

        ind = cus_dev.pressure(ind_dict,
                               temperature_dict,
                               range_dict=range_dict,
                               unit=ana.pressure_unit,
                               gas=gas)
        offset = cus_dev.pressure(offset_dict,
                                  temperature_dict,
                                  range_dict=range_dict,
                                  unit=ana.pressure_unit,
                                  gas=gas)

        ana.store("Pressure", "ind", ind, ana.pressure_unit)
        ana.store("Pressure", "offset", offset, ana.pressure_unit)
        ana.store("Pressure", "ind_corr", ind - offset, ana.pressure_unit)

        # error for rating procedures
        p_ind = ana.pick("Pressure", "ind_corr", cal.unit)
        p_cal = ana.pick("Pressure", "cal", cal.unit)
        ana.store('Error', 'ind', p_ind / p_cal - 1.0, '1')

        ## uncert. calculation
        uncert = Uncert(doc)

        ## we have cmc entries for the FRS
        ## so we can use the GN uncertainty
        u = uncert.contrib_pressure_fill(p_cal, cal.unit)
        ana.store("Uncertainty", "standard", u / p_cal, "1")

        io.save_doc(ana.build_doc())

    print(json.dumps(ret))
Ejemplo n.º 2
0
def main():
    io = Io()
    io.eval_args()
    args = sys.argv
    fail = False
    ret = {'ok': True}

    if '--ids' in args:
        idx_ids = args.index('--ids') + 1
        try:
            ids = args[idx_ids].split(';')
        except:
            fail = True

    if '-u' in args:
        update = True
    else:
        update = False

    if not fail and len(ids) > 0:
        base_doc = io.get_base_doc("dkm_ppc4")
        for id in ids:
            doc = io.get_doc_db(id)

            if update:
                doc = io.update_cal_doc(doc, base_doc)

            cus_dev = init_customer_device(doc)

            res = Analysis(doc)
            uncert = Uncert(doc)
            cal = Cal(doc)
            cal.temperature(res)
            cal.temperature_correction(res)
            cal.pressure_res(res)
            cal.mass_total(res)
            cal.pressure_cal(res)

            # cal uncert of standard
            uncert.total(res)

            ## calculate customer indication
            gas = cal.Aux.get_gas()
            ## todo meas temp room, gas
            temperature_dict = {}

            offset_dict = cal.Pres.get_dict('Type', 'ind_offset')
            ind_dict = cal.Pres.get_dict('Type', 'ind')

            offset = cus_dev.pressure(offset_dict,
                                      temperature_dict,
                                      unit=cal.unit,
                                      gas=gas)
            ind = cus_dev.pressure(ind_dict,
                                   temperature_dict,
                                   unit=cal.unit,
                                   gas=gas)

            ind_corr = ind - offset

            res.store("Pressure", "offset", offset, cal.unit)
            res.store("Pressure", "ind", ind, cal.unit)
            res.store("Pressure", "ind_corr", ind_corr, cal.unit)

            # error for rating procedures
            p_ind_corr = res.pick("Pressure", "ind_corr", cal.unit)
            p_cal = res.pick("Pressure", "cal", cal.unit)
            res.store('Error', 'ind', p_ind_corr / p_cal - 1, '1')
            cus_dev.range_trans(res)

            print(p_ind_corr / p_cal - 1)
            io.save_doc(res.build_doc())
Ejemplo n.º 3
0
def main():
    io = Io()
    io.eval_args()
    ret = {"ok": True}
    result_type = "sens"
    i_unit = "A"
    for id in io.ids:
        doc = io.get_doc_db(id)
        tdo = ToDo(doc)

        if tdo.type not in ["sens"]:
            sys.exit("wrong script")
        if tdo.type == "sens":
            result_type = "sens"

        display = Display(doc)
        cus_dev = init_customer_device(doc)
        analysis = doc.get("Calibration").get("Analysis")

        ## wrong type:
        del analysis["Values"]["Sensitivity"]

        ana = Analysis(doc, init_dict=analysis, analysis_type=result_type)
        res = Result(doc, result_type=result_type, skip=io.skip)

        ## conversion to ana.pressure_unit if necessary
        cal_dict = ana.pick_dict("Pressure", "cal")

        p_ind_corr = ana.pick("Pressure", "ind_corr", i_unit)
        p_ind = ana.pick("Pressure", "ind", i_unit)
        p_ind_offset = ana.pick("Pressure", "ind_offset", i_unit)

        if cal_dict.get("Unit") != ana.pressure_unit:
            p_cal = ana.pick("Pressure", "cal", tdo.pressure_unit)
            conv = ana.Const.get_conv(from_unit=tdo.pressure_unit,
                                      to_unit=ana.pressure_unit)
            p_cal = p_cal * conv
        else:
            p_cal = ana.pick("Pressure", "cal", ana.pressure_unit)

        T_gas = ana.pick("Temperature", "Tuhv", "K")
        T_room = ana.pick("Temperature", "Troom", "K")

        if T_room is None:
            T_room = T_gas

        u_std = ana.pick("Uncertainty", "uncertPcal_rel", "1")

        ## recal Sensitivity
        s = p_ind_corr / (cus_dev.emis_current(i_unit) * p_cal)

        ana.store("Pressure", "cal", p_cal, ana.pressure_unit)
        ana.store("Pressure", "offset", p_ind_offset, i_unit)
        ana.store("Sensitivity", "gauge", s, "1/{}".format(ana.pressure_unit))

        ana.store("Uncertainty", "standard", u_std, "1")
        ana.store("Temperature", "gas", T_gas, "K")
        ana.store("Temperature", "room", T_room, "K")

        conv = ana.Const.get_conv(from_unit=ana.pressure_unit,
                                  to_unit=tdo.pressure_unit)
        average_index = tdo.make_average_index(p_cal * conv,
                                               tdo.pressure_unit,
                                               max_dev=0.2)

        ## will be filled up with aux values:
        d = {}

        display.check_outlier_sens(ana)
        average_index, reject_index = ana.ask_for_reject(
            average_index=average_index)
        flat_average_index = ana.flatten(average_index)

        if result_type == "sens":
            T, Tu = ana.ask_for_bake_out_temperature()
            if T is not None:
                d["Bakeout"] = True
                d["BakeoutTemperature"] = float(T)
                d["BakeoutTemperatureUnit"] = Tu
                t, tu = ana.ask_for_bake_out_time()
                d["BakeoutTime"] = float(t)
                d["BakeoutTimeUnit"] = tu
            else:
                d["Bakeout"] = False

            p, pu, t, tu = ana.ask_for_sputter()
            if T is not None:
                d["Sputter"] = True
                d["SputterPressure"] = float(p)
                d["SputterPressureUnit"] = pu
                d["SputterTime"] = float(t)
                d["SputterTimeUnit"] = tu
            else:
                d["Sputter"] = False

        d["AverageIndex"] = average_index
        d["AverageIndexFlat"] = flat_average_index
        ana.store_dict(quant="AuxValues", d=d, dest=None)

        ## rm values
        p_cal = np.take(p_cal, flat_average_index)
        p_ind_corr = np.take(p_ind_corr, flat_average_index)
        s = np.take(s, flat_average_index)

        ## store reduced quant. for plot
        ana.store("Pressure",
                  "red_ind_corr",
                  p_ind_corr,
                  i_unit,
                  dest="AuxValues")
        ana.store("Pressure",
                  "red_cal",
                  p_cal,
                  ana.pressure_unit,
                  dest="AuxValues")
        ana.store("Sensitivity",
                  "red_gauge",
                  s,
                  "1/{}".format(ana.pressure_unit),
                  dest="AuxValues")

        ## offset contrib
        cus_dev.coll_uncert(ana, ind_unit=i_unit)

        ## default uncert. contrib.  repeat
        cus_dev.repeat_uncert(ana, ind_unit=i_unit)
        cus_dev.digit_uncert(ana, ind_unit=i_unit)
        cus_dev.emis_uncert(ana, ind_unit=i_unit)

        cus_dev.device_uncert(ana)

        ## the uncertainty of the standard is
        # already calculated at analysis step
        ana.total_uncert()

        ## store red version for plot
        u_rep = ana.pick("Uncertainty", "repeat", "1")
        u_off = ana.pick("Uncertainty", "offset", "1")
        u_tot = ana.pick("Uncertainty", "total_rel", "1")
        u_dev = ana.pick("Uncertainty", "device", "1")
        u_std = ana.pick("Uncertainty", "standard", "1")

        ana.store("Uncertainty",
                  "red_u_rep",
                  np.take(u_rep, flat_average_index),
                  "1",
                  dest="AuxValues")
        ana.store("Uncertainty",
                  "red_u_std",
                  np.take(u_std, flat_average_index),
                  "1",
                  dest="AuxValues")
        ana.store("Uncertainty",
                  "red_u_dev",
                  np.take(u_dev, flat_average_index),
                  "1",
                  dest="AuxValues")
        ana.store("Uncertainty",
                  "red_u_tot",
                  np.take(u_tot, flat_average_index),
                  "1",
                  dest="AuxValues")
        ana.store("Uncertainty",
                  "red_u_off",
                  np.take(u_off, flat_average_index),
                  "1",
                  dest="AuxValues")

        display.plot_uncert(ana)

        # start making data sections
        res.make_measurement_data_section(ana, result_type=result_type)

        # start build cert table
        p_cal_mv, p_ind_mv, s_mv, u_mv = res.make_sens_table(
            ana,
            pressure_unit=ana.pressure_unit,
            sens_unit='1/Pa',
            uncert_unit="1",
            ind_unit="A")

        ana.store("Pressure", "ind_mean", p_ind_mv, i_unit, dest="AuxValues")
        ana.store("Pressure",
                  "cal_mean",
                  p_cal_mv,
                  ana.pressure_unit,
                  dest="AuxValues")
        ana.store("Sensitivity",
                  "gauge_mean",
                  s_mv,
                  "1/{}".format(ana.pressure_unit),
                  dest="AuxValues")
        ana.store("Uncertainty", "total_mean", u_mv, "1", dest="AuxValues")

        display.plot_mean(ana)

        doc = ana.build_doc("Analysis", doc)
        doc = res.build_doc("Result", doc)
        io.save_doc(doc)
Ejemplo n.º 4
0
def main(io, config):
    val = Values({})
    struct_path = config.get("struct_path")
    cal_file = config.get("cal_file")
    result_name = config.get("result_name")

    #doc = io.read_json("{}/{}".format(struct_path, cal_file))

    #doc = io.get_doc_db("cal-2020-se3-kk-75021_0001") # 0.1mbar
    #u_digit_abs = 2.9e-6 #Pa

    doc = io.get_doc_db("cal-2020-se3-kk-75093_0001") # 1torr
    u_digit_abs = 2.9e-6 #Pa

    ana = Analysis(doc, init_dict=doc.get("Calibration").get("Analysis"))
    cuco = init_customer_device(doc)

    ##
    Uncert(doc).total(ana)

    p_cal = ana.pick("Pressure", "cal", "Pa")
    p_ind = ana.pick("Pressure", "ind_corr", "Pa")
    u_1 = ana.pick("Uncertainty", "p_fill", "1")
    u_2 = ana.pick("Uncertainty", "p_rise", "1")
    u_3 = ana.pick("Uncertainty", "f", "1")
    u_4 = ana.pick("Uncertainty", "V_start", "1")
    u_5 = ana.pick("Uncertainty", "V_add", "1")
    u_6 = ana.pick("Uncertainty", "T_before", "1")
    u_7 = ana.pick("Uncertainty", "T_after", "1")
    u_8 = ana.pick("Uncertainty", "KF", "1")
    u = ana.pick("Uncertainty", "standard", "1")

    df = pd.DataFrame({"$p_\text{cal}$/Pa"         : to_si(p_cal),
                       "$u(p_\text{fill})$"        : to_si(u_1),
                       "$u(p_\text{rise})$"        : to_si(u_2),
                       "$u(f)$"                    : to_si(u_3),
                       "$u(V_\text{start})$"       : to_si(u_4),
                       "$u(V_\text{add})$"         : to_si(u_5),
                       "$u(T_\text{before})$"      : to_si(u_6),
                       "$u(T_\text{after})$"       : to_si(u_7),
                       "$u(K_iF_i)$"               : to_si(u_8),
                       #"$u_g$"                     : to_si(u),
                       "$U_{\text{SE3}}$"                     : to_si(u*2),
                       "$U_{\text{SE3}}\cdot p_\text{cal}$/Pa" :to_si(u*2*p_cal),
                       })

    print(df.to_latex(index=False, escape=False))

    with open("{}.tex".format(result_name), 'w') as tf:
        tf.write(df.to_latex(index=False, escape=False))

    u_1 = ana.pick("Uncertainty", "offset", "1")
    u_2 = ana.pick("Uncertainty", "repeat", "1")
    u_3 = ana.pick("Uncertainty", "digit", "1")
    if not u_3:
        u_3 = u_digit_abs/p_ind
    u_4 = ana.pick("Uncertainty", "device", "1")
    u_5 = np.sqrt(np.power(u_4,2) +  np.power(u,2))

    e = p_ind/p_cal-1
    U_e = u_5*2*p_ind/p_cal
    df = pd.DataFrame({"$p_\text{cal}$/Pa"                     : to_num(val.round_to_uncertainty_array(p_cal, u_4*p_cal, 2, scientific=True)),
                       "$(p_\text{ind}-p_\text{ind,r}$/Pa"     : to_num(val.round_to_uncertainty_array(p_ind, u_4*p_ind, 2, scientific=True)),
                       "$e$"                                   : to_num(val.round_to_uncertainty_array(e, U_e, 2)),
                       "$u_{\text{SE3}}$"                      : to_si(u),
                       "$u_{\text{offset}}$"                   : to_si(u_1),
                       "$u_{\text{repeat}}$"                   : to_si(u_2),
                       "$u_{\text{digit}}$"                    : to_si(u_3),
                       "$u_{\text{CDG}}$"                      : to_si(u_4),
                       "$U_{e}$"                               : to_si(U_e),
                       })

    print(df.to_latex(index=False, escape=False))

    with open("{}_{}_{}_{}.tex".format(result_name, cuco.dev_class, cuco.type_head, cuco.producer.upper()), 'w') as tf:
        tf.write(df.to_latex(index=False, escape=False))
Ejemplo n.º 5
0
def main(io, config):


    io.eval_args()
    doc = {"_id": "cal-sim-se3",
        "Calibration":{"ToDo":{"Standard": "SE3",
                               "Type": "error"},
                       "Measurement":{}}}
    struct_path = config.get("struct_path")
    values_file = config.get("values_file")
    cal_file = config.get("cal_file")

    ##-----------------------------------------
    ## standard
    ##-----------------------------------------
    base_doc = io.get_base_doc("se3")
    doc = io.update_cal_doc(doc, base_doc)

    vals = io.read_json("{}/{}".format(struct_path, values_file))
    aux_vals = io.read_json("{}/meas_aux_values.json".format(struct_path))
    ana_aux_vals = io.read_json("{}/ana_aux_values.json".format(struct_path))

    doc['Calibration']['Measurement']['Values'] = vals
    doc['Calibration']['Measurement']['AuxValues'] = aux_vals

    ##-----------------------------------------
    ## device
    ##-----------------------------------------
    doc['Calibration']['CustomerObject'] = config.get("customer_object")

    ##-----------------------------------------
    ## ini
    ##-----------------------------------------
    ana = Analysis(doc, insert_dict={'AuxValues': ana_aux_vals}, analysis_type="expansion")
    cal = Cal(doc)
    cal.all(ana)
    Uncert(doc).total(ana)


    cus_dev = init_customer_device(doc)
    gas = config.get("gas")

    temperature_dict = ana.pick_dict('Temperature', 'after')
    offset_dict = cal.Pres.get_dict('Type', 'ind_offset' )
    ind_dict = cal.Pres.get_dict('Type', 'ind' )
    range_dict = cal.Range.get_dict('Type', 'ind' )

    offset = cus_dev.pressure(offset_dict, temperature_dict, range_dict=range_dict, unit = cal.unit, gas=gas)
    ind = cus_dev.pressure(ind_dict, temperature_dict, range_dict=range_dict, unit = cal.unit, gas=gas)
    ana.store("Pressure", "offset", offset, cal.unit)
    ana.store("Pressure", "ind", ind, cal.unit)
    ana.store("Pressure", "ind_corr", ind - offset, cal.unit)

    p_ind = ana.pick("Pressure", "ind_corr", cal.unit)
    p_cal = ana.pick("Pressure", "cal" , cal.unit)
    ana.store('Error', 'ind', p_ind/p_cal-1, '1')
    cus_dev.range_trans(ana)

    cus_dev.offset_uncert(ana)
    cus_dev.repeat_uncert(ana, cmc=False)

    if "uncert_dict" in dir(cus_dev):
        u_add = cus_dev.get_total_uncert(meas_vec=p_ind,
                                        meas_unit=ana.pressure_unit,
                                        return_unit=ana.error_unit,
                                        res=ana,
                                        skip_source="standard",
                                        prefix=False)
    cus_dev.device_uncert(ana)

    ana.total_uncert()


    with open("{}/{}".format(struct_path, cal_file), 'w') as f:
        json.dump(ana.build_doc(), f, indent=4, ensure_ascii=False)
Ejemplo n.º 6
0
def main():
    io = Io()
    io.eval_args()
    ret = {'ok': True}

    cmc = False

    for id in io.ids:
        doc = io.get_doc_db(id)
        display = Display(doc)

        cus_dev = init_customer_device(doc)
        ana = result_analysis_init(doc)

        ## generate result instance with analysis res type

        res = Result(doc, result_type=ana.analysis_type, skip=io.skip)
        if res.ToDo.type != "sigma":
            sys.exit("wrong script")

        p_cal = ana.pick('Pressure', 'cal', ana.pressure_unit)
        p_ind_corr = ana.pick('Pressure', 'ind_corr', ana.pressure_unit)

        ## will be filled up with aux values:
        d = {}

        sigma = ana.pick("Sigma", "eff", "1")
        if sigma is None:
            sigma = p_ind_corr / p_cal
            ana.store("Sigma", "eff", sigma, "1")

        display.check_sigma(ana)

        all_index = cus_dev.make_sigma_index(p_cal, ana.pressure_unit)
        average_index, reject_index = ana.ask_for_reject(
            average_index=all_index)
        flat_average_index = ana.flatten(average_index)
        d["AverageIndex"] = average_index
        d["AverageIndexFlat"] = flat_average_index
        ana.store_dict(quant='AuxValues', d=d, dest=None)

        ## reduce
        p_cal = np.take(p_cal, flat_average_index)
        p_ind = np.take(p_ind_corr, flat_average_index)
        sigma = np.take(sigma, flat_average_index)

        ## store reduced quant. for plot
        ana.store("Pressure",
                  "red_ind_corr",
                  p_ind,
                  ana.pressure_unit,
                  dest="AuxValues")
        ana.store("Pressure",
                  "red_cal",
                  p_cal,
                  ana.pressure_unit,
                  dest="AuxValues")
        ana.store("Sigma", "red_eff", sigma, "1", dest="AuxValues")

        ## cal. sigma
        sigma_null, sigma_slope, sigma_std = cus_dev.sigma_null(
            p_cal, ana.pressure_unit, p_ind, ana.pressure_unit)
        d["SigmaNull"] = float(sigma_null)
        d["SigmaSlope"] = float(sigma_slope)
        d["SigmaCorrSlope"] = float(np.abs(sigma_slope / sigma_null))
        d["SigmaStd"] = float(sigma_std)
        ana.store_dict(quant='AuxValues', d=d, dest=None)

        ## cal. offset and offset scatter
        aux_values_pres = Values(
            doc.get('Calibration').get('Measurement').get("AuxValues").get(
                "Pressure"))
        rd, rd_unit = aux_values_pres.get_value_and_unit(d_type="offset")

        d["OffsetMean"] = float(np.nanmean(rd))
        d["OffsetStd"] = float(np.nanstd(rd))
        d["OffsetUnit"] = rd_unit
        ana.store_dict(quant='AuxValues', d=d, dest=None)

        ## uncert contribs.
        cus_dev.uncert_sigma_eff(ana)
        cus_dev.uncert_ind(ana)
        cus_dev.uncert_temperature(ana)
        cus_dev.uncert_offset(ana)
        cus_dev.uncert_repeat(ana)
        cus_dev.device_uncert(ana)

        ## the uncertainty of the standard is
        # already calculated at analysis step
        ana.total_uncert()

        u_tot = ana.pick("Uncertainty", "total_rel", "1")
        ana.store("Uncertainty",
                  "red_u_tot",
                  np.take(u_tot, flat_average_index),
                  "1",
                  dest="AuxValues")

        # start making data sections
        res.make_measurement_data_section(ana, result_type=ana.analysis_type)

        display.plot_sigma(ana)

        doc = ana.build_doc("Analysis", doc)
        doc = res.build_doc("Result", doc)
        io.save_doc(doc)
Ejemplo n.º 7
0
def main(io, config):
    struct_path = config.get("struct_path")
    cal_file = config.get("cal_file")
    result_name = config.get("result_name")
    plot_title = config.get("plot_title")
    font = config.get("plot_font")
    col_map = config.get("plot_col_map")

    plt.rc('font', **font)
    doc = io.read_json("{}/{}".format(struct_path, cal_file))

    ana = Analysis(doc, init_dict=doc.get("Calibration").get("Analysis"))
    cuco = init_customer_device(doc)

    p_cal = ana.pick("Pressure", "cal", "Pa")

    u_1 = ana.pick("Uncertainty", "p_fill", "1")
    u_2 = ana.pick("Uncertainty", "p_rise", "1")
    u_3 = ana.pick("Uncertainty", "f", "1")
    u_4 = ana.pick("Uncertainty", "V_start", "1")
    u_5 = ana.pick("Uncertainty", "V_add", "1")
    u_6 = ana.pick("Uncertainty", "T_before", "1")
    u_7 = ana.pick("Uncertainty", "T_after", "1")
    u_8 = ana.pick("Uncertainty", "KF", "1")
    u_std = ana.pick("Uncertainty", "standard", "1")

    u_a = ana.pick("Uncertainty", "offset", "1")
    u_b = ana.pick("Uncertainty", "repeat", "1")
    u_c = ana.pick("Uncertainty", "digit", "1")
    u_dev = ana.pick("Uncertainty", "device", "1")

    u_tot = ana.pick("Uncertainty", "total_rel", "1")

    figure(num=None, figsize=(16, 9), dpi=80, facecolor='w', edgecolor='k')
    plt.plot(p_cal,
             u_tot * 2,
             'H-',
             lw=4,
             color=col_map[0],
             label="total (k=2)")

    plt.plot(p_cal, u_dev, 'H:', lw=3, color=col_map[1], label="device (k=1)")
    plt.plot(p_cal, u_a, '*:', lw=2, color=col_map[9], label="off.")
    plt.plot(p_cal, u_b, 's:', lw=2, color=col_map[3], label="rep.")
    plt.plot(p_cal, u_c, 'D:', lw=2, color=col_map[8], label="dig.")

    plt.plot(p_cal,
             u_std,
             'H-',
             lw=3,
             color=col_map[1],
             label="standard (k=1)")
    plt.plot(p_cal, u_1, '*-', lw=2, color=col_map[2], label="$p_{fill}$")
    plt.plot(p_cal, u_2, '*-', lw=2, color=col_map[3], label="$p_{rise}$")
    plt.plot(p_cal, u_3, 's-', lw=2, color=col_map[4], label="$f_i$")
    plt.plot(p_cal, u_4, 'D-', lw=2, color=col_map[5], label="$V_{start}$")
    plt.plot(p_cal, u_5, 'D-', lw=2, color=col_map[6], label="$V_{add}$")
    plt.plot(p_cal, u_6, 'd-', lw=2, color=col_map[7], label="$T_{before}$")
    plt.plot(p_cal, u_7, 'd-', lw=2, color=col_map[8], label="$T_{after}$")
    plt.plot(p_cal, u_8, 'x-', lw=2, color=col_map[9], label="$K_iF_j$")

    plt.title(
        "{} \n Geräteklasse: {}, Vollausschlag: {}, Hersteller: {}".format(
            plot_title, cuco.dev_class, cuco.type_head, cuco.producer.upper()))

    plt.xscale('symlog', linthreshx=1e-12)
    plt.yscale('symlog', linthreshy=1e-12)
    plt.ylim((1e-6, 1e-2))
    plt.xlabel('$p_{cal}$ in Pa')
    plt.ylabel('$u$ (relative)')
    plt.grid(True)
    plt.legend()
    plt.savefig("{}.pdf".format(result_name))
    plt.show()
Ejemplo n.º 8
0
def main():
    io = Io()
    io.eval_args()
    ret = {'ok':True}

    cmc = True
    base_doc = io.get_base_doc("se3")
    for id in io.ids:
        id = id.replace("\"", "")
        doc = io.get_doc_db(id)


        if io.update:
            doc = io.update_cal_doc(doc, base_doc)

        cal = Cal(doc)

        if io.auxval: ## get new the AuxValues from related (meas_date) state measurement
            meas_date = cal.Date.first_measurement()
            state_doc = io.get_state_doc("se3", date=meas_date)
            ana = Analysis(doc, analysis_type="expansion")

            cal.insert_state_results(ana, state_doc)
        else: ## keep AuxValues from Calibration.Analysis.AuxValues
            auxvalues = doc.get('Calibration').get('Analysis', {}).get('AuxValues', {})
            ana = Analysis(doc, insert_dict={'AuxValues': auxvalues}, analysis_type="expansion")

        cus_dev = init_customer_device(doc)

        uncert = Uncert(doc)

        cal.pressure_gn_corr(ana)
        cal.pressure_gn_mean(ana)
        cal.deviation_target_fill(ana)
        cal.temperature_before(ana)
        cal.temperature_after(ana)
        cal.temperature_room(ana)
        cal.temperature_gas_expansion(ana)
        cal.real_gas_correction(ana)
        cal.volume_add(ana)
        cal.volume_start(ana)
        cal.expansion(ana)
        cal.pressure_rise(ana)
        cal.correction_delta_height(ana)
        cal.correction_f_pressure(ana)
        cal.pressure_cal(ana)
        cal.error_pressure_rise(ana)
        cal.deviation_target_cal(ana)

        ## uncert. calculation
        if cmc:
            # bis update CMC Einträge --> vorh. CMC Einträge
            # cal uncertainty of standard
            uncert.cmc(ana)
        else:
            uncert.define_model()
            uncert.gen_val_dict(ana)
            uncert.gen_val_array(ana)
            uncert.volume_start(ana)
            uncert.volume_5(ana)
            uncert.pressure_fill(ana)
            uncert.temperature_after(ana)
            uncert.temperature_before(ana)
            uncert.expansion(ana)
            uncert.total(ana)

        ## calculate customer indication
        gas = cal.Aux.get_gas()
        temperature_dict = ana.pick_dict('Temperature', 'after')
        offset_dict = cal.Pres.get_dict('Type', 'ind_offset' )
        ind_dict = cal.Pres.get_dict('Type', 'ind' )
        range_dict = cal.Range.get_dict('Type', 'ind' )

        offset = cus_dev.pressure(offset_dict, temperature_dict, range_dict=range_dict, unit = cal.unit, gas=gas)
        ind = cus_dev.pressure(ind_dict, temperature_dict, range_dict=range_dict, unit = cal.unit, gas=gas)

        ana.store("Pressure", "offset", offset, cal.unit)
        ana.store("Pressure", "ind", ind, cal.unit)
        ana.store("Pressure", "ind_corr", ind - offset, cal.unit)

        p_ind = ana.pick("Pressure", "ind_corr", cal.unit)
        p_cal = ana.pick("Pressure", "cal" , cal.unit)

        if cal.ToDo.type == "error":
            ana.store('Error', 'ind', p_ind/p_cal-1, '1')
            cus_dev.range_trans(ana)

        if cal.ToDo.type == "sigma":
            ana.store('Error', 'ind', p_ind/p_cal-1, '1') ## used for check analysis
            ana.store('Sigma', 'eff', p_ind/p_cal, '1')

        io.save_doc(ana.build_doc())

    print(json.dumps(ret))