Home > coriolis > bigone > PROJETS > UVMAT.new > read_scalar.m

# read_scalar

## PURPOSE

'read_scalar': reads and calculates the vort div or any scalar from a file

## SYNOPSIS

function [A,time,dt,rangx,rangy,vel_type_out,error,pixcmx,pixcmy]=read_scalar(filename,vel_type,scal_type,rgx_in,rgy_in,npxy_in,maskname,transform);

## DESCRIPTION

    'read_scalar': reads and calculates the vort div or any scalar from a file
     % OBSOLETE: REPLACED BY read_ncfield
    ------------------------------------------------------------------
    [A,time,dt,rangx,rangy,vel_type_out,error,pixcmx,pixcmy]=...
     read_scalar(filename,vel_type,scal_type,rgx_in,rgy_in,npxy_in,maskname,usrtransform);

     OUTPUT:
     A=double m x n matrix representing the scalar field on a regular mesh
     time: absolute time read in the file
     dt: time interval of the image pair (read in the file)
     rangx,rangy: length 2 vectors representing in each direction the coordinates of the first and
     last point of the field, thus describes the whole grid of scalar positions
     vel_type_out: string representing the type of velocity selected (filter2,filter1...)
     error: error flag = 0 when  OK
     error=1: no spatial derivative in the filename;'run patch first'})
     error=2: no field  vel_type in  filename
     error=3: scalar cannot be obtained
     error=4: all points aligned
     pixcmx,pixcmy: pixels per cm in the images (useful when using a mask)

     INPUT:
     filename: string representing the name of the input file
     vel_type: character string or cell (only vel_type{1} is used presently), indicates the types of velocity fields to read ('civ1','civ2'...)
                if vel_type{1}=[], the types are automaticaly set depending on scal_type
     scal_type: character string, indicates the types of scalar to get ('vort','div'...)
     rgx_in,rgy_in: like rangx, rangy but set as input:
     if 'rgx_in' not defined or rgx_in=[], it is set to min max of 'vec_X' in the field
     npxy_in: in general vector with two elements setting the number of grid points in each direction,
     in association with rgx_in,rgy_in, it sets the whole grid
     on which the scalar is linearly interpolated
     if rgx_in=[] and npxy_in='np>256' we interpolate the field to get a resolution > 256 pts
     maskname: name of a mask image file, the scalar is set to 'NaN' at masked points
     transform: names of a user defined transforms
     transform.scal: for the scalar
     transform.ima: for a geometric transform on mask images if a mask is used

## CROSS-REFERENCE INFORMATION

This function calls:

- calc_scal 'calc_scal': defines scalars and calculate them from stored fields. OBSOLETE to replace by calc_field
- griddata_uvmat 'griddata_uvmat': function griddata_uvmat(vec2_X,vec2_Y,vec2_U,vec_X,vec_Y,'linear')
- read_netcdf 'read_netcdf': reads a list of fields and constants in a netcdf file
- varname_generator 'varname_generator': defines the names of constants and variable fields to read in the netcdf files

This function is called by: