Home > atmlab > collocations > AssociatedPOESPlusCPR.m

AssociatedPOESPlusCPR

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

AssociatedPOESPlusCPR.m

SOURCE CODE ^

0001 classdef AssociatedPOESPlusCPR < FieldMultiInstrumentCopier
0002     % Add AMSU-A, HIRS to MHS-CPR
0003     %
0004     % WORK IN PROGRESS!
0005     
0006     % $Id: AssociatedPOESPlusCPR.m 8516 2013-06-26 21:33:48Z gerrit $
0007     
0008     properties (Transient)
0009                 
0010         % For instruments sharing a platform with the primary
0011         %
0012         % FIXME DOC
0013         fieldcopier_other_primary = struct();
0014         
0015         % For instruments sharing a platform with the secondary
0016         %
0017         % FIXME DOC
0018         fieldcopier_other_secondary = struct();
0019         
0020 %        members;
0021     end
0022     
0023     methods
0024         %% constructor
0025         
0026         function self = AssociatedPOESPlusCPR(pparent, f_mhs, f_amsua, f_hirs, f_cpr, varargin)
0027             % Create AssociatedPoesPlusCPR object
0028             %
0029             % IN
0030             %
0031             %   parent      either mhs_cpr or amsub_cpr
0032             %   f_mhs       struct      fields from MHS
0033             %   f_amsua     struct      fields from AMSUA
0034             %   f_hirs      struct      fields from HIRS
0035             %   f_cpr       struct      fields from CPR
0036             %
0037             % FIXME DOC
0038             
0039             %d = datasets;
0040             self = self@FieldMultiInstrumentCopier(pparent, {}, varargin{:});
0041             
0042             self.dynamic_members = true;
0043             
0044             self.parent = pparent;
0045             self.fieldcopier_core = FieldCopier(self.parent, f_mhs, f_cpr, 'name', [self.name '_sub_mhs_cpr'], 'visible', false);
0046             self.fieldcopier_other_primary.amsua = FieldCopier(self.parent, f_amsua, struct(), 'name', [self.name '_sub_amsua'], 'visible', false);
0047             self.fieldcopier_other_primary.hirs = FieldCopier(self.parent, f_hirs, struct(), 'name', [self.name '_sub_hirs'], 'visible', false);
0048             
0049             if length(fieldnames(self.members)) < (...
0050                     length(fieldnames(self.fieldcopier_other_primary.amsua.members)) + ...
0051                     length(fieldnames(self.fieldcopier_other_primary.hirs.members)) + ...
0052                     length(fieldnames(self.fieldcopier_core.members)))
0053                 error(['amtlab:' mfilename], 'Duplicate fieldnames found!');
0054             end
0055             
0056             %            self.fieldstruct_mhs = f_mhs;
0057 %            self.fieldstruct_amsua = f_amsua;
0058 %            self.fieldstruct_hirs = f_hirs;
0059         end               
0060        
0061         %% overload parent methods
0062         
0063         function store(self, varargin)
0064             store@FieldMultiInstrumentCopier(self, varargin{:});
0065         end
0066         
0067     end
0068     
0069     methods (Access = protected)
0070         %% implementation of abstract methods
0071                 
0072         function [newline, newpos] = translate(self, processed_core, data_orig, dsname, data_other)
0073                         
0074             origline = processed_core(:, self.parent.cols.LINE1);
0075             origpos = processed_core(:, self.parent.cols.POS1);
0076 
0077             if size(origline, 1)==0
0078                 newline = origline;
0079                 newpos = origpos;
0080                 return
0081             end
0082 
0083             switch dsname
0084                 case 'amsua'
0085                     [aah, aaw] = size(data_other.lon);
0086                     newline = min(max(round(origline/3), 1), aah);            
0087                     newpos = min(max(round(origpos/3), 1), aaw);
0088                 case 'hirs'
0089                     newline = arrayfun(...
0090                         @(v) self.mini(abs(data_other.time-v)), ...
0091                         data_orig.time(origline));
0092                     newpos = arrayfun(...
0093                         @(i) self.mini(...
0094                         (data_other.lat(newline(i), :)-processed_core(i, self.parent.cols.LAT2)).^2 + ...
0095                         (data_other.lon(newline(i), :)-processed_core(i, self.parent.cols.LON2)).^2 ...
0096                         ), 1:size(processed_core, 1));
0097                 otherwise
0098                     error(['atmlab:' mfilename ':sorry'], ...
0099                         'I don''t know what to do with %s', dsname);
0100             end
0101 
0102         end
0103     end
0104     
0105     methods (Access = {?HomemadeDataset})
0106         function mem = dynamically_get_members(self)
0107 %            logtext(atmlab('OUT'), 'Getting APPC-mems\n');
0108             % FIXME! This should be better implemented.  This wastes a HUGE
0109             % amount of time!
0110             mem = catstruct(self.fieldcopier_core.members, ...
0111                 self.fieldcopier_other_primary.amsua.members, ...
0112                 self.fieldcopier_other_primary.hirs.members);
0113 %             mem = self.members;
0114         end
0115     end
0116     
0117     methods (Static, Access = private)
0118         function i = mini(v)
0119             % mini return index for minimum of v (arrayfun wants 1 output)
0120             [~, i] = min(v);
0121         end
0122     end
0123 
0124 end

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