<div dir="ltr">Hi,<div><br></div><div>I'm trying to overwriting a variable for specific locations in a NetCDF file in following way:</div><div><br></div><div><div>begin</div><div>f = addfile("wrfinput_d03_<wbr>modified","r")</div><div>LU_INDEX = f->LU_INDEX(0,:,:) ;3-D variable(Time:lat:lon)</div><div>var = f->SMOIS(:,:,:,:) ; 4-D variable(Time:layer:lat:lon)</div><div>var_mask = mask(var,(LU_INDEX.ne.1), False)<br></div><div>var_mask_25 = var_mask + var_mask * 0.25</div><div>SMOIS_NEW = var_mask_25<br></div><div>; write to netcdf</div><div>system("rm -f <a href="http://smois.nc" target="_blank">smois.nc</a>")</div><div>fwrite = addfile("<a href="http://smois.nc" target="_blank">smois.nc</a>","c")</div><div>fwrite->SMOIS_NEW = (/SMOIS_NEW/)</div><div>SMOIS_write = new((/1,4,117,117/),typeof(<wbr>var))<br></div><div>SMOIS_write(:,:,:,:) = SMOIS_NEW </div><div><br></div><div><br></div><div>;Replacing the "_FillValues" of SMOIS_write by the var values</div><div>if (any(isnan_ieee(SMOIS_write))) then</div><div><div> if(.not.isatt(SMOIS_write,"_FillValue")) then</div><div> SMOIS_write@_FillValue = var(typeof(var))</div><div> end if </div><div> replace_ieeenan (SMOIS_write, SMOIS_write@_FillValue, 0)</div><div>end if</div><div>print(SMOIS_write)</div></div><div><br></div><div>end</div><div><br></div><div><pre style="color:rgb(0,0,0)">I just want the <b>var</b> array to retain all its attributes </pre><pre style="color:rgb(0,0,0)">but just want to replace the values (specific locations <span style="font-family:arial,sans-serif">where the LU_INDEX=1)</span></pre><pre style="color:rgb(0,0,0)"><span style="font-family:arial,sans-serif"> </span><span style="font-family:arial,sans-serif">with the real values of SMOIS_write.</span></pre><pre style="color:rgb(0,0,0)"><br></pre><pre style="color:rgb(0,0,0)">It seems to me that "if" statement is not working. Still SMOIS_write is printing </pre><pre style="color:rgb(0,0,0)">the "_FillValues" where LU_INDEX=1. Could you please advise me what should be </pre><pre style="color:rgb(0,0,0)">the remaining lines to complete the script.</pre><pre style="color:rgb(0,0,0)"><br></pre><pre style="color:rgb(0,0,0)">Your cooperation will be highly appreciated.</pre><pre style="color:rgb(0,0,0)"><br></pre><pre style="color:rgb(0,0,0)">Kind regards,</pre><pre style="color:rgb(0,0,0)">Imran</pre></div><br><div class="gmail-m_2853446944440751202gmail_signature"><div dir="ltr"><br><br></div></div>
</div></div>