| 37 | | DEFINITION PARAMETERS () |
| 38 | | SETTING PARAMETERS (sig_x=1,sig_y=0,sigPr_x=0,sigPr_y=0,flux=1,dist=1,gamma=0,E0=0, dE=0, lambda0=0,dlambda=-1,phase=-1) |
| | 37 | DEFINITION PARAMETERS (string spectrum_file=NULL) |
| | 38 | SETTING PARAMETERS (sig_x=1,sig_y=0,sigPr_x=0,sigPr_y=0,flux=1,dist=1,gauss=0,gamma=0,E0=0, dE=0, lambda0=0,dlambda=-1,phase=-1) |
| 65 | | |
| 66 | | if (E0){ |
| 67 | | lambda0=2*M_PI/(E0*E2K); |
| | 70 | |
| | 71 | if (spectrum_file){ |
| | 72 | /*read spectrum from file*/ |
| | 73 | int status=0; |
| | 74 | if ( (status=Table_Read(&(prms.T),spectrum_file,0))==-1){ |
| | 75 | fprintf(stderr,"Source_gaussian(%s) Error: Could not parse file \"%s\"\n",NAME_CURRENT_COMP,spectrum_file); |
| | 76 | exit(-1); |
| | 77 | } |
| | 78 | /*data is now in table t*/ |
| | 79 | /*integrate to get total flux, assuming numbers have been corrected for measuring aperture*/ |
| | 80 | int i; |
| | 81 | prms.pint=0; |
| | 82 | t_Table *T=&(prms.T); |
| | 83 | for (i=0;i<prms.T.rows-1;i++){ |
| | 84 | prms.pint+=((T->data[i*T->columns+1]+T->data[(i+1)*T->columns+1])/2.0)*(T->data[(i+1)*T->columns]-T->data[i*T->columns]); |
| | 85 | } |
| | 86 | printf("Source_gaussian(%s) Integrated intensity radiated is %g pht/s\n",NAME_CURRENT_COMP,prms.pint); |
| | 87 | if(E0) printf("Source_gaussian(%s) E0!=0 -> assuming intensity spectrum is parametrized by energy [keV]\n",NAME_CURRENT_COMP); |
| | 88 | } else if (E0){ |
| | 89 | lambda0=2*M_PI/E2K * (E0/(E0*E0-dE*dE)); |
| 104 | | F1=Gauss2D(sig_x,sig_y,x,y,pmul); |
| 105 | | |
| 106 | | if (dlambda){ |
| 107 | | l=lambda0+dlambda*randnorm(); |
| | 123 | F1=Gauss2D(sig_x,sig_y,x,y,prms.pmul); |
| | 124 | |
| | 125 | if (spectrum_file){ |
| | 126 | double pp=0; |
| | 127 | //while (pp<=0){ |
| | 128 | l=prms.T.data[0]+ (prms.T.data[(prms.T.rows-1)*prms.T.columns] -prms.T.data[0])*rand01(); |
| | 129 | pp=Table_Value(prms.T,l,2); |
| | 130 | //} |
| | 131 | p*=pp; |
| | 132 | /*if E0!=0 convert the tabled value to wavelength*/ |
| | 133 | if (E0) { |
| | 134 | l=2*M_PI/(l*1e-3*E2K); |
| | 135 | } |
| | 136 | }else if (dlambda){ |
| | 137 | if (gauss){ |
| | 138 | l=lambda0+dlambda*randnorm(); |
| | 139 | }else{ |
| | 140 | l=randpm1()*dlambda*0.5 + lambda0; |
| | 141 | } |