topskill.dev
CoursesTracks
0
All courses/Intro to NumPy: Pocket ObservatoryFinal project: Pocket Observatory report
7. Observation Lab: Shapes, CSV, and Final Project
11 / 12
← Intro to NumPy: Pocket Observatory
○What is NumPy?○Import NumPy as np○Turn a list into an array○Exercise: Decode a sensor feed○Build a two-dimensional grid○Exercise: Map station rows○Stack observation frames○Exercise: Stack sky snapshots○Read shape and size○Exercise: Label any observation✦Module Quiz
○Mark ticks and intervals○Exercise: Schedule sensor samples○Reserve blank and active grids○Exercise: Prime observation panels○Build patterns without loops○Exercise: Wire a sensor pattern○Replay seeded samples○Exercise: Simulate three station feeds○Choose and convert element types○Exercise: Label observation types✦Module Quiz
○Pick readings by position○Exercise: choose a signal pair○Read a sky grid○Exercise: trace a grid column○Cut a stepped window○Exercise: mute alternating samples○Mark noisy readings○Exercise: censor weak signals○See a view change its source○Exercise: preserve a calibration snapshot✦Module Quiz
○Scale every reading○Exercise: calibrate a pressure series○Combine matching readings○Exercise: find sensor agreement○Find a usable band○Exercise: flag an observation window○Apply functions to a full array○Exercise: transform a light curve○Reuse column offsets across rows○Exercise: correct a horizon map○Give each grid row its own baseline○Exercise: calibrate rows and reject bad shapes✦Module Quiz
○Find the loudest reading○Locate sensor extremes○Choose an axis○Summarize both directions○Keep a running tally○Build an interval counter○Describe a series○Compare center and spread○Sort within rows○Order each observation○Project: read the panel○Project: flag variability✦Module Quiz
○Read the grid○Select a sensor history○Transpose a grid○Turn a scoreboard○Weight a reading○Compute a weighted score○Combine matrix dimensions○Transform a whole panel○Project: calibrate the panel○Project: report calibrated peaks✦Module Quiz
○Fold a signal○Exercise: pack star counts○Trace shared readings○Exercise: audit a view○Raise a new axis○Exercise: align calibration○Stamp a pattern○Exercise: build exposure plan○Read a tiny CSV○Exercise: save and read CSV●Final project: Pocket Observatory report✦Module Quiz

Final project: Pocket Observatory report

The Pocket Observatory has one last packet: a flat strip of sky readings. Arrange it into rows, prepare an exposure schedule, and send the grid through a CSV round trip before reporting its brightest reading and row averages.

You have used each operation already. This starter separates the schedule into small helpers so you can inspect the column, repeated rows, and final paired columns independently. The sample packet is new; assume it is non-empty and its length is a multiple of three.

Build the schedule in stages

np.newaxis turns settings into a column without duplicating them. Then np.repeat(column, 2, axis=0) repeats whole rows. Finally, np.tile(held, (1, 2)) keeps the row count and copies the column across twice. For settings [2, 5], the finished schedule has rows [2, 2], [2, 2], [5, 5], and [5, 5].

The starter connects these helpers for the printed schedule. Each check also calls its helper directly with appropriate input, so you can earn credit one step at a time.

Prepare the hand-off

Use the CSV pattern from the previous exercise: an empty StringIO buffer, np.savetxt with fmt="%d", and getvalue() for the text. Read from a fresh StringIO(text) with dtype=int and ndmin=2. The temporary text is recreated each Run; no external file is needed.

The supplied format_report(rows, brightest, row_means) helper handles the final sentence and one-decimal formatting. Your observation_report function only needs to compute its three inputs: the row count, the overall maximum, and np.mean(grid, axis=1). Return the formatted string rather than printing inside the function.

Edit main.py and Run after each helper. The guarded print calls let you inspect early work while later functions remain unfinished. Submit checks the following outcomes in order.

Your Task

  1. In make_sky_grid(strip), use reshape to return a three-column grid with an inferred row count, without changing the strip's values or shape.
  2. In exposure_column(settings), use np.newaxis to return one column of settings.
  3. In hold_exposures(column), use np.repeat along axis=0 to return two adjacent copies of each row.
  4. In exposure_schedule(settings), use np.tile on the supplied held result to return the finished two-column schedule.
  5. In export_sky(grid), return comma-delimited integer CSV text using np.savetxt and StringIO.
  6. In import_sky(text), use np.genfromtxt and StringIO to return a two-dimensional integer grid.
  7. In observation_report(grid), use the supplied formatter to return a report with the row count, brightest reading, and one mean per row.

For the supplied packet, the report should read Rows: 2; brightest: 9; row means: 6.0, 5.0. You now have a small observation packet that can be shaped, checked, and passed on as text.

Hint 1
1 / 1
HINT 1

Finish one helper at a time; the supplied formatter handles the report punctuation.

Take the Quiz →
Files
  • ⋄main.py
Loading editor…
Press Run to execute your code.