@@ -32,32 +32,44 @@ def generate_level_bounds(self):
3232
3333
3434
35- def bottom (self ):
35+ def bottom (self , choice = "level" ):
3636 """
37- bottom: Extract the bottom level from a dataset
37+ bottom: Extract the bottom level or value from a dataset
3838
39- This extracts the bottom level from each netCDF file. Please note that for
39+ This extracts the bottom level or value from each netCDF file. Please note that for
4040 ensembles, it uses the first file to derive the index of the bottom level.
4141
42- You may need to double check that the bottom vertical level is the sea 'bottom' etc., as this is not always the case.
43-
44- Use bottom_mask for files when the bottom cell in netCDF files do not represent
45- the actual bottom.
42+ Parameters
43+ -------------
44+ choice : str
45+ Set to 'level' to extract the bottom level, or 'value' to extract the bottommost non-missing value.
4646
4747 Examples
4848 ------------
4949
5050 If you wanted to extract the bottom vertical level of a dataset, do the following:
5151
52- >>> ds.bottom()
52+ >>> ds.bottom(choice = 'level' )
5353
5454 This method is most useful for things like oceanic model data, where the bottom cell corresponds to the bottom of the ocean.
5555
56+ If you wanted to find the deepest non-missing value in a dataset, you would do the following:
57+
58+ >>> ds.bottom(choice = 'value')
59+
5660 """
5761
5862 # extract the number of the bottom level
5963 # Use the first file for an ensemble
6064 # pull the cdo command together, then run it or store it
65+
66+ if choice not in ["level" , "value" ]:
67+ raise ValueError ("Choice must be either 'level' or 'value'" )
68+
69+ if choice == "value" :
70+ self .cdo_command ("bottomvalue" )
71+ return None
72+
6173 if len (self ) > 1 :
6274 ff = self .current [0 ]
6375 warnings .warn (
0 commit comments