Re: variable naming

From: Mary Haley (haley AT ucar.edu)
Date: Thu Oct 14 2004 - 15:36:08 MDT

  • Next message: Dennis Shea: "Re: variable naming"

    >
    > Hello all,
    >
    > I have read variables from a file using:
    >
    > vNames = getfilevarnames (inF)
    >
    > and looped through the various elements of vNames. I would like to
    > rewrite the processed data to a netCDF file but using the original
    > variable name (ie the individual string elements of vNames). I have
    > problems creating this new variable for output using simple assignment
    > along the lines of:
    >
    > $vName(n)$ = vAvgInt or, vName(n) = vAvgInt
    >
    > All suggestions appreciated!
    >
    > Regards,
    >
    > Maurice

    Hi Maurice,

    I think you are almost there. You can only use the "$vName$" syntax
    when the "$...$" is used on the right side of the attribute symbol
    "@", or a file pointer "->". For example:

        fnew = addfile("newfile.nc","c")
        fnew->$vName(n)$ = vAvgInt

    If you need to store vName(n) temporarily, then you can attach it to
    another variable using "@":

      tmp_attach = True ; Temp. variable to attach things to.
      tmp_attach@$vName(0)$ = vAvgInt
      tmp_attach@$vName(1)$ = vAvgStd
                        .
                        .
                        .

    Maybe somebody else has a more efficient method of doing this?

    --Mary

    > --
    > Maurice McHugh, Ph.D.
    >
    > mmchug4@lsu.edu
    >
    > Assistant Professor Ph: (225)578-0476
    > Department of Geography and Anthropology Fax: (225)578-4420
    > Louisiana State University
    >
    > _______________________________________________
    > ncl-talk mailing list
    > ncl-talk@ucar.edu
    > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    >

    -- 
    -------------------------------------------------
    Mary Haley                   haley@ucar.edu
    NCAR/SCD/VETS                303-497-1254 (voice)
    1850 Table Mesa Dr           303-497-1804 (fax)
    Boulder, CO  80305
    -------------------------------------------------
    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    



    This archive was generated by hypermail 2b29 : Thu Oct 14 2004 - 15:47:22 MDT