[ncl-talk] overwriting 4d array with 3d array values

Mary Haley haley at ucar.edu
Sun Jun 19 22:43:57 MDT 2016


Tabish,

Since you didn't include a sample code, I wrote a simple program to write a
dummy E_ALD variable to a NetCDF file, using the same dimension names you
indicated in the email. I then wrote another script that does the same
thing you have with:

a1->E_ALD(:,0,:,:)    = E_ALD_00z(:,:,:)

It worked just fine for me, and produced a new file with the new values.

In order to debug your problem, I need more information, like the
printVarSummary output for both E_ALD and E_ALD_00z:

printVarSummary(a1->E_ALD)
printVarSummary(E_ALD_00z)

 and what version of NCL you have:

ncl -V

Finally, it would help if we could see the script as well, and even better
if you can provide the data.

--Mary




On Sun, Jun 19, 2016 at 3:55 PM, Tabish Ansari <tabishumaransari at gmail.com>
wrote:

> Hi
>
> I am trying to do an assignment operation in the following way:
>
> a1->E_ALD(:,0,:,:)    = E_ALD_00z(:,:,:)
>
> Here the LHS is a 4d array variable that I'm reading from a netcdf file
> a1. RHS is another array which is 3d and matches the shape of E_ALD(:,0,:,:)
>
> LHS dimensions are (Time, vert_level, lat, lon)
> RHS dimensions are (Time, lat, lon)
>
> I want the LHS array to retain all its attributes including dimension
> names etc. but just want to replace the values inside the array.
>
> I am getting the following error:
>
> warning:Dimension names of left hand side and right hand side do not
> match, overwriting dimension (Time), use (/ .. /) if this is not the
> desired result
> ncdimrename: ncid 65536: NetCDF: String match to name in use
> fatal:Could not change dimension (4) to (Time) for file
> (wrfchemi_00z_d01_agri_Oct)
> warning:Dimension names of left hand side and right hand side do not
> match, overwriting dimension (south_north), use (/ .. /) if this is not the
> desired result
> ncdimrename: ncid 65536: NetCDF: String match to name in use
> fatal:Could not change dimension (1) to (south_north) for file
> (wrfchemi_00z_d01_agri_Oct)
> warning:Dimension names of left hand side and right hand side do not
> match, overwriting dimension (west_east), use (/ .. /) if this is not the
> desired result
> ncdimrename: ncid 65536: NetCDF: String match to name in use
> fatal:Could not change dimension (0) to (west_east) for file
> (wrfchemi_00z_d01_agri_Oct)
>
> Please help me get this right.
>
> Many thanks!
>
> Tabish
>
>
> Tabish U Ansari
> PhD student, Lancaster Environment Center
> Lancaster Univeristy
> Bailrigg, Lancaster,
> LA1 4YW, United Kingdom
>
> _______________________________________________
> 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/20160619/ad29b3e3/attachment.html 


More information about the ncl-talk mailing list