Esempio n. 1
0
int getatmvariables(float mus, float muv, float phi, int16 height,
	unsigned char *process, float *sphalb, float *rhoray, float *TtotraytH2O,
	float *tOG)
{
	double m, Ttotrayu, Ttotrayd, tO3, tO2, tH2O;
	float psurfratio;
	int j, ib;
/*
Values for bands 9-16 below provided by B Murch and C Hu Univ South Florida
IMaRS, obtained from SEADAS.
For the moment I've retained the Jacques values for 1-8 but show the differing
SEADAS values in the commented out line.
*/
const float aH2O[Nbands]={0.000406601 ,0.0015933 , 0,1.78644e-05 ,0.00296457 ,0.000617252 , 0.000996563,0.00222253 ,0.00094005 , 0.000563288, 0, 0, 0, 0, 0, 0 };
const float bH2O[Nbands]={ 0.812659,0.832931 , 1., 0.8677850, 0.806816 , 0.944958 ,0.78812 ,0.791204 ,0.900564 ,0.942907 , 0, 0, 0, 0, 0, 0 };
/*const float aO3[Nbands]={ 0.0711,    0.00313, 0.0104,     0.0930,   0, 0, 0, 0.00244, 0.00383, 0.0225, 0.0663, 0.0836, 0.0485, 0.0395, 0.0119, 0.00263};*/
  const float aO3[Nbands]={ 0.0433461, 0.0,    0.0178299   ,0.0853012 , 0, 0, 0, 0.0813531,   0, 0, 0.0663, 0.0836, 0.0485, 0.0395, 0.0119, 0.00263};
/*const float taur0[Nbands] = { 0.0507,  0.0164,  0.1915,  0.0948,  0.0036,  0.0012,  0.0004,  0.3109, 0.2375, 0.1596, 0.1131, 0.0994, 0.0446, 0.0416, 0.0286, 0.0155};*/
  const float taur0[Nbands] = { 0.04350, 0.01582, 0.16176, 0.09740,0.00369 ,0.00132 ,0.00033 ,0.05373 ,0.01561 ,0.00129, 0.1131, 0.0994, 0.0446, 0.0416, 0.0286, 0.0155};

	float taur[Nbands], trup[Nbands], trdown[Nbands];
	static float sphalb0[MAXNUMSPHALBVALUES];
	static char first_time = TRUE;


	if (first_time) {
		sphalb0[0] = 0.0F;
		for(j = 1; j < MAXNUMSPHALBVALUES; j++)
			sphalb0[j] = csalbr(j * TAUSTEP4SPHALB);
		first_time = FALSE;
		}

	m = 1.0 / mus + 1.0 / muv;
	if (m > MAXAIRMASS) return -1;

	psurfratio = expf(-height / (float) SCALEHEIGHT);
	for (ib = 0; ib < Nbands; ib++)
		if (process[ib]) taur[ib] = taur0[ib] * psurfratio;

	chand(phi, muv, mus, taur, rhoray, trup, trdown, process);

	for (ib = 0; ib < Nbands; ib++) {
		if (!process[ib]) continue;

		if (taur[ib] / TAUSTEP4SPHALB >= MAXNUMSPHALBVALUES) {
			sphalb[ib] = -1.0F;
			/* Use sphalb as flag to indicate atm variables are not computed successfully */
			continue;
			}

		sphalb[ib] = sphalb0[(int)(taur[ib] / TAUSTEP4SPHALB + 0.5)];
		Ttotrayu = ((2 / 3. + muv) + (2 / 3. - muv) * trup[ib])   / (4 / 3. + taur[ib]);
		Ttotrayd = ((2 / 3. + mus) + (2 / 3. - mus) * trdown[ib]) / (4 / 3. + taur[ib]);
		tO3 = tO2 = tH2O = 1.0;
		if (aO3[ib] != 0) tO3 = exp(-m * UO3 * aO3[ib]);
		if (bH2O[ib] != 0) tH2O = exp(-(aH2O[ib]*(pow((m * UH2O),bH2O[ib]))));
/*
      t02 = exp(-m * aO2);
*/
		TtotraytH2O[ib] = Ttotrayu * Ttotrayd * tH2O;
		tOG[ib] = tO3 * tO2;
		}

  return 0;

}
Esempio n. 2
0
int update_gridcell_atmos_coefs(int irow,int icol,atmos_t *atmos_coef,Ar_gridcell_t *ar_gridcell, sixs_tables_t *sixs_tables,int **line_ar,Lut_t *lut,int nband, int bkgd_aerosol) {
    int ib,ipt,k;
    float mus,muv,phi,ratio_spres,tau_ray,aot550;
    double coef;
    float actual_rho_ray,actual_T_ray_up,actual_T_ray_down,actual_S_r;
    float rho_ray_P0,T_ray_up_P0,T_ray_down_P0,S_r_P0;
    float lamda[7]={486.,570.,660.,835.,1669.,0.,2207.};
    float tau_ray_sealevel[7]={0.16511,0.08614,0.04716,0.01835,0.00113,0.00037}; /* index=5 => band 7 */

    ipt=irow*ar_gridcell->nbcols+icol;	
    mus=cos(ar_gridcell->sun_zen[ipt]*RAD);
    muv=cos(ar_gridcell->view_zen[ipt]*RAD);
    phi=ar_gridcell->rel_az[ipt];
    ratio_spres=ar_gridcell->spres[ipt]/1013.;
/* eric is trying something */
/*                if ((irow == 53 )&&(icol == 83)) 
                  {
                  printf("let's see what is going on\n"); 
                  }
*/
    if (bkgd_aerosol) {
        atmos_coef->computed[ipt]=1;
        aot550=0.01;
    } else {
        if (line_ar[0][icol] != lut->aerosol_fill) {
            atmos_coef->computed[ipt]=1;
            aot550=((float)line_ar[0][icol]/1000.)*pow((550./lamda[0]),-1.);
        } else {
/*
  atmos_coef->computed[ipt]=0;
*/
                                
            atmos_coef->computed[ipt]=1;
            aot550=0.01;
        }
    }

    for (k=1;k<SIXS_NB_AOT;k++) {
        if (aot550 < sixs_tables->aot[k])
            break;
    }
    k--;
    if (k>=(SIXS_NB_AOT-1))
        k=SIXS_NB_AOT-2;
    coef=(aot550-sixs_tables->aot[k])/(sixs_tables->aot[k+1]-sixs_tables->aot[k]);

/*                printf("pressure ratio %d %d %f \n",irow,icol,ratio_spres);*/
    for (ib=0;ib < nband; ib++) {
        atmos_coef->tgOG[ib][ipt]=sixs_tables->T_g_og[ib];				
        atmos_coef->tgH2O[ib][ipt]=sixs_tables->T_g_wv[ib];				
        atmos_coef->td_ra[ib][ipt]=(1.-coef)*sixs_tables->T_ra_down[ib][k]+coef*sixs_tables->T_ra_down[ib][k+1];
        atmos_coef->tu_ra[ib][ipt]=(1.-coef)*sixs_tables->T_ra_up[ib][k]+coef*sixs_tables->T_ra_up[ib][k+1];
        atmos_coef->rho_mol[ib][ipt]=sixs_tables->rho_r[ib];				
        atmos_coef->rho_ra[ib][ipt]=(1.-coef)*sixs_tables->rho_ra[ib][k]+coef*sixs_tables->rho_ra[ib][k+1];
        atmos_coef->td_da[ib][ipt]=(1.-coef)*sixs_tables->T_a_down[ib][k]+coef*sixs_tables->T_a_down[ib][k+1];
        atmos_coef->tu_da[ib][ipt]=(1.-coef)*sixs_tables->T_a_up[ib][k]+coef*sixs_tables->T_a_up[ib][k+1];
        atmos_coef->S_ra[ib][ipt]=(1.-coef)*sixs_tables->S_ra[ib][k]+coef*sixs_tables->S_ra[ib][k+1];
/**
   compute DEM-based pressure correction for each grid point
**/
        tau_ray=tau_ray_sealevel[ib]*ratio_spres;
	
        chand(&phi,&muv,&mus,&tau_ray,&actual_rho_ray);

        actual_T_ray_down=((2./3.+mus)+(2./3.-mus)*exp(-tau_ray/mus))/(4./3.+tau_ray); /* downward */
        actual_T_ray_up = ((2./3.+muv)+(2./3.-muv)*exp(-tau_ray/muv))/(4./3.+tau_ray); /* upward */

        csalbr(&tau_ray,&actual_S_r);
						
        rho_ray_P0=sixs_tables->rho_r[ib];
        T_ray_down_P0=sixs_tables->T_r_down[ib];
        T_ray_up_P0=sixs_tables->T_r_up[ib];
        S_r_P0=sixs_tables->S_r[ib];

        atmos_coef->rho_ra[ib][ipt]=actual_rho_ray+(atmos_coef->rho_ra[ib][ipt]-rho_ray_P0); /* will need to correct for uwv/2 */
        atmos_coef->td_ra[ib][ipt] *= (actual_T_ray_down/T_ray_down_P0);
        atmos_coef->tu_ra[ib][ipt] *= (actual_T_ray_up/T_ray_up_P0);
        atmos_coef->S_ra[ib][ipt] = atmos_coef->S_ra[ib][ipt]-S_r_P0+actual_S_r;
        atmos_coef->td_r[ib][ipt] = actual_T_ray_down;
        atmos_coef->tu_r[ib][ipt]=actual_T_ray_up;
        atmos_coef->S_r[ib][ipt]=actual_S_r;
        atmos_coef->rho_r[ib][ipt]=actual_rho_ray;
					
        if ( is_ar_check_pixel(icol, irow) ) {
            printf( "   line_ar[0][%d]=%d, aot550=%.15g, k=%d, coef=%.15g\n", 
                    icol, line_ar[0][icol], aot550, k, coef );
            report_atmos_coef( atmos_coef, ib, ipt );
        }        
    }

    return 0;
}