Project

General

Profile

Subtract temperature at different pressure levels

Added by Shreya Bhowmick almost 3 years ago

I have a dataset having the temperature at 850hpa and 200hpa pressure levels. I want to subtract temp at 850 hPa from the temperature at 200 hPa. What CDO command should I use? I tried splitting the dataset into two levels and then subtracting them but it seems wrong when i plot it.


Replies (10)

RE: Subtract temperature at different pressure levels - Added by Karin Meier-Fleischer almost 3 years ago

Hi Shreya,

you do not need to split the input data, you can use the operator chaining like (mybe you have to select the variable temp, too)

cdo -sub -sellevel,200 infile -sellevel,850 infile outfile

-Karin

RE: Subtract temperature at different pressure levels - Added by Shreya Bhowmick almost 3 years ago

Karin Meier-Fleischer wrote in RE: Subtract temperature at different pressure levels:

Hi Shreya,

you do not need to split the input data, you can use the operator chaining like (mybe you have to select the variable temp, too)

[...]

-Karin

Thank you. This is working! The only problem is that I get the output for 1st timestep only. How can I do it for all the timesteps. I tried using seltimestep,1/4758 but it also gave the output for the first timestep only.

RE: Subtract temperature at different pressure levels - Added by Karin Meier-Fleischer almost 3 years ago

It should work for all timesteps at once. Which CDO version are you using?

See following example (done with CDO 1.9.9):

infile="$HOME/data/CMIP5/atmos/ta_Amon_MPI-ESM-LR_historical_r1i1p1_198001-198912.nc" 

cdo -sub -sellevel,20000 -selyear,1980 $infile -sellevel,85000 -selyear,1980 $infile tmp.nc

cdo infon tmp.nc
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 1980-01-16 12:00:00   20000    18432       0 :     -81.359     -58.373     -23.975 : ta            
     2 : 1980-02-15 12:00:00   20000    18432       0 :     -82.093     -57.690     -17.707 : ta            
     3 : 1980-03-16 12:00:00   20000    18432       0 :     -83.541     -58.449     -16.481 : ta            
     4 : 1980-04-16 00:00:00   20000    18432       0 :     -84.239     -59.519     -18.832 : ta            
     5 : 1980-05-16 12:00:00   20000    18432       0 :     -86.066     -60.755     -22.218 : ta            
     6 : 1980-06-16 00:00:00   20000    18432       0 :     -88.062     -61.808     -19.838 : ta            
     7 : 1980-07-16 12:00:00   20000    18432       0 :     -84.579     -61.778     -27.698 : ta            
     8 : 1980-08-16 12:00:00   20000    18432       0 :     -85.964     -61.869     -29.521 : ta            
     9 : 1980-09-16 00:00:00   20000    18432       0 :     -85.268     -61.288     -28.724 : ta            
    10 : 1980-10-16 12:00:00   20000    18432       0 :     -82.551     -60.494     -25.970 : ta            
    11 : 1980-11-16 00:00:00   20000    18432       0 :     -82.510     -58.850     -31.545 : ta            
    12 : 1980-12-16 12:00:00   20000    18432       0 :     -82.590     -57.427     -26.239 : ta   

RE: Subtract temperature at different pressure levels - Added by Shreya Bhowmick almost 3 years ago

I am using CDO 1.9.3. I tried to install CDO 2.0.3 but due to some problem, it is not showing.
In the step 'make install' such output is shown.

make2: Entering directory '/home/shreya/Documents/cdo-2.0.3/src'
/bin/mkdir -p '/usr/local/bin'
/bin/bash ../libtool --mode=install /usr/bin/install -c cdo '/usr/local/bin'
libtool: install: /usr/bin/install -c cdo /usr/local/bin/cdo
/usr/bin/install: cannot create regular file '/usr/local/bin/cdo': Permission denied
Makefile:1037: recipe for target 'install-binPROGRAMS' failed
make2: * [install-binPROGRAMS] Error 1
make2: Leaving directory '/home/shreya/Documents/cdo-2.0.3/src'
Makefile:5703: recipe for target 'install-am' failed
make1:
[install-am] Error 2
make1: Leaving directory '/home/shreya/Documents/cdo-2.0.3/src'
Makefile:492: recipe for target 'install-recursive' failed
make: *
* [install-recursive] Error 1

The steps 'configure' and 'make' was executed properly.

