Home > atmlab > retrieval > spareice > process_ccniwp_data.m

process_ccniwp_data

PURPOSE ^

Retrieve SPARE-ICE

SYNOPSIS ^

function process_ccniwp_data(date1, date2, sat)

DESCRIPTION ^

 Retrieve SPARE-ICE

 process_ccniwp_data(date1, date2, sat)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

process_ccniwp_data.m

SOURCE CODE ^

0001 function process_ccniwp_data(date1, date2, sat)
0002 
0003 % Retrieve SPARE-ICE
0004 %
0005 % process_ccniwp_data(date1, date2, sat)
0006 
0007 % TODO: correct for biases etc.
0008 D = datasets();
0009 % if isfield(D, 'col_syn_iwp')
0010 %     datasets('delete', D.col_syn_iwp);
0011 % end
0012 % ccniwp = CollocatedNNIWP('name', 'col_syn_iwp', ...
0013 %     'basedir', '/storage3/user_data/gerrit/products/passive_syn_iwp', ...
0014 %     'subdir', '$YEAR4/$MONTH/$DAY', ...
0015 %     'filename', '$SAT_$HOUR_$MINUTE.nc.gz');
0016 % ccniwp.loadnets('/storage3/user_data/gerrit/neuralnets/avhrr_12345_mhs_345_lat_angles_all_global_MEAN_AVHRR_Y,1,2,3,4,5,B_BT,3,4,5,B_LZA,B_LAA,B_SZA,B_SAA,LAT1,_to_MEAN_IWP_2C,_noise0.00,_0.mat');
0017 % ccniwp.overwrite = 2;
0018 %ud = ccniwp.net.fit.userdata;
0019 
0020 if ~isfield(D, 'col_syn_iwp')
0021     define_local_datasets();
0022 end
0023 
0024 if isempty(D.col_syn_iwp.net)
0025     D.col_syn_iwp.loadnets();
0026 end
0027 
0028 %X = struct();
0029 allgrans = D.mhs.find_granules_for_period(date1, date2, sat);
0030 %parfor i = 1:size(allgrans, 1)
0031     % FIXME: can now use D.retrieve_and_store_period!
0032 for i = 1:size(allgrans, 1)
0033     logtext(atmlab('OUT'), 'Processing: %s\n', num2str(allgrans(i, :)));
0034 %     if isnan(atmlab('SITE'))
0035 %         logtext(1, 'Initialising\n');
0036 %         startup;
0037 %         ccniwp = CollocatedNNIWP('name', 'col_syn_iwp', ...
0038 %             'basedir', '/storage3/user_data/gerrit/products/passive_syn_iwp', ...
0039 %             'subdir', '$YEAR4/$MONTH/$DAY', ...
0040 %             'filename', 'ccniwp_03_$SAT_$HOUR_$MINUTE.nc.gz', ...
0041 %             'altfilename', '$SAT_$HOUR_$MINUTE.nc.gz', ...
0042 %             'version', '0.3');
0043 %         ccniwp.loadnets('/storage3/user_data/gerrit/neuralnets/avhrr_12345_mhs_345_lat_angles_elev_all_global_MEAN_AVHRR_Y,1,2,3,4,5,B_BT,3,4,5,B_LZA,B_LAA,B_SZA,B_SAA,LAT1,Surface_elevation,_to_MEAN_IWP_2C,_noise0.00,_0.mat');
0044 %
0045 %         %ccniwp.loadnets('/storage3/user_data/gerrit/neuralnets/avhrr_12345_mhs_345_lat_angles_all_global_MEAN_AVHRR_Y,1,2,3,4,5,B_BT,3,4,5,B_LZA,B_LAA,B_SZA,B_SAA,LAT1,_to_MEAN_IWP_2C,_noise0.00,_0.mat');
0046 %         %ccniwp.overwrite = 2;
0047 %
0048 %     end
0049     %D = datasets();
0050     %D
0051     %D.col_syn_iwp.find_granule_by_datetime(allgrans(i, :), sat)
0052     try
0053         D.col_syn_iwp.retrieve_and_store_granule(allgrans(i, :), sat);
0054     catch ME
0055         switch ME.identifier
0056             case {'atmlab:find_granule_by_datetime', 'atmlab:collocate', 'atmlab:CollocatedDataset:noother'}
0057                 logtext(atmlab('ERR'), 'Cannot retrieve for %s %s: %s\n', ...
0058                     'noaa18', num2str(allgrans(i, :)), ME.message);
0059                 continue
0060             otherwise
0061                 ME.rethrow();
0062         end
0063     end
0064     
0065 %     t = getCurrentTask();
0066 %     %D = datasets();
0067 %     if ~isfield(X, sprintf('no%d', t.ID))
0068 %         logtext(atmlab('OUT'), 'First run for %d\n', t.ID);
0069 %         X.(sprintf('no%d', t.ID)) = true;
0070 %     end
0071 end
0072 %{
0073     if ~isfield(D, 'mhs')
0074         startover();
0075         D = datasets();
0076     end
0077     if isfield(D, sprintf('col_syn_iwp%d', t.ID))
0078         ccniwp_local = D.(sprintf('col_syn_iwp%d', t.ID));
0079     else
0080         logtext(atmlab('OUT'), 'Creating ccniwp no %d\n', t.ID);
0081         ccniwp_local = CollocatedNNIWP('name', sprintf('col_syn_iwp%d', t.ID), ...
0082             'basedir', '/storage3/user_data/gerrit/products/passive_syn_iwp', ...
0083             'subdir', '$YEAR4/$MONTH/$DAY', ...
0084             'filename', '$SAT_$HOUR_$MINUTE.nc.gz');
0085         ccniwp_local.loadnets('/storage3/user_data/gerrit/neuralnets/avhrr_12345_mhs_345_lat_angles_all_global_MEAN_AVHRR_Y,1,2,3,4,5,B_BT,3,4,5,B_LZA,B_LAA,B_SZA,B_SAA,LAT1,_to_MEAN_IWP_2C,_noise0.00,_0.mat');
0086         ccniwp_local.overwrite = 2;
0087     end
0088 
0089     try
0090         ccniwp_local.retrieve_and_store_gran(allgrans(i, :), sat);
0091     catch ME
0092         switch ME.identifier
0093             case {'atmlab:find_granule_by_datetime', 'atmlab:collocate'}
0094                 logtext(atmlab('ERR'), 'Cannot retrieve for %s %s: %s\n', ...
0095                     'noaa18', num2str(allgrans(i, :)), ME.message);
0096                 continue
0097             otherwise
0098                 ME.rethrow();
0099         end
0100     end
0101 end
0102 %}
0103 
0104 %[result, additional_results, also] = D.collocation_mhs_avhrr.collocate_granule([2007, 1, 1, 1, 53], 'noaa18', 'noaa18', {D.associated_mhs_avhrr, D.collapsed_mhs_avhrr}, true);
0105 %[M, cols] = D.associated_mhs_avhrr.merge_matrix(result, D.collocation_mhs_avhrr.cols, additional_results{1}, D.associated_mhs_avhrr.cols);
0106 %[M, cols] = D.collapsed_mhs_avhrr.merge_matrix(M, cols, additional_results{2}, D.collapsed_mhs_avhrr.cols);
0107 
0108 %[iwp, lat, lon] = ccniwp.retrieve(M, cols, 0.5);
0109 
0110 %ccniwp.retrieve_and_store_gran([2007, 1, 1, 1, 53], 'noaa18');
0111 % flds = structfun(@(X) safegetfield(X, 'chans', -1), ud.inputs, 'UniformOutput', false);
0112 % fldsnms = fieldnames(flds);
0113 %
0114 % [Mp, cp] = get_columns(M, cols, flds);
0115 % for i = 1:length(fldsnms)
0116 %     fld = fldsnms{i};
0117 %     Mp(:, cp.(fld)) = ud.inputs.(fld).transform(Mp(:, cp.(fld)));
0118 % end
0119 %
0120 % lims.B_SZA = [0, 85];
0121 % limmer = collocation_restrain(Mp, limstruct2limmat(lims, cp));
0122 % Mp = Mp(limmer, :);
0123 % M = M(limmer, :); % for lat/lon/time still ekep track
0124 %
0125 % cloudy = cc.net.pat(Mp.');
0126 
0127 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005