Re: modifying WRF geo_em.d01.nc file

From: Don Morton <Don.Morton_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 07 2011 - 08:50:44 MST

Hi, this may not be exactly what you're looking for, but I would also
recommend taking a look at WTOOLS, developed by Kevin Nuss and presented in
a poster at the WRF Workshop last summer.

http://www.nusculus.com/wtools

It's advertised as facilitating the modification of fields in geo_em*
files. I've only used it (so far) for display purposes and have found it
to be very useful.

Disclaimer - I have no stake in this product, and simply know the author to
be a nice, hard-working guy and the minute I saw his poster at the WRF
Workshop, I found myself thanking him profusely for this work! :)

On Wed, Dec 7, 2011 at 7:01 AM, Mary Haley <haley@ucar.edu> wrote:

>
> On Dec 6, 2011, at 5:57 PM, Jinwoong Yoo wrote:
>
> Hello, NCL users.
>
> I'd like to get some tips how to modify an geo_em.d0X.nc file to modify
> topography of the WRF model domain.
> I know somebody had similar question in the ncl-talk previously and I
> followed their ideas but I'm still struggling to modify my geo_em.d0X.ncfile.
> First, I used NCL method, "Change netCDF file" as described in
> http://www.ncl.ucar.edu/Applications/change_netCDF.shtml.
>
> I collected HGT_M values from "ncdump -v HGT_M geo_em.d01.nc" for my 198 by 261 grid domain and pasted the HGT_M values
>
> begin
> in = addfile("./geo_em.d01.nc","w")
> HGT_M = (/30,40,89,78,45,234,98,23,456,294,12,17,40,56,17,32,85,93,72,\
> ... ... \
> 20,46,24,90,89,25/)
>
> in->HGT_M=(/HGT_M/)
>
> end
>
> where I put my modified elevation values in the HGT_M = (/.../).
> However, this failed due to the dimension mismatch about which I could not
> find any help or explanation on the web.
> Because the domain is 198 by 261 array, there should be some (NCL) way
> to specify the HGT_M = (/.../) instead of just putting numbers separated by
> comma as I did.
> If you know how, please let me know.
>
>
> Dear Jinwoong,
>
> You're right, you shouldn't have to list the values by hand with commas
> between each value. The example on the web was just to show you how you
> can directly change a variable on a file, but you don't have to do it
> exactly this way.
>
> How are you getting the new values that you need to replace the old values
> with?
> If these values are in an array that you read in from another file, say,
> you can just use this variable.
>
> For example, let's say the new HGT_M values are on another NetCDF file
> called "geo_hgt.nc", and are stored in a variable called "HGT". Then you
> could do something like this:
>
> hid = addfile("geo_hgt.nc","r")
> in->HGT_M = (/hid->HGT/)
>
> Note that in order to do this, both in->HGT_M and hid->HGT must be exactly
> the same dimensionality. Also, hid->HGT must be coercible to the type of
> in->HGT_M.
> That is, if in->HGT_M is of type "float", and hid->HGT is of type
> "double", then this won't work. You would have to do:
>
> in->HGT_M = tofloat(/hid->HGT/)
>
> Finally, you need to be careful that both variables have the same units.
> If they don't, then you can simply fix the units:
>
> in->HGT_M@units = "..."
>
> Where "..." contains the new units.
>
> I will let Dave answer the question about PyNIO.
>
> --Mary
>
>
>
> Second, I tried PyNIO to modify the geo_em.d01.nc file.
> Actually, I could get array values with it and could modify the values on
> the memory.
> However, it seems that I cannot modify the original geo_em.d01.nc even
> when I used the "w" mode although you can create a new nc file.
> I found this line from PyNGL and PyNIO webpage: "Note that *PyNIO* never
> overwrites an existing file with an entirely new file."
> If I'm wrong and an existing nc file can be overwritten with new values,
> please let me know how to.
> Personally, I'd like to use PyNIO to modify the nc file if possible.
> Maybe PyNIO developers can change the code to let users overwrite their nc
> file directly in the future if it has not been done yet.
>
> Thank you in advance.
>
> Best,
>
>
> Jinwoong Yoo, Ph.D.
> University of South Florida
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

-- 
Voice:  907 450 8679
Arctic Region Supercomputing Center
http://weather.arsc.edu/
http://people.arsc.edu/~morton/ <http://www.arsc.edu/~morton/>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 7 08:51:06 2011

This archive was generated by hypermail 2.1.8 : Fri Dec 09 2011 - 13:09:09 MST