Re: Fixing the values of the variable

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Sat Aug 28 2010 - 13:02:02 MDT

Hi Rashed,
I'm a little unclear what you are trying to do. Are you trying to set each
decade in your .nc file to the 1970s values? Are you sure that indices
145:156 represent the 1970s? Remember that NCL is zero indexed based, so
the first timestep is located in index 0. I am going to assume that the
1970s are actually in indices 144:155 in the following example. You will
want to double check that I am right on this:

a = addfile("aerosol.climatology.nc","w")
arr = a->so4_anthro ; not sure if that's the variable you want
arr70s = arr(144:155,:,:)
cntr = 0
do gg = 0,dimsizes(arr&time)-1,12
   arr(cntr:cntr+11,:,:) = (/ arr70s /)
   cntr = cntr+12
end do
a->so4_anthro = arr

The above will replace every decade with 1970s data, again assuming that
NCL indices 144:155 represent your 1970s values... It simply loops through
each decade, and replaces each decade with the 1970s values. Note that
this is done at each gridpoint individually.

Hopefully this is what you are after. If not, let the group know...
Adam

> Dear Adam
> Thanks for your suggestion.
> Yes this is the variable that I want modify.
> one thing that is confusing me is that the file contains decadal monthly
averages so for one decade there would be 12 time steps.
> for example time=145 (Jan1970)...156(Dec1970). How would I fix the
values
> for these 12 time steps.
> And also the values would be different at each grid point so I dont have
one
> value to enter,,I need something that automatically fixes the values
over
> a
> specified domain. Or we can say something that will not allow this
variable's values to increase from 1970s values.
> Thanks and regards
> Rashed
> Hi Rashed,
> I would use the read/write option in addfile to read in the file, grab
the variable you want, modify it, and write it back to the netCDF file.
(Note: Make a backup copy of your aerosol.climatology.nc file first
before you attempt to alter it.)
> http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml a =
addfile("aerosol.climatology.nc","w")
> arr = a->so4_anthro ; not sure if that's the variable you want arr =
 ; set to whatever value(s) you want
> a->so4_anthro = arr
> That should be it. Just to be clear, the above snippet of code will
overwrite the so4_anthro variable from the aerosol.climatology.nc file.
If the above doesn't help let the ncl-talk group know..
> Adam
> _______________________________________________
> 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 Sat Aug 28 13:02:07 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 09 2010 - 05:56:39 MDT