Averaging/Integrating over Irregular Regions
How to integrate a variable within a surface/volume delimitated by an isoline/isosurface, or other complex regions ?
Integrate temperature only above the 20 degree isotherm
Create a mask, apply it to the variable and then integrate.
yes? LET iso20 = my_temperature[Z=@LOC:20]
yes? LET mask = IF Z[g=my_temperature] .LT. iso20 THEN 1 ! else missing is implied
yes? LET masked_temp = mask*my_temperature
Now integrate masked_temp instead of my_temp.
Average over complex regions in 2-dimensional space.
Averaging over complex regions in space may be achieved by masking the multi-dimensional variable in question and using the multi-dimensional form of @AVE.
yes? LET salinity_where_temp_gt_15 = IF temp GT 15 THEN salt
yes? LIST salinity_where_temp_gt_15[X=@AVE,Y=@AVE,Z=@AVE]
This approach applies an all-or-nothing criterion to each gridcell, rather than including fractional grid cells in the integration. Ifnecessary the accuracy of the integration or averaging can be improved by firstregridding my_temperature to a finer grid.