next up previous
Next: Modifying magnitude.c and magmax.pro Up: Updating magmax, filter and Previous: Updating magmax, filter and

  
Calibration of new filters and SN spectra

The program for the calibration is norm_filter, its source (which has to changed) is norm_filter.so The program integrates a set of filters over either a spectrum of vega (for the calibration of filters) or a SN spectrum (for the calibration of this spectrum).

Calibrating a new filter
If you plan to plug in a new filter, the first step is to change the prototype definition of the struct corrections (at the beginning of the source code):


struct corrections
{
	double u;
	double b;
	double v;
	double r;
	double i;
	double j;
	double h;
	double k;
};

This structure is used to store the calibration data of the filters, so you have to make a new entry for your new filter (let's call it X for now). So you have to add in a new line at the end of struct corrections (after the line ``double k;'') which would have to look like: ``double x;'' The next step is to update the variable ``norm'' which is of type struct corrections. You just have to add ``,0'' right before the closing bracket in order to say that the current correction for the new filter x will be 0. Now you have to go to the main program ``int main (void)''. First of all, add the path of the new filter. Right below the beginning of ``main'' you will find a block of character array definitions. It starts like: char specpath[50]=''.... Before the end of these definitions, you add a new entry, xpath[50]='' <type the path of the filter here> '', just like the other entries. Also, make sure that the entry in specpath[50] is ``....vega_kim.dat'' which is the vega spectrum. The next definiton line in ``main'' is for the variables of type double. It starts with ``double *xu,*yu,....'' The names of the variables are x and y for each filter, e.g. u. So you have to add a new x and y for your filter, let's say *xx, *yx. The next definition line declares the integer variables, it starts with ``int error, i, spec,maxu,...'' You have to add a new max variable (the length of the arrays containing the filter data is stored in those), so you add ``,maxx'' before the ``;'' at the end fo the line. Now look at the program code. Find the statement ``spec=0''. After this statement, the filters are read in. You just take one of those read-in blocks, e.g.


error=readtable(upath,&xu,&yu,&maxu,spec);  /*read the table*/
if(error!=0)   /*if unable to read*/
{
	printf("error in readtable: %i $\backslash$npath: %s$\backslash$n",error,upath);
	return(1);
}
copy it so that the copied block is at the end of all those read-in blocks and modify it to your new defined variables for the new filters. So it would have to look like this:

error=readtable(xpath,&xx,&yx,&maxx,spec);  /*read the table*/
if(error!=0)   /*if unable to read*/
{
	printf("error in readtable: %i $\backslash$npath: %s$\backslash$n",error,xpath);
	return(1);
}
Note that if your filter is in Åinstead of nm, you have to convert it to Å. This is done for the J, H and K band filters, so for adding such a conversion for your filter, you can copy a block like:

for(i=1;i<=maxj;i++)
	xj[i]=xj[i]*10;
so that it is right behind your read-in block for the new filter and then modify it to:

for(i=1;i<=maxx;i++)
	xx[i]=xx[i]*10;
Now, search for the actual integration blocks. They start right behind the comment line ``/*integration*/'' and look like this:

error=integrate(xu,yu,xspec,yspec,maxu,maxspec,&result,'u');
if(error!=0)   /*if unable to integrate*/
{
	printf("error in u integrate: %i $\backslash$n",error);
	return(1);
}
printf("result in u: %2.50f$\backslash$n",result);
Again, you copy one of these blocks to the end of these integration blocks, and modify it like this:

error=integrate(xx,yx,xspec,yspec,maxx,maxspec,&result,'x');
if(error!=0)   /*if unable to integrate*/
{
	printf("error in x integrate: %i $\backslash$n",error);
	return(1);
}
printf("result in x: %2.50f$\backslash$n",result);
Right below the integration blocks, you will find lines like these:

free(xu);
free(yu);
They deallocate the memory used for the filters. At the end of these free-statements, add:

free(xx);
free(yx);
Now the onlly thing left to do is change the function ``integrate''. It is the function right above ``main''. At the end of function ``integrate'' you will find the following statement block:


switch(filter)
{
	case 'u':
		*result=*result+norm.u;
		break;
	case 'b':
		*result=*result+norm.b;
		break;
	case 'v':
		*result=*result+norm.v;
		break;
	case 'r':
		*result=*result+norm.r;
		break;
	case 'i':
		*result=*result+norm.i;
		break;
	case 'j':
		*result=*result+norm.j;
		break;
	case 'h':
		*result=*result+norm.h;
		break;
	case 'k':
		*result=*result+norm.k;
		break;
}
These statements add the value in the struct variable norm, depending on the filter. So, at the end, before the closing bracket, add:

case 'x':
	*result=*result+norm.x;
	break;
After all these changes have been made, recompile the source code with:
gcc -o norm_filter -lm -O2 norm_filter.c
and run it. It will print out the results of the integration of each filter with the vega spectrum. Take the result for your new filter, change the sign of the result and replace the 0 you entered in the declaration of ``norm'' with this number. Now, recompile the source code and run it again, the result for your filter should be 0. Now that you have the calibration, you have to change the source code of magnitude.so This is described in 2.6.2.

Calibrating a new spectrum
If you want to plug in a new spectrum, you first have to calibrate it which is described here. You will have to make some changes to the source code of norm_filter. Make sure that your spectrum is in Ångstrom. If it is in nm, convert it or add a conversion to the source code. In norm_filter.c, look at the beginnig of function ``main''. There's a block of char array declarations which contain the paths for the files. The declaration starts with ``char specpath[50]=...'' Change it to the path of the new spectrum you want to calibrate. A little bit further down, you will find the following if-block:


if(!strcmp(specpath,"/home/astro10/mwetzste/filters/sn_max.dat$\backslash$0"))
{
	for(i=1;i<=maxspec;i++)
		yspec[i]=yspec[i]*pow(10,(-20.01704286+19.46)/2.5);
}
Comment it out (place it between /* (at the beginning) and */ (at the end)). Now, recompile the source code and run it. In the printed messages you will find ``result in b: ....'' Now uncomment the if block above and replace the first number in the second argument of the pow function (-20.01704286) with the number you got as ``result in b'' In the first line of the if block, change the path to the path of the new spectrum as you have already specified it before in the declaration of specpath. Recompile the code and run it, the result in B band should now be -19.4600000... Now you have to make some changes to the source code of magnitude.so which is described below.


next up previous
Next: Modifying magnitude.c and magmax.pro Up: Updating magmax, filter and Previous: Updating magmax, filter and
Peter E. Nugent Jr.
1998-10-01