Skip to content

Treatment and control cell sampling - #6

Merged
alanalutz merged 5 commits into
mainfrom
cell_sampling
Aug 31, 2026
Merged

Treatment and control cell sampling#6
alanalutz merged 5 commits into
mainfrom
cell_sampling

Conversation

@alanalutz

@alanalutz alanalutz commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Description

Implements a new sampling strategy for generating 1km2 treatment and control cells, to replace src/psm/ps_grid_creation.py. Generates a new set of treatment and control cells for all 30 test PAs.

Treatment cells are a grid of all fully interior 1km2 cells within a PA (if the PA is small), or a random sample of fully interior km2 cells (if the PA is large). Control cells are a random sample of unprotected 1km2 cells that are within a given distance of a PA, but outside of a given buffer distance from the PA. They must also fall fully outside a given buffer distance from any PA.

The PSM model is updated to use these newly generated grid cells instead of the old ones from psm_grid_creation.py

Created, updated, or replaced Files and/or tables

  • src/psm/get_interior_cells.py: Iterates through a set of PAs and generates a set of valid interior (treatment) 1km2 cells for each PA. If the PA is <500 km2, a grid of all valid interior cells is generated. If the PA is >500 km2, a random sample of valid interior cells is generated.
  • src/psm/get_exterior_cells.py: Iterates through a set of PAs and generates a random sample of valid exterior (control) 1km2 cells for each PA. These are unprotected cells that fall within a given distance of a PA, but outside of a given buffer distance from that PA.
  • notebooks/get_exterior_cells.ipynb: Test notebook for generating exterior (control) cells; was converted to src/psm/get_exterior_cells.py.
  • notebooks/ps_model.ipynb: Updated to use the newly generated treatment and control cells instead of the ones generated by ps_grid_creation.py

Notes for reviewers

I would appreciate close review on this PR, since this sampling approach is used (largely unchanged) in the current TPARA methodology.

Stack created with GitHub Stacks CLIGive Feedback 💬

@alanalutz alanalutz changed the title cell sampling Treatment and control cell sampling Aug 24, 2026
@alanalutz
alanalutz marked this pull request as ready for review August 24, 2026 22:12
Base automatically changed from psm_initial_testing to main August 27, 2026 18:43

@cjthomas730 cjthomas730 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please address this point, I'm not sure if I'm missing something in the CRS setting, or if this is just a nitpick

Comment thread src/psm/get_exterior_cells.py
@alanalutz
alanalutz requested a review from cjthomas730 August 31, 2026 17:28
@alanalutz
alanalutz merged commit 6da8601 into main Aug 31, 2026
@alanalutz
alanalutz deleted the cell_sampling branch August 31, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants