merlin.chips

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.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
merlin.chips.to_numpy(chips, spec_index)[source]

Converts the data for a sequence of chips to numpy arrays

Parameters:
  • chips (sequence) – a sequence of chips
  • spec_index (dict) – chip_specs keyed by ubid
Returns:

chips with data as numpy arrays

Return type:

sequence

merlin.chips.trim(chips, dates)[source]

Eliminates chips that are not from the specified dates

Parameters:
  • chips – Sequence of chips
  • dates – Sequence of dates that should be included in result
Returns:

filtered chips

Return type:

tuple