コード例 #1
0
    def test_dict_like(self):

        hp = HydrationParameter()

        hp['field'] = 300
        hp['spin_C'] = 200
        hp['ksigma_bulk'] = 95
        hp['T10'] = 1
        hp['T100'] = 2
        hp['tcorr_bulk'] = 50
        hp['D_H2O'] = 3e-10
        hp['D_SL'] = 5e-10
        hp['klow_bulk'] = 350
        hp['smax_model'] = 'free'
        hp['t1_interp_method'] = 'second_order'

        self.assertEqual(hp['field'], hp.field)
        self.assertEqual(hp['spin_C'], hp.spin_C)
        self.assertEqual(hp['ksigma_bulk'], hp.ksigma_bulk)
        self.assertEqual(hp['T10'], hp.T10)
        self.assertEqual(hp['T100'], hp.T100)
        self.assertEqual(hp['tcorr_bulk'], hp.tcorr_bulk)
        self.assertEqual(hp['D_H2O'], hp.D_H2O)
        self.assertEqual(hp['D_SL'], hp.D_SL)
        self.assertEqual(hp['klow_bulk'], hp.klow_bulk)
        self.assertEqual(hp['smax_model'], hp.smax_model)
        self.assertEqual(hp['t1_interp_method'], hp.t1_interp_method)

        with self.assertRaises(ValueError):
            hp['smax_model'] = 'notinlist'
        with self.assertRaises(ValueError):
            hp['t1_interp_method'] = 'notinlist'
コード例 #2
0
    def test_dict_like(self):

        hp = HydrationParameter()

        hp["field"] = 300
        hp["spin_C"] = 200
        hp["ksigma_bulk"] = 95
        hp["T10"] = 1
        hp["T100"] = 2
        hp["tcorr_bulk"] = 50
        hp["D_H2O"] = 3e-10
        hp["D_SL"] = 5e-10
        hp["klow_bulk"] = 350
        hp["smax_model"] = "free"
        hp["t1_interp_method"] = "second_order"

        self.assertEqual(hp["field"], hp.field)
        self.assertEqual(hp["spin_C"], hp.spin_C)
        self.assertEqual(hp["ksigma_bulk"], hp.ksigma_bulk)
        self.assertEqual(hp["T10"], hp.T10)
        self.assertEqual(hp["T100"], hp.T100)
        self.assertEqual(hp["tcorr_bulk"], hp.tcorr_bulk)
        self.assertEqual(hp["D_H2O"], hp.D_H2O)
        self.assertEqual(hp["D_SL"], hp.D_SL)
        self.assertEqual(hp["klow_bulk"], hp.klow_bulk)
        self.assertEqual(hp["smax_model"], hp.smax_model)
        self.assertEqual(hp["t1_interp_method"], hp.t1_interp_method)

        with self.assertRaises(ValueError):
            hp["smax_model"] = "notinlist"
        with self.assertRaises(ValueError):
            hp["t1_interp_method"] = "notinlist"
コード例 #3
0
    def test_default_values(self):

        hp = HydrationParameter()

        self.assertEqual(hp.field, None)
        self.assertEqual(hp.spin_C, None)
        self.assertEqual(hp.T10, None)
        self.assertEqual(hp.T100, None)
        self.assertEqual(hp.smax_model, 'tethered')
        self.assertEqual(hp.ksigma_bulk, 95.4)
        self.assertEqual(hp.tcorr_bulk, 54)
        self.assertEqual(hp.D_H2O, 2.3e-9)
        self.assertEqual(hp.D_SL, 4.1e-10)
        self.assertEqual(hp.klow_bulk, 366)
        self.assertEqual(hp.t1_interp_method, 'second_order')
