bwc
bwc

Reputation: 1115

Extracting data with NCO bounded by variable values

Is it possible to pull out all data within a region (or specific cells) that meet criteria set by a variable rather than a dimension?

For example, I'm looking to pull data within a height ('HGT') bounded region.

Hyperslabbing seems to requires dimension rather than variable.

Upvotes: 1

Views: 723

Answers (2)

ClimateUnboxed
ClimateUnboxed

Reputation: 8107

you can use the mask facility in CDO to set values to missing for variables above or below a threshold, e.g. for above a threshold:

cdo lec,50 in.nc mask.nc
cdo mul in.nc mask.nc masked_output.nc

you can pipe to do this on one line and also include a lower bound:

cdo mul -lec,50 -gec,0 in.nc in.nc masked_output.nc

Upvotes: 0

Charlie Zender
Charlie Zender

Reputation: 6352

The ncap2 where() function serves this purpose, e.g.,

ncap2 -s 'where(th < 0.0 || th > 50.0) th=th.get_miss();' in.nc out.nc

Upvotes: 3

Related Questions