Home > atmlab > arts > arts_y.m

arts_y

PURPOSE ^

ARTS_Y Calculates spectra and jacobians using ARTS

SYNOPSIS ^

function [y,y_aux,J,jq,ji] = arts_y( Q, workfolder )

DESCRIPTION ^

 ARTS_Y   Calculates spectra and jacobians using ARTS

    Takes a qarts structure and calculates corresponding spectra.

    Auxilary data and jacobians are also returned. The later requires an
    active selection through J_DO. Otherwise NaN is returned.
    variables.

 FORMAT   [y,y_aux,J,jq,ji] = arts_y( Q [, workfolder] )
        
 OUT   y            Spectrum vector.
       y_aux        Auxilary data (see *y_aux*).
       J            Jacobian. NaN returned if Q.J not defined.
       jq           Jacobian quantities. NaN returned if Q.J not defined.
       ji           Jacobian indices. NaN returned if Q.J not defined.
                    Indices are 1-based (that is, ARTS indices + 1);
 IN    Q            Qarts structure.
 OPT   workfolder   If not defined or empty, a temporary folder is created.
                    Otherwise this is interpreted as the path to a folder 
                    where calculation output can be stored. These files
                    will be left in the folder. The files are not read if
                    corresponding output argument is not considered.
                    Default is [].

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

arts_y.m

SOURCE CODE ^

0001 % ARTS_Y   Calculates spectra and jacobians using ARTS
0002 %
0003 %    Takes a qarts structure and calculates corresponding spectra.
0004 %
0005 %    Auxilary data and jacobians are also returned. The later requires an
0006 %    active selection through J_DO. Otherwise NaN is returned.
0007 %    variables.
0008 %
0009 % FORMAT   [y,y_aux,J,jq,ji] = arts_y( Q [, workfolder] )
0010 %
0011 % OUT   y            Spectrum vector.
0012 %       y_aux        Auxilary data (see *y_aux*).
0013 %       J            Jacobian. NaN returned if Q.J not defined.
0014 %       jq           Jacobian quantities. NaN returned if Q.J not defined.
0015 %       ji           Jacobian indices. NaN returned if Q.J not defined.
0016 %                    Indices are 1-based (that is, ARTS indices + 1);
0017 % IN    Q            Qarts structure.
0018 % OPT   workfolder   If not defined or empty, a temporary folder is created.
0019 %                    Otherwise this is interpreted as the path to a folder
0020 %                    where calculation output can be stored. These files
0021 %                    will be left in the folder. The files are not read if
0022 %                    corresponding output argument is not considered.
0023 %                    Default is [].
0024 
0025 % 2004-09-17   Created by Patrick Eriksson.
0026 
0027 function [y,y_aux,J,jq,ji] = arts_y( Q, workfolder )
0028 %
0029 if nargin < 2, workfolder = []; end
0030 %
0031 if atmlab( 'STRICT_ASSERT' )
0032   rqre_datatype( Q, @isstruct );
0033   rqre_datatype( workfolder, {@isempty,@ischar} );
0034 end
0035 
0036 
0037 %- Default output
0038 %
0039 [y_aux,J,jq,ji] = deal( NaN );
0040 
0041 
0042 %- Create workfolder?
0043 %
0044 if isempty( workfolder )
0045   workfolder = create_tmpfolder;
0046   cu = onCleanup( @()delete_tmpfolder( workfolder ) );
0047 end
0048 
0049 
0050 %- Avoid unnecessary calculations
0051 %
0052 if nargout < 3
0053   Q.J_DO = false;
0054 end
0055 
0056 
0057 %- Run ARTS
0058 %
0059 parts = qarts2cfile( 'y' );    
0060 S     = qarts2cfile( Q, parts, workfolder );
0061 cfile = fullfile( workfolder, 'cfile.arts' );
0062 strs2file( cfile, S );
0063 arts( cfile );
0064 
0065 
0066 %- Load data
0067 
0068   
0069 y = xmlLoad( fullfile( workfolder, 'y.xml' ) );
0070 
0071 
0072 if nargout >= 2
0073   y_aux = xmlLoad( fullfile( workfolder, 'y_aux.xml' ) );
0074 end
0075 
0076 if nargout >= 3  & qarts_isset( Q.J_DO ) &  Q.J_DO
0077   %
0078   J = xmlLoad( fullfile( workfolder, 'jacobian.xml' ) );
0079   %
0080   if nargout >= 4
0081     jq = xmlLoad( fullfile( workfolder, 'jacobian_quantities.xml' ) );
0082     ji = xmlLoad( fullfile( workfolder, 'jacobian_indices.xml' ) );
0083     for i = 1 : length(ji)
0084       for j = 1 : length(ji{i})
0085         ji{i}{j} = ji{i}{j} + 1;
0086       end
0087     end
0088   end
0089 end
0090 
0091 
0092

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005