/* element of projection --> multplication of (redshifted by cr_z) spectrum * and the filter */ float rb_pixel(float lambda) { float sl,spectrum; unsigned long i,ip1; k_locate(rb_lambda, rb_nl, lambda, &i); if(i>=rb_nl-1 || i<0) return(0.); ip1=i+1; sl=(lambda-rb_lambda[i])/(rb_lambda[ip1]-rb_lambda[i]); spectrum=rb_spectrum[i]+sl*(rb_spectrum[ip1]-rb_spectrum[i]); return(spectrum); } /* end filter */
/* linear interpolate in a given vector; out of bounds --> 0 */ float k_interpolate(float currpos, float vals[], float pos[], IDL_LONG n) { unsigned long i,ip1; float sp,currval; k_locate(pos, (unsigned long) n, currpos, &i); if(i>=n-1) return(vals[n-1]); if(i<0) return(vals[0]); ip1=i+1; sp=currpos-pos[i]; currval=vals[i]+sp*(vals[ip1]-vals[i])/(pos[ip1]-pos[i]); return(currval); } /* end interpolate templates */