CLASS recipes
my home upper

Caution!! Although I am happy to share my research notes below with all visitors to my webpages, these pages are mainly designed for my own use and subject to change without warning. I do not guarantee the correctness of all contents as well.


My reciepes in using CLASS (see more details at the CLASS online documentation homepage)

Table of contents:


(use "help ..." to see help on commands in CLASS prompt line mode)

Installing remarks  (back to top)

  • Beside installing the listed dependencies on GILDAS web, you may encounter such problem: when you open for example CLASS in a bash, you don't get the pop-up CLASS widgets, but an error message like "libimf.so not found". This problem steps from the Intel (R) Fortran Compiler settings. By default, ifort should run with option -imf, then no such problem appears. In case you have such problem, you can do this
    • run "locate libimf.so" to see where the library file is located. For example, in my PC, it's under /opt/intel/Compiler/11.0/069/lib/ia32.
    • then edit your bash settting file .bash_profile in your home directory and add the lib path as:
           export LD_LIBRARY_PATH=%LD_LIBRARY_PATH:/opt/intel/Compiler/11.0/069/lib/ia32    (for my example)
    • when you login your account next time, the environment variable will be set automatically. If you want to use GILDAS right now without logout, just run above command to change the env settings by hand now. That's it. :)

Text formatting:  (back to top)

  • \d makes subscript while 
  • \u makes superscript of the next character. For example, "C\d4H" produces "C4H". If you need more than one character to be in sub- or superscript mode, you need to repeat \d or \u for each character. For example, "\u3\u0SiS" makes "30SiS".
  • \g plus the first letter of the english name of greek letter produce the greek letter. For example, "\gdx" makes a lower case delta symbol followed by character "x" while "\gD\d1" produces a capital delta symbol followed by subscript "1".
  • Return is not allowed in string. Multiple lines have to be treated as multiple string variables or string constants and plotted individually.

Variables: (back to top)

  • Default data header variables are listed on page 25-26 in the document class.pdf.
  • Other data header variables are grouped into sections and listed on pages 75-80 (under the item: SET VARIABLE) in the document class.pdf. (To use these additional header variables, one needs to define them by using the command: set variable Section-Name [Keywords], where the Section-Name is one of POSITION, SPECTRO, BASE, HISTORY, PLOT, FSWITCH, CALIBRATION, SKYDIP, GAUSS, SHELL, NH3 OR HFS, DRIFT, BEAM, CONTINUUM. Keyword can be WRITE, OFF, ...)  Note: the variables are always preceeded by a letter "R" in the list and this letter should be remove before being used in CLASS.

Spectrum manipulation: (back to top)

  • To rebin a spectrum, use 
    • analyse\resample NX Xref Xval Xinc UNIT [shape] [width] [/NOFFT]
    • fit line profile with class model SHELL, the profile formula is
           T(v) = Tc * (1 + HC * (v - vc)^2 / vexp^2),
      where Tc is the line center temperature, vc is the line center LRS velocity, vexp is the expansion velocity of spherical shell, the horn-to-center ratio is defined as
           HC = (Th - Tc) / Tc
      where Tc is the line edge (or horn) temperature. Thus, HC > 0 for double-horn profile, =0 for flat-top profile, and <0 for parabollic profile.With this formula, the line area can be easily computed by
           S = 2/3 Tc * vexp * (3 + HC)
    • ...

Different coordinate systems and positions (back to top)
There are global variables that represent different coordinates.

  • Plot page size: PAGE_X, PAGE_Y in absolute unit (cm). Command greg1\set plot_page can be used to change them.
  • Plot box quantities
    • BOX_ASPECT = Ysize / Xsize ??? I don't know 
    • BOX_XMIN, BOX_XMAX, BOX_YMIN, BOX_YMAX are box edges in absolute unit (cm), w.r.t the origin of page size.
    • BOX_LIMITS ??? I don't know 
  • Plotted user data ranges: USER_XMIN, USER_XMAX, USER_YMIN, USER_YMAX are in user unit (e.g., K, MHz, km/s, etc.).
  • Coordinate transform: user <=> absolute. For a given user coordinates (x,y), the absolute coordinate (X,Y) used for greg1\draw command is w.r.t. the origin of the plot box, not to the canvas, say,
    • X = 0+(x - USER_XMIN) * (BOX_XMAX - BOX_XMIN) / (USER_XMAX - USER_XMIN)
    • Y = 0+(y - USER_YMIN) * (BOX_YMAX - BOX_YMIN) / (USER_YMAX - USER_YMIN)
    • E.g., the command "greg1\draw relocate 0 0" will move the cursor position to the origin of the plot box. To move a line from the origin of the plot box to the lower left corner of the canvas, you should use command "greg1\draw line -BOX_XMIN -BOX_YMIN".
    • Note: when the X axis is in frequency, x must be replaced by "x-frequency" in above formulas.
  • Different ways of manipulation of positions:
    • greg\draw relocate xc yc: xc and yc are in absolute unit (cm), but measured from the left bottom corner of the plot box. This is the same for other greg1\draw related commands.
    • loading curcor position into variables:
      • g\draw relocate
      • The cursor position in user coordinates can is available in the array: use_curs[] (you can check it with exam use_curs)
      • The cursor operation in the last g\draw can be found in the character variable cursor_code.
        • example 1: if you click your mouse for g\draw, you will have cursor_code = R;
        • example 2: if you type E to exit the g\draw, you will end up with cursor_code = E;
        • This can be used to design fantastic cursor applications. Eg., the following lines allow you to read the user-coordinate positions on the current plot for as many times as you want until you exit the loop by typing the letter "E". (from GILDAS engineer Sebastien Bardeau)
          >FOR /WHILE (.true.) ! Infinite loop
          >  g\draw relo
          >  exa use_curs
          >  if (cursor_code.eq."E") then   ! almost any letter can be used to replace E.
          >    ! 'E' typed, exit
          >    BREAK
          >  end if
          >NEXT

Plot control (back to top)

  • Plot axis tick marks: The tick mark ranges (the shown data ranges along X and Y axes) and different ways of tick marking can be changed by using command greg1\limits before loading any data. After loading of user data, greg1\limits will determine the plot ranges from the user data. (Note that because greg1\limits will use previous dataset to compute the box ranges by default, you'd better plot the current dataset before running greg1\box!) When  issuing greg1\box command to plot a box, greg1\limits without arguments are automatically issued. Another command greg1\tickspace can be used to specify how many big and small ticks to be shown for linear scale plots.
  • An example procedure to specify plot axises, titles and data plot ranges:
    • clear
    • limit x1 x2 y1 y2 
    • set mode x x1 x2
    • set mode y y1 y2
    • greg1\box P O I N   (use after the current dataset is plotted, otherwise, the box ranges will be that of the previous dataset.)
    • las\spec
    • greg1\label "your X label" /X
    • greg1\label "your Y label" /Y

      Alternatively, one can use las\box to plot the axis. The difference between the two box commands are
      • greg1\box: does not handle the labelling of upper axis, control the pen color, use the previous axis limits, does not write axis title, can fill the plot canvas with color.
      • las\box: handle the labeling of upper axis with the fourth parameter, does not control the pen color, determine limits from the current spectral data, always write a default axis title, can not fill the plot canvas with color.
  • To control the color, line style and line types, use
    • pen [N] [/color C] [/dashed D] [/weight W] [/default]

 
  (back to top)

 [ upper ] Welcome comments to me: jinhuaheynao.ac.cn [back to my Home]