csv-plot.xl (Conversion of CSV Plot Data to Matrix)

Author: Hirohisa Mori / joshua@globalbase.org + [Transrate]Reiko Inoue Bendtsen c/o Suzaku Translations / (http://www.suzaku-translations.com/) +

PROTOTYPE

xl csv-plot.xl [CSV-FILE] [CORRESPOND] [MATRIX] [X-DOTS] [Y-DOTS]

ARGUMENTS

[CSV-FILE] CSV file of plot data

[CORRESPOND] Corresponding conversion file

[MATRIX] Save destination matrix file

[X-DOTS] Number of dots in the x direction

[Y-DOTS] Number of dots in the y direction

Option

ENVIRONMENT

Agent exl [UNDEF REF (exl)]

EXPLANATION

If you have installed LANDSCAPE, you can find sample data in /usr/local/xl-gbs/xlsamples/gbs/plot1. Please refer to it when you read the following.

This script converts plot data listed in a CSV file [CSV-FILE] to a matrix file with the format given by [MATRIX] . The plot data converted to matrix data covers the entire data set; if some of the plots cannot be displayed on the screen, the script behaves as follows.
  1. Shrink icons
  2. Change icons to simple colored points if they cannot be displayed even if they are shrunk
  3. Merge points and display them as an area if there are many plots within one pixel on the screen
With these operations, an almost inifinite number of plots can be displayed.

While matrix data is basically an integer-type representation, plots tend to be sequential ( real-valued) coordinate systems, for example plots against latitude/longitude. For this reason, a resolution must be specified for the matrix, and plot coordinates are converted to integers accordingly. That is, a real number coordinate system is divided into very small grids and plot positions are expressed as the grid's integer coordinate. [X-DOTS][Y-DOTS] indicate the size of the integer grid.

Attributes assigned to one plot inside a matrix are identified by numbers starting from 0,e.g., the Nth attribute of a plot at coordinate XX,YY. Each attribute has a data type. This data type specifies how to merge plots if it becomes necessary to merge plots during the process of lowering the resolution of a matrix image ( grid). To facilitate this, the following data types have been defined. First, teh basic data types are explained. In addition, each basic data type has a number of more detailed sub-types. A CSV file [CSV-FILE] contains a simple list of attributes and does not indicate coordinates. Similarly, attributes of a CSV file has no type. For this reason, it is necessary to specify:
  1. Which lines of a CSV file should be regarded as coordinate values
  2. To which attributes of a matrix file the remaining lines of a CSV file should be assigned
  3. Which type should be used at assignment
These specifications are made by a file specified by [CORRESPOND] . [CORRESPOND] is an XL script file, but only few instructions actually use it. /usr/local/xl-gbs/xlsamples/plot1/gaz.xl is one of them. When you open it, you can see that the only instructions used are ?xl, Define, and gmxPgPlotField.

Variables defined by Define

<Define> ^reso	3600 </Define>
 

The script above defines resolution in the reso variable, in this case 3600dots/degree. In gaz.csv in the example, the coordinates are specified in lines A and B as degrees while the matrix file defines 1second as 1dot. The command below, which is placed at the end of the file, indicates the number of lines at the beginning of the csv file to be ignored,

<Define> ^StartLine 1 </Define>
 

In this example, the first one line is ignored.

gmxPgPlotField

The following gmxPgPlotField specifies correspondence among each line of the csv file, coordinates of the matrix file and attribute numbers. gmxPgPlotField is a function of Agentgbmx. Please refer to XL Function or Environment (gmxPgPlotField)for the detailed explanation of the function. It is used in the following 2ways in csv-plot.xlscript.

(A)
<gmxPgPlotField id="^mtx" csv="A" merge-type="^mxPgTYPE_INT" dim="0">
  ^Fields ^mxPgFDIT_DD ^reso (* 180 reso) 0</gmxPgPlotField>
 



(B)
(B-1)
<gmxPgPlotField id="^mtx" csv="C" merge-type="^mxPgTYPE_STRING" label="5">
  ^Fields utf-8 ([quote type="direct"] '([field name="LABEL"] ($ ___convert)))</gmxPgPlotField>
(B-2)
<gmxPgPlotField id="^mtx" merge-type="^mxPgTYPE_RGBA" label="0">
  ^Fields 0 0xff000000</gmxPgPlotField>
(B-3)
<gmxPgPlotField id="^mtx" csv="D" merge-type="^mxPgTYPE_STRING" label="1">
  ^Fields utf-8 () test-http </gmxPgPlotField>
 

(A) shows a method of specifying coordinates while (B) shows a method of specifying correspondence between attributes. The following XML attributes can be used. Lastly, how the element data of gmxPgPlotField is specified varies depending on the data type given by the merge-type XML attribute. Integer type [Data type in CSV] The following values can be specified for this type. How to use /usr/local/xl-gbs/xlsamples/gbs/plot1

When you want to disclose plot data, it is possible to disclose it using the following procedure.
  1. Copy /usr/local/xl-gbs/xlsamples/gbs/plot1 to a disclosure point. For example, if the directory is myplot,
  2. edit the img.crd bibliographic data in the myplot directory.
  3. Preprare the CSV file of plot data to be disclosed and save it as a file in the myplot directory, for example as myplot.csv.
  4. Edit gaz.xl file for myplot.csv to match attributes.

  5. 
    Execute xl csv-plot.xl - - / myplot.csv gaz.xl img.mtx [X-DOTS] [Y-DOTS].
     


  6. 
    Execute xl makefile.xl - -.
     



[UP] Go To Page Top

RETURN VALUE

ERRORS

REFERENCE

/usr/local/xl-gbs/xlsamples/gbs/plot1

BUGS



[UP] Go To Page Top
  GLOBALBASE has particated in the open source software support program SORCE FORGE SourceForge.jp SourceForge.net Logo