示例#1
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 not fail and len(ids) > 0:
        for id in ids:
            doc = io.get_doc_db(id)
            if 'Calibration' in doc and 'Analysis' in doc['Calibration']:
                cal = Cal(doc)
                analysis = doc['Calibration']['Analysis']
                res = Analysis(doc, init_dict=analysis)
                chk = Analysis(doc)
                cal.check_analysis(res, chk)
                io.save_doc(chk.build_doc("Check"))
            else:
                ret = {
                    "error": "doc {} contains no analysis to check".format(id)
                }
    else:
        ret = {"error": "no --ids found"}
        # print writes back to relay server by writing to std.out

    print(json.dumps(ret))
示例#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 not fail and len(ids) > 0:
        for id in ids:
            doc = io.get_doc_db(id)
            analysis = doc.get('Calibration', {}).get('Analysis', {})
            if 'Values' in analysis and 'Uncertainty' in analysis['Values']:
                analysis['Values']['Uncertainty'] = []
            res = Analysis(doc, init_dict=analysis)
            u = Uncert(doc)

            u.define_model()
            u.gen_val_dict(res)
            u.gen_val_array(res)

            u.volume_start(res)
            u.volume_5(res)
            u.temperature_before(res)
            u.temperature_after(res)
            u.pressure_fill(res)
            u.total(res)
            io.save_doc(res.build_doc())
示例#3
0
def main():
    io = Io()
    io.eval_args()
    args = sys.argv
    fail = False
    ret = {'ok': True}
    unit = 'Pa'
    cmc = False

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

    if not fail and len(ids) > 0:
        for id in ids:
            doc = io.get_doc_db(id)
            date = "2019-07-10"  #doc[""]
            pn_doc1 = io.get_pn_by_date(std="se2", date=date, cert="9911")
            pn_doc2 = io.get_pn_by_date(std="se2", date=date, cert="0118")

            disp = Display(doc)
            disp.SE2_CDG_error_plot().show()
            disp.SE2_CDG_offset_abs().show()
            disp.SE2_CDG_offset_rel().show()
            disp.SE2_CDG_error_reject().show()

    else:
        ret = {"error": "no --ids found"}
示例#4
0
def main():
    io = Io()
    io.eval_args()
    ret = {'ok': True}

    cmc = True
    base_doc = io.get_base_doc("ce3")
    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)

        ana = Analysis(doc)
        io.save_doc(ana.build_doc())

    print(json.dumps(ret))
示例#5
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 not fail and len(ids) > 0:
        for doc_id in ids:
            doc = io.get_doc_db(doc_id)
            T = Temperature(doc, quant='Analysis')
            p = Pressure(doc, quant='Analysis')
            e = Error(doc, quant='Analysis')
            u = Uncertainty(doc, quant='Analysis')

            p_ind, u_p_ind = p.get_value_and_unit('ind_corr')
            p_cal, u_p_cal = p.get_value_and_unit('cal')
            err = p_ind / p_cal - 1
            u_err = "1"
            plt.subplot(111)
            x = p_cal
            y = err
            plt.plot(x, y, '.')
            plt.xscale('symlog', linthreshx=1e-12)
            plt.xlabel('pressure in {}'.format(u_p_cal))
            plt.ylabel('error in {}'.format(u_err))

            plt.title('calibration document {}'.format(doc_id))
            for i, v in enumerate(x):
                plt.text(v, y[i], i, rotation=45.)

            plt.grid(True)
            plt.show()
