source:
issm/oecreview/Archive/12221-12240/ISSM-12230-12231.diff
Last change on this file was 12325, checked in by , 13 years ago | |
---|---|
File size: 8.3 KB |
-
proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/Container/Observations.cpp
112 112 113 113 if(nobs==0){ 114 114 /*No observation found, double range*/ 115 printf("No observation found within range, doubling range\n");115 //printf("No observation found within range, doubling range\n"); 116 116 xfree((void**)&indices); 117 117 this->ObservationList(&x,&y,&obs,&nobs,x_interp,y_interp,range*2); 118 118 } 119 119 else{ 120 if(nobs>1000) printf("Taking more than 1000 observations\n");120 //if(nobs>1000) printf("Taking more than 1000 observations\n"); 121 121 /*Allocate vectors*/ 122 122 x = (double*)xmalloc(nobs*sizeof(double)); 123 123 y = (double*)xmalloc(nobs*sizeof(double)); -
proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/modules/Krigingx/Krigingx.cpp
15 15 #endif 16 16 17 17 #include "../../objects/Kriging/GaussianVariogram.h" 18 /*FUNCTION Krigingx{{{*/ 18 19 int Krigingx(double** ppredictions,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){ 19 20 20 21 /*output*/ 21 22 double *predictions = NULL; 22 23 23 24 /*Intermediaries*/ 24 int i,j,n_obs;25 25 double range; 26 double numerator,denominator,ratio;27 double *x = NULL;28 double *y = NULL;29 double *obs = NULL;30 double *Gamma = NULL;31 double *GinvG0 = NULL;32 double *Ginv1 = NULL;33 double *GinvZ = NULL;34 double *gamma0 = NULL;35 double *ones = NULL;36 26 char *output = NULL; 37 27 Variogram *variogram = NULL; 38 28 Observations *observations = NULL; 39 29 30 /*threading: */ 31 KrigingxThreadStruct gate; 32 int num=1; 33 #ifdef _MULTITHREADING_ 34 num=_NUMTHREADS_; 35 #endif 36 40 37 /*Get Variogram from Options*/ 41 38 ProcessVariogram(&variogram,options); 42 39 options->Get(&range,"searchrange",0.); … … 44 41 /*Process observation dataset*/ 45 42 observations=new Observations(obs_list,obs_x,obs_y,obs_length,options); 46 43 47 /*Allocat ionoutput*/44 /*Allocate output*/ 48 45 predictions =(double*)xmalloc(n_interp*sizeof(double)); 49 for(i =0;i<n_interp;i++) predictions[i]=0;46 for(int i=0;i<n_interp;i++) predictions[i]=0; 50 47 51 48 /*Get output*/ 52 options->Get(&output,"output"," quadtree");49 options->Get(&output,"output","prediction"); 53 50 54 51 if(strcmp(output,"quadtree")==0){ 55 52 observations->QuadtreeColoring(predictions,x_interp,y_interp,n_interp); 56 *ppredictions=predictions;57 return 1;58 53 } 59 if(strcmp(output,"variomap")==0){54 else if(strcmp(output,"variomap")==0){ 60 55 observations->Variomap(predictions,x_interp,n_interp); 61 *ppredictions=predictions;62 return 1;63 56 } 57 else if(strcmp(output,"prediction")==0){ 64 58 65 /*Loop over all interpolations*/ 66 printf(" interpolation progress: %5.2lf %%",0.0); 67 for(int idx=0;idx<n_interp;idx++){ 68 if(idx%10==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)idx/n_interp*100); 59 /*initialize thread parameters: */ 60 gate.n_interp = n_interp; 61 gate.x_interp = x_interp; 62 gate.y_interp = y_interp; 63 gate.range = range; 64 gate.variogram = variogram; 65 gate.observations = observations; 66 gate.predictions = predictions; 69 67 68 /*launch the thread manager with Krigingxt as a core: */ 69 LaunchThread(Krigingxt,(void*)&gate,num); 70 } 71 else{ 72 _error_("output '%s' not supported yet",output); 73 } 74 75 /*clean-up and Assign output pointer*/ 76 delete variogram; 77 delete observations; 78 xfree((void**)&output); 79 *ppredictions=predictions; 80 return 1; 81 }/*}}}*/ 82 /*FUNCTION Krigingxt{{{*/ 83 void* Krigingxt(void* vpthread_handle){ 84 85 /*gate variables :*/ 86 KrigingxThreadStruct *gate = NULL; 87 pthread_handle *handle = NULL; 88 int my_thread; 89 int num_threads; 90 int i0,i1; 91 92 /*recover handle and gate: */ 93 handle = (pthread_handle*)vpthread_handle; 94 gate = (KrigingxThreadStruct*)handle->gate; 95 my_thread = handle->id; 96 num_threads = handle->num; 97 98 /*recover parameters :*/ 99 int n_interp = gate->n_interp; 100 double *x_interp = gate->x_interp; 101 double *y_interp = gate->y_interp; 102 double range = gate->range; 103 Variogram *variogram = gate->variogram; 104 Observations *observations = gate->observations; 105 double *predictions = gate->predictions; 106 107 /*Intermediaries*/ 108 int i,j,n_obs; 109 double numerator,denominator,ratio; 110 double *x = NULL; 111 double *y = NULL; 112 double *obs = NULL; 113 double *Gamma = NULL; 114 double *GinvG0 = NULL; 115 double *Ginv1 = NULL; 116 double *GinvZ = NULL; 117 double *gamma0 = NULL; 118 double *ones = NULL; 119 120 /*partition loop across threads: */ 121 if(my_thread==0) printf(" interpolation progress: %5.2lf %%",0.0); 122 PartitionRange(&i0,&i1,n_interp,num_threads,my_thread); 123 for(int idx=i0;idx<i1;idx++){ 124 if(my_thread==0 && idx%10==0) printf("\b\b\b\b\b\b\b%5.2lf %%",double(idx-i0)/double(i1-i0)*100); 125 70 126 /*Get list of observations for current point*/ 71 127 observations->ObservationList(&x,&y,&obs,&n_obs,x_interp[idx],y_interp[idx],range); 72 128 … … 88 144 for(i=0;i<n_obs;i++) gamma0[i] = variogram->SemiVariogram(x[i]-x_interp[idx],y[i]-y_interp[idx]); 89 145 90 146 /*Solve the three linear systems*/ 91 GslSolve(&GinvG0,Gamma,gamma0,n_obs); 92 GslSolve(&Ginv1, Gamma,ones,n_obs); 93 GslSolve(&GinvZ, Gamma,obs,n_obs); // Gamma^-1 Z147 GslSolve(&GinvG0,Gamma,gamma0,n_obs); // Gamma^-1 gamma0 148 GslSolve(&Ginv1, Gamma,ones,n_obs); // Gamma^-1 ones 149 GslSolve(&GinvZ, Gamma,obs,n_obs); // Gamma^-1 Z 94 150 95 151 /*Prepare predictor*/ 96 152 numerator=-1.; denominator=0.; … … 112 168 xfree((void**)&Ginv1); 113 169 xfree((void**)&GinvZ); 114 170 } 115 printf("\b\b\b\b\b\b\b\b%5.2lf %%\n",100.0);171 if(my_thread==0) printf("\b\b\b\b\b\b\b\b%5.2lf %%\n",100.0); 116 172 117 /*clean-up and Assign output pointer*/ 118 delete variogram; 119 delete observations; 120 xfree((void**)&output); 121 *ppredictions=predictions; 122 return 1; 123 } 173 return NULL; 174 }/*}}}*/ 124 175 125 176 void ProcessVariogram(Variogram **pvariogram,Options* options){/*{{{*/ 126 177 -
proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/modules/Krigingx/Krigingx.h
8 8 #include "../../objects/objects.h" 9 9 #include "../../toolkits/toolkits.h" 10 10 11 class Observations; 12 class Variogram; 13 11 14 int Krigingx(double** ppredictions,double* x, double* y, double* observations, int n_obs,double* x_interp,double* y_interp,int n_interp,Options* options); 12 15 void ProcessVariogram(Variogram **pvariogram,Options* options); 13 16 void GslSolve(double** pX,double* A,double* B,int n); 14 17 18 /*threading: */ 19 typedef struct{ 20 int n_interp; 21 double *x_interp; 22 double *y_interp; 23 double range; 24 Variogram *variogram; 25 Observations *observations; 26 double *predictions; 27 }KrigingxThreadStruct; 28 29 void* Krigingxt(void*); 15 30 #endif /* _KRIGINGX_H */ -
proj/ice/larour/issm-uci-clean/trunk-jpl/src/c/modules/Shp2Kmlx/Shp2Kmlx.h
21 21 #include "../../objects/objects.h" 22 22 23 23 /* local prototypes: */ 24 int Shp2Kmlx(char* filshp,char* filkml, 25 int sgn); 26 int Shp2Kmlx(char* filshp,char* filkml, 27 int sgn,double cm,double sp); 24 int Shp2Kmlx(char* filshp,char* filkml, int sgn); 25 int Shp2Kmlx(char* filshp,char* filkml, int sgn,double cm,double sp); 28 26 29 27 #endif /* _SHP2KMLX_H */
Note:
See TracBrowser
for help on using the repository browser.