Home > atmlab > arts > scenegen > asg2y_3d_1dbz_scene.m

asg2y_3d_1dbz_scene

PURPOSE ^

ASG2Y_3D_1DBZ_SCENE Performs 3D scattering calculations based on ASG data

SYNOPSIS ^

function [y,ydata,dy,G] =asg2y_3d_1dbz_scene(Gcs,grids_cs,Gdbz,grids_dbz,Q,workfolder)

DESCRIPTION ^

 ASG2Y_3D_1DBZ_SCENE   Performs 3D scattering calculations based on ASG data 

    Calculates spectrum/spectra considering scattering, where the spatial
    structure of the clouds is taken from radar data.

    The atmospheric scene is described by *Gcs* (clear sky fields) and *Gdbz*
    (radar and auxiliary data). These gformat arrays are initially handled
    seperately, mapped to grids specified by *grids_cs* and *grids_dbz*,
    respectively. The data and grids are later merged and arts is called to
    perform the calculations.

    Remaining data are specified by Q. Not all fields must be set. These 
    fields can be left undefined:
       ATMOSPHERE_DIM
       P_GRID
       LAT_GRID
       LON_GRID
       all fields set *asg2q*

    Note that batch calculations are not covered by this function.

 FORMAT   xxx
        
 OUT   y           As returned by *arts_y*.
       ydata       As returned by *arts_y*.
       dy          As returned by *arts_y*.
       G           modified G data
 IN    Gcs         Specification of clear sky fields, in gformat.
       grids_cs    Initial grids for clear sky fields. These grids are used
                   as put into Q before calling *asg_atmgrids*. Obtained
                   grids are used e.g. when calling *asg_rndmz* for clear 
                   sky fields. 
                   The input is given as an array of vectors, where element  
                   1 corresponds to Q.P_GRID, element 2 Q.LAT_GRID and 
                   element 3 Q.LON_GRID. 
       Gdbz        Field of radar dBz measurement, and possible additional 
                   data (such as lidar or Doppler data), in gformat.
                   Padding with zeros is made inside the function, and
                   *Gdbz* should only contain data corresponding to the 
                   "cloudy part" of the atmosphere.
       grids_dbz   As *grids_cs* but used for *Gdbz*.
       Q           Qarts structure. See above.
       workfolder  Used as input to *asg2q*.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg2y_3d_1dbz_scene.m

SOURCE CODE ^

