%create_ctd_calfile
%  a routine for manual entry of CTD calibration constants and creation
%  of the mat file that will be accessed by the MMP_pgrid routine

disp(['Routine for manual entry of CTD calibration constants']);

	disp([' ']);

		serial_ID=input('Enter serial number ID of this CTD sensor : ');
                myname=input('Enter your name :  ','s');
         	disp([' '])
                calperson=input('Enter the name of the person who did CTD the calibration run:   ','s');
                caldate=input('Enter date of CTD calibration run:    ','s');
         	disp([' '])
                fitperson=input('Enter the name of the person who did regression fits:   ','s');
                fitdate=input('Enter date the regression fits were performed:    ','s');
                fitfile=input('For reference, enter the path and name of the data file with regression fit info:  ','s');
         	disp([' '])
         	disp([' '])
         	disp(['Enter any specific comments which need to be carried along']);
         	disp(['regarding this sensor and it''s calibration:']);
         	disp(['(Do not press return until finished with comments!)']);
                disp(' ');
                comments=input('         ','s');
                create_date=date;


	disp([' ']);
disp([' For each sensor (P,T,C) you will enter coefficients of a calibration polynomial of the form: ']);
disp(['      true_values = polyval(coefs,raw_values);']);

	disp([' ']);
		order=input('What order polynomial do you wish for Pressure? ');
			ii=0;
			for i=order:-1:0
			ii=ii+1
		p_coefs(ii)=input(['Enter the coefficient of the term P^',num2str(i),': ']);
			end


	disp([' ']);
		order=input('What order polynomial do you wish for Temperature? ');
			ii=0;
			for i=order:-1:0
			ii=ii+1
		t_coefs(ii)=input(['Enter the coefficient of the term T^',num2str(i),': ']);
			end


	disp([' ']);
		order=input('What order polynomial do you wish for Conductivity? ');
			ii=0;
			for i=order:-1:0
			ii=ii+1
		c_coefs(ii)=input(['Enter the coefficient of the term C^',num2str(i),': ']);
			end

	disp([' ']);
		tlag=input('Lastly, please enter the tlag to be used in C-T lag correction: ');

		
	disp([' ']);
	disp([' ']);
        outfile=input('FINALLY, Please enter the path and name of the new file to write with these data: ','s');


                documentation=(['This matlab file, ',outfile,',',...
                sprintf('\n'),'     was created by ',myname,' on ',date,...
                sprintf('\n'),'     using mfile, create_ctd_calfile.m.',...
                sprintf('\n'),...
                sprintf('\n'),'The terms P_COEFS, T_COEFS, AND C_COEFS were determined ',...
                sprintf('\n'),'    by regression fits to laboratory calibrations.',...
                sprintf('\n'),...
                sprintf('\n'),'The lab calibrations were performed by ',calperson,'  on ',caldate,' .  ',...
                sprintf('\n'),'Regression fits to those were performed by ',fitperson,'  on ',fitdate,' .  ',...
                sprintf('\n'),...
                sprintf('\n'),'The name of ',fitperson,'''s output regression fit file is:',...
                sprintf('\n'),'      ' fitfile,...
                sprintf('\n'),...
                sprintf('\n'),'The TLAG term was estimated by looking at the down vs the up ctd data.',...
                sprintf('\n'),sprintf('\n'),sprintf('\n'),'Special comments:  ',sprintf('\n'),comments]);


eval(['save ',outfile,' serial_ID p_coefs t_coefs c_coefs tlag documentation']);