示例#6
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("frs5")
        for id in ids:
            doc = io.get_doc_db(id)

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

            cal = Cal(doc)
            res = Analysis(doc)
            uncert = Uncert(doc)

            cal.temperature(res)
            cal.pressure_res(res)
            cal.pressure_cal(res)
            uncert.total_standard(res)
            gas = cal.Aux.get_gas()

            devs = (
                "1T_1",
                "1T_2",
                "1T_3",
                "5T_1",
                "10T_1",
                "10T_2",
                "10T_3",
                "50T_1",
                "100T_1",
                "100T_2",
                "100T_3",
            )

            p_cal = res.pick("Pressure", "cal", cal.unit)
            for dev in devs:
                p_offset = cal.Pres.get_value('{}-offset'.format(dev),
                                              cal.unit)
                p_ind = cal.Pres.get_value('{}-ind'.format(dev), cal.unit)
                p_ind_corr = p_ind - p_offset
                res.store("Pressure", '{}-offset'.format(dev), p_offset,
                          cal.unit)
                res.store("Pressure", '{}-ind'.format(dev), p_ind, cal.unit)
                res.store("Pressure", '{}-ind_corr'.format(dev), p_ind_corr,
                          cal.unit)

                res.store('Error', '{}-ind'.format(dev),
                          p_ind_corr / p_cal - 1, '1')
                print(dev)
                print("----------------------------")

                print(p_ind_corr / p_cal - 1)
            print("----------------------------")
            print("----------------------------")
            print(p_cal)
            io.save_doc(res.build_doc())
示例#7
0

def numify(s):
    return "\\num{" + s + "}"


f_info.write("\\begin{tabular}{ l l l l l }\n")
for _, d in enumerate(devs):
    f_info.write("\\verb|{n}|&\\verb|{id}|&{fs}&{t}&{sn}\\\\\n".format(
        id=d["id"], n=d["Name"], sn=d["SN"], t=d["Type"], fs=d["FullScale"]))
f_info.write("\\end{tabular}\n")
f_info.close()

f = open("script/group_normal/gn_result_table.tex".format(d["Name"]), "w+")
for _, d in enumerate(devs):
    cob_doc = io.get_doc_db(d["id"])
    interp_dict = cob_doc.get("CalibrationObject").get("Interpol")
    ind_arr = interp_dict[0].get("Value")
    e_arr = interp_dict[1].get("Value")

    f.write("\\begin{table}\\begin{tabular}{l l }\n\\toprule\n")
    f.write("$p$&$e$\\\\\n Pa & relativ \\\\\\midrule\n")
    for i, _ in enumerate(ind_arr):
        p = "{:.3E}".format(ind_arr[i])
        e = "{:.2E}".format(e_arr[i])
        f.write("{}&{}\\\\\n".format(numify(p), numify(e)))
    f.write("\\bottomrule\n\\end{tabular}\\caption{Ergebnisse " +
            d["Name"].replace("_", " ") + "}\\end{table}")

f.close()
示例#8
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 '--min_pressure' in args:
        min_i = args.index('--min_pressure') + 1
        try:
            min_pressure = float(args[min_i])
        except:
           fail = True

    if '--max_pressure' in args:
        max_i = args.index('--max_pressure') + 1
        try:
            max_pressure = float(args[max_i])
        except:
           fail = True

    if '--pressure_unit' in args:
        unit_i = args.index('--pressure_unit') + 1
        try:
            pressure_unit = str(args[unit_i])
        except:
           fail = True

    if not fail and len(ids) > 0:
        base_doc = io.get_base_doc("se3")
        for id in ids:
            doc = io.get_doc_db(id)
            todo = ToDo(doc)
            const = Constants(base_doc)
            conv = const.get_conv(from_unit=pressure_unit, to_unit=todo.pressure_unit)

            max_pressure = max_pressure * conv
            min_pressure = min_pressure * conv

            todo_dict, rest_dict = todo.shape_pressure(min_p=min_pressure, max_p=max_pressure, unit = todo.pressure_unit)

            doc["Calibration"]["ToDo"]["Values"]["Pressure"] = todo_dict

            io.save_doc(doc)

            if rest_dict:
                ## generate a new doc with issue+1 and rest todo
                rest_doc = copy.deepcopy(doc)

                id_arr = rest_doc["_id"].split("_")
                issue = str(int(id_arr[-1]) + 1 + 10000)[1:5]
                id_arr[1] = issue

                rest_doc["_id"] = "_".join(id_arr)
                rest_doc["Calibration"]["Issue"] = issue
                rest_doc["Calibration"]["ToDo"]["Values"]["Pressure"] = rest_dict
                del rest_doc["_rev"]

                io.save_doc(rest_doc)

    else:
        ret = {"error": "no --ids found"}

    print(json.dumps(ret))
