Re: looping to create a graph from many different files

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 03 2014 - 12:44:02 MST

Ciara,

There are a couple of things wrong here. First, as Lijun Diao already mentioned: you have your "begin" and "end" statements in the wrong place.

You want:

begin
  . . .
  do n=1961,2010
  end do
end

I think the way you had it originally will work, but it's not correct.

Second, your sprinti command is not correct. It should be:

        fnam="/home/cohara/TempData/yearly_data/average/average_" + sprinti("%0.4d",n) + ".nc"

--Mary

On Feb 28, 2014, at 9:41 AM, Ciara O'Hara <cohara1985@hotmail.com> wrote:

> I have 50 files that I want to run a script on one after the other, and to save the generated graph with a unique name each time. My script to create the graph is fine, but looping through the 50 files is not. I have left out many of the resources I'm using.
>
>
> Thanks in advance,
> Ciara
>
>
> My script is:
> 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/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> do n=1961,2010
> begin
> fnam="/home/cohara/TempData/yearly_data/average/average_" + sprinti("0.4n",n) + ".nc"
> x=addfile(fnam,"r")
> data=x->var61(0,0,:,:)
> xwks=gsn_open_wks("ps","Average_" + sprinti("0.4n",n)
> resources=True
> resources@tiMainString="Average Annual Temperature" + sprinti("0.4n",n)
> plot=gsn_csm_contour_map(xwks,data,resources)
> end
> end do
>
>
>
> _______________________________________________
> 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 Mon Mar 3 12:44:11 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 03 2014 - 14:26:18 MST