Task: Generate CLR Files
The CLR file format is designed to be human readable and human writeable
(Just look into the .clr
file for the IASP91 model to see that the file format
is quite easy to understand).
So there are two ways to generate a CLR file:
- Type it by hand
- construct CLR structure from MODEL structure using MKND2CLR, and subsequently
- write CLR file using MKWRITECLR
Unless the model is machine generated and available in a MatLab-variable, it is
probably easier to type .clr files by hand.
The following description explains the typing of a .clr file step-by-step, what is
a bit lenghty and looks more complicated than it actually is.
- Open a new ASCII file.
- Define the model's name.
To do so, enter a new line
!name YourModelName
(You may use either Tab stops (ASCII9) or space (ASCII32) to separate keywords an parameters)
This line defines that the Model is named "YourModelName".
- Define the model's publication year.
To do so, enter a new line
!year PublicationYear
where "PublicationYear" is a number that denotes the year of publication, e.g. 1991.
- You may insert empty lines at any place to provide some optical structuring.
Empty lines are ignored when reading the file.
- Define the planet, for which the model is valid. You have to specify both name and radius
of the planet. Enter two lines:
!planet !name PlanetName
!planet !radius PlanetRadius
here, PlanetName is a string specifying the name of the Planet, and PlanetRadius is
a number (in fixpoint or as float) that gives the Planet's radius in km.
- Now enter the layer data.
- To start the description of a new layer, enter a new line
!layer !start LayerName
where LayerName is a string denoting the Layer's name. This string may be omitted.
- Specify the depth extent of the layer.
You can specify this as depth in km measured
from the surface by entering
!layer !depth TopDepth BottomDepth
where TopDepth and BoottomDepth are numbers denoting the depth of the top and
the bottom of the layer.
OR you can specify the radius in km, measured from the planet's center:
!layer !radius BottomRadius TopRadius
Where BootomRadius and TopRadius are the radius to the bottom and the top
of the layer.
NOTE that the first number is always the smaller one.
- To specify the coefficients of the P wave velocity, enter the coefficients
of the Layer Polynomial in a new line:
!layer !vp p1 p2 p3 pn
The modifier "!vp" declares that this is the P wave velocity. The p1, p2, p3,...,pn
are coefficients of a (n-1)-th degree polynomial, p1 being the constant term and pn being
the coefficient of the highest power. (see section on Layer Polynomials in the CLR
file format description)
- To specify other quantities, use the appropriate modifier:
- !vp
- P wave velocity
- !vs
- S wave velocity
- !rho
- Density
- !qp
- P wave Q-factor
- !qs
- S wave Q-factor
The syntax is the same as for vp.
If you wish to leave one or more of these quantities undefined, just do not enter
a line with the respective modifier.
- To finish the layer, enter a new line
!layer !end
- Finally, enter discontinuity data. A discontinuity is defined by depth and name
!discon !depth DiscontinuityDepth DiscontinuityName
where DiscontinuityDepth is a depth from the surface in km and DiscontinuityName
is a string.
A Discontinuity can also be defined by Radius and name
!discon !radius DiscontinuityRadius DiscontinuityName
where DiscontinuityRadius is the radius measured from the planet's center in km.
There are several standard names for standard discontinuities like the Moho or the
Core Mantle Boundary. A Table of these standard names is given in the
General section of the tutorial.
- You can add comments at any place. A comment begins with "#", "//", or "/*" and ends
at the end of the line.
If your velocity model is given in an .nd file or a MODEL structure as returned by MKREADND, you can
construct a CLR structure from the ND structure by applying MKND2CLR. The following description assumes that you have an .nd file.
- read the .nd file by executing model=mkreadnd(PathToNDFile);
- convert it to .clr by executing clrout=mknd2clr(model,mode); where mode defines what kind of layer polynomials is to be constructed. Available options currently are:
- constant
- All parameters will be taken constant between the depths defined in MODEL. In this mode, the construction of layer "polynomials" is straigh forward.
Note that some models (e.g. ak135) define a certain interpolation mode between discrete depth values. In ak135, linear interpolation has to be applied. The "constant" mode in this case does not give an exact representation!
- save the new CLR structure by executing mkwriteclr(clr,PathToCLRFile);
If your velocity model is already stored in a CLR structure (see
section on Data Structures for definition),
you can write a .clr file using MKWRITECLR.
To do so, execute
mkwriteclr(clr,path);
where clr is your data structure and path the path to store the file at.
eof.