예제 #1
0
    def test_reproduceTypedValue_good(self):
        """
        check various inputs and compare to expected output
        for values that should work
        """
        lva = model.ListVA([12, -3])
        # example value / input str / expected output
        tc = [(3, "-1561", -1561),
              (-9.3, "0.123", 0.123),
              (False, "true", True),
              ({"a": 12.5, "b": 3.}, "c:6,d:1.3", {"c": 6., "d":1.3}),
              ((-5, 0, 6), " 9, -8", (9, -8)), # we don't force to be the same size
              ((1.2, 0.0), "0, -8, -15e-3, 6.", (0.0, -8.0, -15e-3, 6.0)),
              ([1.2, 0.0], "0.1", [0.1]),
              (("cou", "bafd"), "aa,bb", ("aa", "bb")),
              # more complicated but nice to support for the user
              ((1200, 256), "256 x 256 px", (256, 256)),
              ((1.2, 256), " 21 x 0.2 m", (21, 0.2)),
              ([-5, 0, 6], "9,, -8", [9, -8]),
              ((1.2, 0.0), "", tuple()),
              (lva.value, "-1, 63, 12", [-1, 63, 12]), #NotifyingList becomes a list
              ((-5, 0, 6), "9.3, -8", (9, 3, -8)), # maybe this shouldn't work?
              # Note: we don't support SI prefixes
              (("cou",), "aa, c a", ("aa", " c a")), # TODO: need to see if spaces should be kept or trimmed
              ]

        for ex_val, str_val, expo in tc:
            out = reproduceTypedValue(ex_val, str_val)
            self.assertEqual(out, expo,
                 "Testing with %s / '%s' -> %s" % (ex_val, str_val, out))
예제 #2
0
def main(args):
    """
    Handles the command line arguments
    args is the list of arguments passed
    return (int): value to return to the OS as program exit code
    """

    # arguments handling
    parser = argparse.ArgumentParser(description=
                     "SEM fluorescence bleaching map")

    parser.add_argument("--dt", "-d", dest="dt", type=float, required=True,
                        help="ebeam (bleaching) dwell time in s (for each sub-pixel)")
    parser.add_argument("--pxs", "-p", dest="pxs", type=float, required=True,
                        help="distance between 2 spots in nm")
    parser.add_argument("--subpx", "-s", dest="subpx", type=int, default=1,
                        help="number of sub-pixels scanned by the ebeam for "
                            "each pixel acquired by the CCD. Must be a the "
                            "square of an integer.")
    parser.add_argument("--roi", dest="roi", required=True,
                        help="e-beam ROI positions (ltrb, relative to the SEM "
                             "field of view)")
    parser.add_argument("--output", "-o", dest="filename", required=True,
                        help="name of the file output")

    options = parser.parse_args(args[1:])

    roi = driver.reproduceTypedValue([1.0], options.roi)
    if not all(0 <= r <= 1 for r in roi):
        raise ValueError("roi values must be between 0 and 1")

    a = Acquirer(options.dt, roi, options.pxs * 1e-9, options.subpx)
    a.acquire(options.filename)
예제 #3
0
def main(args):
    """
    Handles the command line arguments
    args is the list of arguments passed
    return (int): value to return to the OS as program exit code
    """

    # arguments handling
    parser = argparse.ArgumentParser(description=
                     "AR spectral acquisition")

    parser.add_argument("-x", dest="X", type=int, required=True,
                        help="shape of AR image on the X axis")
    parser.add_argument("-y", dest="Y", type=int, required=True,
                        help="shape of AR image on the Y axis")
    parser.add_argument("--spot", dest="spot", required=True,
                        help="e-beam spot position")
    parser.add_argument("--drift", "-d", dest="drift", type=float, default=None,
                        help="time between 2 drift corrections")
    parser.add_argument("--anchor", dest="anchor", default=None,
                        help="e-beam spot position")
    parser.add_argument("--output", "-o", dest="filename", required=True,
                        help="name of the file output")

    options = parser.parse_args(args[1:])

    shape = (options.X, options.Y)
    if shape[0] <= 0 or shape[1] <= 0:
        raise ValueError("X/Y must be > 0")

    spot = driver.reproduceTypedValue([1.0], options.spot)
    if not (0 <= spot[0] <= 1 and 0 <= spot[1] <= 1):
        raise ValueError("spot must be between 0 and 1")

    if options.anchor is None or options.drift is None:
        anchor = None
    else:
        anchor = driver.reproduceTypedValue([1.0], options.anchor)

    a = Acquirer()
    a.acquire_arcube(shape, spot, dperiod=options.drift, anchor=anchor,
                     filename=options.filename)