RE: Subtract temperature at different pressure levels - Added by Shreya Bhowmick almost 3 years ago

Karin Meier-Fleischer wrote in RE: Subtract temperature at different pressure levels:

It should work for all timesteps at once. Which CDO version are you using?

See following example (done with CDO 1.9.9):

[...]

In my case this is the result
cdo -sub -sellevel,500 temp.nc -sellevel,850 temp.nc sub.nc

cdo infon sub.nc
-1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name
1 : 1982-05-01 06:00:00 500 7381 0 : 42224. 42710. 42977. : z
2 : 1982-05-01 06:00:00 500 7381 0 : 275.85 282.38 288.33 : t
cdo infon: Processed 14762 values from 2 variables over 1 timestep [0.00s 47MB]

RE: Subtract temperature at different pressure levels - Added by Karin Meier-Fleischer almost 3 years ago

The installation error based on the fact that you do not have the permission to write to /usr/local/bin/. You can change the prefix or install CDO with miniconda (see https://code.mpimet.mpg.de/projects/cdo/wiki/Anaconda).

Can you upload the data file? If it is too large select a view timesteps in a sample file.

RE: Subtract temperature at different pressure levels - Added by Shreya Bhowmick almost 3 years ago

Karin Meier-Fleischer wrote in RE: Subtract temperature at different pressure levels:

The installation error based on the fact that you do not have the permission to write to /usr/local/bin/. You can change the prefix or install CDO with miniconda (see https://code.mpimet.mpg.de/projects/cdo/wiki/Anaconda).

Can you upload the data file? If it is too large select a view timesteps in a sample file.

Thank you so much for your time. I changed the prefix and it installed properly. Still the cdo command could be found somehow. I have uploaded a sample file.

tmp.nc (6.87 MB) tmp.nc

RE: Subtract temperature at different pressure levels - Added by Shreya Bhowmick almost 3 years ago

I have updated my cdo version to 1.9.9 but still i am getting the subtracted value for 1 timestep only

RE: Subtract temperature at different pressure levels - Added by Karin Meier-Fleischer almost 3 years ago

I used your uploaded file tmp.nc:

cdo -b F64 -sub -sellevel,500 -selname,t tmp.nc -sellevel,850 -selname,t tmp.nc outfile.nc
cdo(1) sellevel: Process started
cdo(2) selname: Process started
cdo(3) sellevel: Process started
cdo(4) selname: Process started
cdo    sub (Warning): Input parameters have different levels!
cdo(4) selname: Processed 1800964 values from 2 variables over 122 timesteps.
cdo(3) sellevel: Processed 900482 values from 1 variable over 122 timesteps.
cdo(2) selname: Processed 1800964 values from 2 variables over 122 timesteps.
cdo(1) sellevel: Processed 900482 values from 1 variable over 122 timesteps.
cdo    sub: Processed 1800964 values from 2 variables over 244 timesteps [0.03s 9076KB].
cdo infon outfile.nc
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 1982-05-01 06:00:00     500     7381       0 :     -34.396     -27.866     -21.915 : t             
     2 : 1982-05-02 06:00:00     500     7381       0 :     -33.266     -27.294     -20.355 : t             
     3 : 1982-05-03 06:00:00     500     7381       0 :     -33.491     -27.455     -20.683 : t             
     4 : 1982-05-04 06:00:00     500     7381       0 :     -33.902     -27.012     -20.162 : t             
     5 : 1982-05-05 06:00:00     500     7381       0 :     -34.238     -27.598     -22.664 : t             
     6 : 1982-05-06 06:00:00     500     7381       0 :     -33.480     -27.871     -22.538 : t             
     7 : 1982-05-07 06:00:00     500     7381       0 :     -34.255     -28.071     -20.691 : t             
     8 : 1982-05-08 06:00:00     500     7381       0 :     -34.314     -27.937     -21.182 : t             
     9 : 1982-05-09 06:00:00     500     7381       0 :     -34.433     -27.984     -22.230 : t             
    10 : 1982-05-10 06:00:00     500     7381       0 :     -35.386     -28.125     -22.030 : t             
    11 : 1982-05-11 06:00:00     500     7381       0 :     -34.845     -27.798     -22.234 : t             
    12 : 1982-05-12 06:00:00     500     7381       0 :     -33.891     -27.584     -22.179 : t             
    13 : 1982-05-13 06:00:00     500     7381       0 :     -34.224     -26.727     -21.701 : t             
    14 : 1982-05-14 06:00:00     500     7381       0 :     -33.503     -26.027     -21.250 : t             
    15 : 1982-05-15 06:00:00     500     7381       0 :     -32.337     -25.757     -20.457 : t             
    16 : 1982-05-16 06:00:00     500     7381       0 :     -32.990     -25.912     -21.580 : t             
    17 : 1982-05-17 06:00:00     500     7381       0 :     -32.076     -26.330     -22.568 : t             
    18 : 1982-05-18 06:00:00     500     7381       0 :     -34.782     -26.905     -21.960 : t             
    19 : 1982-05-19 06:00:00     500     7381       0 :     -35.132     -27.185     -21.825 : t             
    20 : 1982-05-20 06:00:00     500     7381       0 :     -35.967     -27.580     -21.737 : t             
    21 : 1982-05-21 06:00:00     500     7381       0 :     -35.735     -27.797     -22.191 : t             
    22 : 1982-05-22 06:00:00     500     7381       0 :     -35.621     -28.473     -21.951 : t             
    23 : 1982-05-23 06:00:00     500     7381       0 :     -34.368     -28.211     -21.335 : t             
    24 : 1982-05-24 06:00:00     500     7381       0 :     -34.767     -27.987     -21.343 : t             
    25 : 1982-05-25 06:00:00     500     7381       0 :     -35.536     -27.815     -21.060 : t             
    26 : 1982-05-26 06:00:00     500     7381       0 :     -34.733     -27.346     -21.125 : t             
    27 : 1982-05-27 06:00:00     500     7381       0 :     -33.304     -26.160     -20.626 : t             
    28 : 1982-05-28 06:00:00     500     7381       0 :     -34.219     -26.063     -20.471 : t             
    29 : 1982-05-29 06:00:00     500     7381       0 :     -36.877     -26.529     -20.596 : t             
    30 : 1982-05-30 06:00:00     500     7381       0 :     -35.642     -26.918     -20.436 : t             
    31 : 1982-05-31 06:00:00     500     7381       0 :     -33.373     -26.649     -20.483 : t             
    32 : 1982-06-01 06:00:00     500     7381       0 :     -33.439     -26.815     -20.191 : t             
    33 : 1982-06-02 06:00:00     500     7381       0 :     -34.059     -26.781     -19.086 : t             
    34 : 1982-06-03 06:00:00     500     7381       0 :     -34.614     -26.155     -18.511 : t             
    35 : 1982-06-04 06:00:00     500     7381       0 :     -34.725     -26.319     -17.117 : t             
    36 : 1982-06-05 06:00:00     500     7381       0 :     -35.475     -26.129     -19.139 : t             
    37 : 1982-06-06 06:00:00     500     7381       0 :     -35.633     -25.571     -19.428 : t             
    38 : 1982-06-07 06:00:00     500     7381       0 :     -31.717     -25.401     -19.839 : t             
    39 : 1982-06-08 06:00:00     500     7381       0 :     -31.404     -24.591     -20.535 : t             
    40 : 1982-06-09 06:00:00     500     7381       0 :     -34.135     -24.792     -19.017 : t             
    41 : 1982-06-10 06:00:00     500     7381       0 :     -34.357     -24.647     -18.278 : t             
    42 : 1982-06-11 06:00:00     500     7381       0 :     -34.598     -24.883     -19.560 : t             
    43 : 1982-06-12 06:00:00     500     7381       0 :     -32.687     -24.391     -19.684 : t             
    44 : 1982-06-13 06:00:00     500     7381       0 :     -33.883     -24.162     -19.949 : t             
    45 : 1982-06-14 06:00:00     500     7381       0 :     -33.388     -23.387     -19.960 : t             
    46 : 1982-06-15 06:00:00     500     7381       0 :     -30.865     -23.522     -19.721 : t             
    47 : 1982-06-16 06:00:00     500     7381       0 :     -31.478     -23.652     -20.124 : t             
    48 : 1982-06-17 06:00:00     500     7381       0 :     -33.529     -23.736     -19.792 : t             
    49 : 1982-06-18 06:00:00     500     7381       0 :     -37.852     -24.493     -19.678 : t             
    50 : 1982-06-19 06:00:00     500     7381       0 :     -37.000     -25.502     -19.646 : t             
    51 : 1982-06-20 06:00:00     500     7381       0 :     -36.053     -25.357     -19.779 : t             
    52 : 1982-06-21 06:00:00     500     7381       0 :     -36.275     -24.426     -20.282 : t             
    53 : 1982-06-22 06:00:00     500     7381       0 :     -37.036     -24.532     -20.483 : t             
    54 : 1982-06-23 06:00:00     500     7381       0 :     -37.833     -24.483     -20.027 : t             
    55 : 1982-06-24 06:00:00     500     7381       0 :     -36.802     -24.350     -20.014 : t             
    56 : 1982-06-25 06:00:00     500     7381       0 :     -39.987     -25.031     -20.106 : t             
    57 : 1982-06-26 06:00:00     500     7381       0 :     -37.614     -25.655     -20.030 : t             
    58 : 1982-06-27 06:00:00     500     7381       0 :     -34.536     -26.037     -20.224 : t             
    59 : 1982-06-28 06:00:00     500     7381       0 :     -32.752     -25.853     -20.299 : t             
    60 : 1982-06-29 06:00:00     500     7381       0 :     -31.843     -25.181     -20.805 : t             
    61 : 1982-06-30 06:00:00     500     7381       0 :     -31.057     -24.478     -20.033 : t             
    62 : 1982-09-01 06:00:00     500     7381       0 :     -29.954     -22.653     -19.519 : t             
    63 : 1982-09-02 06:00:00     500     7381       0 :     -27.576     -23.140     -18.771 : t             
    64 : 1982-09-03 06:00:00     500     7381       0 :     -27.884     -23.032     -18.965 : t             
    65 : 1982-09-04 06:00:00     500     7381       0 :     -28.374     -22.936     -19.712 : t             
    66 : 1982-09-05 06:00:00     500     7381       0 :     -27.901     -22.681     -18.962 : t             
    67 : 1982-09-06 06:00:00     500     7381       0 :     -29.677     -22.300     -17.577 : t             
    68 : 1982-09-07 06:00:00     500     7381       0 :     -29.485     -22.383     -18.784 : t             
    69 : 1982-09-08 06:00:00     500     7381       0 :     -28.148     -22.506     -18.785 : t             
    70 : 1982-09-09 06:00:00     500     7381       0 :     -27.598     -22.149     -18.716 : t             
    71 : 1982-09-10 06:00:00     500     7381       0 :     -28.103     -22.413     -20.006 : t             
    72 : 1982-09-11 06:00:00     500     7381       0 :     -28.649     -22.867     -18.978 : t             
    73 : 1982-09-12 06:00:00     500     7381       0 :     -28.648     -22.992     -20.030 : t             
    74 : 1982-09-13 06:00:00     500     7381       0 :     -28.160     -22.567     -19.019 : t             
    75 : 1982-09-14 06:00:00     500     7381       0 :     -29.009     -22.929     -19.269 : t             
    76 : 1982-09-15 06:00:00     500     7381       0 :     -29.445     -23.497     -19.516 : t             
    77 : 1982-09-16 06:00:00     500     7381       0 :     -31.101     -23.441     -18.514 : t             
    78 : 1982-09-17 06:00:00     500     7381       0 :     -30.535     -22.954     -17.046 : t             
    79 : 1982-09-18 06:00:00     500     7381       0 :     -28.060     -22.512     -17.329 : t             
    80 : 1982-09-19 06:00:00     500     7381       0 :     -27.286     -22.745     -19.383 : t             
    81 : 1982-09-20 06:00:00     500     7381       0 :     -28.706     -23.239     -20.748 : t             
    82 : 1982-09-21 06:00:00     500     7381       0 :     -32.525     -23.563     -20.963 : t             
    83 : 1982-09-22 06:00:00     500     7381       0 :     -30.522     -23.989     -20.278 : t             
    84 : 1982-09-23 06:00:00     500     7381       0 :     -28.775     -23.683     -20.693 : t             
    85 : 1982-09-24 06:00:00     500     7381       0 :     -27.582     -22.961     -19.365 : t             
    86 : 1982-09-25 06:00:00     500     7381       0 :     -26.898     -22.728     -20.065 : t             
    87 : 1982-09-26 06:00:00     500     7381       0 :     -29.748     -22.909     -19.910 : t             
    88 : 1982-09-27 06:00:00     500     7381       0 :     -31.353     -23.308     -19.807 : t             
    89 : 1982-09-28 06:00:00     500     7381       0 :     -32.654     -23.581     -19.535 : t             
    90 : 1982-09-29 06:00:00     500     7381       0 :     -34.112     -23.828     -19.100 : t             
    91 : 1982-09-30 06:00:00     500     7381       0 :     -36.375     -25.017     -20.475 : t             
    92 : 1982-10-01 06:00:00     500     7381       0 :     -34.535     -25.867     -21.641 : t             
    93 : 1982-10-02 06:00:00     500     7381       0 :     -33.170     -25.537     -20.965 : t             
    94 : 1982-10-03 06:00:00     500     7381       0 :     -31.495     -24.797     -21.199 : t             
    95 : 1982-10-04 06:00:00     500     7381       0 :     -32.031     -25.248     -21.893 : t             
    96 : 1982-10-05 06:00:00     500     7381       0 :     -32.472     -25.189     -22.318 : t             
    97 : 1982-10-06 06:00:00     500     7381       0 :     -32.248     -25.361     -21.550 : t             
    98 : 1982-10-07 06:00:00     500     7381       0 :     -32.597     -25.690     -21.750 : t             
    99 : 1982-10-08 06:00:00     500     7381       0 :     -34.514     -26.292     -22.478 : t             
   100 : 1982-10-09 06:00:00     500     7381       0 :     -34.411     -26.400     -22.776 : t             
   101 : 1982-10-10 06:00:00     500     7381       0 :     -33.114     -26.276     -22.599 : t             
   102 : 1982-10-11 06:00:00     500     7381       0 :     -33.432     -26.182     -22.419 : t             
   103 : 1982-10-12 06:00:00     500     7381       0 :     -33.423     -25.429     -21.100 : t             
   104 : 1982-10-13 06:00:00     500     7381       0 :     -33.948     -25.497     -21.776 : t             
   105 : 1982-10-14 06:00:00     500     7381       0 :     -33.877     -25.509     -20.925 : t             
   106 : 1982-10-15 06:00:00     500     7381       0 :     -32.718     -25.398     -21.417 : t             
   107 : 1982-10-16 06:00:00     500     7381       0 :     -32.317     -25.176     -20.946 : t             
   108 : 1982-10-17 06:00:00     500     7381       0 :     -31.803     -24.690     -21.058 : t             
   109 : 1982-10-18 06:00:00     500     7381       0 :     -32.249     -24.147     -21.223 : t             
   110 : 1982-10-19 06:00:00     500     7381       0 :     -32.375     -24.065     -20.522 : t             
   111 : 1982-10-20 06:00:00     500     7381       0 :     -30.983     -24.291     -20.463 : t             
   112 : 1982-10-21 06:00:00     500     7381       0 :     -30.066     -23.565     -20.490 : t             
   113 : 1982-10-22 06:00:00     500     7381       0 :     -29.722     -23.487     -20.159 : t             
   114 : 1982-10-23 06:00:00     500     7381       0 :     -28.924     -23.859     -20.701 : t             
   115 : 1982-10-24 06:00:00     500     7381       0 :     -29.802     -24.118     -21.956 : t             
   116 : 1982-10-25 06:00:00     500     7381       0 :     -29.144     -24.265     -21.744 : t             
   117 : 1982-10-26 06:00:00     500     7381       0 :     -30.487     -24.533     -22.416 : t             
   118 : 1982-10-27 06:00:00     500     7381       0 :     -29.530     -24.358     -21.962 : t             
   119 : 1982-10-28 06:00:00     500     7381       0 :     -29.325     -24.463     -21.404 : t             
   120 : 1982-10-29 06:00:00     500     7381       0 :     -28.391     -24.457     -21.790 : t             
   121 : 1982-10-30 06:00:00     500     7381       0 :     -29.067     -24.451     -21.856 : t             
   122 : 1982-10-31 06:00:00     500     7381       0 :     -29.972     -24.527     -21.658 : t             
       :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
cdo    infon: Processed 900482 values from 1 variable over 122 timesteps [0.01s 7584KB].

RE: Subtract temperature at different pressure levels - Added by Shreya Bhowmick almost 3 years ago

Karin Meier-Fleischer wrote in RE: Subtract temperature at different pressure levels:

I used your uploaded file tmp.nc:

[...]

[...]

Thank you so much. This is working for me too after increasing the precision. It is giving values for all timesteps now.

    (1-10/10)