Home > atmlab > arts > scenegen > asg_iwc_relhumid.m

asg_iwc_relhumid

PURPOSE ^

ASG_IWC_RELHUMID modify the water vapour field in Gcs

SYNOPSIS ^

function Gcs=asg_iwc_relhumid(Gcs,Q)

DESCRIPTION ^

 ASG_IWC_RELHUMID modify the water vapour field in Gcs

 The function reguires that water vapour and
 temperatures are fields in Gcs, and iwc in
 Gdbz. The water vapor field is modified if
 the iwc is above zero in a given position. 
 A stochastic relative humidity field centered
 around 100% +-10% rhi is computed, and weighted with 
 the original relative humidity field (computed from 
 temperature and water vapour field).

 The "returned" relative humdity field is then
 rhi=w*rhi(stochastic)+(1-w)*rhi(original)
 where w=1-exp(-100*iwc)

 The relative humdity field is not returned,
 but the water vapour field in Gcs is modified.

 The grids of Q will determine the grids of
 of the water vapor data in the returned Gcs  

 OUT Gcs modified Gformat array

 IN  D    gformat definition structure
     Gcs  gformat atmospheric data
     Q    Qarts setting structure

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

asg_iwc_relhumid.m

SOURCE CODE ^

0001 % ASG_IWC_RELHUMID modify the water vapour field in Gcs
0002 %
0003 % The function reguires that water vapour and
0004 % temperatures are fields in Gcs, and iwc in
0005 % Gdbz. The water vapor field is modified if
0006 % the iwc is above zero in a given position.
0007 % A stochastic relative humidity field centered
0008 % around 100% +-10% rhi is computed, and weighted with
0009 % the original relative humidity field (computed from
0010 % temperature and water vapour field).
0011 %
0012 % The "returned" relative humdity field is then
0013 % rhi=w*rhi(stochastic)+(1-w)*rhi(original)
0014 % where w=1-exp(-100*iwc)
0015 %
0016 % The relative humdity field is not returned,
0017 % but the water vapour field in Gcs is modified.
0018 %
0019 % The grids of Q will determine the grids of
0020 % of the water vapor data in the returned Gcs
0021 %
0022 % OUT Gcs modified Gformat array
0023 %
0024 % IN  D    gformat definition structure
0025 %     Gcs  gformat atmospheric data
0026 %     Q    Qarts setting structure
0027 
0028 % 2007-12-12 created by Bengt Rydberg
0029 
0030 function Gcs=asg_iwc_relhumid(Gcs,Q)
0031 
0032 Q1=Q;
0033 
0034 %find indices
0035 water_ind=min(find(strncmp(lower({Gcs.DATA_NAME}),'h2o',3)));
0036 tem_ind=min(find(strncmp(lower({Gcs.DATA_NAME}),'temperature',11)));
0037 iwc_ind=min(find(strncmp(lower({Gcs.DATA_NAME}),'iwc',3)));
0038 
0039 if isempty(water_ind)
0040    error('water vapour must be included in Gcs')
0041 end
0042 
0043 if isempty(tem_ind)
0044    error('Temperature must be included in Gcs')
0045 end
0046 
0047 if isempty(iwc_ind)
0048    error('iwc must be included in Gdbz')
0049 end
0050 
0051 dim1=Gcs(water_ind).DIM;
0052 dim2=Gcs(tem_ind).DIM;
0053 dim3=Gcs(iwc_ind).DIM;
0054 
0055 %check dimensionality
0056 if ~any(dim1==dim2 & dim1==dim3)
0057 
0058    error('all data has not the same dimensions')
0059 
0060 end
0061 
0062 %reduce the resolution of Gcs in order to be able
0063 %to make perturbation while calling asg_rndmz
0064 %without memory problem
0065 dim=dim1;
0066 
0067 Q.P_GRID         = 1000/16e3;
0068 Q.LAT_GRID       =1;
0069 Q.LON_GRID       =1;
0070 Q.LAT_GRID = Gcs(iwc_ind).GRID2;
0071 Q.LON_GRID = Gcs(iwc_ind).GRID3;
0072 
0073 [grid1a] = gf_get_grid( Gcs(water_ind), 1 );
0074 [grid1b] = gf_get_grid( Gcs(iwc_ind), 1 );
0075 grid1=flipud(vec2col(sort(union(grid1a,grid1b))));
0076 grid1 = gridconvert( grid1, false, @log10, true );
0077 grid1 = gridthinning( grid1, Q.P_GRID );
0078 Q.P_GRID = gridconvert( grid1, true, @pow10 );
0079  
0080 if dim==3
0081   [grid1a] = gf_get_grid( Gcs(water_ind), 2 );
0082   [grid1b] = gf_get_grid( Gcs(iwc_ind), 2 );
0083   grid1=vec2col(sort(union(grid1a,grid1b)));
0084   grid1 = gridthinning( grid1, Q.LAT_GRID );
0085   Q.LAT_GRID=grid1;
0086 
0087   [grid1a] = gf_get_grid( Gcs(water_ind), 3 );
0088   [grid1b] = gf_get_grid( Gcs(iwc_ind), 3 );
0089   grid1=vec2col(sort(union(grid1a,grid1b)));
0090   grid1 = gridthinning( grid1, Q.LON_GRID );
0091   Q.LON_GRID=grid1;
0092 end
0093 
0094 
0095 Gcs1 = asg_regrid( Gcs([water_ind,tem_ind,iwc_ind]), Q );
0096 
0097 
0098 %create a random relative humidity field
0099 %
0100 Grhi=Gcs1(1);
0101 %set randomize parameters
0102 if dim<4
0103    RND.FORMAT    = 'param'; 
0104    RND.SEPERABLE = 1;
0105    RND.CCO       = 0.01;           % Cut-off for correlation values
0106    RND.TYPE      = 'rel';          % Relative disturbances as default
0107    RND.DATALIMS  = [0];            % Do not allow negative values
0108    %
0109    RND.SI        = 0.1;            % 10 % std. dev. as default
0110    %
0111    RND.CFUN1     = 'exp';              % Exp. correlation function for p-dim.
0112    RND.CL1       = [0.15 0.3 0.3]';    % Corr. length varies with altitude
0113    RND.CL1_GRID1 = [1100e2 10e2 1e-3];
0114 end
0115 
0116 if dim>1    
0117    %
0118    RND.CFUN2     = 'lin';            % Linear correlation function for lat-dim.
0119    RND.CL2       = 0.5;              % Corr. length 0.5 deg everywhere
0120    %
0121 end
0122 
0123 if dim>2
0124    RND.CFUN3     = 'lin';            % Linear correlation function for lat-dim.
0125    RND.CL3       = 0.5;              % Corr. length 0.5 deg everywhere
0126 end
0127 
0128 Grhi.RNDMZ=RND;
0129 
0130 %set the field to be 1==100%rhi
0131 Grhi.DATA=ones(size(Grhi.DATA));
0132 
0133 %perturb the field
0134 Grhi = asg_rndmz( Grhi );
0135 
0136 
0137 
0138 %Equilibrium water vapor pressure over ice
0139 ei = e_eq_ice(Gcs1(2).DATA);
0140 
0141 %create a pressure matrix
0142 P=zeros(size(Gcs1(3).DATA));
0143 if dim==1
0144    P=Gcs1(3).GRID1;
0145 end
0146 
0147 if dim>1
0148    p=vec2col(Gcs1(3).GRID1)*ones(1,length(Gcs1(3).GRID2));
0149    if dim==2
0150       P=p;
0151    else
0152       for i=1:length(Gcs1(3).GRID3)
0153           P(:,:,i)=p;
0154       end
0155    end
0156 end
0157 
0158 %relative humdity
0159 rhi=Gcs1(1).DATA.*P./ei;
0160 
0161 %weights
0162 %an iwc of 0.1 will give 100% weight to the stochastic value
0163 %0.01 63%
0164 %0.001 10%
0165 %0.0001 1%
0166 w=1-exp(-100*Gcs1(3).DATA);
0167 
0168 %apply the weights
0169 rhi=w.*Grhi.DATA+(1-w).*rhi;
0170 
0171 %transform back to vmr
0172 Gcs1(1).DATA=rhi.*ei./P;
0173 
0174 %regrid back to input grids
0175 Gcs(water_ind)=asg_regrid(Gcs1(1),Q1);

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