How to edit GFS input gribs?

All other topics about postprocessing model data (GrADS and other software), about other numerical weather prediction software (including WRF-NMM and WRF-ARW discussion unrelated to UEMS/WRF EMS), and general meteorology talk go in this forum.
Antonix
Posts: 260
Joined: Fri Oct 16, 2009 8:53 am

Re: How to edit GFS input gribs?

Post by Antonix » Tue Sep 24, 2013 12:47 pm

ok
I have these values ​​in the grib input file.

dset ^big.grb2
index ^big.grb2.idx
undef 9.999E+20
title big.grb2
* produced by g2ctl v0.0.8.8
* command line options: -verf big.grb2
* griddef=1:0:(159 x 75):grid_template=0:winds(N/S): lat-lon grid:(159 x 75) units 1e-06 input WE:SN output WE:SN res 48 lat 26.000000 to 63.000000 by 0.500000 lon 332.500000 to 51.500000 by 0.500000 #points=11925:winds(N/S)

dtype grib2
ydef 75 linear 26.000000 0.5
xdef 159 linear -27.5 0.5
tdef 57 linear 12Z23sep2013 3hr
* PROFILE hPa
zdef 26 levels 100000 97500 95000 92500 90000 85000 80000 75000 70000 65000 60000 55000 50000 45000 40000 35000 30000 25000 20000 15000 10000 7000 5000 3000 2000 1000
options pascals
vars 26
HGTsfc 0,1,0 0,3,5 ** surface Geopotential Height [gpm]
HGTprs 26,100 0,3,5 ** (1000 975 950 925 900.. 70 50 30 20 10) Geopotential Height [gpm]
ICECsfc 0,1,0 10,2,0 ** surface Ice Cover [Proportion]
LANDsfc 0,1,0 2,0,0 ** surface Land Cover (1=land [0=sea)]
MSLETmsl 0,101,0 0,3,192 ** mean sea level MSLP (Eta Model Reduction) [Pa]
PRESsfc 0,1,0 0,3,0 ** surface Pressure [Pa]
PRMSLmsl 0,101,0 0,3,1 ** mean sea level Pressure Reduced To MSL [Pa]
RHprs 26,100 0,1,1 ** (1000 975 950 925 900.. 100 70 50 30 10) Relative Humidity [%]
RH2m 0,103,2 0,1,1 ** 2 m above ground Relative Humidity [%]
SOILW0_10cm 0,106,0,0.1 2,0,192 ** 0-0.1 m below ground Volumetric Soil Moisture Content [Proportion]
SOILW10_40cm 0,106,0.1,0.4 2,0,192 ** 0.1-0.4 m below ground Volumetric Soil Moisture Content [Proportion]
SOILW40_100cm 0,106,0.4,1 2,0,192 ** 0.4-1 m below ground Volumetric Soil Moisture Content [Proportion]
SOILW100_200cm 0,106,1,2 2,0,192 ** 1-2 m below ground Volumetric Soil Moisture Content [Proportion]
SPFH2m 0,103,2 0,1,0 ** 2 m above ground Specific Humidity [kg/kg]
TMPsfc 0,1,0 0,0,0 ** surface Temperature [K]
TMPprs 26,100 0,0,0 ** (1000 975 950 925 900.. 70 50 30 20 10) Temperature [K]
TMP2m 0,103,2 0,0,0 ** 2 m above ground Temperature [K]
TMP0_10cm 0,106,0,0.1 0,0,0 ** 0-0.1 m below ground Temperature [K]
TMP10_40cm 0,106,0.1,0.4 0,0,0 ** 0.1-0.4 m below ground Temperature [K]
TMP40_100cm 0,106,0.4,1 0,0,0 ** 0.4-1 m below ground Temperature [K]
TMP100_200cm 0,106,1,2 0,0,0 ** 1-2 m below ground Temperature [K]
UGRDprs 26,100 0,2,2 ** (1000 975 950 925 900.. 70 50 30 20 10) U-Component Of Wind [m/s]
UGRD10m 0,103,10 0,2,2 ** 10 m above ground U-Component Of Wind [m/s]
VGRDprs 26,100 0,2,3 ** (1000 975 950 925 900.. 70 50 30 20 10) V-Component Of Wind [m/s]
VGRD10m 0,103,10 0,2,3 ** 10 m above ground V-Component Of Wind [m/s]
WEASDsfc 0,1,0 0,1,13 ** surface Water Equivalent Of Accumulated Snow Depth [kg m-2]
ENDVARS


but do not understand how WRF derive the initial precipitation.



how do I change the snow on the ground??
what do you prefer?!

meteoadriatic
Posts: 1603
Joined: Wed Aug 19, 2009 10:05 am

Re: How to edit GFS input gribs?

Post by meteoadriatic » Tue Sep 24, 2013 1:15 pm

Those are GFS ptiles gribs?