示例#9
0
def main():
    io = Io()
    io.eval_args()
    doc = io.load_doc()
    unit = "Pa"
    if doc:

        ## save the doc in ana.org
        res = Analysis(doc, analysis_type='expansion')
        const = Constants(doc=doc)
        val = Values({})

        ## -------------------------
        ## SE3
        ## -------------------------
        base_doc_se3 = io.get_base_doc("se3")
        se3_doc = io.update_cal_doc(doc, base_doc_se3)

        se3_calc = Se3Calc(se3_doc)
        uncert_se3 = Se3Uncert(se3_doc)

        f_names = se3_calc.get_expansion_name()
        f_name = f_names[0]

        se3_calc.temperature_before(res)
        se3_calc.temperature_after(res)
        se3_calc.temperature_room(res)

        se3_calc.pressure_gn_corr(res)
        se3_calc.pressure_gn_mean(res)
        se3_calc.expansion(res)
        se3_calc.time_meas(res)
        se3_calc.real_gas_correction(res)

        rg = res.pick("Correction", "rg", "1")
        p_0 = res.pick("Pressure", "fill", "Pa")
        p_1 = res.pick("Pressure", "cal", "Pa")
        T_0 = res.pick("Temperature", "before", "K")
        T_1 = res.pick("Temperature", "after", "K")

        u_p_0 = uncert_se3.contrib_pressure_fill(p_0, unit, skip_type="A")
        u_T_1 = uncert_se3.contrib_temperature_vessel(T_1, "K", skip_type="A")
        u_T_0 = uncert_se3.contrib_temperature_volume_start(T_0,
                                                            "K",
                                                            f_names,
                                                            skip_type="A")

        res.store("Pressure", "fill", p_0, unit)
        res.store("Uncertainty", "fill", u_p_0, unit)
        res.store("Temperature", "before", T_0, "K")
        res.store("Temperature", "after", T_1, "K")
        res.store("Uncertainty", "before", u_T_0, "K")
        res.store("Uncertainty", "after", u_T_1, "K")
        res.store("Correction", "rg", rg, "1")

        ## old Standard section does not have delta_heigth
        ## values
        ## dh correction for f_s = 0.9999609272217588
        dh = 0.9999609272217588
        res.store("Correction", "delta_heigth", np.full(len(p_0), dh), "1")

        ## -------------------------
        ## frs5
        ## -------------------------
        base_doc_frs5 = io.get_base_doc("frs5")
        frs_doc = io.update_cal_doc(doc, base_doc_frs5)
        cal_frs = FrsCalc(frs_doc)
        uncert = FrsUncert(frs_doc)

        cal_frs.temperature(res)
        cal_frs.pressure_res(res)
        cal_frs.pressure_cal(res)
        uncert.total_standard(res, no_type_a=True)

        p_1 = res.pick("Pressure", "cal", unit)
        u_p_1 = res.pick("Uncertainty", "standard", "1")

        res.store("Pressure", "cal", p_1, unit)
        res.store("Uncertainty", "cal", u_p_1 * p_1, unit)

        ## -------------------------
        ## p_nd
        ## -------------------------
        pres = Pressure(doc)
        auxval = AuxValues(doc)
        time = Time(doc)

        p_nd_offset_before = auxval.get_value("nd_offset_before", "mbar")
        p_nd_offset_after = auxval.get_value("nd_offset_after", "mbar")
        if p_nd_offset_after:
            p_nd_offset = (p_nd_offset_before + p_nd_offset_after) / 2
        else:
            p_nd_offset = p_nd_offset_before

        p_nd_ind = pres.get_value("nd_ind", "mbar")
        conv = const.get_conv(from_unit="mbar", to_unit=unit)
        p_nd = (p_nd_ind - p_nd_offset) * conv

        CustomerDevice = Cdg(doc, io.get_doc_db("cob-cdg-nd_se3"))
        u_p_nd = CustomerDevice.get_total_uncert(p_nd_ind,
                                                 unit,
                                                 unit,
                                                 skip_type="A")

        res.store("Pressure", "nd_corr", p_nd, unit)
        res.store("Uncertainty", "nd_corr", u_p_nd, unit)

        ## -------------------------
        # Unsicherheit Ausgasung:
        ## -------------------------
        p_rise_rate = 3e-8  #Pa/s gemessen: 2019-01-18 08:40:27 (s. state docs)
        t = time.get_rmt("amt_meas", "ms")
        conv = const.get_conv(from_unit="ms", to_unit="s")
        p_rise = p_rise_rate * t * conv
        u_p_rise = 0.2  # Druckanstieg 20% Unsicher

        res.store("Pressure", "rise", p_rise, unit)
        res.store("Uncertainty", "rise", p_rise * u_p_rise / p_1, "1")

        ## -------------------------
        # f:
        ## -------------------------
        p_a = p_1 - p_nd + p_rise
        p_b = p_0 * rg * dh
        n = len(p_a)
        x = np.full(n, 0.0)
        y = np.full(n, 0.0)
        for i in range(n):
            # y[i] = p_a[i]/p_b[i]*T_0[i]/T_1[i] ## okish
            if i == 0:

                y[i] = p_a[i]
                x[i] = p_b[i] * T_0[i] / T_1[i]
            else:
                #x[i] = p_a[i - 1]/T_1[i -1]*T_0[i]/p_0[i] ## okish
                y[i] = p_a[i] - p_a[i - 1] * T_1[i] / T_1[i - 1]
                x[i] = p_b[i] * T_1[i] / T_0[i] - p_a[i - 1] * T_1[i] / T_1[i -
                                                                            1]

        f = y / x
        f = np.delete(f, f.argmin())
        f = np.delete(f, f.argmax())

        print(np.mean(f))
        print(np.std(f) / np.mean(f))

        ## -------------------------
        # save
        ## -------------------------
        io.save_doc(res.build_doc())
