Skip to content

006 feature sampler near land - #28

Open
b-barton wants to merge 5 commits into
mainfrom
006-feature-sampler-near-land
Open

006 feature sampler near land#28
b-barton wants to merge 5 commits into
mainfrom
006-feature-sampler-near-land

Conversation

@b-barton

Copy link
Copy Markdown
Collaborator

This fixes #6 . The code now account for profiles that are sampled on the model grid and fall on land. These profiles are rejected and not returned in the dataset of model profiles.

@b-barton
b-barton requested review from atb299 and oj-tooth July 24, 2026 12:45
@b-barton b-barton self-assigned this Jul 24, 2026
@b-barton b-barton added the mod:sampler Relates to sampling modules. label Jul 24, 2026
@b-barton b-barton linked an issue Jul 24, 2026 that may be closed by this pull request

@atb299 atb299 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.

The code all reads OK to me, so I think it is OK to be merged. I will leave that step for Ollie, since this will be merged with main and I am still not entirely familiar with the repo.


Return
index: indicies of model in i an j
index: indicies of model in i and j

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo - indices

return profile


def space_bounds(self, ds, ji, score):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks okay to me; one question I have is where this filtering should occur in the ObsSampler lifecycle.

One option might be to shift the responsibility of filtering out land-values to the generation of the probability map and your random sample generator? Meaning that, we can never produce a (j, i) pair for a synthetic observation that does not correspond to a wet grid point.



def find_nearest_time(self, ds, profile, thresh=10):
def find_nearest_time(self, ds, profile):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What was the threshold parameter intended for originally?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking a window in time that an obs could be associated with a model point but it didn't make sense.

assert (model_t.votemper.sel(profile_id=1)
assert ((model_t.votemper.sel(profile_id=1)
== synthetic_ds.votemper[5, :, 6, 8]).all()
& (model_t.sizes['profile_id'] == 1))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These look okay to me!

@oj-tooth oj-tooth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Happy with this PR, but wanted to pose my question on where the land-sea filtering implementation should happen before we merge into main?

It may be possible to move this filtering earlier in the ObsSampler lifecycle, ensuring we do not generate any (j, i) model coordinates for synthetic profiles that are located on land and then filtering during extraction would not be needed.

Would be good to get @b-barton and @atb299 thoughts on this?

@b-barton

b-barton commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

I think the nearest neighbour sampler sits in parallel to the RandomSampler. In config you will pick which route your going. I thought either you pass it a dataset of profiles you want to replicate in model space or you want a random set from the probability distribution?

For the wet cell filtering, I think it need to happen in both places.
Off issue but the probability map doesn't necessarily correspond to the model grid you want to apply it to so they might have different land masks. The probability map gets interpolated to the model grid.

If there is a better place for it, it could get moved later. I'm not sure where that would be though because before ObsSampler is DataLoading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:sampler Relates to sampling modules.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Sampler near land

3 participants