% Overall initialization script for the analysis code. Simply
% performs miscellaneous initializations of various variables
% set by the ubiquitous user and other wascally wabbits.

% Note, there is a tendency here to make global variables of
% type 'struct'. The reason for this is that in MatLab, when
% one declares a global variable, that variable is automatically
% made of type double. If one tries to then assign, say, a char
% value to the variable, this produces an error message. However,
% one can convert a double global to a struct global with no 
% problems. I don't know the reason for this; I only work here...
%
% Another way around this problem is to declare a variable as 
% global after one has assigned a value to it. Then the global
% can be of any type, but MatLab gives a warning message to
% the effect that this sort of thing will not be allowed in
% future versions of MatLab. So I have avoided doing this.

clear global n_abs n_pix abs_gas abs_ex dir

global n_abs		% # of absorber gases
global n_pix		% # of pixels on the horizontal axis of our CCD
global dir			% directory pathnames (struct)
global filenames	% various filenames (struct)
% Struct fields of "filenames":
%		file_nms			char 2d matrix, stores filenames of data spectra (1 per row)
%		std_name			filename of absolute reference spectrum
%		cs_data			char 2d matrix, contains names of files storing cross section data
global abs_ex		% sets wavelength regions for absorber cross sections that are to
						% be excluded from a global SCD fit.
% Struct fields of "abs_ex":                  
%		low_cut			lower wavelength limit (nanometers)
% 		high_cut			upper wavelength limit (nanometers)
global data_ex		% allows us to exclude regions of data from a global SCD fit
% Struct fields of "data_ex": same as for "abs_ex".

n_abs = 7;

n_pix = 2000;

% Cell array "abs" tells us which indices correspond to various absorber gases:
abs_gas(1) = {'O3'};
abs_gas(2) = {'NO2'};
abs_gas(3) = {'OClO'};
abs_gas(4) = {'O4'};
abs_gas(5) = {'H2O'};
abs_gas(6) = {'BrO'};
abs_gas(7) = {'Ring effect'};		
% If we are using NO3 instead of the Ring effect, then READ.M will change the 
% value of abs_gas(7).

% Struct "dir" is used to store directory pathnames
dir.ip = '..\input_files\';	% Directory path to the input files required by READ.M
dir.data = strcat(dir.ip,'data_files\');	% Directory path to the data files 
														% (output from DOASDATA program)
dir.cs_op = '..\Mat_files\';	% Directory path for storing cross section variables

%REQUIRED DIRECTORY STRUCTURE:
% 													CONTENTS:								
%		Analyse									Parent directory
%			|
%			|___Input_code					M-files (ie code) for data input tasks
%			|
%			|___Input_files				Input files (eg analyse.txt, etc)
%			|		|
%			|		|___Data_files			Files containing the spectra to be analysed
%			|
%			|___Mat_files					directory for storing useful .mat files
%			|
%			|___Calib_code					M-files for calibration of spectra

disp(['Warning: Occasionally, MatLab spits out totally useless warning messages.'])
global abs_gas		% names of absorber gases
disp(['Warning: Your coffee is getting cold.'])

% Note: it is important to declare the above variables as global _after_ values
% have been assigned to them. Otherwise, MatLab will force them to be of
% type double.
% 		Doing this does generate an warning message, but we can just ignore it
% for now. 

% Struct "data_ex" lets us exclude regions of data from the fits.
% Fields:
%		low_cut			lower wavelength limit (nanometers)
% 		high_cut			upper wavelength limit (nanometers)
data_ex.low_cut	= 300;
data_ex.high_cut	= 600;

% Struct array "abs_ex" lets us exclude cross section regions from a global SCD
% fit. Indices correspond to absorber gases.
% Fields:
%		low_cut			lower wavelength limit (nanometers)
% 		high_cut			upper wavelength limit (nanometers)
abs_ex(1).low_cut 	= 320;		% O3
abs_ex(1).high_cut 	= 600;
abs_ex(2).low_cut 	= 320;		% NO2
abs_ex(2).high_cut 	= 550;
abs_ex(3).low_cut 	= 300;		% OClO
abs_ex(3).high_cut 	= 470;
abs_ex(4).low_cut 	= 340;		% O4
abs_ex(4).high_cut 	= 600;
abs_ex(5).low_cut 	= 495;		% H2O
abs_ex(5).high_cut 	= 604;
abs_ex(6).low_cut 	= 320;		% BrO
abs_ex(6).high_cut 	= 380;
abs_ex(7).low_cut		= 320;		% Ring or NO3
abs_ex(7).high_cut	= 550;	
% I've set current values of low_cut and high_cut by looking at the cross sections
% in Deb Fish's these, pg 84 (July 20)
% BUT this wasn't a very good idea, because in SEQ_EST.FOR, there are wavelength
% regions for analysis given. (Aug 19)

