Project

General

Profile

cell by cell veritcal integration of variable x from minimum value of variable y onwards

Added by Clarissa Kroll over 4 years ago

Hello,

I am looking for an efficient way of vertically integrating a variable x from a minimum value of variable y onwards for all cells and timesteps in a global dataset.

Basically my roadmap would be

1 - getting the index of the vertical minimum of variable y for each cell+timestep

2 - creating a mask (zero below the minimum, else 1)

3 - multiplying the mask with the dataset containing variable x

4 - proceeding with the integration

This procedure is very slow in my current python implementation and I would like to use cdos to speed things up.

However I could not find a cdo command to determine the index of the vertical minimum (step 1), only its value (vertmin). Did I miss this command/is there a workaround/even a more efficient way to accomplish the integration?

Thank you very much!

Clarissa


Replies (7)

RE: cell by cell veritcal integration of variable x from minimum value of variable y onwards - Added by Ralf Mueller over 4 years ago

hi Clarissa!

your plan seems fine, but you don't need to know the index for the y variable. you can create the mask from y by using the gtc operator. This will create a 0-1-mask.

This mask-file possibly has to many zeros in the columns, where the value of y is going above and below your threshold. so you have to fill up the zeros with 1 in case the threshold was exceeded ones. Here it's a little hard for me to say how to do it, because it depends on the ordering of your vertical axis. Ocean model data usually use positive depths starting by 0 which can be seen as downward although the numbers become bigger. But if you manage to fill these zeros, you can just multiply the mask and to the vertical summation just like you have it in mind.

I would do a division by the final mask instead of multiplication in order to create missing values instead of zeros. This will lead to the correct integral because the zeros will not be taken into account and hence don't spoil the result.

hth
ralf

RE: cell by cell veritcal integration of variable x from minimum value of variable y onwards - Added by Clarissa Kroll over 4 years ago

Hi Ralf,

my problem is that I do not have a constant threshold value which I could choose for the global data. I could determine the value individually for each cell and timestep - does gtc also take arrays, not only individual floats as 'c'?

Thanks for pointing out that the multiplication would be disadvantageous.

Best,
Clarissa

RE: cell by cell veritcal integration of variable x from minimum value of variable y onwards - Added by Ralf Mueller over 4 years ago

check the gt operator. this one compares input files - gtc stands for greater than constant

RE: cell by cell veritcal integration of variable x from minimum value of variable y onwards - Added by Clarissa Kroll over 4 years ago

Hi Ralf,

thank you, but the reason why I was looking for the vertminIDX was that, unfortunately, I want to integrate from the minimum value of variable y (atmospheric temperature, see attachment), the gt operator would select all points excluding only the minimum. This would allow me to create the mask eventually with some additional steps but as I am processing a rather large amount of data I would prefer to limit the number of cdo commands to a minimum.

It seems though there is no possibility to get the verminIDX (of variable y) directly and create a mask above in height (below in pressure)?

If this is correct I might go for the gt operator and do an indirect selection. This would entail comparing a 4d array (data.plev) to a 3d array (data.tropo). From the cdo description this does not seem to be intended?
Cheers,
Clarissa

RE: cell by cell veritcal integration of variable x from minimum value of variable y onwards - Added by Clarissa Kroll over 4 years ago

Hi Ralf,

as discussed I am posting more information on the data analysis I want to do:

The raw data I am currently looking at is stored in /work/mh0066/m300657/mpiesm-1.1.00p2/experiments - 600 runs stored in the folders evaXssiY with X in [0,2.5,5,10,20,40] and Y in [101,200].
There are several files, the variables of interest are in evaXssiY_echam6_echam_Z.grb with Z in [1991,1992,1993].

The script I was using for the analysis before is stored in /work/bb1093/m300733/Scripts/SWVintegration/mpiEsm. It is written for ICON-A model output, the "new data" in the folder above is MPI-ESM output, I will adapt the postprocessing accordingly.

File content:
batch1FindTropopause.py: Post-processing, selection of variables of interest (will be adapted to MPI-ESM output later, selection of 23 degrees will not be applied) (cdo based)
batch2FindTropopause.py: Find temperature minimum in tropopause region (index 10:38) and get the corresponding height index
batch3_0FindTropopause.py: multiply the specific humidity with density of air to get the "density of water vapor" [kg/m3] (cdo based)
batch3_1FindTropopause.py: get the height differences between levels (python) and multiply the "density of WV" by this - "[kg/m2]" (cdo based)
batch3_2FindTropopause.py: sum over all indices above the cold point level (python)

I did a new trail analysis, for the ICON data, stored in /work/bb1093/m300733/iconCMIP6Aerosols/icon-aes/experiments/CMIP6atm_amip/data2.

The problem spots are:
- I am trying to run several process simultaneously e.g. line 62 ff in batch2FindTropopause. Although several processes are started I think something is wrong with my setup since I noticed that the processing is slowed down and if i use cdo commands they crash sometimes (memory issues? - how can I estimate when I will run into those?). This also (/especially) happened to me when I tried to used this process for the cdo afterburner version for the MPI-ESM data. I would be very grateful for advice on how to improve my code here.
- the non-cdo processing is quite time costly (especially in batch2FindTropopause, the unavoidable step with no replacement via cdo commands).
- I have to multiply the final result with the corresponding column base - is this information stored somewhere in the grid files or do I have to calculate it?
- Is there a way to use ml2pl and calculate ml2hl simultaneously (need both for the tropopause pressure and the integration)?

Thank you very much,
cheers,
Clarissa

RE: cell by cell veritcal integration of variable x from minimum value of variable y onwards - Added by Clarissa Kroll about 4 years ago

Is there a way to speed things up? Should I perhaps write out some of the variables of interest while the model is running? I noticed a file named mo_tropopause.f90, perhaps this could be used?

RE: cell by cell veritcal integration of variable x from minimum value of variable y onwards - Added by Ralf Mueller about 4 years ago

hi Clarissa!

If you don't mind I can come to your office early next week. Might be a bit easier for me to understand what you want to do.

If that's ok, let's use mail for finding a date+time.

cheers
ralf

    (1-7/7)