[ncl-talk] problems with loop
Rick Brownrigg
brownrig at ucar.edu
Mon Jun 26 10:21:06 MDT 2017
Hi,
The notation Rad_in(i,:,:) is causing the projection from 3D down to 2D.
If you want to preserve the 3D shape, use
Rad_in(i:i,:,:).
I'm not sure about the warning. Did you post your entire script, i.e.,
does line #17 correspond to "alb = 0.7*Rad_in(i,:,:)" ?
Rick
On Mon, Jun 26, 2017 at 8:55 AM, Vanúcia Schumacher <
vanucia-schumacher at hotmail.com> wrote:
> Hi NCL users,
>
>
> I need to calculate a variable based on a parameter that varies with time.
> For the first year the value of the parameter is 0.7
> For the second year the parameter is 0.4
> For the third year onwards the parameter is 0.3
>
> So I must multiply the variable with the value of the parameter and I want
> to get a new variable with all the coordinates (time, lat and lon), but
> I'm having the variable only with lat and lon and getting the following
> warning:
>
> warning:VarVarWrite: rhs has no coordinate variable for dimension number
> (0), destroying coordinate var, use "(/../)" if this is not desired outcome
> warning:["Execute.c":8640]:Execute: Error occurred at or near line 17 in
> file test.ncl
>
>
> My script:
> ( here in this test, my time is 3 days (average from 12 files), so the
> parameter is varying for 1 day = 0.7, 2 day = 0.4, and 3 day =0.3
>
> files = systemfunc("ls -1 wrfout_d01_*") + ".nc"
> a = addfiles(files,"r")
> nfiles = dimsizes(files)
>
> do k = 0,nfiles-1
>
> rad = wrf_user_getvar(a[k],"SWDDNI",-1)
> rad&Time = wrf_times_c(a[k]->Times, 0)
> Rad_in = calculate_daily_values(rad, "avg", 0, False)
>
> times = wrf_user_getvar(a[k],"times",-1)
> ntimes = dimsizes(times)
>
> do i = 0, ntimes-1
>
> if (i.lt.2) then
> alb = 0.7*Rad_in(i,:,:)
> end if
>
> if (i.gt.2.and.i.lt.3) then
> alb = 0.4*Rad_in(i,:,:)
> end if
>
> if (i.gt.3) then
> alb = 0.3*Rad_in(i,:,:)
> end if
> end do
> end do
>
> Variable: nfiles
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 12
>
>
> Variable: rad
> Type: float
> Total Size: 5600 bytes
> 1400 values
> Number of Dimensions: 3
> Dimensions and sizes: [Time | 1] x [south_north | 50] x [west_east | 28]
> Coordinates:
> Number Of Attributes: 6
> coordinates : XLONG XLAT
> stagger :
> units : W/m^2
> description : Shortwave surface downward direct normal irradiance
> MemoryOrder : XY
> FieldType : 104
>
> Variable: Rad_in
> Type: float
> Total Size: 5600 bytes
> 1400 values
> Number of Dimensions: 3
> Dimensions and sizes: [Time | 1] x [south_north | 50] x [west_east | 28]
> Coordinates:
> Time: [ 0.. 0]
> Number Of Attributes: 9
> NCL_tag : calculate_daily_values: arith=avg
> Time : 0
> FieldType : 104
> MemoryOrder : XY
> description : Shortwave surface downward direct normal irradiance
> units : W/m^2
> stagger :
> coordinates : XLONG XLAT
> _FillValue : 9.96921e+36
>
>
> Variable: ntimes
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 1
>
> Variable: alb
> Type: float
> Total Size: 5600 bytes
> 1400 values
> Number of Dimensions: 2
> Dimensions and sizes: [50] x [28]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 9.96921e+36
>
>
> Is there any other way I can do this? Thanks any help
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170626/44817c9d/attachment.html
More information about the ncl-talk
mailing list