Home > ctdcal > create_cruise_dir.m

create_cruise_dir

PURPOSE ^

create_cruise_dir: Setup a new working directory for CTD calibration.

SYNOPSIS ^

function [newPath] = create_cruise_dir(parentdir,cruiseid)

DESCRIPTION ^

 create_cruise_dir: Setup a new working directory for CTD calibration.
 
 CTD Calibration toolbox
 
 INPUT: 
   parentdir: Path to the parent directory in which the "cruiseid" 
            subdirectory will be created.
   cruiseid: Cruise identification name (The name of the subdirectory). 

 OUTPUT:
   newdir: the absolute path to the new cruise directory.  

 ERRORS: If there is an error, newdir, will be returned empty and the  error
    message can be retrieved using the lasterr syntax.

 DESCRIPTION:
   This program will create a "cruiseid" directory and all the 
 necessary subdirectories to store the CTD and samples data as well the 
 calibrated files.
 
 Depending on the calling syntax, the "cruiseid" directory will be created 
 in the current working directory or in the given "parentdir"
   Cruiseid can be the mneumonic used to name the CTD aquisition files. 
 For example: CTD files from the second Subtropical Cells cruise were 
 named STC2001.btl where "001" is associated with station number, so 
 a good "cruiseid" for the cruise is STC2. 

 CHANGELOG: 
   08-Jul-2004, Version 1.0
        * Initial version.
10-Aug-2004   DPS <  >
    * create_cruise_dir.m (): Added different error checking, fixed one logical bug associated %with isempty(dir())
    
 AUTHORS:Carlos Fonseca
         UM/CIMAS
         Mon Jul 12 13:02:10 EDT 2004


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [newPath]  = create_cruise_dir(parentdir,cruiseid)
0002 % create_cruise_dir: Setup a new working directory for CTD calibration.
0003 %
0004 % CTD Calibration toolbox
0005 %
0006 % INPUT:
0007 %   parentdir: Path to the parent directory in which the "cruiseid"
0008 %            subdirectory will be created.
0009 %   cruiseid: Cruise identification name (The name of the subdirectory).
0010 %
0011 % OUTPUT:
0012 %   newdir: the absolute path to the new cruise directory.
0013 %
0014 % ERRORS: If there is an error, newdir, will be returned empty and the  error
0015 %    message can be retrieved using the lasterr syntax.
0016 %
0017 % DESCRIPTION:
0018 %   This program will create a "cruiseid" directory and all the
0019 % necessary subdirectories to store the CTD and samples data as well the
0020 % calibrated files.
0021 %
0022 % Depending on the calling syntax, the "cruiseid" directory will be created
0023 % in the current working directory or in the given "parentdir"
0024 %   Cruiseid can be the mneumonic used to name the CTD aquisition files.
0025 % For example: CTD files from the second Subtropical Cells cruise were
0026 % named STC2001.btl where "001" is associated with station number, so
0027 % a good "cruiseid" for the cruise is STC2.
0028 %
0029 % CHANGELOG:
0030 %   08-Jul-2004, Version 1.0
0031 %        * Initial version.
0032 %10-Aug-2004   DPS <  >
0033 %    * create_cruise_dir.m (): Added different error checking, fixed one logical bug associated %with isempty(dir())
0034 %
0035 % AUTHORS:Carlos Fonseca
0036 %         UM/CIMAS
0037 %         Mon Jul 12 13:02:10 EDT 2004
0038 %
0039 %
0040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0041 
0042 % default output in case of error
0043 newPath = '';
0044 
0045 % Parse input parameters
0046 msg = nargchk(1,2,nargin);
0047 if ~isempty(msg)
0048     lasterror(struct('message',msg,'identifier','CTD:IncorrectNargin'));
0049     return
0050 end
0051 
0052 if nargin == 1
0053     parentdir = pwd;
0054     cruiseid = varargin{1};
0055 elseif nargin == 2
0056     parentdir = varargin{1};
0057     cruiseid = varargin{2};
0058 else
0059     lasterror(struct('message','Error parsing input arguments.',...
0060             'identifier','CTD:UnknownAssertion'))
0061     return
0062 end
0063 
0064 % Check if the parentdir exists
0065 if exist(parentdir,'dir') ~= 7
0066     lasterror(struct('message','Specified parent directory does not exist.',...
0067             'identifier','CTD:DirectoryDoesNotExist'))
0068     return
0069 end
0070 
0071 % OK. mkdir should do the rest.  mkdir will not clobber any of the subdirectories
0072 % if they already exist.
0073 cruiseid=fullfile(parentdir,cruiseid);
0074 
0075 %-------------------------------------------------------------------------------
0076 %- Create output directory, if necessary
0077 %-------------------------------------------------------------------------------
0078 %- Create the top level output directory
0079 %if options.verbose
0080 fprintf('Creating directory %s...\n',cruiseid);                 
0081 %end
0082 if cruiseid(end) == filesep,                                        
0083     cruiseid(end) = [];                                             
0084 end                                                                        
0085 [pathdir, namedir] = fileparts(cruiseid);                           
0086 if isempty(pathdir)                                                        
0087     [status, msg] = mkdir(namedir);                                        
0088 else                                                                       
0089     [status, msg] = mkdir(pathdir, namedir);                               
0090 end                                                                        
0091 if ~status, error(msg); end
0092 [status, msg] = mkdir(namedir, 'bottle');
0093 [status, msg] = mkdir(namedir, 'salts');
0094 [status, msg] = mkdir(namedir, 'oxy');
0095 [status, msg] = mkdir(namedir, 'proc_data');
0096 [status, msg] = mkdir(namedir, 'calibrated');
0097 [status, msg] = mkdir(namedir, 'log');
0098 [status, msg] = mkdir(namedir, 'tmp');
0099 [status, msg] = mkdir(namedir, 'figures');
0100 
0101 % Write to the log file here.
0102 
0103 
0104 if nargout == 1
0105     newPath = cruiseid;
0106 end
0107 return
0108

Generated on Wed 15-Sep-2004 12:51:46 by m2html © 2003