예제 #4
0
def main(args):
    """
    Handles the command line arguments
    args is the list of arguments passed
    return (int): value to return to the OS as program exit code
    """

    # arguments handling
    parser = argparse.ArgumentParser(description=
                     "AR spectral acquisition")

    parser.add_argument("-x", dest="X", type=int, required=True,
                        help="shape of AR image on the X axis")
    parser.add_argument("-y", dest="Y", type=int, required=True,
                        help="shape of AR image on the Y axis")
    parser.add_argument("--spot", dest="spot", required=True,
                        help="e-beam spot position")
    parser.add_argument("--drift", "-d", dest="drift", type=float, default=None,
                        help="time between 2 drift corrections")
    parser.add_argument("--anchor", dest="anchor", default=None,
                        help="e-beam spot position")
    parser.add_argument("--output", "-o", dest="filename", required=True,
                        help="name of the file output")

    options = parser.parse_args(args[1:])

    shape = (options.X, options.Y)
    if shape[0] <= 0 or shape[1] <= 0:
        raise ValueError("X/Y must be > 0")

    spot = driver.reproduceTypedValue([1.0], options.spot)
    if not (0 <= spot[0] <= 1 and 0 <= spot[1] <= 1):
        raise ValueError("spot must be between 0 and 1")

    if options.anchor is None or options.drift is None:
        anchor = None
    else:
        anchor = driver.reproduceTypedValue([1.0], options.anchor)

    a = Acquirer()
    a.acquire_arcube(shape, spot, dperiod=options.drift, anchor=anchor,
                     filename=options.filename)
예제 #5
0
    def test_reproduceTypedValue_bad(self):
        """
        check various inputs and compare to expected output
        for values that should raise an exception
        """
        # example value / input str
        tc = [(3, "-"),
              (-9, "0.123"),
              (False, "56"),
              ({"a": 12.5, "b": 3.}, "6,1.3"),
              (9.3, "0, 123"),
              ]

        for ex_val, str_val in tc:
            with self.assertRaises((ValueError, TypeError)):
                out = reproduceTypedValue(ex_val, str_val)
예제 #6
0
def main(args):
    """
    Handles the command line arguments
    args is the list of arguments passed
    return (int): value to return to the OS as program exit code
    """

    # arguments handling
    parser = argparse.ArgumentParser(description=
                     "SEM fluorescence bleaching map")

    parser.add_argument("--dt", "-d", dest="dt", type=float, required=True,
                        help="ebeam (bleaching) dwell time in s (for each sub-pixel)")
    parser.add_argument("--pxs", "-p", dest="pxs", type=float, required=True,
                        help="distance between 2 spots in nm")
    parser.add_argument("--subpx", "-s", dest="subpx", type=int, default=1,
                        help="number of sub-pixels scanned by the ebeam for "
                            "each pixel acquired by the CCD. Must be a the "
                            "square of an integer.")
    parser.add_argument("--roi", dest="roi", required=True,
                        help="e-beam ROI positions (ltrb, relative to the SEM "
                             "field of view)")
    parser.add_argument("--lpower", "-lp", dest="lpower", type=float, default=0.02,
                        help="excitation light power on the first fluorescence pixel. "
                            "Choose the value between 0.004 and 0.4 (in W). "
                            "Power will be gradually scaled up to the maximum (0.4 W) "
                            "on the last pixel to compensate photobleaching effect "
                            "in the signal drop.")
    parser.add_argument("--output", "-o", dest="filename", required=True,
                        help="name of the file output")

    options = parser.parse_args(args[1:])

    roi = driver.reproduceTypedValue([1.0], options.roi)
    if not all(0 <= r <= 1 for r in roi):
        raise ValueError("roi values must be between 0 and 1")

    a = Acquirer(options.dt, roi, options.pxs * 1e-9, options.subpx, options.lpower)
    a.acquire(options.filename)
예제 #7
0
def main(args):
    """
    Handles the command line arguments
    args is the list of arguments passed
    return (int): value to return to the OS as program exit code
    """

    # arguments handling
    parser = argparse.ArgumentParser(description=
                     "SEM fluorescence bleaching map")

    parser.add_argument("--dt", "-d", dest="dt", type=float, required=True,
                        help="ebeam (bleaching) dwell time in s (for each sub-pixel)")
    parser.add_argument("--pxs", "-p", dest="pxs", type=float, required=True,
                        help="distance between 2 spots in nm")
    parser.add_argument("--subpx", "-s", dest="subpx", type=int, default=1,
                        help="number of sub-pixels scanned by the ebeam for "
                            "each pixel acquired by the CCD. Must be a the "
                            "square of an integer.")
    parser.add_argument("--roi", dest="roi", required=True,
                        help="e-beam ROI positions (ltrb, relative to the SEM "
                             "field of view)")
    parser.add_argument("--lpower", "-lp", dest="lpower", type=float, default=0.02,
                        help="excitation light power on the first fluorescence pixel. "
                            "Choose the value between 0.004 and 0.4 (in W). "
                            "Power will be gradually scaled up to the maximum (0.4 W) "
                            "on the last pixel to compensate photobleaching effect "
                            "in the signal drop.")
    parser.add_argument("--output", "-o", dest="filename", required=True,
                        help="name of the file output")

    options = parser.parse_args(args[1:])

    roi = driver.reproduceTypedValue([1.0], options.roi)
    if not all(0 <= r <= 1 for r in roi):
        raise ValueError("roi values must be between 0 and 1")

    a = Acquirer(options.dt, roi, options.pxs * 1e-9, options.subpx, options.lpower)
    a.acquire(options.filename)