示例#10
0
def main():
    io = Io()
    io.eval_args()
    args = sys.argv
    fail = False
    ret = {'ok': True}
    unit = 'Pa'
    cmc = False

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

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

            customer_object = doc.get('Calibration').get('CustomerObject')
            if customer_object.get("Class") == "SRG":
                customer_device = Srg(doc, customer_object)
            if customer_object.get("Class") == "CDG":
                customer_device = Cdg(doc, customer_object)
            tdo = ToDo(doc)
            analysis = doc.get('Calibration').get('Analysis')

            if "Values" in analysis and "Uncertainty" in analysis["Values"]:
                del analysis["Values"]["Uncertainty"]

            ana = Analysis(doc, init_dict=analysis)
            se2_uncert = UncertSe2(doc)

            result_type = analysis.get("AnalysisType", "default")
            result_type = "se2_expansion_direct"
            res = Result(doc, result_type=result_type)

            p_cal = ana.pick('Pressure', 'cal', unit)
            p_ind_corr = ana.pick('Pressure', 'ind_corr', unit)
            p_off = ana.pick('Pressure', 'offset', unit)

            conv = res.Const.get_conv(from_unit=unit,
                                      to_unit=res.ToDo.pressure_unit)
            average_index = res.ToDo.make_average_index(
                p_cal * conv, res.ToDo.pressure_unit)
            print(average_index)
            average_index = ana.coarse_error_filtering(
                average_index=average_index)
            print(average_index)
            average_index, ref_mean, ref_std, loops = ana.fine_error_filtering(
                average_index=average_index)
            pressure_range_index = ana.make_pressure_range_index(
                ana, average_index)

            print(average_index)
            print(ref_mean)
            print(ref_std)
            print(loops)

            if result_type == "se2_expansion_direct" and tdo.type == "error":
                average_index, reject_index = ana.ask_for_reject(
                    average_index=average_index)
                reject_index_offset = ana.ask_for_reject_offset(
                    average_index=average_index)
                d = {
                    "AverageIndex": average_index,
                    "AverageIndexFlat": ana.flatten(average_index),
                    "PressureRangeIndex": pressure_range_index,
                    "RejectIndex": reject_index,
                    "RejectIndexOffset": reject_index_offset
                }

                p_tdo, p_tdo_unit = tdo.Pres.get_value_and_unit("target")
                conv = res.Const.get_conv(from_unit=p_tdo_unit, to_unit="Pa")

                p_tdo = conv * p_tdo
                #assuming pascals, temperature correction only if more than 1 decade below 100 Pa
                p_tdo_evis = [
                    p_tdo[i] for i in range(len(p_tdo)) if p_tdo[i] < 9.5
                ]

                if len(p_tdo_evis) > 1:
                    e_vis, cf_vis, u_vis, vis_unit = ana.ask_for_evis()
                    d["Evis"] = e_vis
                    d["CFvis"] = cf_vis
                    d["Uvis"] = u_vis
                    d["VisUnit"] = vis_unit
                    print(d)

                ana.store_dict(quant="AuxValues", d=d, dest=None, plain=True)
                res.store_dict(quant="AuxValues", d=d, dest=None, plain=True)

            if "Uncertainty" in customer_object:
                print("lll")
                u_dev = customer_device.get_total_uncert(
                    meas_vec=p_ind_corr,
                    meas_unit="Pa",
                    return_unit="Pa",
                    res=ana,
                    skip_source="standard",
                    prefix=False)

            se2_uncert.u_PTB_rel(ana)
            se2_uncert.make_offset_stability(ana)

            customer_device.repeat_uncert(ana)
            customer_device.device_uncert(ana)

            ana.total_uncert()
            u = ana.pick("Uncertainty", "total_rel", "1")
            print(customer_device.doc)
            print("ffffffffffffffffffffffffffffff")
            print(tdo.type)
            print(result_type)
            if result_type == "se2_expansion_direct" and tdo.type == "sigma":

                p_ind_corr = np.take(p_ind_corr, ana.flatten(average_index))
                p_cal = np.take(p_cal, ana.flatten(average_index))
                p_off = np.take(p_off, ana.flatten(average_index))
                d = {
                    "AverageIndex": average_index,
                    "AverageIndexFlat": ana.flatten(average_index)
                }
                print(p_ind_corr)
                print(p_cal)
                #u =  np.delete(u, skip)
                sigma_null, sigma_slope, sigma_std = customer_device.sigma_null(
                    p_cal=p_cal,
                    cal_unit=unit,
                    p_ind=p_ind_corr,
                    ind_unit=unit)
                d["SigmaNull"] = sigma_null
                d["SigmaCorrSlope"] = np.abs(sigma_slope / sigma_null)
                d["SigmaStd"] = sigma_std

                # 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"] = np.nanmean(rd)
                # d["OffsetStd"] = np.nanstd(rd)
                # d["OffsetUnit"] = rd_unit

                ana.store_dict(quant="AuxValues", d=d, dest=None, plain=True)
                res.store_dict(quant="AuxValues", d=d, dest=None, plain=True)

            maesurement_date = cl.Counter(
                doc["Calibration"]["Measurement"]["Values"]["Date"]
                ["Value"]).most_common(1)[0][0]
            doc["Calibration"]["Measurement"]["Date"] = [{
                "Type":
                "measurement",
                "Value": [maesurement_date]
            }]

            res.make_measurement_data_section(ana, result_type=result_type)

            if tdo.type == "error":
                # start build cert table
                p_ind, err, u = res.make_error_table(ana,
                                                     pressure_unit=unit,
                                                     error_unit='1')

            doc = ana.build_doc("Analysis", doc)
            doc = res.build_doc("Result", doc)
            io.save_doc(doc)

    else:
        ret = {"error": "no --ids found"}
