Re: partial answer to my own question

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sun, 30 Nov 2008 07:13:15 -0700

Sorry, Jonathan, I didn't see that you had answered your own
question. Still, I'm not sure why the _FillValue that was associated
with your "B" variable got clobbered. I'm hoping Dave Brown can
explain this one.

I use the method of passing lots of variables as attached attributes
myself, as a way of sneaking in lots of variables. I believe this
should be perfectly okay.

--Mary

On Nov 28, 2008, at 3:49 PM, Jonathan Vigh wrote:

> Hi Again,
> Not completely satisfied with my question, I worked on it some
> more. I realized that I was not assigning the Fill Value attribute
> correctly.
>
> I was setting all the Fill Values like:
> integer_FillValue = -999
>
> I think it's more correct to do the following:
> integer_type = new(1,"integer")
> integer_FillValue = getVarFillValue(integer_type)
>
> Thus, when integer_FillValue is assigned to my attached attribute
> quasi-variable, the _FillValue attribute of integer_FillValue seems
> to also get passed along and ismissing works as expected. Another
> option would be to use the assignFillValue procedure to transfer
> the metadata. I'm not sure why this works, as I don't think that an
> attribute can be attached to an attribute, but for some reason,
> this fixes my problem. I've attached a script (now with 5 cases)
> illustrating which ways work and which don't for those who are
> interested.
>
> But I'd still like comments on my big-picture question from before
> - is my approach of passing lots of variables as attached
> attributes a good one? I think it's slightly better than just
> declaring everything globally. Is there a better way to do this? Or
> should I go back to traditional variable passing?
>
> Thanks,
> Jonathan
> ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ; Test the feasibility of passing arguments to functions as
> ; attributes rather than variables.
> ;*****************************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;********************************************************
>
> ; global parameters
>
> ; this (what I had before) is probably not the "mother-approved"
> way to assign the Fill Value
> bad_integer_FillValue = -999
>
> ; I think this method is more kosher:
> integer_type = new(1,"integer")
> integer_FillValue = getVarFillValue(integer_type)
>
>
> procedure do_stuff(CONTAINER)
> local stuff
>
> begin
>
> CONTAINER_at_variableB = bad_integer_FillValue
> CONTAINER_at_variableC = integer_FillValue
> assignFillValue(integer_FillValue,CONTAINER_at_variableD)
> assignFillValue(bad_integer_FillValue,CONTAINER_at_variableE)
>
> print("In procedure . . .")
> print("variableA = "+CONTAINER_at_variableA+" ismissing?
> "+ismissing(CONTAINER_at_variableA))
> print("variableB = "+CONTAINER_at_variableB+" ismissing?
> "+ismissing(CONTAINER_at_variableB))
> print("variableC = "+CONTAINER_at_variableC+" ismissing?
> "+ismissing(CONTAINER_at_variableC))
> print("variableD = "+CONTAINER_at_variableD+" ismissing?
> "+ismissing(CONTAINER_at_variableD))
> print("variableE = "+CONTAINER_at_variableE+" ismissing?
> "+ismissing(CONTAINER_at_variableE))
> print(" ")
>
> end
>
>
> ; main program
> begin
>
> CONTAINER = True
> CONTAINER_at_variableA = new(1,"integer",bad_integer_FillValue)
> CONTAINER_at_variableB = new(1,"integer",bad_integer_FillValue)
> CONTAINER_at_variableC = new(1,"integer",integer_FillValue)
> CONTAINER_at_variableD = new(1,"integer",integer_FillValue)
> CONTAINER_at_variableE = new(1,"integer",integer_FillValue)
>
> print("In main program . . .")
> print("variableA = "+CONTAINER_at_variableA+" ismissing?
> "+ismissing(CONTAINER_at_variableA))
> print("variableB = "+CONTAINER_at_variableB+" ismissing?
> "+ismissing(CONTAINER_at_variableB))
> print("variableC = "+CONTAINER_at_variableC+" ismissing?
> "+ismissing(CONTAINER_at_variableC))
> print("variableD = "+CONTAINER_at_variableD+" ismissing?
> "+ismissing(CONTAINER_at_variableD))
> print("variableE = "+CONTAINER_at_variableE+" ismissing?
> "+ismissing(CONTAINER_at_variableE))
> print(" ")
>
> do_stuff(CONTAINER)
>
> print("In main program . . .")
> print("variableA = "+CONTAINER_at_variableA+" ismissing?
> "+ismissing(CONTAINER_at_variableA))
> print("variableB = "+CONTAINER_at_variableB+" ismissing?
> "+ismissing(CONTAINER_at_variableB))
> print("variableC = "+CONTAINER_at_variableC+" ismissing?
> "+ismissing(CONTAINER_at_variableC))
> print("variableD = "+CONTAINER_at_variableD+" ismissing?
> "+ismissing(CONTAINER_at_variableD))
> print("variableE = "+CONTAINER_at_variableE+" ismissing?
> "+ismissing(CONTAINER_at_variableE))
> print(" ")
>
>
> end
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Nov 30 2008 - 07:13:15 MST

This archive was generated by hypermail 2.2.0 : Sun Nov 30 2008 - 08:25:42 MST