merlin.chips¶
-
merlin.chips.
bounds_to_coordinates
(bounds, grid, cfg)[source]¶ Returns chip coordinates from a sequence of bounds. Performs minbox operation on bounds, thus irregular geometries may be supplied.
Parameters: - bounds – a sequence of bounds.
- grid (dict) – {‘sx’: SCALE_FACTOR, ‘sy’: SCALE_FACTOR}
- cfg (dict) – {‘snap_fn’: some_func}
Returns: chip coordinates
Return type: tuple
Example
>>> xys = bounds_to_coordinates( bounds=((112, 443), (112, 500), (100, 443)), grid={'sx': 3000, 'sy': 3000}, cfg={'snap_fn': some_func}) >>> ((100, 500),)
-
merlin.chips.
chip_to_numpy
(chip, chip_spec)[source]¶ Removes base64 encoding of chip data and converts it to a numpy array
Parameters: - chip – A chip
- chip_spec – Corresponding chip_spec
Returns: a decoded chip with data as a shaped numpy array
-
merlin.chips.
coordinates
(ulx, uly, lrx, lry, grid, cfg)[source]¶ Returns all the chip coordinates that are needed to cover a supplied bounding box.
Parameters: - ulx (float) – upper left x
- uly (float) – upper left y
- lrx (float) – lower right x
- lry (float) – lower right y
- grid (dict) – {‘sx’: 3000, ‘sy’: 3000, ‘rx’: 1, ‘ry’: -1}
- cfg (dict) – A Merlin configuration
Returns: tuple of tuples of chip coordinates ((x1,y1), (x2,y1) …)
Return type: tuple
This example assumes chip sizes of 500 pixels.
Example
>>> chip_coordinates = coordinates(ulx=-1000, uly=1000, lrx=-500, lry=500, grid={'sx': 500, 'sy': 500}, cfg={'snap_fn': some_func})
((-1000, 500), (-500, 500), (-1000, -500), (-500, -500))
-
merlin.chips.
dates
(chips)[source]¶ Dates for a sequence of chips
Parameters: chips – sequence of chips Returns: datestrings Return type: tuple
-
merlin.chips.
deduplicate
(chips)[source]¶ Accepts a sequence of chips and returns a sequence of chips minus any duplicates. A chip is considered a duplicate if it shares an x, y, UBID and acquired date with another chip.
Parameters: chips (sequence) – Sequence of chips Returns: A nonduplicated tuple of chips Return type: tuple
-
merlin.chips.
identity
(chip)[source]¶ Determine the identity of a chip.
Parameters: chip (dict) – A chip Returns: Tuple of the chip identity field Return type: tuple
-
merlin.chips.
locations
(x, y, cw, ch, rx, ry, sx, sy)[source]¶ Computes locations for array elements that fall within the shape specified by chip_spec[‘data_shape’] using the x & y as the origin. locations() does not snap() x & y… this should be done prior to calling locations() if needed.
Parameters: - x – x coordinate
- y – y coordinate
- cw – chip width in pixels (e.g. 100 pixels)
- ch – chip height in pixels (e.g. 100 pixels)
- rx – x reflection (e.g. 1)
- ry – y reflection (e.g. -1)
- sx – x scale (e.g. 3000 meters)
- sy – y scale (e.g. 3000 meters)
Returns: a two (three) dimensional numpy array of [x, y] coordinates
-
merlin.chips.
mapped
(x, y, acquired, specmap, chips_fn)[source]¶ Maps chips_fn results to keys from specmap.
Parameters: - x (int) – x coordinate
- y (int) – y coordinate
- acquired (str) – iso8601 date range
- specmap (dict) – map of specs
- chips_fn (fn) – function to return chips
Returns: {k: chips_fn()}
Return type: dict
-
merlin.chips.
rsort
(chips, key=<function <lambda>>)[source]¶ Reverse sorts a sequence of chips by date.
Parameters: chips – sequence of chips Returns: sorted sequence of chips