;$Id$ ;--------------------------------------------------- ; apply filters ; phase_true will be set to -1 for filtered data ; ; cod_clear_thresh = threshold for total cod to consider clear ; cod_ice_water_thresh = threshold for ice above water to consider water phase ;---------------------------------------------------- pro apply_filters, phase_true, $ time_diff, time_diff_max, $ zen, zen_min, zen_max, $ solzen, solzen_min, solzen_max, $ lunzen, lunzen_min, lunzen_max, $ land_class, $ cfrac_in, cfrac_min, cfrac_max, $ solglintzen, solglintzen_min, solglintzen_max, $ lunglintzen, lunglintzen_min, lunglintzen_max, $ solscatang, solscatang_min, solscatang_max, $ snow_class, snow_class_min, snow_class_max, $ solglint_mask, solglint_mask_min, solglint_mask_max, $ lunglint_mask, lunglint_mask_min, lunglint_mask_max, $ city_mask, city_mask_min, city_mask_max, $ moon_illum_frac_in, moon_illum_frac_min, moon_illum_frac_max, $ coast_mask, coast_mask_min, coast_mask_max, $ tpw, tpw_min, tpw_max, $ tsfc, tsfc_min, tsfc_max, $ zsfc, zsfc_min, zsfc_max, $ zsfc_std, zsfc_std_min, zsfc_std_max, $ lat, lat_min, lat_max, missing, phase_uni_flag = phase_uni_flag print, 'initial number of phase_true = ', phase_true.length idx = where(phase_true ge 0,cc) print, 'initial number of valid phase_true = ', cc ;--- phase uni filter if (keyword_set(phase_uni_flag)) then begin idx = where(phase_true ne smooth(phase_true,3,/edge_truncate),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by phase uniformity = ', cc endif endif ;--- time filter idx = where(time_diff gt time_diff_max,cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by time = ', cc endif ;-- cloud fraction filter (remove partially cloudy results) idx = where(cfrac_in gt cfrac_min and cfrac_in lt cfrac_max,cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by cloud fraction = ', cc endif ;--- snow class filter idx = where(snow_class lt snow_class_min or snow_class gt snow_class_max,cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by snow_class = ', cc endif ;-- solar glint filter idx = where(land_class ne 1 and snow_class eq 1 and solglint_mask ge 0 and solglint_mask le 1 and (solglint_mask lt solglint_mask_min or solglint_mask gt solglint_mask_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by solar glint = ', cc endif ;-- solar glint filter idx = where(land_class ne 1 and snow_class eq 1 and solglint_mask ge 0 and solglint_mask le 1 and (solglint_mask lt solglint_mask_min or solglint_mask gt solglint_mask_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by solar glint = ', cc endif ;-- lunar glint filter idx = where(land_class ne 1 and snow_class eq 1 and lunglint_mask ge 0 and lunglint_mask le 1 and (lunglint_mask lt lunglint_mask_min or lunglint_mask gt lunglint_mask_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by lunar glint = ', cc endif ;-- coast filter idx = where(coast_mask ge 0 and (coast_mask lt coast_mask_min or coast_mask gt coast_mask_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by coast = ', cc endif ;-- zen filter idx = where(zen ne missing and zen lt zen_min or zen gt zen_max,cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by zen = ', cc endif ;-- solar glintzen filter (not for land or sea-ice) idx = where(solzen lt 90.0 and solzen ne missing and solglintzen ne missing and $ land_class ne 1 and snow_class eq 1 and $ (solglintzen lt solglintzen_min or solglintzen gt solglintzen_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by solar glint = ', cc endif ;-- lunar glintzen filter (not for land or sea-ice) idx = where(lunzen lt 90.0 and lunzen ne missing and lunglintzen ne missing and $ land_class ne 1 and snow_class eq 1 and $ (lunglintzen lt lunglintzen_min or lunglintzen gt lunglintzen_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by lunar glint = ', cc endif ;-- moon_illum_frac (not for land or sea-ice) moon_illum_frac = moon_illum_frac_in idx = where(moon_illum_frac ne missing,cc) if (cc gt 0) then moon_illum_frac[idx] = moon_illum_frac[idx] idx = where(moon_illum_frac ne missing and $ (moon_illum_frac lt moon_illum_frac_min or moon_illum_frac gt moon_illum_frac_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by moon illum fraction = ', cc endif ;-- city mask idx = where(city_mask ge 0 and city_mask le 1 and (city_mask lt city_mask_min or city_mask gt city_mask_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by city mask= ', cc endif ;-- solzen filter idx = where(solzen ne missing and (solzen lt solzen_min or solzen gt solzen_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by solzen = ', cc endif ;-- lunzen filter idx = where(lunzen ne missing and (lunzen lt lunzen_min or lunzen gt solzen_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by lunzen = ', cc endif ;-- solar scattering angle filter idx = where(solscatang ne missing and (solscatang lt solscatang_min or solscatang gt solscatang_max),cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by solar scattering angle = ', cc endif ;-- tpw filter idx = where(tpw lt tpw_min or tpw gt tpw_max, cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by tpw = ', cc endif ;-- tsfc filter idx = where(tsfc lt tsfc_min or tsfc gt tsfc_max, cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by tsfc = ', cc, Tsfc_Min, Tsfc_Max ii = where(tsfc eq missing,kk) print, 'number of pixels filtered by missing tsfc = ', kk endif ;-- zsfc filter idx = where(zsfc lt zsfc_min or zsfc gt zsfc_max, cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by zsfc = ', cc, zsfc_min, zsfc_max endif ;-- zsfc_std filter idx = where(zsfc_std lt zsfc_std_min or zsfc_std gt zsfc_std_max, cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by zsfc_std = ', cc, zsfc_std_min, zsfc_std_max endif ;-- lat filter idx = where(lat lt lat_min or lat gt lat_max, cc) if (cc gt 0) then begin phase_true[idx] = -1 print, 'number of pixels filtered by lat = ', cc endif idx = where(phase_true ge 0,cc) print, 'final number of valid phase_true = ', cc print, '% valid phase_true = ', 100.0 * float(cc) / float(phase_true.length) end