;------------------------------------------------------------------------------------------------ ; for a given classifier lut and attrs structure, compute conditional ratios ; this works for 1d, 2d and 3d tables ;------------------------------------------------------------------------------------------------ pro get_prob_mask_phase, x, $ ;1st dim variable y, $ ;2nd dim variable, missing is rank < 2 z, $ ;3rd dim variable, missing if rank < 3 zen, $ solzen, $ lunzen, $ solglintzen, $ lunglintzen, $ solscatang, $ tpw, $ tsfc, $ zsfc, $ zsfc_std, $ land_class, $ snow_class, $ solglint_mask, $ lunglint_mask, $ coast_mask, $ city_mask, $ moon_illum_frac, $ isfc, $ lut, $ attrs, $ missing, $ clear_cond_ratio, $ water_cond_ratio, $ ice_cond_ratio, $ obs_prob clear_cond_ratio = missing water_cond_ratio = missing ice_cond_ratio = missing obs_prob = missing skipped = 1 ;---- if on for this sfc_idx if (lut[isfc].on_flag eq 0) then goto, skip ;-- check for data that is withing the limits for this classifier if (zen ne missing and $ (zen lt attrs.zen_min or zen gt attrs.zen_max)) then goto, skip if (solzen ne missing and $ (solzen lt attrs.solzen_min or solzen gt attrs.solzen_max)) then goto, skip if (solglintzen ne missing and land_class ne 1 and snow_class eq 1 and $ (solglintzen lt attrs.solglintzen_min or solglintzen gt attrs.solglintzen_max)) then goto, skip if (lunglintzen ne missing and land_class ne 1 and snow_class eq 1 and $ (lunglintzen lt attrs.lunglintzen_min or lunglintzen gt attrs.lunglintzen_max)) then goto, skip if (solscatang ne missing and $ (solscatang lt attrs.solscatang_min or solscatang gt attrs.solscatang_max)) then goto, skip if (tpw ne missing and $ (tpw lt attrs.tpw_min or tpw gt attrs.tpw_max)) then goto, skip if (tsfc ne missing and $ (tsfc lt attrs.tsfc_min or tsfc gt attrs.tsfc_max)) then goto, skip if (zsfc ne missing and $ (zsfc lt attrs.zsfc_min or zsfc gt attrs.zsfc_max)) then goto, skip if (zsfc_std ne missing and $ (zsfc_std lt attrs.zsfc_std_min or zsfc_std gt attrs.zsfc_std_max)) then goto, skip if (snow_class ge 1 and $ (snow_class lt attrs.snow_class_min or snow_class gt attrs.snow_class_max)) then goto, skip ; print, 'snow_class = ', snow_class, snow_class_min, snow_class_max ; if (snow_class ge 1 and $ ; (snow_class lt attrs.snow_class_min or snow_class gt attrs.snow_class_max)) then begin ; print, 'snow skipped ', snow_class, snow_class_min, snow_class_max ; goto, skip ; endif if (land_class ne 1 and snow_class eq 1 and solglint_mask ge 0 and solglint_mask le 1 and $ (solglint_mask lt attrs.solglint_mask_min or solglint_mask gt attrs.solglint_mask_max)) then goto, skip if (land_class ne 1 and snow_class eq 1 and lunglint_mask ge 0 and lunglint_mask le 1 and $ (lunglint_mask lt attrs.lunglint_mask_min or lunglint_mask gt attrs.lunglint_mask_max)) then goto, skip if (coast_mask ge 0 and $ (coast_mask lt attrs.coast_mask_min or coast_mask gt attrs.coast_mask_max)) then goto, skip if (moon_illum_frac ne missing and $ (moon_illum_frac lt attrs.moon_illum_frac_min or moon_illum_frac gt attrs.moon_illum_frac_max)) then goto, skip if (city_mask ne missing and city_mask ge 0 and city_mask le 1 and $ (city_mask lt attrs.city_mask_min or city_mask gt attrs.city_mask_max)) then goto, skip ;--- check for valid data if (x eq missing) then goto, skip if (~finite(x)) then goto, skip if (attrs.rank ge 2) then begin if (y eq missing) then goto, skip if (~finite(y)) then goto, skip endif if (attrs.rank ge 3) then begin if (z eq missing) then goto, skip if (~finite(z)) then goto, skip endif ix = min([attrs.nbins_x -1,max([0,fix((x - attrs.x_min) / attrs.x_bin)])]) iy = 0 iz = 0 if (attrs.rank ge 2) then begin iy = min([attrs.nbins_y -1,max([0,fix((y - attrs.y_min) / attrs.y_bin)])]) endif if (attrs.rank ge 3) then begin iz = min([attrs.nbins_z -1,max([0,fix((z - attrs.z_min) / attrs.z_bin)])]) endif case attrs.rank of 1:obs_prob = lut[isfc].obs[ix] 2:obs_prob = lut[isfc].obs[ix,iy] 3:obs_prob = lut[isfc].obs[ix,iy,iz] endcase ;obs_prob_thresh = 1.0 / attrs.nbins_x / attrs.nbins_y / attrs.nbins_z obs_prob_thresh = 0.0 if (obs_prob gt obs_prob_thresh) then begin case attrs.rank of 1:begin clear_cond_ratio = lut[isfc].clear[ix] ice_cond_ratio = lut[isfc].ice[ix] water_cond_ratio = lut[isfc].water[ix] end 2:begin clear_cond_ratio = lut[isfc].clear[ix,iy] ice_cond_ratio = lut[isfc].ice[ix,iy] water_cond_ratio = lut[isfc].water[ix,iy] end 3:begin clear_cond_ratio = lut[isfc].clear[ix,iy,iz] ice_cond_ratio = lut[isfc].ice[ix,iy,iz] water_cond_ratio = lut[isfc].water[ix,iy,iz] end endcase endif else begin ;print, 'no data ', obs_prob, lut[isfc].clear[ix,iy,iz], lut[isfc].ice[ix,iy,iz], lut[isfc].water[ix,iy,iz] endelse ;print, x, y, z, ix, iy, iz, isfc, clear_cond_ratio, ice_cond_ratio, water_cond_ratio skipped = 0 skip: ;if (skipped eq 1) then begin ; print, 'skipped point' ;endif end