示例#11
0
def main():
    io = Io()
    io.eval_args()
    args = sys.argv
    fail = False
    ret = {'ok': True}
    unit = "Pa"

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

    if not fail and len(ids) > 0:
        for id in ids:
            id = id.replace("\"", "")
            ## -------------------------
            ## se3
            ## -------------------------
            base_doc_se3 = io.get_base_doc("se3")
            doc = io.get_doc_db(id)
            doc = io.update_cal_doc(doc, base_doc_se3)

            res = Analysis(doc, analysis_type="expansion")
            uncert_se3 = UncertSe3(doc)
            cal_se3 = CalSe3(doc)

            f_names = cal_se3.get_expansion_name()
            f_name = f_names[0]

            cal_se3.pressure_gn_corr(res)
            cal_se3.pressure_gn_mean(res)
            cal_se3.temperature_before(res)
            cal_se3.temperature_after(res)
            cal_se3.real_gas_correction(res)
            cal_se3.correction_delta_height(res)

            rg = res.pick("Correction", "rg", "1")
            dh = res.pick("Correction", "delta_heigth", "1")
            p_0 = res.pick("Pressure", "fill", unit)
            T_0 = res.pick("Temperature", "before", "K")
            T_1 = res.pick("Temperature", "after", "K")

            u_p_0 = uncert_se3.contrib_pressure_fill(p_0, unit, skip_type="A")
            u_T_1 = uncert_se3.contrib_temperature_vessel(T_1,
                                                          "K",
                                                          skip_type="A")
            u_T_0 = uncert_se3.contrib_temperature_volume_start(T_0,
                                                                "K",
                                                                f_names,
                                                                skip_type="A")

            ## -------------------------
            ## p_nd
            ## -------------------------
            customer_device = doc['Calibration']['CustomerObject']
            CustomerDevice = Cdg(doc, customer_device)

            temperature_dict = res.pick_dict('Temperature', 'before')
            gas = cal_se3.get_gas()
            ind_dict = cal_se3.Pres.get_dict('Type', 'nd_ind')
            offset_dict = cal_se3.Pres.get_dict('Type', 'nd_offset')

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

            p_nd = ind - offset
            u_p_nd = CustomerDevice.get_total_uncert(p_nd,
                                                     unit,
                                                     unit,
                                                     skip_type="A")

            ## -------------------------
            ## frs5
            ## -------------------------
            base_doc_frs5 = io.get_base_doc("frs5")
            doc = io.update_cal_doc(doc, base_doc_frs5)

            res = Analysis(doc, analysis_type="expansion")

            cal_frs = CalFrs(doc)
            res = Analysis(doc)
            uncert = UncertFrs(doc)

            cal_frs.temperature(res)
            cal_frs.pressure_res(res)
            cal_frs.pressure_cal(res)
            uncert.total_standard(res, no_type_a=True)

            p_1 = res.pick("Pressure", "cal", unit)
            u_p_1 = res.pick("Uncertainty", "standard", "1") * p_1

            ## -------------------------
            ## f
            ## -------------------------
            corr_tem = T_0 / T_1
            f = (p_1 - p_nd) / (p_0 * rg * dh) * corr_tem

            s_p_1 = 1 / p_0 * corr_tem
            s_p_0 = -(p_1 - p_nd) / (p_0**2) * corr_tem
            s_p_nd = 1 / p_0 * corr_tem
            s_T_0 = (p_1 - p_nd) / (p_0) / T_1
            s_T_1 = -(p_1 - p_nd) / (p_0) * T_0 / T_1**2

            uc_p_1 = (s_p_1 * u_p_1)
            uc_p_0 = (s_p_0 * u_p_0)
            uc_p_nd = (s_p_nd * u_p_nd)
            uc_T_1 = (s_T_1 * u_T_1)
            uc_T_0 = (s_T_0 * u_T_0)

            u = (uc_p_1**2 + uc_p_0**2 + uc_p_nd**2 + uc_T_1**2 +
                 uc_T_0**2)**0.5

            res.store("Expansion", f_name, f, "1")
            res.store("Pressure", "nd_offset", offset, unit)
            res.store("Pressure", "nd_corr", p_nd, unit)
            res.store("Uncertainty", "nd_corr", u_p_nd, unit)
            res.store("Pressure", "fill", p_0, unit)
            res.store("Uncertainty", "fill", u_p_0, unit)
            res.store("Pressure", "cal", p_1, unit)
            res.store("Uncertainty", "cal", u_p_1 * p_1, unit)
            res.store("Temperature", "before", T_0, "K")
            res.store("Temperature", "after", T_1, "K")
            res.store("Uncertainty", "before", u_T_0, "K")
            res.store("Uncertainty", "after", u_T_1, "K")
            res.store("Uncertainty", "total", u, "1")
            res.store("Correction", "delta_heigth", dh, "1")
            res.store("Correction", "rg", rg, "1")
            res.store("Correction", "temperature", corr_tem, "1")

            doc = res.build_doc()
            doc["Calibration"]["Standard"] = [
                base_doc_se3["Standard"], base_doc_frs5["Standard"]
            ]

            io.save_doc(doc)
            print("------------------- p_nd:")
            print(p_nd)

            print(ind_dict["SdValue"])
            print(offset_dict["SdValue"])

            print("-------------------u p_0:")
            print(u_p_0 / p_0)

            print("-------------------u p_1:")
            print(u_p_1)

            print("-------------------u p_nd:")
            print(u_p_nd)

            #f = np.delete(f, f.argmin())
            #f = np.delete(f, f.argmax())
            print("-------------------f:")
            print(f)
            print(np.mean(f))
            print(np.std(f))
            print(np.std(f) / np.mean(f))
            print(np.std(f) / np.mean(f) / (len(f) - 1)**0.5)

            print("-------------------u:")
            print(u / f)
