<div dir="ltr">Hi Dennis,<div><br></div><div>I tested the script you sent and noticed the values of the input file for some variables will change after using the script (check the attached). In addition, around the selected area, there would be rectangles in the same colors, which I did not expect.</div><div> I wonder why this happened. I attached the original input file and the modified one.</div><div>Please kindly advise me in these regards.</div><div><br></div><div>Best wishes,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 26, 2024 at 6:36 AM Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dave ... As always .... THX</div><div>-------------------------<br></div><div>Attached is an *untested* version of my original script with Dave's suggested modifications. Again, I do not have a local NCL version so I can not test it.<br></div><div><br></div><div>Note: because the WRF coordinate dimensions are curvilinear, the subscripts may return a larger area than 1D coordinate variables. You may have to come up with your own version.<br></div><div><br></div><div>Good Luck<br></div><div><br></div><div>D<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 25, 2024 at 3:18 PM Dave Allured - NOAA Affiliate via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Setareh, with simple 1-D coordinate variables, you would easily do this with coordinate range subscripting.  Read about that in the NCL ref manual.  Here is an example that writes directly into an existing file, rather than making a new file.<br><br>      f->MSEBIO_ISOP( {0,10}, {10,30} ) = 0<br></div><div><br></div><div>However, the coordinates in your particular file are 3-D, so you have to use extra code.  Here is the simplest way.  This is also the slowest, but if you are only working with a small amount of data, it is better to keep the code simple.  This example also writes directly into the existing file.  Not tested:</div><div><br></div><div>      lat1 = 0</div><div>      lat2 = 10</div><div>      lon1 = 10</div><div>      lon2 = 30</div><div><br></div><div>      do t = 0, ntimes-1</div><div>         do i = 0, nlats-1</div><div>            do j = 0, nlons-1</div><div>               if ( (XLAT(t,i,j) .ge. lat1) .and. (XLAT(t,i,j) .le. lat2) \</div><div>                  .and. (XLONG(t,i,j) .ge. lon1) .and. (XLONG(t,i,j) .le. lon2) ) then</div><div>                     f->MSEBIO_ISOP(t,i,j) = 0</div><div>                          ! You can add more variables here</div><div>               end if</div><div>            end do</div><div>         end do</div><div>      end do</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 25, 2024 at 1:04 PM Setareh Rahimi <<a href="mailto:setareh.rahimi@gmail.com" target="_blank">setareh.rahimi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Dave,<div><br></div><div>So many thanks for your help. I just checked it and it worked. </div><div><br></div><div>May I ask you please to advise me on how to only convert the values of all variables to zero for a specific region and not whole the domain? (for example lat[0,10], and lon[10,30])?</div><div><br></div><div>Thanks in advance.</div><div>Kind regards,<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 25, 2024 at 11:18 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>The problem is that Dennis's program did not copy the file global attributes, which contain part of the georeferencing.  Just add this line near the top of the program, after the line "print (vNames)":</div><div><br></div><div>      copy_VarAtts (f, fout)</div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 25, 2024 at 11:07 AM Ehsan Taghizadeh via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:"bookman old style","new york",times,serif;font-size:16px"><div><div dir="ltr">Dear Setareh,</div><div dir="ltr"><div><div>I suggest you read the variables from the fout file again. For example, if there is a variable named "V10" in fout, you just need to read that variable from fout, as follows:</div><div>V10_zero=fout->V10</div><div><br></div><div>This V10_zero has the same coordinates as V10 in the original file, but its values are zero.</div><div>I hope this is correct.</div></div></div><div dir="ltr"><br></div></div><div><br></div>
        
        </div><div id="m_-194137024263042819m_-4424335007305317192m_-6165975761838463980m_8078946574129595812m_-2853437640240134846m_5376276308783386129yahoo_quoted_6819469700">
            <div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;color:rgb(38,40,42)">
                
                <div>
                    On Thursday, January 25, 2024 at 06:17:12 PM GMT+3:30, Setareh Rahimi via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:
                </div>
                <div><br></div>
                <div><div id="m_-194137024263042819m_-4424335007305317192m_-6165975761838463980m_8078946574129595812m_-2853437640240134846m_5376276308783386129yiv5053542009"><div><div>Dear Dennis,</div><div>I noticed an issue. When I use the attached script it converts all values to zero, but the data is no georefrenced any more. So how can I fix this please?</div><div>Thanks in advance.</div><div>Best regards, <br clear="all"><br clear="all"><div><div dir="ltr">S.Rahimi<br clear="none"><br clear="none"></div></div></div><div><br></div><div id="m_-194137024263042819m_-4424335007305317192m_-6165975761838463980m_8078946574129595812m_-2853437640240134846m_5376276308783386129yiv5053542009yqt39142"><div><div><div dir="ltr">On Sun, Jan 21, 2024 at 18:44 Dennis Shea <<a rel="nofollow noopener noreferrer" shape="rect" href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br clear="none"></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Attached is a script that does what you requested.</div><div><br clear="none"></div></div><br clear="none"><div></div><div><div dir="ltr">On Sat, Jan 20, 2024 at 6:40 AM Setareh Rahimi via ncl-talk <<a rel="nofollow noopener noreferrer" shape="rect" href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br clear="none"></div></div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"></blockquote></div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br clear="all"><div>Dear NCL users,</div><div><br clear="none"></div><div>I have a NetCDF file (attached) that contains some variables. I would like to change the values of all variables to zero for all grid points. So how can I do this using NCL, please?</div><div><br clear="none"></div><div>This file is an input file for the WRF-Chem model, and I do not want to change the format of the file, only want to change the values to zero.</div><div><br clear="none"></div><div>Please kindly advise me in this regard.</div><div><br clear="none"></div><div>Thanks in advance.</div><div>Kind regards,</div><span>-- </span><br clear="none"><div dir="ltr">S.Rahimi</div></div></blockquote></div></blockquote></div></div></div></div></div></div></div></div></div></blockquote></div></div></blockquote></div></div></div>
</blockquote></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">S.Rahimi<br><br></div>