コード例 #4
0
ファイル: app.py プロジェクト: DNPLab/odnplab
def set_par(ppar: ProcParameter, hpar: HydrationParameter):
    """Prompt for users to choose parameters

    Returns: tuple(ProcParameter, HydrationParameter)

    """
    # Defaults
    ppar.eiw = 20
    hpar.field = 348.5
    hpar.t1_interp_method = 'second_order'

    # st.sidebar.markdown('**Experiments**')
    hpar.spin_C = st.sidebar.number_input("Spin label concentration (uM)",
                                          min_value=0.01,
                                          value=500.0,
                                          step=1.0,
                                          key='spin_C')
    hpar.T100 = st.sidebar.number_input("T1,0(0) (s)",
                                        min_value=0.1,
                                        max_value=3.0,
                                        value=2.5,
                                        step=0.05,
                                        key='t100')
    hpar.smax_model = st.sidebar.radio('The spin is ',
                                       options=['tethered', 'free'],
                                       key='smax_model')

    if st.sidebar.checkbox("More"):
        ppar.eiw = st.sidebar.number_input("Integration Width",
                                           min_value=10,
                                           max_value=500,
                                           value=20,
                                           step=10,
                                           key='eiw')
        hpar.field = st.sidebar.number_input("Field (mT)",
                                             value=348.5,
                                             step=1.0,
                                             key='field')
        hpar.t1_interp_method = st.sidebar.radio(
            'T1 interpolation method',
            options=['linear', 'second_order'],
            index=1,
            key='t1_interp_method')

    return ppar, hpar
コード例 #5
0
ファイル: test_hydration.py プロジェクト: ylin00/DNPLab
        -2.4709892163826400, -2.5184316153191200, -2.556110148443770,
        -2.576413132701720, -2.675593912859120, -2.8153300703866400,
        -2.897475156648710, -3.0042154567120800, -3.087886507216510
    ]),
    'E_power':
    np.array([
        0.0006454923080882520, 0.004277023425898170, 0.004719543572446050,
        0.00909714298712173, 0.01344187403986090, 0.01896059941058610,
        0.02101937603827090, 0.022335737104727900, 0.026029715703921800,
        0.02917012237740640, 0.0338523245243911, 0.03820738749745440,
        0.04733370907740660, 0.05269608016472140, 0.053790874615060400,
        0.05697639350179900, 0.06435487925718170, 0.07909179437004270,
        0.08958910066880800, 0.1051813598911370, 0.11617812912435900
    ])
}
TESTSET_PARAM = HydrationParameter()
TESTSET_PARAM.field = 348.5
TESTSET_PARAM.spin_C = 125
TESTSET_PARAM.T100 = 2.0
TESTSET_PARAM.T10 = 1.5


class TestHydration(unittest.TestCase):
    def setUp(self):
        ws = create_workspace()
        hydration = {
            k: TESTSET.get(k)
            for k in ['T1', 'T1_power', 'E', 'E_power']
        }
        hydration.update({
            k: TESTSET_PARAM.__dict__.get(k)
コード例 #6
0
ファイル: app.py プロジェクト: DNPLab/odnplab
    """
    drop_es, drop_t1s = {}, {}
    if len(drop_e_powers) + len(drop_t1_powers) > 0:
        drop_es = st.sidebar.multiselect('Drop Enhancements at power(s):',
                                         drop_e_powers,
                                         key='drop_es')
        drop_t1s = st.sidebar.multiselect('Drop T1 at power(s):',
                                          drop_t1_powers,
                                          key='drop_t1s')
    return drop_es, drop_t1s


# =======THE APP=======
ss = stss.get(
    ppar=ProcParameter(drop_e_powers=[], drop_t1_powers=[]),
    hpar=HydrationParameter(),
    results={},
    expname='',
    old_expname='',
    data={},
    epowers=[],  # E_power from the data
    t1powers=[],  # T1_power from the data
    b_run=False)

st.markdown('<style>' + open('app.css').read() + '</style>',
            unsafe_allow_html=True)
st.title(
    f'ODNPLab: One-Step ODNP Processing \n {VERSION} \t Powered by [DNPLab]({DNPLAB_DOC_LINK}) '
)

st.markdown("## Upload a Zip file")