There are no precipitation in WRF at analyze time (initial time). Precipitation starts to build in WRF as soon as it integrates first timestep but not before. If you plot precipitation at t=1 (first time in output gribs = analyze time) you will get 0. As for boundary conditions, there are also no use of having this information.

WEASDsfc is parameter that should be affected by modification. Can you make correction with this logic:

"if WEASDsfc < 10, then WEASDsfc = 0, else do not modify" ?

If you can, will then it be possible to automate this modification using scripts?

Antonix
Posts: 260
Joined: Fri Oct 16, 2009 8:53 am

Re: How to edit GFS input gribs?

Post by Antonix » Tue Sep 24, 2013 5:21 pm

yes if you are using matlab.
creates an executable that can be run on each machine.
I try first how it works and then decide which code to use.
Fortran, C, PHP!

meteoadriatic
Posts: 1603
Joined: Wed Aug 19, 2009 10:05 am

Re: How to edit GFS input gribs?

Post by meteoadriatic » Wed Sep 25, 2013 12:45 pm

viewtopic.php?f=6&t=295&p=3053#p3052

This is another reason why we should work on this modification.

Antonix
Posts: 260
Joined: Fri Oct 16, 2009 8:53 am

Re: How to edit GFS input gribs?

Post by Antonix » Wed Sep 25, 2013 1:11 pm

Yesterday I wrote the matlab code.
it works but it is not very convenient to run operational.
I'm trying to use NCO and CDO.
you know them??
might be good "snow-10cm" setting??
discard the first 10-20 cm of snow.

meteoadriatic
Posts: 1603
Joined: Wed Aug 19, 2009 10:05 am

Re: How to edit GFS input gribs?

Post by meteoadriatic » Wed Sep 25, 2013 1:33 pm

Yes, this would also work but I think it should not give negative values because unexpected things might happen in WRF.

meteoadriatic
Posts: 1603
Joined: Wed Aug 19, 2009 10:05 am

Re: How to edit GFS input gribs?

Post by meteoadriatic » Wed Sep 25, 2013 3:58 pm

I never used ncl, but quick search found this, it might help you, see example to convert °C to K:

http://www.ncl.ucar.edu/Document/Functi ... file.shtml
Example 5

Change values and meta data of a variable using the "w" status option.

a = addfile("foo.nc","w")

t = a->TEMP ; degC
t = t + 273.15 ; change values
t@units = "degK" ; update appropriate attribute

a->TEMP = t ; overwrite

Antonix
Posts: 260
Joined: Fri Oct 16, 2009 8:53 am

Re: How to edit GFS input gribs?

Post by Antonix » Wed Sep 25, 2013 4:43 pm

I think nco is the best way.
1 command, and you get what you want.
now I have to figure out how to do! :D
but if we follow different paths to arrive to secure a good result


http://nco.sourceforge.net/nco.html#Com ... ne-Options

meteoadriatic
Posts: 1603
Joined: Wed Aug 19, 2009 10:05 am

Re: How to edit GFS input gribs?

Post by meteoadriatic » Wed Sep 25, 2013 5:07 pm

Great!

I did it with ncl right now :mrgreen:

1) downloaded analyze .nc file from wpsprd directory
2) installed ncl to my PC
3) wrote simple script like above example:

Code: Select all

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"

begin

  a = addfile("met_em.d01.2013-09-25_06:00:00.nc","w")
  x = a->SNOW               ; existing snow
  x = x - 0.1            ; change values
  a->SNOW = x               ; overwrite

end
4) named it test.ncl and put in same directory as my .nc analyze file
5) fired up command "ncl test.ncl"

Then I checked out variable SNOW in ncview utility and it showed up displayed range lowered for 0.1 in comparision to original!

Two things here:
a) there are two variables (SNOW and SNOWH), both should be modified. We need to decide how much. SNOW is mass of snow per square meter (kg/m2) and SNOWH is height in meters. In fact I should lower SNOWH for 0.1m, but proof of concept is here.
b) minimum value is now -0.1 which I don't know how would affect WRF. It might just be ignored, we need to test this. If there is problem because of that, script needs to be modified to not write negative values.

I hope this helps you! Now from here, we will need to write testing script that will actually do what we want and then fire up two identical WRF simulations, one with original nc files, other with modified analyze time nc file. Boundary files (all other than analyze time), in my opinion, does not need to be changed, no effect should be.

If you have some free time try to continue from here and followup here with what you find. I'm little bit busy to finish this right now.

Antonix
Posts: 260
Joined: Fri Oct 16, 2009 8:53 am

Re: How to edit GFS input gribs?

Post by Antonix » Wed Sep 25, 2013 6:06 pm

with NCO is very fast.
install NCO.
(debian) sudo apt-get install nco
and try

ncap2 -s 'where(snow < 10) snow=0' in.nc out.nc

for example in wrfinput_d01

Post Reply