;"$Id:$" @determine_table_rank @push pro combine_single_tables single_table_path = "./single_tables/" single_tables = file_search(single_table_path, "*.nc") ntables = single_tables.length version = "ecm_2_0_0" ;--- open file for output output_table_path = "./combined_tables/" output_name = 'test.nc' ;output_name = 'original_lut.nc' sd_id = ncdf_create(output_table_path+output_name,/CLOBBER,/NETCDF4_FORMAT) print, 'output sd_id = ', sd_id ;--- set cloud mask probability thresholds based on sfc type CONF_CLEAR_PROB_CLEAR_THRESH = [0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10] PROB_CLEAR_PROB_CLOUD_THRESH = [0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50] PROB_CLOUD_CONF_CLOUD_THRESH = [0.90, 0.90, 0.90, 0.90, 0.90, 0.90, 0.90] ;--- based on lut training with 25% of clear and cloud as probably ;CONF_CLEAR_PROB_CLEAR_THRESH = [0.03, 0.03, 0.11, 0.28, 0.36, 0.38, 0.04] ;PROB_CLEAR_PROB_CLOUD_THRESH = [0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50] ;PROB_CLOUD_CONF_CLOUD_THRESH = [0.98, 0.98, 0.96, 0.84, 0.82, 0.68, 0.97] RUT_CLEAR_PROB_CLEAR_THRESH = [1.0, 1.0, 0.2, 0.2, 0.2, 0.2, 0.2] TUT_CLEAR_PROB_CLEAR_THRESH = [0.6, 0.6, 1.1, 1.1, 1.1, 1.1, 1.1] ;-------------------------------------------------------- ; loop over tables ;-------------------------------------------------------- for itable = 0, ntables - 1 do begin print,'Processing Table = ',single_tables[itable] ;--- determine rank of tables rank = determine_table_rank(single_tables[itable]) ;--- read table (according to rank) case rank of 1: read_1d_table, single_tables[itable], lut, attrs, channels_used, read_success 2: read_2d_table, single_tables[itable], lut, attrs, channels_used, read_success 3: read_3d_table, single_tables[itable], lut, attrs, channels_used, read_success else: begin print, 'unsupported rank ' stop end endcase push, classifier_names, attrs.classifier_name print, 'read success = ', read_success, attrs.classifier_name ;--- write table to output (according to rank) case rank of 1: write_1d_table, sd_id, lut, attrs, channels_used, write_success 2: write_2d_table, sd_id, lut, attrs, channels_used, write_success 3: write_3d_table, sd_id, lut, attrs, channels_used, write_success endcase print, 'write success = ', write_success endfor nsfc = attrs.nsfc sensor = attrs.sensor ncdf_attput,sd_id, "sensor", sensor, /CHAR, /global ncdf_attput,sd_id, "timestamp", timestamp(), /CHAR, /global ncdf_attput,sd_id, "version", version, /CHAR, /global ;--- write classifier info ncdf_attput,sd_id, "nclassifiers", ntables, /SHORT, /global max_len_class_names = max(strlen(classifier_names)) ncdf_attput,sd_id, "max_length_classifier_names", max_len_class_names, /SHORT, /global nsfc_id = NCDF_DIMDEF(sd_id, 'nsfc', nsfc) nclass_id = NCDF_DIMDEF(sd_id, 'nclassifiers', ntables) nlength_class_id = NCDF_DIMDEF(sd_id, 'nlength_class', 50) sds_id_1 = NCDF_VARDEF(sd_id, 'classifier_names', [nlength_class_id,nclass_id], /CHAR) sds_id_2 = NCDF_VARDEF(sd_id, 'conf_clear_prob_clear_thresh', [nsfc_id], /FLOAT) sds_id_3 = NCDF_VARDEF(sd_id, 'prob_clear_prob_cloud_thresh', [nsfc_id], /FLOAT) sds_id_4 = NCDF_VARDEF(sd_id, 'prob_cloud_conf_cloud_thresh', [nsfc_id], /FLOAT) sds_id_5 = NCDF_VARDEF(sd_id, 'rut_clear_prob_clear_thresh', [nsfc_id], /FLOAT) sds_id_6 = NCDF_VARDEF(sd_id, 'tut_clear_prob_clear_thresh', [nsfc_id], /FLOAT) NCDF_CONTROL, sd_id, /ENDEF ; Put the file into data mode NCDF_VARPUT, sd_id, sds_id_1, classifier_names NCDF_VARPUT, sd_id, sds_id_2, conf_clear_prob_clear_thresh NCDF_VARPUT, sd_id, sds_id_3, prob_clear_prob_cloud_thresh NCDF_VARPUT, sd_id, sds_id_4, prob_cloud_conf_cloud_thresh NCDF_VARPUT, sd_id, sds_id_5, rut_clear_prob_clear_thresh NCDF_VARPUT, sd_id, sds_id_6, tut_clear_prob_clear_thresh ;--- close file for output ncdf_close, sd_id end