Beispiel #1
0
 def group_blocks(self, stream):
     """Bunch tagged stream into sub blocks. Each sub block
     containing a measurement data block.
     """
     token, lineno, rad = next(stream)
     running = True
     while running:
         comments = []
         header = []
         data = []
         out = [comments, header, data]
         while token == "Comment":
             comments.append(rad)
             try:
                 token, lineno, rad = next(stream)
             except StopIteration:
                 raise SPDataIOError("File can not end in comments")
         if token == "Header":
             header.append(rad)
             try:
                 token, lineno, rad = next(stream)
             except StopIteration:
                 raise SPDataIOError("File can not end in header")
         else:
             raise SPDataIOError("Missing header")
         while running and (token == "Data"):
             data.append([to_numeric(x, False) for x in rad.split("\t")])
             try:
                 token, lineno, rad = next(stream)
             except StopIteration:
                 running = False
         yield out
Beispiel #2
0
def convert_with_unit(unit, value):
    if unit is None:
        return hftools.dataset.hfarray(value, unit=None)
    unit = unit.strip()
    if unit:
        mul, unit = unit_to_multiplier(unit)
    else:
        mul = 1
        unit = None
    return hftools.dataset.hfarray(to_numeric(value, error=True) * mul, unit=unit)
Beispiel #3
0
def convert_with_unit(unit, value):
    if unit is None:
        return hftools.dataset.hfarray(value, unit=None)
    unit = unit.strip()
    if unit:
        mul, unit = unit_to_multiplier(unit)
    else:
        mul = 1
        unit = None
    return hftools.dataset.hfarray(to_numeric(value, error=True) * mul,
                                   unit=unit)
Beispiel #4
0
WR62	WG18	R140	12.40	18.00	9.488	18.976	0.622	0.311
WR51	WG19	R180	15.00	22.00	11.572	23.143	0.510	0.255
WR42	WG20	R220	18.00	26.50	14.051	28.102	0.420	0.170
WR34	WG21	R260	22.00	33.00	17.357	34.715	0.340	0.170
WR28	WG22	R320	26.50	40.00	21.077	42.154	0.280	0.140
WR22	WG23	R400	33.00	50.00	26.346	52.692	0.224	0.112
WR19	WG24	R500	40.00	60.00	31.391	62.782	0.188	0.094
WR15	WG25	R620	50.00	75.00	39.875	79.75	0.148	0.074
WR12	WG26	R740	60.00	90.00	48.373	96.746	0.122	0.061
WR10	WG27	R900	75.00	110.00	59.015	118.03	0.100	0.050
WR8	WG28	R1200	90.00	140.00	73.768	147.536	0.080	0.040
WR7	WG29	R1400	112.00	172.00	90.791	181.583	0.0650	0.0325
WR5	WG30	R1800	140.00	220.00	115.714	231.429	0.0510	0.0255
WR4	WG31	R2200	172.00	260.00	137.243	274.485	0.0430	0.0215
WR3	WG32	R2600	220.00	330.00	173.571	347.143	0.0340	0.0170"""

WaveGuide = namedtuple("WaveGuide", "EIA RCSC IEC f0 f1 fcl fcu a b")

WR = dict()

for rad in waveguides.strip().split("\n")[1:]:
    x = [to_numeric(x, False) for x in rad.split()]
    x[-1] *= 25.4
    x[-2] *= 25.4
    x[3] *= 1e9
    x[4] *= 1e9
    x[5] *= 1e9
    x[6] *= 1e9
    wg = WaveGuide(*x)
    WR[wg.EIA] = wg
Beispiel #5
0
 def test_nonnumeric_2(self):
     self.assertEqual(utils.to_numeric("", False), "")
Beispiel #6
0
 def test_nonnumeric_1(self):
     self.assertEqual(utils.to_numeric("a1.2", False), "a1.2")
Beispiel #7
0
 def test_date_2(self):
     self.assertEqual(utils.to_numeric("2012-05-30 10:34"),
                      np.datetime64("2012-05-30 10:34:00"))
Beispiel #8
0
 def test_cplx_1(self):
     self.assertEqual(utils.to_numeric("1+1j", False), "1+1j")
Beispiel #9
0
 def test_int_1(self):
     self.assertEqual(utils.to_numeric("1"), 1)
Beispiel #10
0
 def test_float_1(self):
     self.assertEqual(utils.to_numeric("1.2"), 1.2)