Re: File variable string references

From: Sara Rauscher <rauscher_at_nyahnyahspammersnyahnyah>
Date: Mon, 17 Aug 2009 14:50:34 -0600

Yes - perfect - thank you!
sara

Adam Phillips wrote:
> Hi Sara,
> I think this will do what you want:
>
> copy_VarCoords(vctlavg,prob)
> tname = "t"+names(i)
> out->$tname$ = prob
>
> Adam
>
> Sara Rauscher wrote:
>> Hello,
>> I am running a script where I read in a file, and use
>> "getfilevarnames" to determine variable names. If the variables have
>> 2 or more dimensions I then process further, like this:
>>
>>
>> names = getfilevarnames( ctlavg )
>> do i = 0, dimsizes( names ) - 1
>> rank = dimsizes(dimsizes(ctlavg->$names(i)$)) ; # of dimensions
>> if (rank.ge.2) then
>> print("Variable Name: " + names(i))
>> vctlavg = ctlavg->$names(i)$
>> vexpavg = expavg->$names(i)$
>> vctlstd = ctlstd->$names(i)$(0,:,:)
>> vexpstd = expstd->$names(i)$(0,:,:)
>> prob=
>> 100*(1-ttest(vexpavg,vexpstd^2,100,vctlavg,vctlstd^2,100,True,False))
>> copy_VarCoords(vctlavg,prob)
>> out->$names(i)$ = prob
>>
>>
>> This seems to be work, but I want to change the output variable name
>> so that it is not just $names(i)$ but the variable name with a "t" in
>> front of it or something like that. I've tried putting quotes around
>> the names and using plus signs but I am not sure 1) if this is
>> possible and 2) what the syntax would be. I know I could do this with
>> a shell script where I pass the variable names through the shell and
>> process one at a time that way, but I'd like to process all the
>> variables within the ncl script itself.
>>
>> thanks for any help.
>> sara
>>
>

-- 
Sara A. Rauscher
T-3 Fluid Dynamics
MS B216
Los Alamos National Lab
Los Alamos, NM 87545 USA
(505) 606-0512
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Aug 17 2009 - 14:50:34 MDT

This archive was generated by hypermail 2.2.0 : Mon Aug 24 2009 - 11:15:23 MDT