Project

General

Profile

Creating Pressure values from the hybrid A&B coefficients.

Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Hi,

I have two netCDF files with hybrid pressure as vertical coordinate. I need to pick up few variables from each set of data and combine into one. But one of the files does not have any info about the pressure values at the levels, but has only the indexes as 1,2,3..19. while the other has all the pressure values listed. 'cdo merge' command combines the data, but stores them into their own native grids, which means that one of the data has 'mlev' as level and the other has 'lev' as level. So the merged data set has got 5 dimensions now (lat,lon,lev,mlev,time). I need to have a common level for the final data set.

Is there any way in cdo to do this whole job? I was thinking about calculating the pressure values at the levels from the hybrid A&B coefficients of the data which has only the indexes and then merge the data sets!

Any better solution?

Cheers,
Semeena


Replies (12)

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Jaison-Thomas Ambadan almost 12 years ago

Hi Semeena,

It is quite hard give you a better solution without looking into the actual data? Can you please upload a sample of your data? (must be < 50MB) If the data is huge, you may strip to regional (using "sellonlatbox") and fewer time steps.

Nevertheless, my guess is that the NetCDF co-ordinate variable NAMES associated with the vertical level are different for the two NetCDF files (mlev & lev, as you mentioned); one solution is to change the name of the co-ordinate variable name using other tools such as nco (see the last post by Ralf Mueller in this thread <https://code.zmaw.de/boards/1/topics/996#message-1001&gt;), before merging (unfortunately CDO cannot do that) OR you can try converting the original files to GRIB (cdo -f grb) and then merge - it may solve the problem but I'm not sure. Hope this helps.

Cheers,
J.

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Hi Jaison,

Oh yes, I have tried to rename the mlev to lev using 'ncrename' so that at least the data has the same dimension attribute! But could not cheat my model to read in that data ;) I unfortunately cannot convert the data format as well since the model needs netcdf input. So I need to work around with what I have and in the worst case to write a fortran prog to do all these :(

But if you could check my data and give me a final answer it will be very helpful. I am uploading a small data set which I have used to work with.

Cheers,
Semeena

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Hi Jaison,

Again.. I see that a month ago Uwe has responed to a question 'Creating a full pressure level variable with CDO?' that CDO has an undocumented module to do the calculation of full level, half level, and deltaP from the hybrid A&B coefficients provided that the A&B data follows ECHAM level convention. What is this module? Is this available to public?

Cheers,
Semeena

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Jaison-Thomas Ambadan almost 12 years ago

Hi Semeena,

No I get it. okay, the point is, as you may know, you CANNOT simply merge pressure level and hybrid levels even though both the total number of vertical levels is same - both data should be either in pressure levels or in hybrid levels - even if you manage to merge without converting - its wrong!.

so you can use the operator "pressure_fl" to create full pressure levels from EMAC_20050101_var.nc since it contains the A & B coefficients. BUT you need surface pressure, which you have to merge/cat first to the file, then just use the operator:

cdo -pressure_fl ifile.nc ofile.nc

Cheers,
J.

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Jaison-Thomas Ambadan almost 12 years ago

Hi again,

sorry: just ignore the first paragraph of the above post (my comments are misleading, i guess) but you can use the "pressure_fl" as mentioned

Cheers,
J.

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Hi Jaison,

Thanks a lot! Now we are talking ;) Actually both the data are in hybrid levels, only thing is that one of them is lacking the pressure information at model levels. I almost knew that my method will not work and hence been looking around for the actual decent options! This 'pressure_fl' is the one I desperately needed. I was reading it as 'pressure_fi' and of course cdo could not identify it. Now let me try all these once again and will let u know what I get..

btw, r u from CUSAT?

Cheers,
Semeena

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Hi Jaison,

This 'pressure_fl' didn't work :( The output produced by this command had only 'surface pressure' (have no idea abt what happened to the rest of the variables in the file) and the model levels still showed the indexes only as 1,2,3....19

In the mean time I found another way to work around.

Cheers,
Semeena

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Jaison-Thomas Ambadan almost 12 years ago

Can you please upload the the surface pressure file corresponding to "EMAC_20050101_var.nc"?

Cheers,
J.

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Hi Jaison,

Here is the file including surface pressure now. The original file had 'surface pressure' and I extracted this also into 'EMAC_20050101_var.nc'.

Thanks.

Cheers,
Semeena

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Jaison-Thomas Ambadan almost 12 years ago