示例#12
0
def main():
    io = Io()
    io.eval_args()
    args = sys.argv
    fail = False
    ret = {'ok': True}

    #    with open(".\script\se2\input.json") as input_json:
    #        print(json.load(input_json))

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

    if '-u' in args:  # erzeugt Einträge für KOnstatne und Calibrierobjekte
        update = True
    else:
        update = False

    if not fail and len(ids) > 0:
        base_doc = io.get_base_doc("se2")
        for id in ids:
            id = id.replace("\"", "")

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

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

            if 'CustomerObject' in doc['Calibration']:
                customer_device = doc['Calibration']['CustomerObject']
                dev_class = customer_device.get('Class', "generic")
                if dev_class == 'SRG':
                    CustomerDevice = Srg(doc, customer_device)
                if dev_class == 'CDG':
                    CustomerDevice = Cdg(doc, customer_device)
                if dev_class == 'RSG':
                    CustomerDevice = Rsg(doc, {})

            cal.temperature_after(ana)
            cal.temperature_room(ana)
            cal.pressure_cal(ana)
            cal.pressure_ind(ana)
            cal.pressure_offset(ana)
            cal.pressure_indication_error(ana)
            #cal.measurement_time(ana)
            cal.faktor(ana)
            cal.range(ana)

            io.save_doc(ana.build_doc())

    else:
        ret = {"error": "no --ids found"}
        # print writes back to relay server by writing to std.out

    print(json.dumps(ret))
