How to use the ds.vertical() method? #64
-
Hello Robert! I have data on air pollutants concentrations through the atmosphere, divided into 47 vertical levels. I need to sum up the concentrations from 0 to 30 to work with only tropospheric data. I tried using the ds.vertical_sum(), but the sum is calculated for all 47 values. Is it possible to use any of the vertical methods to specify which levels I want to sum up and avoid getting the sum of all levels? I highly appreciate any guidance you can provide on this! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
You would need to subset the levels first. Something like this would work:
|
Beta Was this translation helpful? Give feedback.
-
Hello @robertjwilson! I tried subsetting the levels as suggested, but I failed. The dataset has 47 vertical levels associated with atmospheric pressure. Level 47 has the lowest value (3.8e-5, at the top of the atmosphere), and level 1 has the highest value (0.99, at the ground level). I tried subsetting the levels using the index as you suggested "levs = [ds.levels[0], ds.levels[29]]" and also tried using the actual value of the levels "levs = [ds.levs[0.99], ds.levels[0.19]]" but it did not work. And also tried switching the order of the values, but it did not work. Again, thank you very much for any guidance you can provide me on how to make it work, and I apologize for bothering you with my questions. P.S. I paste @here the list with the values of the levels, just in case it helps to solve the issue. [3.8000005e-05, |
Beta Was this translation helpful? Give feedback.
-
I would need the data to figure out what is going wrong. Can you upload a file or point to where to download it? It sounds like something might be mispecified in the file. |
Beta Was this translation helpful? Give feedback.
-
I see the problem. nctoolkit uses CDO to subset this, but the CDO call only takes integer values, so it won't work very well for your data as it goes from 0-1. I'll see if I can fix that or just ask the CDO developers to adjust their method. In the meantime you can use the following by calling CDO internally. Note: the level order displayed by
|
Beta Was this translation helpful? Give feedback.
I see the problem. nctoolkit uses CDO to subset this, but the CDO call only takes integer values, so it won't work very well for your data as it goes from 0-1. I'll see if I can fix that or just ask the CDO developers to adjust their method.
In the meantime you can use the following by calling CDO internally. Note: the level order displayed by
ds.levels
is the reverse of what's in the file raw data. This is automatically ordered by nctoolkit, because in general that's easier for users. But this is a rare case where it might be confusing. I might need a warning to flag it's been re-ordered.