function []=sim_airmass(Sim,varargin)
%--------------------------------------------------------------------------
% sim_airmass function                                             ImBasic
% Description: Get or calculate the airmass of SIM images, based on
%              their header information. This function is looking for
%              the airmass or RA, Dec, observatory coordinates and time
%              and date in a set of header keywords and convert
%              it to airmass. 
% Input  : - Structure array images or any of the input supported by
%            images2sim.m. Default '*.fits'.
%            The input must have an header.
%          * Arbitrary number of pairs or arguments: ...,keyword,value,...
%            where keyword are one of the followings:
%            'KeyAM' - List of airmass keywords in header in which to
%                      check for the airmass. The first populated keyword
%                      will be used. Default is {'AIRMASS'}.
%            'UseKeyAM' - {false|true}. If true then use attempt to read
%                      airmass from airmass keyword.
%                      If false recalculate airmass. Default is false.
%            'ObsLon'- Observatory longitude. This is either a scalar
%                      value of the observatory longitude in radians,
%                      or a string indicating the name of the 
%                      header keywrord containing the observatory
%                      longitude in either sexagesimal or degrees.
%            'ObsLat'- Observatory latitude. This is either a scalar
%                      value of the observatory latitude in radians,
%                      or a string indicating the name of the 
%                      header keywrord containing the observatory
%                      latitude in either sexagesimal or degrees.
%            'WriteAM'- Keyword header name in which to write the
%                      airmass. If empty, do not write it.
%                      Default is 'MAIRMASS'.
%            'WriteLST'- Keyword header name in which to write the
%                      LST. If empty, do not write it.
%                      Default is 'MLST'.
%            'LSTunits'- Units of LST to write to header.
%                      'frac' - fraction of day.
%                      'SH'   - sexagesimal hours.
%                      'deg'  - degrees.
%                      'rad'  - radians.


%            --- Additional parameters
%            Any additional key,val, that are recognized by one of the
%            following programs:
% Output : - 
% Tested : Matlab R2014a
%     By : Eran O. Ofek                    Dec 2014
%    URL : http://weizmann.ac.il/home/eofek/matlab/
% Example: 
% Reliable: 
%--------------------------------------------------------------------------


DefV. = 
InPar = set_varargin_keyval(DefV,'n','use',varargin{:});