示例#13
0
def main():
    io = Io()
    io.eval_args()

    if io.ids:
        doc = io.get_doc_db(io.ids[0])
        cal = Cal(doc)

        t_arr = cal.Temp.get_array("ch_", channels, "_after", "C")
        cor_arr = cal.TDev.get_array("corr_ch_", channels, "", "K")

        if io.args.point:
            p = int(io.args.point[0])
        else:
            p = -1

    if io.n:
        doc = io.get_base_doc("se3")

        res = requests.post(conf_dev_hub.get("url"),
                            json=conf_dev_hub.get("dmm_task"))
        res = res.json()
        doc["Measurement"] = {"Values": {"Temperature": res.get("Result")}}
        cal = Cal(doc)

        t_arr = cal.Temp.get_array("ch_", channels, "_now", "C")
        cor_arr = cal.TDev.get_array("corr_ch_", channels, "", "K")

        p = 0

    t = t_arr + cor_arr
    t_i = np.array([e[p] for e in t])

    fig = plt.figure()
    ax = fig.gca(projection='3d')

    x_arr = []
    y_arr = []
    z_arr = []
    sl_arr = []  ## sensor labels
    cl_arr = []  ## chamber labels

    s = 0
    for i, _ in enumerate(y_vec):
        alpha = gen_alpha(n_vec[i], o_vec[i], dir_vec[i])
        x = gen_x(alpha, r_vec[i])
        y = np.full(n_vec[i], y_vec[i])
        z = gen_z(alpha, r_vec[i])

        for j in range(0, n_vec[i]):
            if put_sensor(dist_vec[i], j):
                x_arr.append(x[j])
                y_arr.append(y[j])
                z_arr.append(z[j])
                cl = "$C_{}{}{} D_{}{}{}$".format("{", i, "}", "{", j, "}")
                cl_arr.append(cl)
                sl = "$ch_{}{}{}$".format("{", channels[s], "}")
                sl_arr.append(sl)
                ax.text(x[j], y[j], z[j], sl)
                ## next sensor:
                s = s + 1

        ## helper
        if i != 0 and i != 9:
            alpha = gen_alpha(n_h, 0)
            x = gen_x(alpha, rh_vec[i])
            y = np.full(n_h, y_vec[i])
            z = gen_z(alpha, rh_vec[i])
            ax.plot(x, y, z, c="lightgray")

    fig.colorbar(ax.scatter(x_arr,
                            y_arr,
                            z_arr,
                            c=t_i,
                            cmap=conf_plot.get("color_map"),
                            s=conf_plot.get("sphere_size"),
                            alpha=0.5),
                 ax=ax)

    ax.xaxis.pane.fill = False
    ax.yaxis.pane.fill = False
    ax.zaxis.pane.fill = False
    ax.xaxis.pane.set_edgecolor('w')
    ax.yaxis.pane.set_edgecolor('w')
    ax.zaxis.pane.set_edgecolor('w')

    ax.grid(False)

    ax.set_title(conf_plot.get("title").format(date=date))
    ax.set_xlabel(conf_plot.get("xlab"))
    ax.set_zlabel(conf_plot.get("zlab"))
    ax.set_ylabel(conf_plot.get("ylab"))

    f = conf_plot.get("axis_enlarge")

    ax.set_xlim3d(-f * r_o, f * r_o)
    ax.set_ylim3d(-y_t, y_t)
    ax.set_zlim3d(-f * r_o, f * r_o)

    plt.show()
