[ncl-talk] read/write HDF5 files

Michael Toy - NOAA Affiliate michael.toy at noaa.gov
Fri May 13 23:38:06 MDT 2022


Dave,

1.  My mistake.  The line should have read “W = ff->W”.

2.  I’m embarrassed to say that I tried my script out again, and it works now.  I don’t know what I was doing before that was causing it to corrupt the file.

Problem solved.

Thank you for your response.

— Mike



> On May 13, 2022, at 7:57 PM, Dave Allured - NOAA Affiliate <dave.allured at noaa.gov> wrote:
> 
> 1.  Something does not make sense here.  Why "W = f_in->W" rather than "W = ff->W" ??
> 
> 2.  Instead of addfile(“wrfinput_d01”,”w”), try addfile(“wrfinput_d01.h5”,”w”).  It is a long shot.
> 
> 
> On Fri, May 13, 2022 at 7:43 PM Michael Toy - NOAA Affiliate via ncl-talk <ncl-talk at mailman.ucar.edu <mailto:ncl-talk at mailman.ucar.edu>> wrote:
> Hello,
> 
> I want to modify one of the fields of a WRF “wrfinput” file.  I have no problem doing this if the file is netCDF, but this one is an HDF5 file (“Hierarchical Data Format (version 5) data”).
> 
> Here’s my script:
> 
> ff = addfile(“wrfinput_d01”,”w”)
> W = f_in->W    ; read the variable W (vertical velocity)
> .
> .
> “make some changes to W”
> .
> .
> ff->W=W     ; write the new values of W back to the file
> 
> These lines execute just fine, but the resulting file is corrupted and unreadable.  The problem, I guess, is that I haven’t correctly accounted for the fact that wrfinput_d01 is an HDF5 file.  I’ve checked online and it looks like I have to add following line at the top of my script:
> setfileoption(“h5”,”FileStructure”,”Advanced”)
> However, I tried this, and it didn’t work.
> 
> I would appreciate any assistance with this.  Thank you.
> 
> Best regards,
> Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220513/5ee613a1/attachment.html>


More information about the ncl-talk mailing list