This has also been asked in the GitHub
issue.
I have some ideas which I posted there and will add here.
I have looked into this some more. It
seems that the format for wrf files is not consistent with the
COARDS and CF netCDF standards used by PyFerret https://www.ncl.ucar.edu/Applications/wrfnetcdf.shtml
I expect that this problem will be resolved with updates that are in the code base but not yet in a PyFerret release. I do not know what the plans are for the next release.
However, I have a suggestion, which I'd like to add here. I will show it using a small example file, attached to this message. This is a file from a previous question, which I think shows the behavior that is seen in the wrf files. Its netCDF header looks like this:
netcdf sample_wrf {
dimensions:
Time = UNLIMITED ; // (13 currently)
bottom_top = 2 ;
south_north = 6 ;
west_east = 7 ;
variables:
float FNM(Time, bottom_top) ;
FNM:FieldType = 104 ;
FNM:MemoryOrder = "Z " ;
FNM:description = "upper weight for vertical stretching" ;
FNM:units = "" ;
FNM:stagger = "" ;
float P(Time, bottom_top, south_north, west_east) ;
P:FieldType = 104 ;
P:MemoryOrder = "XYZ" ;
P:description = "perturbation pressure" ;
P:units = "Pa" ;
P:stagger = "" ;
// global attributes:
:TITLE = "Grids as in WRF model" ;
:history = "Downloaded orig file from link at https://www.riinu.me/2014/05/saving-subset/" ;
}
netcdf sample_wrf {
dimensions:
Time = UNLIMITED ; // (13 currently)
bottom_top = 2 ;
south_north = 6 ;
west_east = 7 ;
variables:
double Time(Time) ;
Time:axis = "T" ;
double bottom_top(bottom_top) ;
bottom_top:axis = "Z" ;
double south_north(south_north) ;
south_north:axis = "Y" ;
double west_east(west_east) ;
west_east:axis = "X" ;
float FNM(Time, bottom_top) ;
FNM:FieldType = 104 ;
FNM:MemoryOrder = "Z " ;
FNM:description = "upper weight for vertical stretching" ;
FNM:units = "" ;
FNM:stagger = "" ;
float P(Time, bottom_top, south_north, west_east) ;
P:FieldType = 104 ;
P:MemoryOrder = "XYZ" ;
P:description = "perturbation pressure" ;
P:units = "Pa" ;
P:stagger = "" ;
// global attributes:
:TITLE = "Grids as in WRF model" ;
:history = "Downloaded orig file from link at https://www.riinu.me/2014/05/saving-subset/" ;
data:
Time = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ;
bottom_top = 1, 2 ;
south_north = 1, 2, 3, 4, 5, 6 ;
west_east = 1, 2, 3, 4, 5, 6, 7 ;
}
We can create a new, separate netCDF file that contains the desired coordinate variables. Then use the netcdf utility ncks to add the coordinate variables to the wrf file.
Here is a Ferret script to write a dummy file with the desired "axis" attributes. The appropriate axis attributes are automatically written by modern Ferret and PyFerret.
! Define the coordinate axes, the dimension names and lengths from the wrf file. Keep
! the same upper-case and lower-case spellings as in the file.
define axis/t=1:13:1 Time
define axis/z=1:2:1 bottom_top
define axis/y=1:6:1 south_north
define axis/x=1:7:1 west_east
! Define variables on these axes to write to a new netCDF file.
let/title=Time tcoord = t[gt=Time]
let/title=bottom_top zcoord = z[gz=bottom_top]
let/title=south_north ycoord = y[gy=south_north]
let/title=west_east xcoord = x[gx=west_east]
! Write the dummy variables. We will get the coordinate axes from this file.
cancel mode upcase
save/clobber/file=wrf_axes.nc tcoord, zcoord, ycoord, xcoord
> ncks -A -h -v Time wrf_axes.nc sample_wrf.nc
> ncks -A -h -v bottom_top wrf_axes.nc sample_wrf.nc
> ncks -A -h -v south_north wrf_axes.nc sample_wrf.nc
> ncks -A -h -v west_east wrf_axes.nc sample_wrf.nc
I have wrfout file at one time step and trying to open in ferret. but I am having error like this (below)
(``` base) jeevan@MacBook-Pro idojaros % pf NOAA/PMEL TMAP PyFerret v7.63 (optimized) Darwin 19.6.0 - 10/13/20 5-Sep-21 12:14 yes? use wrfout_d01_2020-01-16_00:00_jk_E_G.nc *** NOTE: *** NOTE: Could not adjust grid for variable ZNU **ERROR: inconsistent data grids: File needs axis attributes on coordinate variables indicating correct directions yes? sh d currently SET data sets: yes? qHow can I solve this ?
Attachment:
sample_wrf.nc
Description: Binary data