I was trying to regrid prcipitation nc file to higher resolution, but getting an error message: : ncap2: ERROR assign(): LHS cast for latn - cannot make RHS ~zz@value_list conform. I run the script below using ncap2 command as follows:
lantn[$latn] should have 7 elements on the Right Hand Side (RHS) you have 10
lonn[$lonn] should have 17 elements on the RHS , you have 19
the call to bilinear_interp() should look something like this - i am assuming that the variable that you wish to regrid is pre_cru($time,$lat,$lon):
`/****/
defdim("latn",7);
defdim("lonn",17);
// change to your new range here
latn[$latn] = {30, 32.5, 35, 37.5, 40, 42.5, 45};
// change to your new range here
lonn[$lonn] = {-17.5, -15, -12.5, -10, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20 ,22.5};
out[$latn,$lonn]=0.0;
Thank you for your response. I made the corrections and tried but seems I made a syntax error somewhere. When checked against your suggestion above I could not fined the problem with my script. The error message this time is
/****************/`
defdim("latn",3);
defdim("lonn",5);
// the number of values here on RHS must equal the latn dim size
latn[$latn] = {3.5,4.5,5.5};
// the number of values here on RHS must equal the lonn dim size
lonn[$lonn] = {37.0,38.0,39.0,40.1 ,40.9};
out[$latn,$lonn]=0.0;
Hi All,
I was trying to regrid prcipitation nc file to higher resolution, but getting an error message: : ncap2: ERROR assign(): LHS cast for latn - cannot make RHS ~zz@value_list conform. I run the script below using ncap2 command as follows:
ncap2 -v -S pre_rgrid.nco pre_cru_1901_2014.nc pre_cru_new_1901_2014.nc
/*****/
defdim("latn",7);
defdim("lonn",17);
// change to your new range here
latn[$latn] = {30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60};
// change to your new range here
lonn[$lonn] = {-17.5, -15, -12.5, -10, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20 ,22.5, 25, 27.5};
out[$latn,$lonn]=0.0;
// no time dimension
pre_cru_new[$latn,$lonn]=0.0;
for( idx=0 ; idx<$time.size ; idx++ ) {
pre_cru_new(idx,:,:)=bilinear_interp(pre_cru_new(0,:,:),out,latn,lonn,lat,lon);
}
I would appreciate if you share your experince how this challange is addressed.
Dawit
Hi Dawit,
you are mixing things up a bit:
lantn[$latn] should have 7 elements on the Right Hand Side (RHS) you have 10
lonn[$lonn] should have 17 elements on the RHS , you have 19
the call to bilinear_interp() should look something like this - i am assuming that the variable that you wish to regrid is pre_cru($time,$lat,$lon):
`/****/
defdim("latn",7);
defdim("lonn",17);
// change to your new range here
latn[$latn] = {30, 32.5, 35, 37.5, 40, 42.5, 45};
// change to your new range here
lonn[$lonn] = {-17.5, -15, -12.5, -10, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20 ,22.5};
out[$latn,$lonn]=0.0;
out[$latn,$lonn]=0.0;
pre_cru_new[$time,$latn,$lonn]=0.0;
for(idx=0;idx<$time.size;idx++)(
pre_cru_new(idx,:,:)=bilinear_interp(pre_cru(idx,:,:),out,latn,lonn,lat,lon);
}
/****/`
if you still have troubles can you please put your netcdf file in an accessible place and then i can have a go
...Henry
`
Dear Henry,
Thank you for your response. I made the corrections and tried but seems I made a syntax error somewhere. When checked against your suggestion above I could not fined the problem with my script. The error message this time is
(my_ncl) Dagemawes-MacBook-Pro:CRU_TS_PRE dawitabebe$ ncap2 -v -S regrid_cru.nco pre_cru_1901-2014_dat.nc pre_cru_new_1901_2014_dat.nc
regridcru.nco:15:77: expecting ), found ';'
I wanted to send the file but I don't know how! I wonder if you could share your e-mail address so as I can send through.
my script for scrutiny
/*****/
defdim("lat_new", 13);
defdim("lon_new",23);
// new lat range
latn[$latn] = {3.25, 3.5, 3.75, 4.0, 4.25, 4.75, 5.0, 5.25, 5.75, 6.0, 6.25};
// new lon range
lonn[$lonn] = {36.25, 36.5, 36.75, 37.0, 37.25, 37.5, 37.75, 38.0, 38.25, 38.5, 38.75, 39.0, 39.25, 39.5, 39.75, 40.0, 40.25, 40.5, 40.75, 41.0, 41.25, 41.5, 41.75};
out[$latn,$lonn]=0.0;
out[$latn,$lonn]=0.0;
pre_cru_new[$time,$latn,$lonn]=0.0;
for(idx=0;idx<$time.size;idx++)(
pre_cru_new(idx,:,:)=bilinear_interp(pre_cru(idx,:,:),out,latn,lonn,lat,lon);
}
/**/
Thanks again
Dawit
Hi Dawit,
only send file if <20 meg other wise my email provider rwill barf
henryb at ntlworld dot com
Hi Henry
Thank you so much for your support. Attached the file (only 957 KB).
Dawit
Hi Henry,
I am just wondering if the file has ended in you mail box.
Thanks
Dawit
yep got it will look tomorrow
On 4/28/2017 at 7:10 PM, "Dawit" wrote:
Dawit
https://sourceforge.net/p/nco/discussion/9830/
https://sourceforge.net/auth/subscriptions/
Please use syntax formatting widgets to format code. Your script as printed above contains this:
Change the opening parenthesis to a brace:
Dear Charlie,
I'm not just good at this! With the correcion you noted still have an error message
ncap2 -v -S regrid_cru_script.nco pre_cru_1901-2014_dat.nc pre_cru_new_1901_2014_dat.nc
ncap2: ERROR ncap_cst_mk(): Unrecognized dimension "latn"in LHS subscripts
Sorry for bothering you, I'm just learning
Thanks for your patience
Dawit
HI Dawit,
Pls try the following script
/****************/`
defdim("latn",3);
defdim("lonn",5);
// the number of values here on RHS must equal the latn dim size
latn[$latn] = {3.5,4.5,5.5};
// the number of values here on RHS must equal the lonn dim size
lonn[$lonn] = {37.0,38.0,39.0,40.1 ,40.9};
out[$latn,$lonn]=0.0;
pre_cru_new[$time,$latn,$lonn]=0.0;
for(idx=0;idx<$time.size;idx++)
{
pre_cru_new(idx,:,:)=bilinear_interp(pre(idx,:,:),out,latn,lonn,lat,lon);
}
/************/
...Henry