Help on convert grid to image

Help
2006-07-24
2013-04-24
  • Juan Hidalgo

    Juan Hidalgo - 2006-07-24

    Hello,

    I have a problem with the command "convert grid to image". I have read the manual and the examples and even used the trial-error method, but I still have problems to understand how GRI transforms the data. I am using version 2.12.10 under Windows XP. I am trying to represent a simple gridded data like this

    7.3891    1.3891    7.3891    7.3891   
    2    1    1    1   

    but all the values above 2 are not in the final image (they are masked according to the output).
    Can anybody help me to understand how the data is transformed by GRI? To plot the data I use the GRI file below. What is wrong with it?

    Thank you in advance for your help,
    Juan.

    ###########################
    #
    \file = "ScaledFields.out"
    open \file
    #
    .nx. = 4
    .ny. = 2
    #
    # Computes dimensions and some constants.
    #
    .xLength. = {rpn .nx. 0.1 *}
    .yLength. = {rpn .ny. 0.1 *}
    .xMinGrid. = {rpn .xLength. .nx. / 2 /} #Lx/(2Nx)
    .xMaxGrid. = {rpn .xLength. .xMinGrid. -}
    #Lx-Lx/(2Nx)
    .yMinGrid. = {rpn .yLength. .ny. / 2 /} #Ly/(2Ny)
    .yMaxGrid. = {rpn .yLength. .yMinGrid. -}
    #Ly-Ly/(2Ny)
    .xAxisInc. = {rpn .xLength. .nx. / 1 *}
    .yAxisInc. = {rpn .yLength. .ny. / 1 *}
    .imgMin. = 0
    .imgMax. = 10
    .imgInc. = 1
    .palDelta. = {rpn .imgMax. .imgMin. - 100 / }
    .palMin. = {rpn .imgMin. .palDelta. -}
    .palMax. = {rpn .imgMax. .palDelta. +}
    .palInc. = {rpn .imgMax. .imgMin. - 10 / }
    #
    # Builds the grid
    #
    set x grid .xMinGrid. .xMaxGrid.  /.nx.
    set y grid .yMinGrid. .yMaxGrid.  /.ny.
    #
    read grid data .ny. .nx.
    #
    # Axis definition
    #
    set x name "X"
    set y name "Y"
    set x axis 0 .xLength. .xAxisInc.
    set y axis 0 .yLength. .yAxisInc.
    #
    # Image range and scale.
    #
    set image range  .imgMin. .imgMax.
    set image grayscale black .imgMin. white .imgMax. increment .imgInc.
    #
    # Grid to image conversion
    # To avoid interpolation, the size of the
    # image is equal to the grid.
    #
    convert grid to image size .nx. .ny.
    show image
    #
    draw image
    draw axes
    draw title "Sacled Field"
    draw image palette  left .palMin. right .palMax. increment .palInc.
    #
    # End
    #
    quit
    #
    ###########################

     
    • Dan Kelley

      Dan Kelley - 2006-07-24

      Can you post, or email, any datafiles that are required?  (If this "help" forum won't let you attach, then maybe you could post this as a bug ... I'm pretty sure the bug system will let you attach files.)

      Thanks.  Dan.

       
    • Juan Hidalgo

      Juan Hidalgo - 2006-07-24

      The datafile is very small and looks like this

      7.3891 1.3891 7.3891 7.3891 
      2.0000 1.0000 1.0000 1.0000 

      I used 'show grid' after 'read grid data' to verify that it is being read properly. I don't think it is a bug. I think it's just that I don't understand how it works.

      Thank you,
      Juan.

       
    • Juan Hidalgo

      Juan Hidalgo - 2006-07-26

      Hello,

      Since I'm not sure it is a bug, I have uploaded the files to the public ftp site of my university.

      The GRI and the data files can be found at

      ftp://ftp.etcg.upc.es/%23uploads/GRI

      They are called ScaledField.gri and ScaledField.dat.

      I was wondering if it could be related to the resolution of the grid and the image. Both resolutions are equal in order to obtain quadrilaterals of uniform color, since the data are equally spaced and I don't want any interpolation nor smoothing. Could it be that the masked pixels have not enough neighbors?

      Regards,
      Juan

       

Log in to post a comment.