Hi,

It seems "pressure_fl" operator simply calculate the actual pressure levels store it as another variable named "pressure" in the output file. But it won't change the level attributes of the actual variables. You've mentioned that you already found a work around but just in case; once Uwe Schulzweida suggested a workaround to modify the z axis/vertical levels for me. here is the steps (assuming that the input data are in pressure levels).

1) Create a vertical description file for your input file, store into a text file, you can use:

cdo -zaxisdes -selvar,SO2 EMAC_20050101_var.nc > myzaxis.dat

the file "myzaxis.dat" looks like
--------------------------------------- #
  1. zaxisID 1 #
    zaxistype = hybrid
    size = 19
    name = mlev
    longname = hybrid level at layer midpoints
    units = level
    levels = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
    vctsize = 40
    vct = 0 2000 4000 6046.1106 8267.92756 10609.5132 12851.1002 14698.4981
    15861.1252 16116.2366 15356.9241 13621.4604 11101.562 8127.14415
    5125.14175 2549.96941 783.195032 0 0 0
    0 0 0 0.0003389933 0.0033571866 0.0130700434 0.0340771467 0.0706498323
    0.125916683 0.201195409 0.295519649 0.405409199 0.524932224
    0.646107948 0.759698377 0.856437557 0.928746914 0.972985185
    0.992281481 1
    ---------------------------------------

2) Now get the actual pressure levels using the "pressure_fl" operator:

cdo -outputf,%13.6f,1 -sellonlatbox,0,0,0,0 -seltimestep,1 -selvar,pressure -pressure_fl EMAC_20050101_var.nc > plevels.dat

The file "plevels.dat" looks like:
---------------------------------------
1000.000000
3000.000000
5038.879166
7329.553059
10205.527065
13931.090387
18663.349780
24455.339982
31257.946233
38922.742555
47207.849936
55788.918451
64277.337232
72247.776386
79277.164852
84997.208167
89162.550184
91736.682735
92997.707275
---------------------------------------

3. Now simple replace the levels (1..19) in the "myzaxis.dat" with actual pressure values in "plevels.dat", and also the name and units (just for the info) like:


#
  1. zaxisID 1 #
    zaxistype = pressure
    size = 19
    name = lev
    longname = Pressure levels
    units = Pa
    levels = 1000.000000 3000.000000 5038.879166 7329.553059 10205.527065 13931.090387 18663.349780 24455.339982 31257.946233 38922.742555 47207.849936 55788.918451 64277.337232 72247.776386 79277.164852 84997.208167 89162.550184 91736.682735 92997.707275
    vctsize = 40
    vct = 0 2000 4000 6046.1106 8267.92756 10609.5132 12851.1002 14698.4981
    15861.1252 16116.2366 15356.9241 13621.4604 11101.562 8127.14415
    5125.14175 2549.96941 783.195032 0 0 0
    0 0 0 0.0003389933 0.0033571866 0.0130700434 0.0340771467 0.0706498323
    0.125916683 0.201195409 0.295519649 0.405409199 0.524932224
    0.646107948 0.759698377 0.856437557 0.928746914 0.972985185
    0.992281481 1
    ---------------------------------------

4. Now you can change the the z-axis of your original file like:

cdo setzaxis,myzaxis.dat -selvar,SO2 EMAC_20050101_var.nc outfile.nc

and that's it! done!

It might look very complicated but trust me it is simple. You need to create the template "myzaxis.dat" only once afterwards you can use it with "setzaxis" command. And offcourse all the credit for this cheat-sheet goes to Uwe!

Cheers,
Jaison.

PS: the above data is from your file so you can simply copy & paste the final "myzaxis.dat" in step 3.

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Hi Jaison,

Thanks a lot! Of course I am going to try this out. My solution was also a kind of cheating the model ;) but it worked! So I'll test this too and will be intersting to see the difference between the two!

Thanks once again.

Cheers,
Semeena

RE: Creating Pressure values from the hybrid A&B coefficients. - Added by Valiyaveetil Shamsudheen Semeena almost 12 years ago

Valiyaveetil Shamsudheen Semeena wrote:

Hi Jaison,

Great!!! Thanks a lot! Of course I am going to try this out. My solution was also a kind of cheating the model ;) but it worked! So I'll test this too and will be intersting to see the difference between the two!

Thanks once again.

Cheers,
Semeena

    (1-12/12)