0001 % ASG2Y_3D_1DBZ_SCENE   Performs 3D scattering calculations based on ASG data
0002 %
0003 %    Calculates spectrum/spectra considering scattering, where the spatial
0004 %    structure of the clouds is taken from radar data.
0005 %
0006 %    The atmospheric scene is described by *Gcs* (clear sky fields) and *Gdbz*
0007 %    (radar and auxiliary data). These gformat arrays are initially handled
0008 %    seperately, mapped to grids specified by *grids_cs* and *grids_dbz*,
0009 %    respectively. The data and grids are later merged and arts is called to
0010 %    perform the calculations.
0011 %
0012 %    Remaining data are specified by Q. Not all fields must be set. These
0013 %    fields can be left undefined:
0014 %       ATMOSPHERE_DIM
0015 %       P_GRID
0016 %       LAT_GRID
0017 %       LON_GRID
0018 %       all fields set *asg2q*
0019 %
0020 %    Note that batch calculations are not covered by this function.
0021 %
0022 % FORMAT   xxx
0023 %
0024 % OUT   y           As returned by *arts_y*.
0025 %       ydata       As returned by *arts_y*.
0026 %       dy          As returned by *arts_y*.
0027 %       G           modified G data
0028 % IN    Gcs         Specification of clear sky fields, in gformat.
0029 %       grids_cs    Initial grids for clear sky fields. These grids are used
0030 %                   as put into Q before calling *asg_atmgrids*. Obtained
0031 %                   grids are used e.g. when calling *asg_rndmz* for clear
0032 %                   sky fields.
0033 %                   The input is given as an array of vectors, where element
0034 %                   1 corresponds to Q.P_GRID, element 2 Q.LAT_GRID and
0035 %                   element 3 Q.LON_GRID.
0036 %       Gdbz        Field of radar dBz measurement, and possible additional
0037 %                   data (such as lidar or Doppler data), in gformat.
0038 %                   Padding with zeros is made inside the function, and
0039 %                   *Gdbz* should only contain data corresponding to the
0040 %                   "cloudy part" of the atmosphere.
0041 %       grids_dbz   As *grids_cs* but used for *Gdbz*.
0042 %       Q           Qarts structure. See above.
0043 %       workfolder  Used as input to *asg2q*.
0044 
0045 % 2007-11-28   Created by Patrick Eriksson and Bengt Rydberg.
0046 
0047 
0048 function [y,ydata,dy,G] = ...
0049                  asg2y_3d_1dbz_scene(Gcs,grids_cs,Gdbz,grids_dbz,Q,workfolder)
0050 
0051 %- Check input
0052 %
0053 % ???
0054 
0055 
0056 %- Some fixed settings
0057 %
0058 D = asgD;
0059 %
0060 Q.ATMOSPHERE_DIM = 3;
0061 
0062 
0063 %- Determine grids for clear sky fields
0064 %
0065 Q.P_GRID   = grids_cs{1};
0066 Q.LAT_GRID = grids_cs{2};
0067 Q.LON_GRID = grids_cs{3};
0068 %
0069 Q = asg_atmgrids( D, Gcs, Q );
0070 
0071 %This happens occasionally since the endpoints are
0072 %treated separately in the functions, and we remove it
0073 if Q.P_GRID(end)==Q.P_GRID(end-1)
0074    Q.P_GRID=Q.P_GRID(1:end-1);
0075 end
0076 
0077 %- Create final clear sky fields
0078 %
0079 Gcs = asg_dimadd( D, Gcs, Q );
0080 Gcs = asg_regrid( D, Gcs, Q );
0081 Gcs = asg_fixed_relhumid( D, Gcs );
0082 Gcs = asg_rndmz( D, Gcs );
0083 Gcs = asg_hydrostat( D, Gcs, Q );
0084 
0085 
0086 %- Determine grids for dbz field(s)
0087 %
0088 Q.P_GRID   = grids_dbz{1};
0089 Q.LAT_GRID = grids_dbz{2};
0090 Q.LON_GRID = grids_dbz{3};
0091 %
0092 Q = asg_atmgrids( D, Gdbz, Q );
0093 
0094 
0095 %- Create final dbz field(s)
0096 %
0097 Gdbz = asg_dimadd( D, Gdbz, Q );
0098 Gdbz = asg_regrid( D, Gdbz, Q );
0099 
0100 
0101 %- Determine merged grids
0102 %
0103 % Smallest scalar value (if exist) in grids_cs and grids_dbz is used
0104 % to remove very close grid points.
0105 %
0106 if isscalar( grids_cs{1} ),  step1=grids_cs{1};  else, step1=0; end
0107 if isscalar( grids_dbz{1} ), step2=grids_dbz{1}; else, step2=0; end
0108 Q.P_GRID = min( [ step1 step2] );
0109 %
0110 if isscalar( grids_cs{2} ),  step1=grids_cs{2};  else, step1=0; end
0111 if isscalar( grids_dbz{2} ), step2=grids_dbz{2}; else, step2=0; end
0112 Q.LAT_GRID = min( [ step1 step2] );
0113 %
0114 if isscalar( grids_cs{3} ),  step1=grids_cs{3};  else, step1=0; end
0115 if isscalar( grids_dbz{3} ), step2=grids_dbz{3}; else, step2=0; end
0116 Q.LON_GRID = min( [ step1 step2] );
0117 %
0118 
0119 Q = asg_atmgrids( D, [Gcs Gdbz], Q );
0120 
0121 
0122 %- Make final re-gridding of clear sky fields
0123 %
0124 % Hydrostatic eq. does not necesserily apply at "new" points
0125 %
0126 Gcs = asg_regrid( D, Gcs, Q );
0127 Gcs = asg_hydrostat( D, Gcs, Q );  
0128 
0129 
0130 %- Pad dbz fields with zeros
0131 %
0132 % These fields do not need to match grids in Q. A reinterpolation is anyhow
0133 % done in ARTS
0134 %
0135 Gdbz = asg_zeropad( D, Gdbz, Q);
0136 % As we fill data field with zeros, but the unit is in dBZe
0137 % we give all zero valued data the minimum value (-50 )
0138 Gdbz.DATA(find(Gdbz.DATA==0))=min(Gdbz.DATA(:));  
0139 
0140 
0141 %- Convert dbz field(s) to pnd fields but first regrid atmospheric fields
0142 %  to the dbz grid
0143 %
0144 Q1          = Q;
0145 Q1.P_GRID   = Gdbz.GRID1;
0146 Q1.LAT_GRID = Gdbz.GRID2;
0147 Q1.LON_GRID = Gdbz.GRID3;
0148 Gcs1        = asg_regrid( D, Gcs, Q1 );
0149 %
0150 Gdbz = asg_dbz2pnd( D, [Gcs1 Gdbz], Q ,Gdbz.PROPS);
0151 Gdbz = Gdbz(length(Gcs1)+1:end);
0152 
0153 %- Modify water vapour to match cloud distribution
0154 %
0155 % How?
0156 if 1
0157    Gcs=asg_iwc_relhumid(D,Gcs,Gdbz,Q);
0158    Gcs = asg_hydrostat( D, Gcs, Q );
0159 end
0160 
0161 %- Determine size of cloud box
0162 %
0163 iwc_ind = find( strcmp( lower({Gdbz.NAME}), 'iwc field' ) );
0164 %
0165 C1=[];
0166 C2=[];
0167 C3=[];
0168 C4=[];
0169 C5=[];
0170 C6=[];
0171 %
0172 for i=1:size(Gdbz(iwc_ind).DATA,3)
0173   [c1,c2]=find(Gdbz(iwc_ind).DATA(:,:,i));
0174   if ~isempty(c1)
0175      C1=min([C1,vec2col(c1)']);
0176   end
0177   if ~isempty(c1)
0178      C2=max([C2,vec2col(c1)']);
0179   end
0180   if ~isempty(c2)
0181      C3=min([C3,vec2col(c2)']);
0182   end
0183   if ~isempty(c2)
0184      C4=max([C4,vec2col(c2)']);
0185   end
0186 end
0187 %
0188 for i=1:size(Gdbz(iwc_ind).DATA,1)
0189   [c1,c2]=find(squeeze(Gdbz(iwc_ind).DATA(i,:,:)));
0190     if ~isempty(c2)
0191        C5=min([C5,vec2col(c2)']);
0192     end
0193     if ~isempty(c2)
0194        C6=max([C6,vec2col(c2)']);
0195    end
0196 end
0197 %
0198 
0199 if ~isempty(C1) %if C1 is empty we don't have any cloud particles
0200     p1   = Gdbz(iwc_ind).GRID1(C1);
0201     p2   = Gdbz(iwc_ind).GRID1(C2);
0202     lat1 = Gdbz(iwc_ind).GRID2(C3);
0203     lat2 = Gdbz(iwc_ind).GRID2(C4);
0204     z    = p2z_cira86([p1 p2]',mean([lat1 lat2]),160);
0205     lon1 = Gdbz(iwc_ind).GRID3(C5);
0206     lon2 = Gdbz(iwc_ind).GRID3(C6);
0207     %
0208     Q.CLOUDBOX.LIMITS = [z(1)-1e3 z(2)+1e3 lat1 lat2 lon1 lon2];
0209     
0210     %- Merge G arrays
0211     %
0212     G = [Gcs Gdbz];
0213 else
0214     G = Gcs;
0215 end
0216 
0217 %- Run ARTS
0218 %
0219 Q = asg2q( D, G, Q, workfolder );
0220 %
0221 [y,ydata,dy] = arts_y( Q, workfolder )
0222

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