;$Id:$ ;--------------------------------------------------- ; make_true_phase ; ; phase_lidar = raw calipso cloud phase ; 0 = unknown ; 1 = ice ; 2 = water ; 3 = random oriented ice ; ; phase_true = our massaged calipso cloud phase for training ; -1 = unknown ; 0 = clear ; 1 = water ; 2 = ice ; ; phase_true will be set to -1 for filtered data ; ; cod_clear_water_thresh = threshold for total cod to consider clear if water cloud ; cod_clear_ice_thresh = threshold for total cod to consider clear if ice cloud ; ; cod_ice_water_thresh = threshold for ice above water to consider water phase ; ;---------------------------------------------------- pro make_true_phase, phase_lidar, frac_lidar, tc_lidar, cod_lidar, cod_ice_lidar, $ cod_clear_water_thresh, cod_clear_ice_thresh, $ sfc_type, topa, zopa, $ solzen, glint_mask, coast_mask, zsfc, tsfc, $ refl_min_3x3, refl, $ temp_max_3x3, temp, $ cod, cod_cloud_thresh, $ etrop, etrop_cloud_thresh, mod_flag, phase_true, missing frac_lidar_clear_thresh = 0.25 ; fraction at or below this threshold are clear frac_lidar_cloud_thresh = 0.75 ; fraction at or above this threshold are cloudy ;------------------------------------------------------------------------------- ;--- make missing values uniform ;------------------------------------------------------------------------------- ;goto, skip1 idx = where(cod_lidar lt 0.00,cc) if (cc gt 0) then begin print, 'number of pixels with sub-zero cloud optical depth = ', cc cod_lidar[idx] = missing endif idx = where(cod_ice_lidar lt 0.00,cc) if (cc gt 0) then begin print, 'number of pixels with sub-zero ice_cloud optical depth = ', cc cod_ice_lidar[idx] = missing endif idx = where(tc_lidar lt 160.0, cc) if (cc gt 0) then begin print, 'number of pixels with sub-zero cloud temperature = ', cc tc_lidar[idx] = missing endif idx = where(frac_lidar lt 0.00,cc) if (cc gt 0) then begin print, 'number of pixels with sub-zero cloud fraction = ', cc frac_lidar[idx] = missing endif ;-- 1km results inconsistent - throw these away idx = where(cod_lidar eq 3.0 and phase_lidar eq 0,cc) if (cc gt 0) then begin phase_lidar[idx] = -1 endif ;--------------------------------------------------------------------------------- ;skip1: ;---------------------------------------------------------------------------------- ; translate phase_lidar (in) to phase_true (out) ; for now, we'll assume phase_lidar = 0 = clear ;---------------------------------------------------------------------------------- phase_true = phase_lidar idx = where(phase_lidar eq 2, cc) if (cc gt 0) then phase_true[idx] = 1 idx = where(phase_lidar eq 1 or phase_lidar eq 3, cc) if (cc gt 0) then phase_true[idx] = 2 idx = where(phase_lidar lt 0 or phase_lidar gt 3, cc) if (cc gt 0) then phase_true[idx] = -1 idx = where(phase_true eq -1, cc_bad) idx = where(phase_true eq 0, cc0) idx = where(phase_true eq 1, cc1) idx = where(phase_true eq 2, cc2) n = float(cc0+cc1+cc2) print, "initial phase fractions(bad/c/i/w) = ", float(cc_bad)/(n+cc_bad),float(cc0)/n, float(cc1)/n, float(cc2)/n ;---------------------------------------------------------------------------------- ; look at pixels with phase_lidar eq 0 ;---------------------------------------------------------------------------------- idx0 = where(phase_lidar eq 0,cc0) print, 'number of clear pixels phase_lidar pixels = ', cc0 ;;;;;cc0 = 0 ;TURN OFF if (cc0 gt 0) then begin ;--- look for pixels that could be ice idx_sub_wat = where(tc_lidar[idx0] ne missing and tc_lidar[idx0] gt 270.0,cc_sub_wat) if (cc_sub_wat gt 0) then phase_true[idx0[idx_sub_wat]] = 1 print, 'number of clear pixels classified as water tc_lidar = ', cc_sub_wat ;--- look for pixels that could be water idx_sub_ice = where(tc_lidar[idx0] ne missing and tc_lidar[idx0] lt 250.0,cc_sub_ice) if (cc_sub_ice gt 0) then phase_true[idx0[idx_sub_ice]] = 2 print, 'number of clear pixels classified as ice by tc_lidar = ', cc_sub_ice endif ;---------------------------------------------------------------------------------- ;--- find situations where thin ice overlies water cloud and ;--- reclassify as water cloud ;--- should not impact the clear phase values ;---------------------------------------------------------------------------------- cc = 0 idx = where(phase_true eq 2 and $ cod_ice_lidar ne missing and $ cod_lidar ne missing and $ cod_ice_lidar lt cod_clear_ice_thresh and $ cod_lidar-cod_ice_lidar gt cod_clear_water_thresh, cc) if (cc gt 0) then begin phase_true[idx] = 1 endif print, 'number of pixels rephased to water by ice cloud optical depth = ', cc idx = where(phase_true eq -1, cc_bad) idx = where(phase_true eq 0, cc0) idx = where(phase_true eq 1, cc1) idx = where(phase_true eq 2, cc2) n = float(cc0+cc1+cc2) print, "intermediate phase fractions(bad/c/i/w) = ", float(cc_bad)/n,float(cc0)/n, float(cc1)/n, float(cc2)/n ;--------------------------------------------------------------------------------- ;-- identify additional clear using cod_lidar ;---------------------------------------------------------------------------------- idx = where(cod_lidar ne missing and phase_true eq 1 and cod_lidar lt cod_clear_water_thresh,cc) if (cc gt 0) then begin phase_true[idx] = 0 endif print, 'number of water pixels cleared by cloud optical depth = ', cc idx = where(cod_lidar ne missing and phase_true eq 2 and cod_lidar lt cod_clear_ice_thresh,cc) if (cc gt 0) then begin phase_true[idx] = 0 endif print, 'number of ice pixels cleared by cloud optical depth = ', cc ;--------------------------------------------------------------------------------- ;-- set partly cloudy to missing ;---------------------------------------------------------------------------------- idx = where(frac_lidar gt frac_lidar_clear_thresh and frac_lidar lt frac_lidar_cloud_thresh,cc) if (cc gt 0) then begin phase_true[idx] = -1 endif print, 'number of pixels filtered by intermediate cloud fractions = ', cc ;----------------------------------------------------------------------------------- ; call remaining clear pixels and with significant cloud fraction as suspect ;----------------------------------------------------------------------------------- idx = where(phase_true eq 0 and frac_lidar gt frac_lidar_clear_thresh,cc) if (cc gt 0) then begin phase_true[idx] = -1 endif print, 'number of clear pixels filtered by large cloud fractions = ', cc ;------------------------------------------------------------------------------------- ; remaining unclassified pixels are mainly clear, lets try to move some back to ; clear ;------------------------------------------------------------------------------------- idx = where(phase_true eq -1, cc_bad) if (cc_bad gt 0) then begin idx_sub = where(cod_lidar[idx] lt cod_clear_ice_thresh and cod_lidar[idx] ne missing,cc_sub) if (cc_sub gt 0) then phase_true[idx[idx_sub]] = 0 print, 'number of bad pixels reset to clear by optical depth= ', cc_sub endif if (mod_flag eq 1) then begin idx = where(phase_true le 0, cc_bad) if (cc_bad gt 0) then begin idx_sub = where((sfc_type[idx] eq 1 or sfc_type[idx] eq 2) and coast_mask[idx] eq 0 and $ topa[idx] gt 260.0 and $ temp_max_3x3[idx] ne missing and temp[idx] ne missing and $ temp_max_3x3[idx] - temp[idx] gt 0.5, cc_sub) if (cc_sub gt 0) then phase_true[idx[idx_sub]] = 1 print, 'number of bad or clear ocean pixels set to water cloud by passive observations = ', cc_sub endif if (cc_bad gt 0) then begin idx_sub = where(sfc_type[idx] eq 3 and coast_mask[idx] eq 0 and $ topa[idx] gt 260.0 and zsfc[idx] lt 2000.0 and tsfc[idx] gt 260.0 and $ temp_max_3x3[idx] ne missing and temp[idx] ne missing and $ temp_max_3x3[idx] - temp[idx] gt 4.0, cc_sub) if (cc_sub gt 0) then phase_true[idx[idx_sub]] = 1 print, 'number of bad or clear land pixels set to water cloud by passive observations = ', cc_sub endif endif ;------------------------------------------------------------------------------------- idx = where(phase_true eq -1, cc_bad) idx = where(phase_true eq 0, cc0) idx = where(phase_true eq 1, cc1) idx = where(phase_true eq 2, cc2) n = float(cc0+cc1+cc2) print, "final phase fractions(bad/c/w/i) = ", float(cc_bad)/(n+cc_bad),float(cc0)/n, float(cc1)/n, float(cc2)/n end ;------------------------------------------------------------------------------------- ; make true phase without any filtering ;------------------------------------------------------------------------------------- pro make_true_phase_no_filter, phase_lidar, phase_true phase_true = phase_lidar idx = where(phase_lidar eq 2, cc) if (cc gt 0) then phase_true[idx] = 1 idx = where(phase_lidar eq 1 or phase_lidar eq 3, cc) if (cc gt 0) then phase_true[idx] = 2 idx = where(phase_lidar lt 0 or phase_lidar gt 3, cc) if (cc gt 0) then phase_true[idx] = -1 end