Home > atmlab > arts > scenegen > asg2y_1d_1dbz_scene.m

asg2y_1d_1dbz_scene

PURPOSE ^

ASG2Y_1D_1DBZ_SCENE Performs 1D scattering calculations based on ASG data

SYNOPSIS ^

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

DESCRIPTION ^

 ASG2Y_1D_1DBZ_SCENE   Performs 1D 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_1d_1dbz_scene.m

SOURCE CODE ^

0001 % ASG2Y_1D_1DBZ_SCENE   Performs 1D 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 % 2008-02-06   Created by Bengt Rydberg.
0046 
0047 
0048 function [y,ydata,dy,G] = ...
0049                  asg2y_1d_1dbz_scene(Gcs,grids_cs,Gdbz,grids_dbz,Q,workfolder)
0050 
0051 %- Check input
0052 %
0053 % ???
0054 
0055 %- Some fixed settings
0056 %
0057 D = asgD;
0058 %
0059 
0060 
0061 %- Determine grids for clear sky fields
0062 %
0063 Q.P_GRID   = grids_cs{1};
0064 if Q.ATMOSPHERE_DIM==3
0065    Q.LAT_GRID = grids_cs{2};
0066    Q.LON_GRID = grids_cs{3};
0067 end
0068 
0069 %
0070 Q = asg_atmgrids( D, Gcs, Q );
0071 
0072 %This happens occasionally since the endpoints are
0073 %treated separately in the functions, and we remove it
0074 if Q.P_GRID(end)==Q.P_GRID(end-1)
0075    Q.P_GRID=Q.P_GRID(1:end-1);
0076 end
0077 
0078 %- Create final clear sky fields
0079 %
0080 
0081 Gcs = asg_dimadd( D, Gcs, Q );
0082 Gcs = asg_regrid( D, Gcs, Q );
0083 Gcs = asg_fixed_relhumid( D, Gcs );
0084 Gcs = asg_rndmz( D, Gcs );
0085 Gcs = asg_hydrostat( D, Gcs, Q );
0086 
0087 
0088 %- Determine grids for dbz field(s)
0089 %
0090 Q.P_GRID   = grids_dbz{1};
0091 if Q.ATMOSPHERE_DIM==3
0092    Q.LAT_GRID = grids_dbz{2};
0093    Q.LON_GRID = grids_dbz{3};
0094 end
0095 %
0096 Q = asg_atmgrids( D, Gdbz, Q );
0097 
0098 
0099 %- Create final dbz field(s)
0100 %
0101 
0102 Gdbz = asg_dimadd( D, Gdbz, Q );
0103 Gdbz = asg_regrid( D, Gdbz, Q );
0104 
0105 
0106 %- Determine merged grids
0107 %
0108 % Smallest scalar value (if exist) in grids_cs and grids_dbz is used
0109 % to remove very close grid points.
0110 %
0111 if isscalar( grids_cs{1} ),  step1=grids_cs{1};  else, step1=0; end
0112 if isscalar( grids_dbz{1} ), step2=grids_dbz{1}; else, step2=0; end
0113 Q.P_GRID = min( [ step1 step2] );
0114 %
0115 if Q.ATMOSPHERE_DIM==3
0116    if isscalar( grids_cs{2} ),  step1=grids_cs{2};  else, step1=0; end
0117    if isscalar( grids_dbz{2} ), step2=grids_dbz{2}; else, step2=0; end
0118    Q.LAT_GRID = min( [ step1 step2] );
0119    %
0120    if isscalar( grids_cs{3} ),  step1=grids_cs{3};  else, step1=0; end
0121    if isscalar( grids_dbz{3} ), step2=grids_dbz{3}; else, step2=0; end
0122    Q.LON_GRID = min( [ step1 step2] );
0123    %
0124 end
0125 
0126 Q = asg_atmgrids( D, [Gcs Gdbz], Q );
0127 
0128 
0129 %- Make final re-gridding of clear sky fields
0130 %
0131 % Hydrostatic eq. does not necesserily apply at "new" points
0132 %
0133 Gcs = asg_regrid( D, Gcs, Q );
0134 Gcs = asg_hydrostat( D, Gcs, Q );  
0135 
0136 
0137 %- Pad dbz fields with zeros
0138 %
0139 % These fields do not need to match grids in Q. A reinterpolation is anyhow
0140 % done in ARTS
0141 %
0142 Gdbz = asg_zeropad( D, Gdbz, Q);
0143 % As we fill data field with zeros, but the unit is in dBZe
0144 % we give all zero valued data the minimum value (-50 )
0145 Gdbz.DATA(find(Gdbz.DATA==0))=-50;  
0146 
0147 
0148 %- Convert dbz field(s) to pnd fields but first regrid atmospheric fields
0149 %  to the dbz grid
0150 %
0151 Q1          = Q;
0152 Q1.P_GRID   = Gdbz.GRID1;
0153 if Q.ATMOSPHERE_DIM==3
0154    Q1.LAT_GRID = Gdbz.GRID2;
0155    Q1.LON_GRID = Gdbz.GRID3;
0156 end
0157 Gcs1        = asg_regrid( D, Gcs, Q1 );
0158 %
0159 Gdbz = asg_dbz2pnd( D, [Gcs1 Gdbz], Q ,Gdbz.PROPS);
0160 %remove atmospheric data from Gdbz
0161 Gdbz = Gdbz(length(Gcs1)+1:end);
0162 
0163 %- Modify water vapour to match cloud distribution
0164 %
0165 % How?
0166 Gcs=asg_iwc_relhumid(D,Gcs,Gdbz,Q);
0167 Gcs = asg_hydrostat( D, Gcs, Q );
0168 
0169 %- Determine size of cloud box
0170 %
0171 iwc_ind = find( strcmp( lower({Gdbz.NAME}), 'iwc field' ) );
0172 %
0173 C1=[];
0174 C2=[];
0175 C3=[];
0176 C4=[];
0177 C5=[];
0178 C6=[];
0179 %
0180 for i=1:size(Gdbz(iwc_ind).DATA,3)
0181   [c1,c2]=find(Gdbz(iwc_ind).DATA(:,:,i));
0182   if ~isempty(c1)
0183      C1=min([C1,vec2col(c1)']);
0184   end
0185   if ~isempty(c1)
0186      C2=max([C2,vec2col(c1)']);
0187   end
0188   if ~isempty(c2)
0189      C3=min([C3,vec2col(c2)']);
0190   end
0191   if ~isempty(c2)
0192      C4=max([C4,vec2col(c2)']);
0193   end
0194 end
0195 %
0196 for i=1:size(Gdbz(iwc_ind).DATA,1)
0197   [c1,c2]=find(squeeze(Gdbz(iwc_ind).DATA(i,:,:)));
0198     if ~isempty(c2)
0199        C5=min([C5,vec2col(c2)']);
0200     end
0201     if ~isempty(c2)
0202        C6=max([C6,vec2col(c2)']);
0203    end
0204 end
0205 %
0206 
0207 if ~isempty(C1) %if C1 is empty we don't have any cloud particles
0208     p1   = Gdbz(iwc_ind).GRID1(C1);
0209     p2   = Gdbz(iwc_ind).GRID1(C2);
0210     z    = p2z_cira86([p1 p2]',0,160);
0211     Q.CLOUDBOX.LIMITS = [z(1)-1e3 z(2)+1e3];
0212     if Q.ATMOSPHERE_DIM==3
0213        lat1 = Gdbz(iwc_ind).GRID2(C3);
0214        lat2 = Gdbz(iwc_ind).GRID2(C4);
0215        lon1 = Gdbz(iwc_ind).GRID3(C5);
0216        lon2 = Gdbz(iwc_ind).GRID3(C6);
0217        z    = p2z_cira86([p1 p2]',mean([lat1 lat2]),160);
0218        %
0219        Q.CLOUDBOX.LIMITS = [z(1)-1e3 z(2)+1e3 lat1 lat2 lon1 lon2];
0220     end
0221     %- Merge G arrays
0222     %
0223     G = [Gcs Gdbz];
0224 else
0225     G = Gcs;
0226     Q.CLOUDBOX_DO=0;
0227 end
0228 
0229 %- Run ARTS
0230 %
0231 Q = asg2q( D, G, Q, workfolder );
0232 Q                  = qarts_abstable( Q );
0233 Q.ABS_LOOKUP       = arts_abstable( Q );
0234 [y,ydata,dy] = arts_y( Q, workfolder )
0235     
0236

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