示例#14
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))
示例#15
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())
示例#16
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)
示例#17
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)
示例#18
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))
示例#19
0
from vpy.values import Expansion, Temperature, Error, Uncertainty, Pressure
font = {
    'family': 'normal',
    #'weight' : 'bold',
    'size': 12
}

plt.rc('font', **font)

io = Io()
plt.subplot(111)

s = -10
e = -1
f_n2_1 = Expansion(
    io.get_doc_db('cal-2019-se3|frs5-vg-1001_0001').get("Calibration").get(
        "Analysis")).get_value('f_s', '1')[s:e]
p_n2_1 = Pressure(
    io.get_doc_db('cal-2019-se3|frs5-vg-1001_0001').get("Calibration").get(
        "Analysis")).get_value('cal', 'mbar')[s:e]

f_n2_2 = Expansion(
    io.get_doc_db('cal-2019-se3|frs5-vg-1001_0003').get("Calibration").get(
        "Analysis")).get_value('f_s', '1')[s:e]
p_n2_2 = Pressure(
    io.get_doc_db('cal-2019-se3|frs5-vg-1001_0003').get("Calibration").get(
        "Analysis")).get_value('cal', 'mbar')[s:e]

f_he_1 = Expansion(
    io.get_doc_db('cal-2019-se3|frs5-vg-1001_0004').get("Calibration").get(
        "Analysis")).get_value('f_s', '1')[s:e]
p_he_1 = Pressure(